Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nicolashery's full-sized avatar

Nicolas Hery nicolashery

View GitHub Profile
@nicolashery
nicolashery / README.md
Last active August 29, 2015 14:06
(deprecated) Throttling key presses in JavaScript CSP
@nicolashery
nicolashery / throttle.js
Last active August 29, 2015 14:06
Throttle a channel in js-csp
// 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;
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 September 25, 2014 16:42
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).

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 August 29, 2015 14:14
Sketchpad: Event-driven design in TypeScript
// Playing around with TypeScript
// Inspiration: https://github.com/abdullin/omni
// core.event
interface DomainEventType {
name: string;
}
interface DomainEvent {
_type: DomainEventType;
@nicolashery
nicolashery / keybase.md
Created April 17, 2015 16:09
Keybase proof

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:

// 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';
// 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 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.

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