Skip to content

Instantly share code, notes, and snippets.

View vasanthk's full-sized avatar

Vasa vasanthk

View GitHub Profile

cf-ui monorepo

Technical Decision

Build our UI framework inside a monorepo using Lerna.

TL;DR

Building npm packages across many individual repos make big changes difficult to make, test, and publish. Using a monorepo we can solve many of these and

Broken Promises

Technical Decision

Eliminate all promises from application.

TL;DR

The Promise API is the source of many confusing errors in our application, using node style callbacks eliminates the issue without reducing code quality.

import { connect } from 'react-redux'
import ProfilePicture from 'components/ProfilePicture'
import { changeProfilePicture } from '../actions'
export function mapStateToProps(state:any, ownProps:any):any
{
return {
profilePictureUrl: state.user.profilePictureUrl,
}
}
var npm = require("npm");
var fs = require("fs-extra");
var chokidar = require("chokidar");
var packagePaths = [
"../mobile-app/node_modules/shared-package/lib",
"../web-app/node_modules/shared-package/lib",
];
var noop = () => {};
@vasanthk
vasanthk / gist:285ae586fafc7d607ecd24aec57d364f
Created June 24, 2016 18:17 — forked from jagregory/gist:710671
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork git@github...my-fork.git
@vasanthk
vasanthk / pr.md
Created July 11, 2016 23:03 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

var tableRowNodes = document.querySelectorAll('.cast_list tr')
var tableRowArray = Array.from(tableRowNodes)
var {mainCast} = tableRowArray.reduce((acc, row) => {
if (!acc.firstSkipped) {
acc.firstSkipped = true
} else if (acc.restOfCastStarted) {
acc.rest.push(row)
} else if (row.classList.contains('odd') || row.classList.contains('even')) {
acc.mainCast.push(row)
} else {
@vasanthk
vasanthk / emojiToImage.js
Created August 8, 2016 23:46 — forked from mwunsch/emojiToImage.js
Replace emoji characters in a string with an image of said emoji.
// (c) 2012 Mark Wunsch http://markwunsch.com
// MIT license.
if (!String.fromCodePoint) {
/*!
* ES6 Unicode Shims 0.1
* (c) 2012 Steven Levithan <http://slevithan.com/>
* MIT License
*/
String.fromCodePoint = function fromCodePoint () {
@vasanthk
vasanthk / renderDoctor.js
Created October 3, 2016 18:36 — forked from timhwang21/renderDoctor.js
Diagnose inefficient renders by identifying "changed" props that are actually equal
import React from "react";
import { isEqual } from "underscore";
/**
* HOC for diagnosing unnecessary renders and identifying faulty selectors
*
* Adds a logger function to a component that lists all changed props
* Also checks if changed props are deeply equal
*
* Usage: Decorate the component you are investigating with renderDoctor:
@vasanthk
vasanthk / destructuring.js
Created October 16, 2016 22:46 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];