Skip to content

Instantly share code, notes, and snippets.

View vasanthk's full-sized avatar

Vasa vasanthk

View GitHub Profile
@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 / 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 / idea.md
Created June 2, 2017 23:32 — forked from mxstbr/idea.md
Code splitting react-router routes with webpack 2

NOTE: Sokra confirmed I had a misunderstanding, Webpack is still a static build tool and the below won't work. It's still a nice concept though...

With webpack 1, code splitting react-router routes is quite tedious. It requires us to repeat the getComponent function over and over again. (See here for an explanation how it works with webpack 1)

Example:

<Router history={history}>
  <Route
    path="/"
@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 / 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 / draft.md
Created April 25, 2017 23:19 — forked from mpj/draft.md
Feedback for episode draft: 7 critical traits for a normal programmer

7 critical traits for a normal programmer

EARLY DRAFT FOR NEXT EPISODE, PLEASE PROVIDE FEEDBACK

This week I tweeted and tooted this question:

”What do you think are critical traits in a programmer? NOT to be super 10x or anything - just to feel good and function well professionally.”

Link to full threads here: [https://twitter.com/mpjme/status/855691565460848640]

@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
class Counter extends Component {
componentWillMount() {
let self = this;
class IfEven extends Component {
render() {
let {children} = this.props;
return !(self.props.value % 2) ? children : null;
}
}