Skip to content

Instantly share code, notes, and snippets.

View sakshamsaxena's full-sized avatar

Saksham Saxena sakshamsaxena

View GitHub Profile
@sakshamsaxena
sakshamsaxena / Keeping your fork up to date.md
Last active June 13, 2018 10:33 — forked from CristinaSolana/gist:1885435
Keeping your fork up to date

1. Clone your fork:

git clone git@github.com:USERNAME/FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-USERNAME/ORIGINAL-REPO.git
git fetch upstream
@sakshamsaxena
sakshamsaxena / GitTips.md
Last active July 5, 2016 08:05
A list of common git situations and solutions
  • You have no files staged yet, but you're sure that all of these you will commit right now. Quick way?

    • git commit -am "Thou art badass."
  • You have some files staged, and some not. What will happen if I commit "all" of them?

    • git commit -am "Thou art badass." would only commit the staged files.
  • How do I selectively add multiple files to stage using a single command?

    • git add file1 file2 file3 file4 should do it.

git config --list

user.email=ontenth@live.com
user.name=sakshamsaxena
push.default=simple
url.git://.insteadof=https://
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true

General Development

1. Comparison Between Git, Mercurial, Sub Version

Git Hg SVN
Based on C Based on Python and C Based on C
Git thinks of its data more like a set of snapshots of a miniature filesystem Hg also has snapshot oriented design SVN only measures the diffs of the files
Distributed Distributed Centralized

JavaScript

Closures are special objects or functions that refer to independent variables and/or functions defined in a scope. These keep intact the environment in which they were created.

Normally, the local variables within a function only exist for the duration of that function's execution. However, a Closure retains the function as well as the "environment" (variables in that scope). Thus, the existence of that variable will be accounted for if we're using closures.

Closure definitions returns an accessible quantity like an object (in case of module pattern design) or a function (in case of attaching event listeners dynamically).

Programming

Sorting Algorithms

Name Best Average Worst Memory
Insertion n n^2 n^2 1
Selection n^2 n^2 n^2 1
Merge nlogn nlogn nlogn n
Heap nlogn nlogn nlogn 1
@sakshamsaxena
sakshamsaxena / GFGExtractor.js
Last active October 19, 2018 08:07
A simple JavaScript Snippet to get the list of all the links with titles on it's "Must Do Coding Questions" page.
// Extracted from "https://www.geeksforgeeks.org/must-do-coding-questions-for-companies-like-amazon-microsoft-adobe/" on April 7, 2018
/* How To Use :
1. Install Node.js
2. Fire up your console and create a fresh directory and enter it.
3. Run `npm init -y && npm i superagent cheerio`
4. Save this file in that directory.
5. Run it with `node GFGExtractor.js`
*/
/*
Required Modules
@sakshamsaxena
sakshamsaxena / Upgradation.md
Created June 17, 2018 11:08
How to Update Sublime Text 3 on Linux
  1. Download the tarball
  2. Extract the tarball. Let's say it is extracted to ~/Downloads/sublime_text_3
  3. Check where your current Sublime Text lies by running which subl or which sublime or whatever you've named it currently
  4. Move and overwrite the extracted folder over to the current Sublime's folder which you found above.
  5. Done!
using System;
namespace DemoApp
{
public class Almira
{
private Door Door { get; set; }
public void LockAlmira()
{
this.Door.LockDoor();

Find all HTML Style Comment Blocks

(?s)<!--.*?-->

The second question mark makes it non-greedy, and the first (?s) is the dotall identifier to include newlines in search.