Skip to content

Instantly share code, notes, and snippets.

View theankitgaurav's full-sized avatar
🏠
Working from home

Ankit Gaurav theankitgaurav

🏠
Working from home
View GitHub Profile
[
{ "keys": ["super+backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["super+r"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
{ "keys": ["super+shift+up"], "command": "swap_line_up" },
{ "keys": ["super+shift+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} },
{ "keys": ["alt+super+i"], "command": "reindent", "args": {"single_line": false}},
@theankitgaurav
theankitgaurav / Default (OS X).sublime-keymap
Last active August 20, 2022 04:56 — forked from asafch/Default (OS X).sublime-keymap
IntelliJ style key-bindings for Sublime-text on MacOS
[
{ "keys": ["super+y"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["super+`"], "command": "toggle_side_bar" },
{ "keys": ["super+r"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
{ "keys": ["super+shift+up"], "command": "swap_line_up" },
{ "keys": ["super+shift+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} },
@theankitgaurav
theankitgaurav / http-status-codes.md
Last active July 23, 2018 16:23
A list of HTTP error codes and status
  • 400 BadRequest
  • 401 Unauthorized
  • 402 PaymentRequired
  • 403 Forbidden
  • 404 NotFound
  • 405 MethodNotAllowed
  • 406 NotAcceptable
  • 407 ProxyAuthenticationRequired
  • 408 RequestTimeout
  • 409 Conflict
@theankitgaurav
theankitgaurav / gist:1b71ce8c7f6b8f206307ae53f5b19d91
Last active December 18, 2017 10:42
Vanilla JS alternative to JQuery's document ready function
var callback = function () {
// The code to be executed after DOM is ready
}
if ( document.readyState === "complete" ||
(document.readyState !== "loading" && !document.documentElement.doScroll) ) {
callback();
} else {
document.addEventListener("DOMContentLoaded", callback);
}

Start a local repo and push to push to remote

git init

git add .

git commit -m "Add intial files"

git remote add origin REPO_URL

@theankitgaurav
theankitgaurav / this.md
Created November 20, 2016 07:35
An elegant illustration of the utility of 'this' in javascript

Why this?

If the this mechanism is so confusing, even to seasoned JavaScript developers, one may wonder why it's even useful? Is it more trouble than it's worth? Before we jump into the how, we should examine the why.

Let's try to illustrate the motivation and utility of this:

function identify() {
    return this.name.toUpperCase();
}
@theankitgaurav
theankitgaurav / jsArrayMethods.md
Last active November 17, 2016 07:12
Some js array utility methods

The shift() method removes the first element from an array and returns that element. This method changes the length of the array.

var a = [1, 2, 3];
a.shift();

console.log(a); // [2, 3]

The slice() method returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included). The original array will not be modified.

@theankitgaurav
theankitgaurav / functionalArrayMethods.md
Created November 4, 2016 16:37
JavaScript Map, Filter, Reduce methods Cheatsheet

map()

Use it when: You want to translate/map all elements in an array to another set of values.

Example: convert Fahrenheit temps to Celsius.

var fahrenheit = [0, 32, 45, 50, 75, 80, 99, 120];

var celcius = fahrenheit.map(function(elem) {
@theankitgaurav
theankitgaurav / randomHslColor.js
Created June 21, 2016 06:52
Random eye friendly color generator
var randomColor = function() {
return "hsl(" + Math.random() * 360 + ",50%,50%)";
};
@theankitgaurav
theankitgaurav / gist:5b9abb30be4fbb3b91e3c19d448963cd
Created June 21, 2016 06:48
NativeScript quick setup for windows cmd
To quickly set up your system for the latest NativeScript CLI, paste the following PowerShell script in the Command Prompt and hit Enter:
===========================================================================================================================
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))"
Alternatively, your can paste the following PowerShell setup script in a Windows PowerShell console and hit Enter:
======================================================================================================================