Skip to content

Instantly share code, notes, and snippets.

View jimbol's full-sized avatar
🕵️‍♂️
Working on a secret project

Jim Hall jimbol

🕵️‍♂️
Working on a secret project
View GitHub Profile
@jimbol
jimbol / assign-doest-do-deep.js
Created March 25, 2016 18:13
Object.assign doesn't deep copy
a = {b: 1, c:{ d:3 }}
z = Object.assign({}, a)
z.c.d = 4
console.log(a.c.d) // 4
@jimbol
jimbol / show-schedule.bookmarklet
Created May 20, 2016 04:48
show-schedule.bookmarklet
javascript:(function()%7Bvar%20table%20%3D%20document.getElementsByTagName('table')%5B2%5D%3Bvar%20rows%20%3D%20table.getElementsByTagName('tr')%3Bvar%20parseTime%20%3D%20function(rawDateTime%2C%20offset)%7Bvar%20tomorrow%20%3D%20new%20Date()%3Btomorrow.setDate(tomorrow.getDate()%20%2B%20offset)%3Bvar%20splitDateTime%20%3D%20rawDateTime.split('%5Cn%20%20')%3Bvar%20isPM%20%3D%20splitDateTime%5B1%5D.indexOf('pm')%20%3E%20-1%3Bvar%20date%20%3D%20splitDateTime%5B0%5D.split('%2F')%3Bvar%20month%20%3D%20parseInt(date%5B0%5D)%20-%201%3Bvar%20day%20%3D%20parseInt(date%5B1%5D)%3Bvar%20year%20%3D%20parseInt(date%5B2%5D)%3Bvar%20time%20%3D%20splitDateTime%5B1%5D.split('.')%3Bvar%20hour%20%3D%20parseInt(time%5B0%5D)%3Bif(isPM%20%26%26%20hour%20%3C%2012)%7Bhour%20%2B%3D%2012%3B%7Dvar%20min%20%3D%20parseInt(time%5B1%5D)%3Bif(tomorrow.getMonth()%20%3D%3D%3D%20month%20%26%26%20tomorrow.getDate()%20%3D%3D%3D%20day)%20%7Breturn%20new%20Date(year%2C%20month%2C%20day%2C%20hour%2C%20min)%3B%7D%7D%3Bvar%20s%20%3D%20%7Bcontainer%3A
Connection to localhost port 8081 [tcp/sunproxyadmin] succeeded!
Port 8081 already in use, packager is either not running or not running correctly
Command /bin/sh failed with exit code 2
@jimbol
jimbol / gist:46d76fa9abed1d8003e83d1659f37dbb
Created September 22, 2016 20:07
Thread download performance refactor
BEFORE THREAD DOWNLOAD REFACTOR
| ---------------------------------------------------------------------------------------------------- 8765 total
configure-store | ------------------ 1598ms
get-stored-stat | ----------------- 1567ms
create-store... | 7ms
run-saga-middle | 23ms
bootstrap...... | 53ms
download-device | ------- 688ms
get-devices.... | ------- 616ms
get-store...... | ---- 396ms
@jimbol
jimbol / spy-on-effects.js
Last active December 21, 2016 14:29
Spying on redux-saga effects
// In test file
const spy = effectSpy(generator)
.next('init')
.next('getToken', token) // name and pass in yield values
.next('getUpdatedFooBars', fooBars)
.next('putFooBars');
// in beforeEach
mySpyRun = spy.run({
@jimbol
jimbol / features.js
Last active November 15, 2016 17:07
Features module concept
// Having some sort of feature flags allows us to
// - write centralized logic around when to show features
// - develop features in smaller pieces behind feature flags
// - turn on/off features at will
// In a view, effect, whereever
import features from '../features'
if (features('showFooBar')) {
// display FooBar
@jimbol
jimbol / README.md
Last active November 16, 2016 15:21
Redux-Saga Effect Runner

Testing with Effect Runner

A Redux-Saga test runner for Mocha

Goals

  • Switching the order of instructions should be easy
  • Associate instructions with their results
  • Changing instruction results should be easy

Guide

@jimbol
jimbol / selector-dep-injection.js
Created January 27, 2017 14:03
Selector dependency injection
// It gets hard to test combined selectors after a while.
// The dependency chains run deep. To get around this we
// can test the callback function seperately from the rest
// of the selector, but that leaves a testing gap.
// In order to test that createSelector gets called with the
// right stuff, we could do something like this
// WARNING UNTESTED CODE
@jimbol
jimbol / eq-eq-null.js
Created January 31, 2017 15:10
equals equals null
0 == null; // false
'' == null; // false
undefined == null; // true
@jimbol
jimbol / partial-reducers.js
Last active February 6, 2017 16:06
Partial reducers
// my-reducer.js
function myReducer(plugins, state, action) {
// ...
}
// reducers.js
import { myReducer } from './my-reducer';
export const reducers = {
myReducers,