Dhananjay Kuber

Day 3 at rtCamp

On my third day at rtCamp, I completed the OS module and set up my local development environment. I explored process life cycles, states, and threads in the OS module. Additionally, I delved into Git and GitHub.

  • Set up a local development environment using LocalWP by Flywheel.
  • Configured Visual Studio Code (VS Code) and installed essential extensions.
  • Installed Node.js, Composer, wget, Git, and the GitHub CLI.

Inter-Process Communication

While I was reading about IPC, I came across an important consideration: whether shared memory or message passing is better.

IPC

Message Passing

  • In message passing, two processes, A and B for example, create a communication channel.
  • Each time data is sent, it requires a CPU cycle for the communication to happen.

Shared Memory

  • In shared memory, processes share a same portion of memory.
  • Using shared memory needs CPU cycle at the beginning. However after it's ready it can read and write messages in the shared memory without using extra CPU cycle.

Process State

A running program is referred to as a process, and it undergoes different stages during execution

Process Lifecycle

  • Creation: When a program starts running, a new process is created
  • Ready: In the ready state, the process is waiting for its turn to use the computer's CPU
  • Running: Once the process gets the CPU, it's in the running state and doing its tasks. This state can be interrupted if a more important task comes up, like when a higher-priority process needs to run (based on scheduling algorithm it using)
  • Waiting: If the process needs to do IO operation something like reading from a file, it goes to the waiting state. After it's done it goes back to the ready state, waiting for its turn again.
  • Terminated: When the process completes its tasks this state is called as terminated state.

AJAX (Asynchronous JavaScript and XML)

  • AJAX is a way to talk to a server without refreshing the whole web page. jQuery makes easy to handle AJAX requests
// Syntax: $.get(url, callback_function)
$.get({
    url: 'myserver.com/api/v1/users', // URL of server
    function(data, status) {
        // we can do whatever we want
    }
});


// Syntax: $.post(url, data, callback_function)
$.post({
    url: 'myserver.com/api/v1/login', // URL of server
    {
        username: 'username',   // data in json format
        password: 'password',
    },
    function(data, state) {
        // we can do whatever we want
    }
})

Transient

  • A transient is a way to store and retrieve temporary data in the database. It's often used to cache results of expensive database queries which we dont want to perform again and again.
  • Transient store the data in wp_options table.
  • We have some following function in wordpress to set, get and delete transient
    • set_transient(key, data, time_in_seconds)
    • get_transient(key)
    • delete_transient(key)

Cron Job

  • Cron jobs are scheduled tasks that run automatically at specified intervals, providing a convenient way to automate repetitive or time-sensitive processes.
  • For example, if I want to send notifications to users every Saturday at 12 PM, I can automate this using a cron job. Here, we will write a script to send notifications to users and set up a cron job to execute that script every Saturday at 12 PM.

Git and Github

Went throught different commands from basic to advance

  • git branch [branch-name]: Creates a new branch with the specified name
  • git checkout [branch-name]: Switch to specified branch
  • git checkout -b [branch-name]: Create and checkout to new branch with specified name
  • git merge [branch-name]: Merge changes from specified branch in current branch
  • git branch -d [branch-name]: Delete specified branch
  • git clone [url]: Copy a repo on local machine it will include all commits and history

Sync With Remote Repository:

  • git fetch: Download all history from remote branch
  • git merge: Merge remote branch changes to local branch
  • git push: Push changes to remote repository
  • git pull: Fetches the changes from remote repository to current local branch

Redo Changes

  • git reset [commit]: Undo all changes after the specified commit

Stash

  • git stash push [msg]: Stash changes with message
  • git stash pop: Apply the latest stash and remove it from stash
  • git stash apply [stash]: Applies a specific stash to working directory

Additional Advance Commands

  • git cherry-pick [commit]: Integrates the changes from the specified commit into the current branch