Skip to content

Instantly share code, notes, and snippets.

type Transition<State, Operation> = (state: State, operation: Operation) => State;
class Store<State, Operation> {
private initialState: State;
private operations: Operation[] = [];
private transition: Transition<State, Operation>;
private currentState: State;
constructor(initialState: State, transition: Transition<State, Operation>) {
this.initialState = initialState;
export default class Trie {
private tree: any = {};
public add(s: string): void {
let cur = this.tree;
for (const c of s) {
if (!cur[c]) cur[c] = { isString: false };
cur = cur[c];
}
cur.isString = true;
class TailRec<T> {
private next: () => TailRec<T>;
private done: boolean;
private result: T;
constructor(next: () => TailRec<T>, done: boolean, result: T) {
this.next = next;
this.done = done;
this.result = result;
}
class Human {
private age: number = 42;
getAge() {
return this.age;
}
}
let f = new Human().getAge
console.log(f());
import { OAuth1Session } from 'requests_oauthlib';
import json from 'json';
let savedSession = json.load(open('./twitter.json', 'r'));
let sess = OAuth1Session(
savedSession.ck
savedSession.cs
savedSession.at
savedSession.cs
);
Require Import Arith.Mult.
Definition is_even (n : nat) : Prop :=
exists (k : nat), n = 2 * k.
Theorem even_plus_even_is_even :
forall (n m : nat), is_even n /\ is_even m -> is_even (n + m).
Proof.
intro n.
intro m.
((x,w,d,i,g,b,p)=>{i=d.createElement('iframe');i.onload=()=>{g=Object.keys(i.contentWindow);for(b in window){p=w[b];if(w.hasOwnProperty(b)&&p&&!g.includes(b)){x[b]=p}}console.log(x)};i.src='about:blank';d.body.appendChild(i)})({},window,document);
const valueSource = 'hage';
const keysSource = 'a/b/c';
const keys = keysSource.split('/');
const result = keys.reduceRight((value, key) => {
return { [key]: value };
}, valueSource);
console.log(result);
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Web.Scotty
import Data.Aeson.TH
data Person = Person { name :: String, country :: String }
$(deriveJSON defaultOptions ''Person)
@AyaMorisawa
AyaMorisawa / hage.hs
Last active December 23, 2015 14:11
import System.Random
main = do
gen <- getStdGen
let xs = ["hage", "はげ", "ハゲ", "ハゲ" ,"禿" ,"彡⌒ミ"]
mapM_ putStr [xs !! i | i <- randomRs (0, length xs - 1) gen]