This file contains 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 join([ head, ...tail ], separator = ',') { | |
if (head === undefined && !tail.length) return ''; | |
return tail.length ? head + separator + join(tail, separator) : head; | |
} |
This file contains 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 filter([ head, ...tail ], fn) { | |
const newHead = fn(head) ? [ head ] : []; | |
return tail.length ? [ ...newHead, ...(filter(tail, fn)) ] : newHead; | |
} |
This file contains 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
// === Arrays | |
var [a, b] = [1, 2]; | |
console.log(a, b); | |
//=> 1 2 | |
// Use from functions, only select from pattern | |
var foo = () => [1, 2, 3]; |
This file contains 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 d3 = require('d3'); | |
var jsdom = require("jsdom-little"); | |
var React = require('react-native'); | |
var { View, Text } = React; | |
var Svg = require('./Svg'); | |
var parseDate = d3.time.format("%d-%b-%y").parse; | |
var D3Chart = React.createClass({ | |
componentDidMount() { |
This file contains 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
// library or otherwise | |
// { | |
type Func<T, TResult> = (value: T) => TResult; | |
type Predicate<T> = Func<T, boolean>; | |
function compose<TIn, TMiddle, TOut>(f: Func<TMiddle, TOut>, g: Func<TIn, TMiddle>) { | |
return (value: TIn) => f(g(value)); | |
} |
This file contains 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 { action } from 'common/utils/redux/redux'; | |
@action | |
export class Actions { | |
static types = { | |
set3d: Symbol('set3d') | |
}; | |
static set3d(val) { |
This file contains 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 reduce([ head, ...tail ], fn, initial) { | |
if(head === undefined && tail.length === 0) return initial; | |
if(!initial) { | |
const [ newHead, ...newTail] = tail; | |
return reduce(newTail, fn, fn(head, newHead)); | |
} | |
return tail.length ? reduce(tail, fn, fn(initial, head)) : [ fn(initial, head) ]; | |
} |
This file contains 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
$ rails generate scaffold BusinessEntry content:string --no-stylesheets --no-fixture --no-test-framework --no-helper --pretend | |
invoke mongoid | |
create app/models/business_entry.rb | |
route resources :business_entries | |
invoke scaffold_controller | |
create app/controllers/business_entries_controller.rb | |
invoke haml | |
create app/views/business_entries | |
create app/views/business_entries/index.html.haml | |
create app/views/business_entries/edit.html.haml |
This file contains 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 { Pipe } from 'angular2/core.js'; | |
/** | |
* Map to Iteratble Pipe | |
* | |
* It accepts Objects and [Maps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) | |
* | |
* Example: | |
* | |
* <div *ngFor="#keyValuePair of someObject | mapToIterable"> |
This file contains 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
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("XML", "ggplot2", "lubridate", "reshape2", "scales") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Find your XML file from those listed at | |
# http://cdn.realclearpolitics.com/epolls/charts/ | |
URL <- "http://cdn.realclearpolitics.com/epolls/charts/1171.xml" | |
parsedXML <- xmlParse(URL) # First pass |
OlderNewer