Skip to content

Instantly share code, notes, and snippets.

import { combineReducers } from 'redux'
import { createAction, reduceActions } from './playground';
export const addTodo = createAction('ADD_TODO', combineReducers({
todos(state = [], text) {
return [
{
id: state.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1,
completed: false,
text
export const simpleAction = () => {
return {
type: 'SIMPLE_ACTION'
};
};
export const complexAction = (arg) => {
return {
type: 'COMPLEX_ACTION',
arg
@chapel
chapel / actions.js
Last active February 21, 2016 05:44
playing around with redux
import { createAction, createEffect, reduceActions } from './playground';
export const addTodo = createAction('ADD_TODO', (state, text) => {
return [
{
id: state.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1,
completed: false,
text
},
...state
1,2c1,3
< CREATE TYPE check_parent_table AS (parent_table text, count bigint);
< CREATE TABLE part_config (
---
> CREATE SCHEMA partman;
> CREATE TYPE partman.check_parent_table AS (parent_table text, count bigint);
> CREATE TABLE partman.part_config (
21,22c22,23
< CREATE INDEX part_config_type_idx ON @extschema@.part_config (type);
< SELECT pg_catalog.pg_extension_config_dump('part_config', '');
@chapel
chapel / setup.js
Last active August 28, 2015 19:49 — forked from 58bits/setup.js
Lab BDD Setup
// Lab setup
var Code = require('code');
var Lab = require('lab');
var lab = exports.lab = Lab.script();
var describe = lab.describe;
var it = lab.it;
var before = lab.before;
var after = lab.after;
var expect = Code.expect;
Error: write after end
at writeAfterEnd (_stream_writable.js:130:12)
at Protocol.Writable.write (_stream_writable.js:178:5)
at write (_stream_readable.js:583:24)
at flow (_stream_readable.js:592:7)
at Socket.pipeOnReadable (_stream_readable.js:624:5)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
@chapel
chapel / About.md
Last active October 15, 2016 15:15
Discourse topic list customizations for http://discourse.wastingyourlife.co
var Wreck = require('wreck');
function collectData(count) {
var results = {};
var called = 0;
var index = 0;
return function (url) {
results[url] = {
url: url,
index: index
var Hapi = require('hapi');
var cv = require('opencv');
var cam = new cv.VideoCapture(0);
var server = Hapi.createServer(9999);
server.route({
path: '/cam.jpg',
method: 'GET',
@chapel
chapel / 1-output-new.txt
Last active August 29, 2015 14:02
UPDATE: I was wrong and my implementation has a critical bug and was lucky that the order I chose came to the correct answer. Leaving everything here for historical purposes. I modified the example JS script to use a more efficient way of processing the "forests". I also modified it to be run with Node.js. Based on: http://unriskinsight.blogspot…
$ node new-magicForest.js 2017 2055 2006
total forests: 6128
{ goats: 0, wolves: 0, lions: 4023 }
total time: 20ms