Skip to content

Instantly share code, notes, and snippets.

View vasanthk's full-sized avatar

Vasanth Krishnamoorthy vasanthk

View GitHub Profile
App Life Cycles
- Response
- Animations
- Idle
- Load (XHR, Websockets, HTML imports)
In Chronological Order:
Load (~1 sec) Initial page load
Idle (~ 50ms) Lazy load items
Response (~100ms) On interaction, respond within 100ms
@vasanthk
vasanthk / squash-pr-commits-to-one.txt
Last active August 29, 2015 14:23
Squash PR commits into a single commit
git fetch upstream
git checkout mybranch
git merge upstream/master
# if necessary, resolve conflicts and git commit
# ...
git reset --soft upstream/master
git commit -am 'Some cool description for a single commit'
git push -f
@vasanthk
vasanthk / dispatcher-callback.txt
Created June 11, 2015 06:06
Difference between Dispatcher and callbacks
Dispatcher is used to broadcast payloads to registered callbacks. This is different from generic pub-sub systems in two ways:
1) Callbacks are not subscribed to particular events. Every payload is dispatched to every registered callback.
2) Callbacks can be deferred in whole or part until other callbacks have been executed.

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

@vasanthk
vasanthk / .eslintrc
Created April 27, 2015 23:05
React + ES6 --- ESLint
{
"parser": "babel-eslint",
"env": {
"browser": true,
"es6": true,
"node": true
},
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": true,
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true
},
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"classes": true,
@vasanthk
vasanthk / keybase.md
Created April 21, 2015 18:58
Keybase.io

Keybase proof

I hereby claim:

  • I am vasanthk on github.
  • I am vasa (https://keybase.io/vasa) on keybase.
  • I have a public key whose fingerprint is 0872 9F46 406A ABE5 4EBC F69A 1BA1 6FF2 9340 598D

To claim this, I am signing this object:

@vasanthk
vasanthk / node-http-post-listener.js
Created April 20, 2015 12:13
A simple http server that listens for POST events at port 9000 and will print out the data it receives. This is useful for setting up as the url for a webhook and viewing/verifying the data that gets sent to that URL.
var app = require('http').createServer(handler);
var statusCode = 200;
app.listen(9000);
function handler (req, res) {
var data = '';
if (req.method == "POST") {
req.on('data', function(chunk) {
<html>
<head>
<script src="https://apis.google.com/js/client.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>
function auth() {
var config = {
'client_id': 'OAUTH_CLIENT_ID',
'scope': 'https://www.google.com/m8/feeds'
};