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
View projections.js
// We can mentally separate "core state" from "derived state".
// Core state is where you can put normalized data (for relational data):
// it is the "single source of truth".
// Derived state is where you shape the core state into a representation that's
// closer to what you need in your views and components.
var coreState = {
venuesById: {
'v1': {id: 'v1', name: 'Hipster Coffee House'},
'v2': {id: 'v2', name: 'Veggies For Everyone'}
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';
@nicolashery
nicolashery / rxjs-react.js
Last active Feb 25, 2019
Fetching data asynchronously with RxJS and React
View rxjs-react.js
import React from 'react';
import _ from 'lodash';
import Rx from 'rx';
import superagent from 'superagent';
let api = {
host: 'http//localhost:3001',
getData(query, cb) {
superagent
View npm-cheat-sheet.sh
# avoid "works on my machine" by always locking dependency versions
npm config set save-exact=true
# install/uninstall project packages with flags that will update package.json
npm install --save lodash
npm install --save-dev jshint
npm uninstall --save lodash
# tool that makes upgrading dependencies easier, install it globally
npm install -g david
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:

@nicolashery
nicolashery / 01-simplest.jsx
Last active Nov 18, 2015
Snippets for blog post on isomorphic React + Flux
View 01-simplest.jsx
// - 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);
View react-render-tree.jsx
// Exploring using "expose React component tree as data" @swannodette
// (https://www.youtube.com/watch?v=5hGHdETNteE#t=1559)
// for routing and fetching data ("react-router-mega-demo" @ryanflorence)
// (https://github.com/rackt/react-router-mega-demo/blob/master/app/utils/fetchData.js)
var appState = {
route: '/contacts',
contacts: [],
messages: []
};
@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;
@nicolashery
nicolashery / gulpfile-react-jshint.js
Created Oct 20, 2014
Gulpfile for JSHint on a React app with watch, JSX error logging, and cache
View gulpfile-react-jshint.js
var gulp = require('gulp');
var react = require('gulp-react');
var jshint = require('gulp-jshint');
var cache = require('gulp-cached');
var jsFiles = [
'src/**/*.js',
'test/**/*.js',
'*.js'
];
@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:

You can’t perform that action at this time.