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
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; |
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 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; |
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
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; | |
} |
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
class Human { | |
private age: number = 42; | |
getAge() { | |
return this.age; | |
} | |
} | |
let f = new Human().getAge | |
console.log(f()); |
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 { 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 | |
); |
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
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. |
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
((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); |
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 valueSource = 'hage'; | |
const keysSource = 'a/b/c'; | |
const keys = keysSource.split('/'); | |
const result = keys.reduceRight((value, key) => { | |
return { [key]: value }; | |
}, valueSource); | |
console.log(result); |
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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Web.Scotty | |
import Data.Aeson.TH | |
data Person = Person { name :: String, country :: String } | |
$(deriveJSON defaultOptions ''Person) |
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 System.Random | |
main = do | |
gen <- getStdGen | |
let xs = ["hage", "はげ", "ハゲ", "ハゲ" ,"禿" ,"彡⌒ミ"] | |
mapM_ putStr [xs !! i | i <- randomRs (0, length xs - 1) gen] |
NewerOlder