Skip to content

Instantly share code, notes, and snippets.

View vasanthk's full-sized avatar

Vasa vasanthk

View GitHub Profile
@vasanthk
vasanthk / promises-faq.md
Created May 18, 2017 06:21 — forked from joepie91/promises-faq.md
The Promises FAQ - addressing the most common questions and misconceptions about Promises.
@vasanthk
vasanthk / react-event-handler-papp-props.jsx
Created January 16, 2017 03:28 — forked from sergiodxa/react-event-handler-papp-props.jsx
Example of how to use partial application to pass parameters to event handlers in React
// with props
import React, { Component } from 'react';
// this method work as a our base `handleClick` function
function handleClick(name, event) {
alert(`hello ${name}`);
}
class App extends Component {
constructor(props) {
@vasanthk
vasanthk / *state-machine-component.md
Created September 6, 2017 04:19 — forked from developit/*state-machine-component.md
265b lib for building pure functional state machine components. https://npm.im/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

Usage

The API is a single function that accepts 2 pure functions as arguments:

stateMachineComponent(reduce, render)
@vasanthk
vasanthk / redux-is-smarter-than-you-think.md
Created August 28, 2017 22:32 — forked from armw4/redux-is-smarter-than-you-think.md
Optimizing your react components via redux....shouldComponentUpdate for free and more...

The Beginning

Yes...it's true...redux is smart....smarter than you even know. It really does want to help you. It strives to be sane and easy to reason about. With that being said, redux gives you optimizations for free that you probably were completely unaware of.

connect()

connect is the most important thing in redux land IMO. This is where you tie the not between redux and your underlying components. You usually take state and propogate it down your component hiearchy in the form of props. From there, presentational

@vasanthk
vasanthk / redux-light-example.js
Created June 9, 2016 00:03 — forked from bloodyowl/redux-light-example.js
redux in 14 lines of code
const store = createStore((state = { counter: 0 }, action) => {
switch(action.type) {
case "INCREMENT":
return { counter: state.counter + 1 }
case "DECREMENT":
return { counter: state.counter - 1 }
default:
return state
}
})
@vasanthk
vasanthk / area.json
Created August 15, 2017 09:44 — forked from revelutions/area.json
Mike Bostock's zoomable pack hierarchy with my data.
{
"name": "Area",
"children": [
{
"name": "group3",
"children": [
{
"name": "group0",
"children": [
{
@vasanthk
vasanthk / plugins.md
Created August 11, 2017 22:36
Guidelines for using plugins to organize your hapi application

This document outlines the proper way of using plugins in a hapi-based application. By "proper" I mean "as designed". Of course you can do whatever you want in your code and there are many other patterns you can choose or develop, but this is what I had in mind when I designed the plugin system and as I continue to evolve it.

This document is a work-in-progress and only half-way done. It should probably move to a page on the hapijs.com site if someone wants to do the proofing work and submit it. I got bored writing it so will probably never finish it.

When should I organize my code using plugins?

Always.

Every hapi application should be implemented inside a plugin. This provides an easy path for extensibility and isolates your code from other plugins you are likely to use (e.g. inert for services static files, vision for template rendering, etc.). It also allows you to use more advace tools such as [glue](https://github.com/hapijs/g

@vasanthk
vasanthk / js-crypto-libraries.md
Created February 12, 2017 03:50 — forked from jo/js-crypto-libraries.md
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

I start with a list and plan to create a comparison table.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

@vasanthk
vasanthk / glam-for-css-folks.md
Created May 5, 2017 05:52 — forked from threepointone/glam-for-css-folks.md
why css purists will love glam

I made a little styling lib called glam

(some features are in development)

one

let's start off with the simplest use case. we'll make an 'index.html' page, and assume we've setup our js bundler to output bundle.js

@vasanthk
vasanthk / css-with-react-checklist.md
Created April 9, 2017 23:16 — forked from DavidWells/css-with-react-checklist.md
Lots of talk about different CSS solutions for React. This gist attempts to shed light on pros/cons of approaches.

Here is a checklist of all the things I need my CSS solution to handle.

I can explain any of the points. Leave a comment on the gist or tweet @DavidWells

Challenge: Take your favorite CSS solution and see how the checklist holds up.

  • Has ability Localize classes
  • Has ability to use global classes
  • Has ability to write raw CSS
  • Syntax highlighting and auto completion