Skip to content

Instantly share code, notes, and snippets.

@casesandberg
casesandberg / keymap-manager.js
Created December 15, 2016 21:07
Dispatching Actions With Hotkeys Using Mousetrap
import Mousetrap from 'mousetrap'
export const init = (dispatch, state) => {
const keymaps = getKeymaps()
_.each(keymaps, (action, combo) => {
Mousetrap.bind(combo, () => {
dispatch(action(dispatch, state))
})
})
@casesandberg
casesandberg / list-item.js
Created December 6, 2016 18:48
reactcss playground
import React from 'react'
import reactCSS from 'reactcss'
const ListItem = ({ label, first, last, hover }) => {
const styles = reactCSS({
'default': {
item: {
marginTop: 1,
padding: 15,
background: '#333',
@casesandberg
casesandberg / server.js
Created November 7, 2016 20:35
Express + React Router
app.use(express.static('src'))
app.get('*', (request, response) => {
response.sendFile(path.resolve(__dirname, '../src', 'index.html'))
})
@casesandberg
casesandberg / index.js
Last active October 31, 2016 23:20
Auto Scope State to Selectors in Root Reducer
//reducers/index.js
import { scopeStateToSelectors } from '../helpers/redux'
import threads, { selectors as threadsSelectors } from './threads'
...
// Scopes the state sent down to each of the selector functions by the key:
export const selectors = scopeStateToSelectors({
threads: threadsSelectors,
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 🔑 Felony (PGP made easy) v0.0.1
Comment: 👀 How dafuq do I use this? --> http://felony.io 😉
xsFNBFdcTDwBEACd6x2F48mpnsWNvfXBxdFsvZfPw5D5PmN4XsDPHCHPlMXg
YZEK/PPNWKQUYkUCW7kjLRqoCwyik3uAoGTVHHIC9NaC2jOXfNTy85mLu1Hb
u4J3+RBdXOntzIvUB2I7JREYw31eSRutO9S8PNkOyzBo1JuPiX2oeolYboFv
Og7OHYvmd/Tcq0kojSgvV898rHB6a8fspbfZoJWd0Ac9bWSPmxvwyY9QG7EM
lrbd3EFlrjVBIGLxpN+BzBT3FzQGvJF98bCq3987es+7tqyf4ptAF3AOZIY0
PvblM1KusdVE1z/I14bC142OCHWfItQYXjdx5VmEfWOanLDnVl8cEC0OGeXP
@casesandberg
casesandberg / babel-regex.js
Created March 7, 2016 02:27
How can I transform file output?
export default function() {
return {
visitor: {
Program(path, { file: { code }}) {
code = transform(code)
},
},
};
}