Skip to content

Instantly share code, notes, and snippets.

View nicolashery's full-sized avatar

Nicolas Hery nicolashery

View GitHub Profile
@nicolashery
nicolashery / process_customers.js
Created November 29, 2013 14:32
Working with JSON using Node.js, Streams, and the Unix command line
// Usage:
// cat customers_raw.json | node process_customers > customers.json
// https://github.com/dominictarr/JSONStream
var JSONStream = require('JSONStream');
// https://github.com/rvagg/through2
var through2 = require('through2');
process.stdin
.pipe(JSONStream.parse('*'))
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://cloud.gf3.ca/M5rG
# A big thanks to \amethyst on Freenode
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
fi
if tput setaf 1 &> /dev/null; then
@nicolashery
nicolashery / variable-names.js
Last active December 24, 2015 03:59
Change variable names to another naming convention in JavaScript
// Change variable names to another naming convention
//
// Thanks to Oliver Caldwell for the inspiration
// http://oli.me.uk/2013/09/25/grabbing-elements-from-the-dom/
// 'hello_world' -> 'helloWorld'
function snakeToCamelCase(name) {
return name.toLowerCase().replace(/_(\w)/ig, function (match, hump) {
return hump.toUpperCase();
});
@nicolashery
nicolashery / no-framework.md
Last active December 19, 2015 14:09
Exploring the possibility of building a web app without frameworks

Building a web app without a framework

Rough draft exploring the possibility of building a web app without a framework, picking and choosing from small & focused pieces, a la Unix.

Tools

Packages/Modules

@nicolashery
nicolashery / markdown-cheat-sheet.md
Last active December 18, 2015 07:48
Markdown cheat sheet

Markdown cheat sheet

# Header 1

## Header 2

### Header 3

This is a paragraph.
@nicolashery
nicolashery / 01-simplest.jsx
Last active November 18, 2015 09:26
Snippets for blog post on isomorphic React + Flux
// - rendering library (like React) should be able to "pick up" where server
// left off (i.e. hook up to the existing HTML)
// server.js
var server = express();
server.use(function(req, res) {
var appHtml = React.renderToString(<App />);
var html = injectIntoHtml({app: appHtml});
res.send(html);
@nicolashery
nicolashery / 0-flowtype-playground.js
Last active October 28, 2015 17:48
Flow playground (flowtype.org)
/* @flow */
import _ from "lodash";
type UserId = string;
type UserRole =
'admin' |
'guest' |
'member';
@nicolashery
nicolashery / choco.txt
Created December 5, 2012 15:18
Chocolatey v0.9.8.20 testing
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
> chocolatey update -pre
The most recent version of chocolatey available from '-Source "http://chocolatey.org/api/v2/" -Source "https://go.microsoft.com/fwlink/?LinkID=230477" ' (if value is empty, using sources in nuget.config file) is 0.9.8.20-beta1. On your machine you have 0.9.8.19 installed.
=====================================================
Chocolatey (0.9.8.19) is installing chocolatey to "C:\Chocolatey\lib". By installing you accept the license for the
package you are installing (please run chocolatey /? for full license acceptance terms).
=====================================================
@nicolashery
nicolashery / README.md
Created September 21, 2012 14:48
Python development web server for Windows

Python development web server for Windows

This is a simple Python script to serve static files from any project directory, useful when doing web development.

Usage

Simply put server.py and server.cmd in a directory, for instance C:\Users\YourName\bin and add that directory to your PATH.

Then in the console, cd to your project folder, type server and hit Enter (it will run on port 8000 by default, use server 5000 for example to change port). Use Ctrl+C to stop the server.

// Flux actions called by views (components) are meant to be "fire and forget":
// the view will get an update after the dispatcher has updated the store.
//
// But sometimes, for view state that only really matters to the mounted
// component (like a loading indicator), it might be simpler to have
// a "done" callback in the action creator. This is considered a Flux
// anti-pattern, but if you don't actually pass data to the callback, you
// make sure not to break the "store = single-source of truth" principle.
// For example, let's say we have a widget that allows the user to add places