I made a little styling lib called glam
(some features are in development)
let's start off with the simplest use case. we'll make an 'index.html' page,
and assume we've setup our js bundler to output bundle.js
I made a little styling lib called glam
(some features are in development)
let's start off with the simplest use case. we'll make an 'index.html' page,
and assume we've setup our js bundler to output bundle.js
const MODULE_DIR = /(.*([\/\\]node_modules|\.\.)[\/\\](@[^\/\\]+[\/\\])?[^\/\\]+)([\/\\].*)?$/g; | |
{ | |
loader: 'babel-loader', | |
test: /\.jsx?$/, | |
include(filepath) { | |
if (filepath.split(/[/\\]/).indexOf('node_modules')===-1) return true; | |
let pkg, manifest = path.resolve(filepath.replace(MODULE_DIR, '$1'), 'package.json'); | |
try { pkg = JSON.parse(fs.readFileSync(manifest)); } catch (e) {} | |
return !!(pkg.module || pkg['jsnext:main']); |
import { createStore, combineReducers } from 'redux' | |
const createInjectableStore = (createStore) => { | |
return (reducers) => { | |
const store = createStore(combineReducers(reducers)) | |
const replace = () => { | |
store.replaceReducer(combineReducers(reducers)) | |
} | |
store.injectReducer = (key, reducer) => { | |
reducers[key] = reducer |
I would recommend @acdlite's redux-actions over the methods suggested in this Gist.
The methods below can break hot-reloading and don't support Promise-based actions.
Even though 'redux-actions' still uses constants, I've come to terms with the fact that constants can be good, especially in bigger projects. You can reduce boilerplate in different places, as described in the redux docs here: http://gaearon.github.io/redux/docs/recipes/ReducingBoilerplate.html
// ------------ | |
// counterStore.js | |
// ------------ | |
import { | |
INCREMENT_COUNTER, | |
DECREMENT_COUNTER | |
} from '../constants/ActionTypes'; | |
const initialState = { counter: 0 }; |
var Dialog = React.createClass({ | |
mixins: [Portal], | |
createPortal: function() { | |
this.dialog = $(this.portalNode).dialog({ | |
autoOpen: false, | |
title: this.props.title, | |
close: this.props.onClose | |
}).data('ui-dialog'); | |
}, |
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
# AR transactions wrap a block of code, issuing a rollback if any errors are raised. | |
# | |
#(note: this gist makes use of SecondBase https://github.com/customink/secondbase) | |
require 'secondbase/model' | |
AR = ActiveRecord::Base | |
SB = SecondBase::Base | |
# The transaction returns the return value of the block | |
AR.transaction { 14 } #=> 14 |