Skip to content

Instantly share code, notes, and snippets.

Nicolas Hery nicolashery

Block or report user

Report or block nicolashery

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nicolashery
nicolashery / README.md
Last active Aug 29, 2015
(deprecated) Throttling key presses in JavaScript CSP
View README.md
@nicolashery
nicolashery / throttle.js
Last active Aug 29, 2015
Throttle a channel in js-csp
View throttle.js
// https://github.com/jlongster/js-csp
// Throttle ported from:
// https://gist.github.com/swannodette/5886048
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
nicolashery / divshot-webpack.md
Created Sep 25, 2014
Using env variables with Webpack and Divshot
View divshot-webpack.md

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).

Problem:

  • 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
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: https://github.com/abdullin/omni
// core.event
interface DomainEventType {
name: string;
}
interface DomainEvent {
_type: DomainEventType;
View keybase.md

Keybase proof

I hereby claim:

  • I am nicolashery on github.
  • I am nicolashery (https://keybase.io/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
// https://github.com/gaearon/redux
// 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
nicolashery / README.md
Created Sep 21, 2012
Python development web server for Windows
View README.md

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.

@nicolashery
nicolashery / README.md
Created Oct 18, 2012
Python setup on Windows
View README.md

Python setup on Windows

Last updated: Oct 2012

This document is a step-by-step walkthrough on how to set up Python and various tools on a Windows 7 environment.

The primary goal is to have a Python setup that can be used for data analysis, but some more general tools are also installed.

Console2

You can’t perform that action at this time.