Skip to content

Instantly share code, notes, and snippets.

View joeyfigaro's full-sized avatar
🦀
Becoming a Rustacean

Jay Figaro joeyfigaro

🦀
Becoming a Rustacean
View GitHub Profile
@joeyfigaro
joeyfigaro / configureStore.js
Created June 16, 2017 00:46
Ramda & Redux (when example)
function sayHello() {
return console.log('Hello.');
}
when(
equals(true, true),
sayHello
);
// -> Hello.
@joeyfigaro
joeyfigaro / configureStore.js
Last active June 16, 2017 00:45
Ramda & Redux (pick example)
store.subscribe(() => {
const state = store.getState();
storage.set('saved', pick(['lessons', 'auth', 'notifications'], state));
});
/*
{
saved: {
lessons: {...},
auth: {...},
@joeyfigaro
joeyfigaro / configureStore.js
Last active June 16, 2017 14:26
Real World Ramda: Configuring Your Redux Store
// client/store/configureStore.js
import { createStore } from 'redux';
import { compose, when, equals } from 'ramda';
import enhancer from 'client/store/enhancers';
import rootReducer from 'client/reducers';
function configureStore(initialState) {
const store = createStore(rootReducer, initialState, enhancer);
const addStoreToObj = obj => (obj.store = store);
@joeyfigaro
joeyfigaro / .hyper.js
Last active April 2, 2017 11:35
HyperJS Backup
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
@joeyfigaro
joeyfigaro / .hyper.js
Created April 2, 2017 00:39
Initial hyperjs config
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
@joeyfigaro
joeyfigaro / dsl-abstraction-proposal.md
Last active March 27, 2017 14:55
Early DSL abstraction proposal for redux apps

Overview

Idea suggests that we contain language within a module, auto-generate plurals and any other pieces off of a singular base, and consume the pieces throughout our code.

constants/language.js

export const USER = {
	SINGULAR: 'account_holder',
	PLURAL: () => `${USER.SINGULAR}s`
};
@joeyfigaro
joeyfigaro / gulp-reloader.js
Created January 25, 2017 23:11
Snippet for reloading gulp process when gulpfile.js is updated
//
// gulpfile.babel.js
//
import { spawn } from 'child_process';
function autoload() {
let process;
const spawnChildren = e => {
if (process) process.kill();
import React, { Component } from 'react';
import { Search } from 'reactabular';
import EasyTable from 'reactabular-easy';
import { list } from 'react-immutable-proptypes';
class UserTable extends Component {
static propTypes = {
users: list
}
@joeyfigaro
joeyfigaro / api-middleware-in-use.js
Last active September 17, 2016 23:32
Example of using redux API middleware
export const authenticate = (credentials) => ({
type: 'CALL_API',
[CALL_API]: {
types: [AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE],
endpoint: 'auth/login',
method: 'POST',
data: credentials
}
});
@joeyfigaro
joeyfigaro / ava-errors.md
Created September 6, 2016 16:56
AVA testing issue regarding dependency in node_modules

Error after running tests:

/<ProjectRepository>/node_modules/react-ga/src/index.js:51
          m = s.getElementsByTagName(o)[0];
                ^
TypeError: s.getElementsByTagName is not a function

Configuration from package.json: