Skip to content

Instantly share code, notes, and snippets.

@jdjkelly
jdjkelly / small.js
Last active April 30, 2017 18:47
simplest-possible-redux-app
import { createStore } from 'redux'; // CommonJS: const createStore = require('redux')['createStore']
const app = createStore((state, action) => { return state });
@jdjkelly
jdjkelly / Reducer.flow.js
Created April 30, 2017 16:38
flow-typed/redux.js
declare type Reducer<S, A> = (state: S, action: A) => S;
@jdjkelly
jdjkelly / createStore.js
Created April 30, 2017 16:27
redux/createStore.js
let currentReducer = reducer
let currentState = preloadedState
let currentListeners = []
let nextListeners = currentListeners
let isDispatching = false
@jdjkelly
jdjkelly / createStore.js
Last active April 30, 2017 16:16
redux/createStore.js
export default function createStore(reducer, preloadedState, enhancer) {
...
return {
dispatch,
subscribe,
getState,
replaceReducer,
[$$observable]: observable
}
}
@jdjkelly
jdjkelly / index.js
Created April 25, 2017 14:44
redux/index.js
export {
createStore,
combineReducers,
bindActionCreators,
applyMiddleware,
compose
}
Running bash inside docker
`docker run -it <image> /bin/bash`
@jdjkelly
jdjkelly / generate-highlights.rb
Created September 8, 2015 01:56
Kindle Highlights -> Jekll Collection
require 'kindle_highlights'
require 'active_support/inflector'
kindle = KindleHighlights::Client.new(ARGV[0], ARGV[1])
books = kindle.books
bsins = books.keys.select { |key| books[key] =~ Regexp.new(ARGV[2], 'i') }
bsins.each {|bsin| puts "#{bsin} #{books[bsin]}\n" }
puts "\nChoose a BSIN:"

Once, the Hassidic rabbi Zusya came to his followers with tears in his eyes. They asked him:

"Zusya, what's the matter?

And he told them about his vision; "I learned the question that the angels will one day ask me about my life."

The followers were puzzled. "Zusya, you are pious. You are scholarly and humble. You have helped so many of us. What question about your life could be so terrifying that you would be frightened to answer it?"

Zusya replied; "I have learned that the angels will not ask me, 'Why weren't you a Moses, leading your people out of slavery?' and that the angels will not ask me, 'Why weren't you a Joshua, leading your people into the promised land?"' Zusya sighed; "They will say to me, 'Zusya, why weren't you Zusya?'"

"Gamergate is a collective response to an epochal narrowing of human experience to the point where the only things we care to defend are consumer goods, distraction apparatuses whose reassuring simulations of progress and accomplishment must be sanctified because they can no longer imagine living without them."

@jdjkelly
jdjkelly / gist:de3a3873175186c8e562
Last active August 29, 2015 14:06
How to track events emitted by Uniiverse.com's Direct Payments Platform
// Include, and initialize analytics
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');