Skip to content

Instantly share code, notes, and snippets.

@gaearon
gaearon / reducers.js
Last active December 11, 2020 14:56
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
import { action } from 'common/utils/redux/redux';
@action
export class Actions {
static types = {
set3d: Symbol('set3d')
};
static set3d(val) {
@bmhatfield
bmhatfield / .profile
Last active January 29, 2025 11:11
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@trueter
trueter / dev.config.js
Created April 12, 2016 09:32
DLL Bundles with webpack-isomorphic-tools
// Webpack config for development
var fs = require( 'fs' )
var path = require( 'path' )
var webpack = require( 'webpack' )
var WebpackIsomorphicTools = require( 'webpack-isomorphic-tools' )
var HappyPack = require( 'happypack' )
var assetsPath = path.resolve( __dirname, '../static/dist' )
var host = process.env.HOST || 'localhost'
@frankleng
frankleng / RHLclient.js
Last active August 1, 2016 19:05
Avoid RR warning in RHL 3.0
const createRoutes = require('../routes/root').default;
const routes = createRoutes(store);
const render = () => {
const { pathname, search, hash } = window.location;
return match({ routes, location: `${pathname}${search}${hash}` }, () => {
ReactDOM.render(
<AppContainer>
<Provider store={store}>
<Router

A top-level App component returns <Button /> from its render() method.

  1. What is the relationship between <Button /> and this in that Button’s render()?

  2. Does rendering <Button><Icon /></Button> guarantee that an Icon mounts?

  3. Can the App change anything in the Button output? What and how?


@rsms
rsms / btree.ts
Last active May 6, 2021 00:47
Compile-time constant binary tree for fast byte-array key lookups in JavaScript
export interface BTreeNode<T> {
k :ArrayLike<byte>
v :T
L? :BTreeNode<T>
R? :BTreeNode<T>
}
export class BTree<T> {
readonly root :BTreeNode<T>
constructor(root :BTreeNode<T>) {
@cmod
cmod / hugofastsearch.md
Last active April 17, 2025 23:32 — forked from eddiewebb/readme.md
Fast, instant client side search for Hugo static site generator
@sainnhe
sainnhe / everforest-dark-hard.yaml
Created April 3, 2021 01:34
Everforest base16
scheme: "Everforest dark, hard"
author: "Sainnhe Park ([email protected])"
base00: "2b3339" # Default Background
base01: "323c41" # Lighter Background (Used for status bars, line number and folding marks)
base02: "503946" # Selection Background
base03: "868d80" # Comments, Invisibles, Line Highlighting
base04: "d3c6aa" # Dark Foreground (Used for status bars)
base05: "d3c6aa" # Default Foreground, Caret, Delimiters, Operators
base06: "e9e8d2" # Light Foreground (Not often used)
<script>
var module = WebAssembly.instantiateStreaming(fetch("linked_list.wasm"), {});
</script>