Skip to content

Instantly share code, notes, and snippets.

View AlexMost's full-sized avatar

Alexander AlexMost

View GitHub Profile
fibs = ->
[a, b] = [-1, 1]
->
[a, b] = [b, a + b]
b
fibs = 0:1: zipWith (+) fibs (tail fibs)
@AlexMost
AlexMost / formatting.py
Created September 25, 2014 21:48
python formating examples
# 1. lookup values within objects
from datetime.datetime import now
print "minutes = {0.minutes}".format(now())
# 2. %s or %r == __str__() or __repr__()
# 3
print "{0:>10}".format("some")
print "{0:>10}".format("some"1)
# will print out
// Simple implementation of funciton for autocurrying other functions
// accepst function as a parameter
function curry(f) {
return function(){
var args = Array.prototype.slice.call(arguments);
if (args.length >= f.length){
return f.apply(this, args)
} else {
return curry(args.reduce(function(f, arg){return f.bind(this, arg)}, f));
function caller(f) {
f();
}
class A {
constructor(name) {
this.name = name;
}
/* @flow */
class Monad<M> {
bind(f: (a: any) => Monad<M>): Monad<M> {
return this // tmp stub, don't know how to implement interface in flow without implementation.
}
}
class Maybe<T> extends Monad<Maybe> {
val: T;
function getDelayedMessages(stream, scheduler) {
return stream.delay(100, scheduler)
}
const chai = require('chai');
const rxAssert = require('chai-rx-assert');
chai.use(rxAssert);
const expect = chai.expect;
const {TestScheduler, ReactiveTest: {onNext, onCompleted}} = require('rx');
describe('Test delay', () => {
it('test getDelayedMessages', () => {
const scheduler = new TestScheduler();
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ var parentJsonpFunction = window["webpackJsonp"];
/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [], result;
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
// var a = 5;
// {
// let a = 7;
// console.log(`scoped ${a}`)
// }
// function test() {
// console.log(a);
// }