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 { compose, map, prop, curry, reduce, pipe } from 'ramda' | |
const combine = curry((c, o) => x => (<div>{c(x)} {o(x)}</div>)) | |
const combineComponents = (...args) => { | |
const [first, ...rest] = args | |
return reduce((acc, c) => combine(acc, c), first, rest) | |
} |
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
const Nuddles = function(clientId, clientSecret) { | |
this.clientId = clientId | |
this.clientSecret = clientSecret | |
} | |
let myNuddlesObject = new Nuddles("myidkey", "mysecrettoken") | |
const Venue = function(nuddlesObject, venueId) { |
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 on (object, eventName, listenerFn) { | |
object.addEventListener(eventName, listenerFn) | |
return function unsubscribe () { | |
object.removeEventListener(eventName, listenerFn) | |
} | |
} | |
on(object, 'eventName', callback); |
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
def fold(f, init, arr): | |
return init if len(arr) < 1 else fold(f, f(init, arr[0]), arr[1:]) | |
def map(f, xs): | |
return fold(lambda acc, v: acc + [f(v)], [], xs) | |
def multiplyByTwo(x): | |
def multiplySecond(y): | |
return x * y | |
return multiplySecond |
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 sys | |
from django.conf.urls import url | |
from django.http import HttpResponse | |
from django.conf import settings | |
settings.configure( | |
DEBUG=True, | |
SECRET_KEY='thisisthesecretkey', | |
ROOT_URLCONF=__name__, |
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
export someClass { | |
private relplay: ReplaySubject<any> = new ReplaySubject<any>(1); | |
subscribeToReplay(): ReplaySubject<any> { | |
return this.replay; | |
} | |
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
def most_populated(births, deaths): | |
b = dict((i, births.count(i)) for i in births) | |
d = dict((i, deaths.count(i)) for i in deaths) | |
alive = 0 | |
years = {} | |
for year in range(min(births), max(deaths)): | |
alive = alive + b.get(year, 0) - d.get(year, 0) | |
years[year] = alive | |
max_year = max(years.values()) | |
return [key for key, val in years.iteritems() if val == max_year] |
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
const map = f => arr => arr.map(f); | |
const compose = (f, g) => x => f(g(x)); | |
const add = x => y => x + y; | |
const nestedData = [[1, 2, 3], [4, 5, 6]]; | |
const nestedData2 = [[[1, 2, 3], [4 ,5, 6], [7, 8, 9]], [[1, 2, 3], [4 ,5, 6], [7, 8, 9]], [[1, 2, 3], [4 ,5, 6], [7, 8, 9]]]; | |
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 timeout( milliseconds: number = 0 ) { | |
return function( target, key, descriptor ) { | |
var originalMethod = descriptor.value; | |
descriptor.value = function (...args) { | |
setTimeout(() => { | |
originalMethod.apply(this, args); |
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 {EventEmitter} from 'events'; | |
import AppDispatcher from '../dispatcher/AppDispatcher'; | |
export default class BaseStore extends EventEmitter { | |
constructor() { | |
super(); | |
} | |
subscribe(actionSubscribe) { | |
this._dispatchToken = AppDispatcher.register(actionSubscribe()); | |
} |