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 / 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,
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 / Flyweight.js
Created October 29, 2017 19:31
Flyweight pattern in a nutshell
function Flyweight (make, model, processor) {
this.make = make;
this.model = model;
this.processor = processor;
};
var FlyWeightFactory = (function () {
var flyweights = {};
return {
/*
React v16.1.0-beta
react-dom.production.min.js
Copyright (c) 2013-present, Facebook, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
Modernizr 3.0.0pre (Custom Build) | MIT
*/
/** @license React v16.1.0-beta
* react-dom.development.js
*
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
(function (global, factory) {