Skip to content

Instantly share code, notes, and snippets.

Avatar
🐮
https://github.com/RebootJeff/cowGoesMoo

Jeff Lee RebootJeff

🐮
https://github.com/RebootJeff/cowGoesMoo
View GitHub Profile
@RebootJeff
RebootJeff / formatHelpers.js
Last active Dec 19, 2018
OWL API parsing for SFS 2019 season schedule
View formatHelpers.js
const moment = require('moment')
const momentTz = require('moment-timezone')
const getWeek = (timestamp, stage) => {
// Use momentjs to get number of weeks since start of stage
return ' ??? '
}
const getOpponent = competitors => {
@RebootJeff
RebootJeff / reactReduxDynamicInitialStateExample.js
Created Jun 28, 2017
Illustrating a question on how to initialize state in redux
View reactReduxDynamicInitialStateExample.js
// How do I initialize state when I do *NOT* want to use hard-coded values?
// in MyComponent.js ...
const mapStateToProps = (state, ownProps) => {
return {
usernames: state.MyComponent.usernames,
selectedDesserts: state.MyComponent.selectedDesserts || ownProps.availableDesserts
};
};
@RebootJeff
RebootJeff / example.css
Last active Jun 20, 2017
rendering different message "things"
View example.css
.foo {
margin: 10px;
}
.banner {
padding: 10px;
text-align: center;
}
.error {
@RebootJeff
RebootJeff / combineKeyedArrays.js
Last active Feb 28, 2016
Beginner-friendly example of refactoring JavaScript to functional programming style
View combineKeyedArrays.js
// See this blog post for full explanation:
// https://rebootjeff.github.io/blog/2015/12/11/example-refactoring-to-functional-js-combine-keyed-lists/
// Dependencies
var _ = require('lodash');
var R = require('ramda');
// Example input
var usersBySocialNetwork = {
twitter: [
@RebootJeff
RebootJeff / cottage_garden.html
Last active Aug 29, 2015
HTML CSS example (for teaching)
View cottage_garden.html
<!DOCTYPE html>
<html>
<head>
<style>
body, h1, p {
border: 2px solid red;
}
h1, p {
margin: 10px;
@RebootJeff
RebootJeff / gist:c2f9752360591f7b784c
Last active Aug 29, 2015
Function composition for type conversion
View gist:c2f9752360591f7b784c
function makeConverter(pairs) {
function converter(value) {
for(var i = 0; i < pairs.length; i++) {
var predicate = pair[0];
var func = pair[1];
if(predicate(value)) {
return converter(func(value));
}
@RebootJeff
RebootJeff / promiseExamples.js
Last active Sep 27, 2018
Examples of common patterns for promises in JS
View promiseExamples.js
// =============================================================================
// Example for unit testing an async func that doesn't already support promises
var Q = require('q'); // You must do `npm install q` first
// Async function that uses callbacks instead of promises
function authenticate(dataToSubmit, callback) {
// blah blah blah
}