Skip to content

Instantly share code, notes, and snippets.

View vasanthk's full-sized avatar

Vasa vasanthk

View GitHub Profile
View gist:64e723ddcdedac631701
<script src=""></script>
<script src=""></script>
function auth() {
var config = {
'client_id': 'OAUTH_CLIENT_ID',
'scope': ''

Getting Started with NPM (as a developer)

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

npm set "Your Name"
npm set ""
npm set ""

npm adduser


Better local require() paths for Node.js


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

vasanthk /
Last active November 30, 2023 14:29 — forked from ryanflorence/
React Folder Structure

Folder Structure


  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
View on-jsx.markdown

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

View functional-utils.js
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
vasanthk / ReduxMicroBoilerplate.js
Last active August 29, 2015 14:26 — forked from gaearon/ReduxMicroBoilerplate.js
Super minimal React + Redux app
View ReduxMicroBoilerplate.js
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
vasanthk /
Created October 6, 2015 03:49 — forked from jlongster/
List of immutable libraries

A lot of people mentioned other immutable JS libraries after reading my post. I thought it would be good to make a list of available ones.

There are two types of immutable libraries: simple helpers for copying JavaScript objects, and actual persistent data structure implementations. My post generally analyzed the tradeoffs between both kinds of libraries and everything applies to the below libraries in either category.

Libraries are sorted by github popularity.

Persistent Data Structures w/structural sharing

vasanthk / gist:9fe2550feecdae624f85
Created October 12, 2015 07:00 — forked from liamcurry/gist:2597326
Vanilla JS vs jQuery
View gist:9fe2550feecdae624f85

Moving from jQuery


// jQuery
$(document).ready(function() {
  // code
View Difference between debounce and

Difference between Debounce and Throttle


Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.