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
find ./db/migrate/* | xargs sed -i 's/create_table [^ ]*/&, :options => "ENGINE=MEMORY"/' |
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
This is my short-ish tutorial on how to implement closures in | |
a simple functional language: Foo. | |
First, some boilerplate. | |
> {-# LANGUAGE DeriveFunctor, TypeFamilies #-} | |
> import Control.Applicative | |
> import Control.Monad.Gen | |
> import Control.Monad.Writer | |
> import Data.Functor.Foldable |
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
;; Delimited continuations | |
#lang racket ; but will work in any Scheme (without this line) | |
;; There are other implementations along the same lines floating around. | |
;; Here we are trying to paint a more comprehensible (or at least a less | |
;; incomprehensible) picture by structuring the implementation as three | |
;; distinct layers: | |
;; Layer 1 |
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
from ast import ( | |
NodeTransformer, | |
arguments, | |
arg, | |
Lambda, | |
parse, | |
In, | |
Call, | |
Expression, | |
fix_missing_locations, |
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
let valid_cpf cpf = | |
let aux size = | |
let sum = ref 0 in | |
for i = 0 to (size - 2) do | |
sum := !sum + cpf.(i) * (size - i); | |
done; | |
!sum * 10 mod 11 | |
in | |
(aux 10) == cpf.(9) && (aux 11) == cpf.(10) |
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
type exists<V> = <Y>(p: (v: V) => Y) => Y; | |
// module interface | |
type Unique_S<T> = { | |
next: () => T, | |
equal: (a: T, b: T) => boolean, | |
compare: (a: T, b: T) => number, | |
show: (t: T) => string, | |
}; |
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
type Eq<A, B> = <X>(a: A, eq: (x: A & B) => X) => X; | |
const refute = (x: never) => x; | |
const refl = <A, X>(a: A, eq: (x: A) => X) => eq(a); | |
const sickos = <A>(x: A, eq: Eq<A, number>) => eq(x, (x) => x); | |
const two = sickos(2, refl); | |
type Ty<A> = | |
| { tag: "number"; eq: Eq<A, number> } | |
| { tag: "string"; eq: Eq<A, string> }; |