Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Boyko brianboyko

View GitHub Profile
View reduxify.js
// While I started the original Reduxify project on NPM, my repo partner, Johnathan Sun, improved on it.
// However, I still like incorporating my original into my own projects, and so I'm making this Gist for my
// own reference.
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
const pick = (state, list) => list.reduce((pv, cv) => {
pv[curr] = state[curr];
return pv;
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@brianboyko
brianboyko / util.js
Last active Aug 10, 2016
bindAllMethods()
View util.js
import _ from 'lodash';
/** function bindAllMethods()
* This takes and ES6 class with methods, and automatically binds "this" - ie.,
* the class itself, to the methods. This should not be used if even one
* method needs a different context for "this", but otherwise, it's a timesaver.
* @param {class} SomeClass - an ES6 class which contains methods
* @sideeffect - someClass will have "this" bound to all methods
*/
export const bindAllMethods = (someClass) => {
for(let key of Object.keys(someClass)){
@brianboyko
brianboyko / Number.prototype.iterate
Created May 29, 2016
Number.prototype.iterate - use to call a function multiple times on it's own output.
View Number.prototype.iterate
Number.prototype.iterate = function(func) {
let iters = this;
return (input) => {
let output = input;
for (let i = iters; i > 0; i--) {
output = func(output);
}
return output;
};
};
@brianboyko
brianboyko / callbacks.js
Created May 13, 2016
Explaining Callbacks
View callbacks.js
// Callbacks!
// Callbacks are both really, really simple,
// o((*^▽^*))o
// and really really difficult to wrap your head around.
// ( ´△`)
// They're what make Javascript so powerful... but also so complex.
// You're familiar with f(x) from algebra, right?
// ¯\_( ͠° ͟ʖ °͠ )_/¯
@brianboyko
brianboyko / reduxify.js
Created May 11, 2016
Reduxify.js - a boilerplate reducer for Redux/React
View reduxify.js
// ==========================
// ./utilities/reduxify.js
// desc: Development tools to automatically bind actions and storestate to props.
// ==========================
// More Details:
//
// Reduxify might not be the "standard" way of doing Redux; certainly,
// not every component will need access to every action, not everyone will
// need to pass the dispatcher or the getState() method to their components,
// and certainly, some users would prefer that each appliction exists on a
View gist:1a6083877bc65c983ef4
app.post('/', function(req, res){
console.log(req.body);
var type = req.body.type;
if(type === 'signup'){
console.log('type is signup')
passport.authenticate('local-signup', {
successRedirect: '/teacher',
failureRedirect: '#',
View gist:3b80d3f570f0c8acd7ae
<div ng-repeat="fbCriterion in fbCriteria" class="col-xs-8">
<label for="criteria">{{fbCriterion.name}}: {{fbCriterion.prompt}}</label>
<div class="range range-info">
<input type="range" name="range" min="1" max="100" value="50" ng-change="$('#' + fbCriterion.name).value=value" ng-model="presentation[fbCriterion.name]">
<output id="{{fbCriterion.name}}">50</output>
</div>
</div>
View gist:cd060c3e7077d42b3053
A flashing red traffic light signifies that a driver should do what?
A. stop *
B. speed up
C. proceed with caution
D. honk the horn
A knish is traditionally stuffed with what filling?
A. potato *
View gist:17d71eda0cd035f15f3b
// Your code here.
var isObject = function(x) {
if (typeof x === "object" && x !== null) {
return true;
} else {
return false;
}
};
var deepEqual = function(a, b) { // takes two objects
You can’t perform that action at this time.