Namespace your flux action types to prevent collisions:
function constants(namespace, constants) {
return Object.freeze(
constants.reduce((obj, constant) => {
return {
...obj,
[constant]: `${namespace}/${constant}`
}
const R = require('ramda') | |
const colors = ['green', 'blue', 'red'] | |
const notEmpty = R.compose(R.not, R.isEmpty) | |
const minLength = a => b => R.length(b) > a | |
const hasPresetColors = x => R.indexOf(x, colors) !== -1 | |
const input = { | |
id: 1, | |
userName: 'Random', |
Namespace your flux action types to prevent collisions:
function constants(namespace, constants) {
return Object.freeze(
constants.reduce((obj, constant) => {
return {
...obj,
[constant]: `${namespace}/${constant}`
}
var Aws = require('aws-sdk'); | |
var sinon = require('sinon'); | |
// Only works for 'createBucket', 'update' and a few others since most API methods are generated dynamically | |
// upon instantiation. Very counterintuitive, thanks Amazon! | |
var createBucket = sinon.stub(Aws.S3.prototype, 'createBucket'); | |
createBucket.yields(null, 'Me create bucket'); | |
// For other methods, we can 'assign' the stubs to the proto, already defined function won't be overridden | |
var listBuckets = Aws.S3.prototype.listBuckets = sinon.stub(); |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# A simple Makefile alternative to using Grunt for your static asset compilation | |
# | |
## Usage | |
# | |
# $ npm install | |
# | |
# And then you can run various commands: | |
# | |
# $ make # compile files that need compiling | |
# $ make clean all # remove target files and recompile from scratch |
module.exports = function(grunt) { | |
// Load Grunt tasks declared in the package.json file | |
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
// Configure Grunt | |
grunt.initConfig({ | |
// grunt-contrib-connect will serve the files of the project | |
// on specified port and hostname |
// Short module explanation // Something to gather my thoughts | |
// // I think this looks cool. | |
// | |
module.exports = the_exported_function // Modules are a function. Always. | |
// | |
module.exports.extra = extra // Additional API entry points if | |
module.exports.other = other // desired. | |
// | |
var util = require('util') // Other packages from npm or core | |
var assert = require('assert') // No comma-first due to lots of |
#!/bin/bash | |
# License: Public Domain. | |
# Author: Joseph Wecker, 2012 | |
# | |
# -- DEPRICATED -- | |
# This gist is slow and is missing .bashrc_once | |
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch | |
# (Thanks gioele) | |
# | |
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile? |