made with esnextbin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import type { Element } from "react" | |
import React from "react" | |
import invariant from "invariant" | |
type State = { | |
data: Object | null, | |
error: Error | null, | |
fetching: boolean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Async version of Array.prototype.reduce() | |
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => { | |
* acc[v] = await (await fetch(v)).json(); | |
* return acc; | |
* }, {}); | |
*/ | |
export async function reduce(arr, fn, val, pure) { | |
for (let i=0; i<arr.length; i++) { | |
let v = await fn(val, arr[i], i, arr); | |
if (pure!==false) val = v; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render } from 'react-dom'; | |
import { createStore, combineReducers } from 'redux'; | |
import { Provider } from 'react-redux'; | |
import { Router, Route, IndexRedirect } from 'react-router'; | |
import { useBasename, createHistory } from 'history'; | |
import { syncReduxAndRouter, routeReducer } from 'redux-simple-router'; | |
const reducer = combineReducers({ | |
routing: routeReducer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initialState() { | |
return []; | |
} | |
function selectReducer(state = initialState(), action) { | |
switch (action.type) { | |
case SELECT_OPTION: | |
return state.map(option => | |
option.id === action.id | |
? { ...option, selected: true } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew tap homebrew/completions | |
brew install django-completion | |
# resource your profile | |
source ~/.bashrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!#/usr/bin/python | |
import sys | |
file = open(sys.argv[1]) | |
lst = [] | |
for line in file: | |
lst.append(line.strip().split()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var urls = process.argv.slice(2); | |
var results = []; | |
var done = 0; | |
function printResults() { | |
for (var i = 0; i < 3; i++) console.log(results[i]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema; | |
var fields = { | |
// fields for model | |
name: String | |
}; | |
var ModelSchema = new Schema(fields); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Table = React.createClass({ | |
getInitialState: function () { | |
var data = []; | |
for (var r = 0; r < this.props.rows; r++) { | |
data[r] = []; | |
for (var c = 0; c < this.props.columns; c++) { | |
data[r][c] = 0; | |
} | |
} | |
return { |
NewerOlder