Skip to content

Instantly share code, notes, and snippets.

View nitin42's full-sized avatar
👋

Nitin Tulswani nitin42

👋
View GitHub Profile
@nitin42
nitin42 / LOP.txt
Created April 5, 2016 05:49
Launching Other Programs from Python Interpreter
#### Launching other programs using python
You can launch other program using `Popen()` function present in built in `subprocess()` module.
To start an external progra, from your python script,pass filename to subprocess.Popen()
For example
```
>>> import subprocess
>>> subprocess.Popen('C:\\Windows\\System32\\calc.exe')
```
@nitin42
nitin42 / gist:f5fc37b1581967dd5d629ec02f7c7b3a
Created June 20, 2016 20:23
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@nitin42
nitin42 / eventemitter.js
Created June 19, 2017 21:46 — forked from mudge/eventemitter.js
A very simple EventEmitter in pure JavaScript (suitable for both node.js and browsers).
/* Polyfill indexOf. */
var indexOf;
if (typeof Array.prototype.indexOf === 'function') {
indexOf = function (haystack, needle) {
return haystack.indexOf(needle);
};
} else {
indexOf = function (haystack, needle) {
var i = 0, length = haystack.length, idx = -1, found = false;
@nitin42
nitin42 / SSR.md
Created July 11, 2017 15:25
server side rendering with glamorous

server side rendering

To perform server-side rendering, use renderStatic from glamor, which takes a callback. Render your component inside the callback and all of the calls to css() will be collected and generated html and css will be returned. This will also return an array of ids to rehydrate the styles for fast startup.

To perform rehydration, call rehydrate with the array of ids returned by renderStatic.

Example -

import { renderStatic } from 'glamor/server';
@nitin42
nitin42 / nativeJavaScript.js
Created July 21, 2017 12:52 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@nitin42
nitin42 / downshit-flow-typed.js
Created August 27, 2017 07:12
Flow typed definitions for downshift
// @flow
type A11yOptionsStatusMessageOptions = {
highlightedIndex: number,
highlightedValue: any,
inputValue: string,
isOpen: boolean,
itemToString: (item: any) => string,
previousResultCount: number,
resultCount: number,
This file has been truncated, but you can view the full file.
/*
Jimp v0.2.28
https://github.com/oliver-moran/jimp
Ported for the Web by Phil Seaton
The MIT License (MIT)
Copyright (c) 2014 Oliver Moran
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
class App extends React.Component {
state = { src: '', err: null }
render() {
return (
<ProcessImage
image='http://365.unsplash.com/assets/paul-jarvis-9530891001e7f4ccfcef9f3d7a2afecd.jpg'
colors={{
mix: {
color: 'mistyrose',
if(Function.prototype.name===undefined&&Object.defineProperty!==undefined){Object.defineProperty(Function.prototype,"name",{get:function(){var regex=/function\s([^(]{1,})\(/,match=regex.exec(this.toString());return match&&match.length>1?match[1].trim():""}})}if(String.prototype.trimRight===undefined){String.prototype.trimRight=function(){return String(this).replace(/\s+$/,"")}}var stylus=function(){function require(p){var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');if(!mod.exports){mod.exports={};mod.call(mod.exports,mod,mod.exports,require.relative(path))}return mod.exports}var bifs="called-from = ()\n\nvendors = moz webkit o ms official\n\n// stringify the given arg\n\n-string(arg)\n type(arg) + ' ' + arg\n\n// require a color\n\nrequire-color(color)\n unless color is a 'color'\n error('RGB or HSL value expected, got a ' + -string(color))\n\n// require a unit\n\nrequire-unit(n)\n unless n is a 'unit'\n error('unit expected, got a ' + -strin
@nitin42
nitin42 / gc.js
Created September 23, 2017 17:50
Mark and Sweep Algorithm implementation
let HEAP = [];
const A = {
language: 'JavaScript'
};
HEAP.push(A);
const root = () => HEAP[0];