Skip to content

Instantly share code, notes, and snippets.


Nicolas Hery nicolashery

View GitHub Profile
nicolashery /
Last active Aug 29, 2015
(deprecated) Throttling key presses in JavaScript CSP
nicolashery / throttle.js
Last active Aug 29, 2015
Throttle a channel in js-csp
View throttle.js
// Throttle ported from:
var csp = require('js-csp');
var chan = csp.chan;
var go = csp.go;
var put = csp.put;
var take = csp.take;
var timeout = csp.timeout;
View db.js
var merge = require('react/lib/merge');
var m = require('mori');
var toArray = function (val) {
if (!Array.isArray(val)) {
val = [val];
return val;
nicolashery /
Created Sep 25, 2014
Using env variables with Webpack and Divshot

Using env variables with Webpack and Divshot

This shows a way to have "environment variables" working for both the webpack-dev-server (local development) and the Divshot server (to test a build locally).


  • Divshot server expects a .env.json file in the project directory, and uses it to serve a __/env.js file
  • Webpack dev server can serve static files from the project directory, but we need to create the __/env.js file ourselves

A solution:

nicolashery / typed-event-driven.ts
Last active Aug 29, 2015
Sketchpad: Event-driven design in TypeScript
View typed-event-driven.ts
// Playing around with TypeScript
// Inspiration:
// core.event
interface DomainEventType {
name: string;
interface DomainEvent {
_type: DomainEventType;

Keybase proof

I hereby claim:

  • I am nicolashery on github.
  • I am nicolashery ( on keybase.
  • I have a public key whose fingerprint is 852A E7B2 14A7 7B4A 4A49 27D3 FA69 6E9C F40A DF41

To claim this, I am signing this object:

View redux-example.js
// example/Counter.js
import React from 'react';
import { performs, observes } from 'redux';
// Explicit import of stores/actions so you know what your component depends on
// (could also be useful for some static analysis tool?)
import { increment, decrement } from './actions';
import { CounterStore } from './stores';
View action-creator-callback.js
// 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
nicolashery /
Created Sep 21, 2012
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.


Simply put 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.

nicolashery / choco.txt
Created Dec 5, 2012
Chocolatey v0.9.8.20 testing
View choco.txt
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
> chocolatey update -pre
The most recent version of chocolatey available from '-Source "" -Source "" ' (if value is empty, using sources in nuget.config file) is On your machine you have installed.
Chocolatey ( 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).