Skip to content

Instantly share code, notes, and snippets.

@pratapaditya1997
pratapaditya1997 / Git_Notes.md
Created July 29, 2020 20:26
some notes on git

Git Notes

VCS - Version Control System tracks the history of changes on a project

DVCS - Distributed VCS. Git is also a DVCS. Git doesn't need a constant connection to a central repository. Developers can work anywhere and colloborate asynchronously from any time zone.

Repository - repo or git project. It encompasses the entire collection of files and folders associated with the project, along with each file's revision history. This revision history appears as snapshots called commits, and the commits exist as a linked list relationship and can be organized into multiple lines of development called branches

Some very basic commands in Git are

  1. git init - initializes a brand new git repo. It adds a hidden subfolder that houses the internal data structures required for version control
@pratapaditya1997
pratapaditya1997 / Locking.java
Created July 8, 2020 16:30
Lock and ReadWriteLock implementation
/*
* in ReadWriteLock notifyAll() is called rather than notify()
* inside this lock many threads are waiting for read access and threads waiting for write access. if a thread is awakened by notify() was a read access thread, it would be put back to waiting because there are threads waiting for write access.
* however none of the threads awaiting write access are awakened, so nothing more happens. no threads gain neither read nor write access.
*/
class ReadWriteLock {
private int readers = 0;
private int writers = 0;
private int writeRequests = 0;
@pratapaditya1997
pratapaditya1997 / ThreadPool.java
Created July 8, 2020 16:19
Thread pool implementation using our BlockingQueue created earlier
//we are using our own definition of BlockingQueue as created by us in BlockingQueue.java file
public class ThreadPool {
private BlockingQueue<Runnable> taskQueue = null;
private List<PoolThread> threads = new ArrayList<PoolThread>();
private boolean isStopped = false;
public ThreadPool(int noOfThreads, int maxNoOfTasks) {
taskQueue = new BlockingQueue<Runnable>(maxNoOfTasks);
for(int i=0; i<noOfThreads; i++) {
threads.add(new PoolThread(taskQueue));
@pratapaditya1997
pratapaditya1997 / BlockingQueue.java
Created July 8, 2020 16:18
Blocking Queue implementation
import java.util.*;
public class BlockingQueue<T> {
private Queue<T> queue = new LinkedList<T>();
private int capacity = 10; //default capacity is 10
BlockingQueue() {}
BlockingQueue(int capacity) {
this.capacity = capacity;
}
@pratapaditya1997
pratapaditya1997 / postgres-database-migration.md
Last active November 15, 2021 22:43
my first blog article ever. this is on how to migrate postgres database from one server to another

title: "Postgres Database Migration" date: 2020-04-17T21:00:46+05:30 draft: true metaAlignment: center categories: [] tags: []