Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacob Chapel chapel

View GitHub Profile
View actions.js
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
View actions.js
export const simpleAction = () => {
return {
type: 'SIMPLE_ACTION'
};
};
export const complexAction = (arg) => {
return {
type: 'COMPLEX_ACTION',
arg
@chapel
chapel / actions.js
Last active Feb 21, 2016
playing around with redux
View actions.js
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
View pg_partman.diff
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 Aug 28, 2015 — forked from 58bits/setup.js
Lab BDD Setup
View setup.js
// 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;
View gist:a19c4f58e12e902628b9
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 Oct 15, 2016
Discourse topic list customizations for http://discourse.wastingyourlife.co
View About.md
View getall.js
var Wreck = require('wreck');
function collectData(count) {
var results = {};
var called = 0;
var index = 0;
return function (url) {
results[url] = {
url: url,
index: index
View cam.js
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 Aug 29, 2015
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…
View 1-output-new.txt
$ node new-magicForest.js 2017 2055 2006
total forests: 6128
{ goats: 0, wolves: 0, lions: 4023 }
total time: 20ms
You can’t perform that action at this time.