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
C# program: | |
using System; | |
using System.Threading.Tasks; | |
namespace Scratch | |
{ | |
class Program | |
{ | |
static void Main() |
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
0 * 0 = 0 5 * 0 = 0 | |
0 * 1 = 0 5 * 1 = 5 | |
0 * 2 = 0 5 * 2 = 10 | |
0 * 3 = 0 5 * 3 = 15 | |
0 * 4 = 0 5 * 4 = 20 | |
0 * 5 = 0 5 * 5 = 25 | |
0 * 6 = 0 5 * 6 = 30 | |
0 * 7 = 0 5 * 7 = 35 | |
0 * 8 = 0 5 * 8 = 40 | |
0 * 9 = 0 5 * 9 = 45 |
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
package truthy | |
interface Truthy for T { | |
fn truthy?(T) -> Boolean | |
} | |
def ||[A: Truthy, B: Truthy](a: A, b: B): A | B => truthy?(a) ? a : b | |
def &&[A: Truthy, B: Truthy](a: A, b: B): A | B => truthy?(a) ? a : b | |
def !(a: Truthy): Boolean => !a.truthy? |
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
fn slowAdd(x: Int, y: Int) -> Int { | |
sleep(2.seconds) | |
x + y | |
} | |
// main1 takes 4 seconds to run | |
fn main1() { | |
a = slowAdd(1, 2) | |
b = slowAdd(10, 20) | |
puts(a + b) |
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
interface Enumerable T for E { | |
fn each(E, T -> Unit) -> Unit | |
} | |
impl Enumerable T for Array T { | |
fn each(array: Array T, f: T -> Unit) -> Unit { ... } | |
} | |
impl Enumerable T for I : Iterator T { | |
fn each(it: I, visit: T -> Unit) = ... | |
} | |
impl Enumerable T for Iterator T { |
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
interface Enumerable T for E { | |
fn each(E, T -> Unit) -> Unit | |
} | |
impl Enumerable T for Array T { | |
fn each(array: Array T, f: T -> Unit) -> Unit { ... } | |
} | |
impl Enumerable T for I : Iterator T { | |
fn each(it: I, visit: T -> Unit) = ... | |
} | |
impl Enumerable T for Iterator T { |
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
interface Enumerable T for E { | |
fn each(E, T -> Unit) -> Unit | |
} | |
impl Enumerable T for Array T { | |
fn each(array: Array T, f: T -> Unit) -> Unit { ... } | |
} | |
impl Enumerable T for I : Iterator T { | |
fn each(it: I, visit: T -> Unit) = ... | |
} | |
impl Enumerable T for Iterator T { |
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
package hashids | |
MinAlphabetLength = 16 | |
SepDiv = 3.5 | |
GuardDiv = 12 | |
DefaultAlphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" | |
DefaultSeps = "cfhistuCFHISTU" | |
struct Encoder { |
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
// I found the following implementation (verbatim) of Fibers in Go at https://play.golang.org/p/NSIlZ327sC | |
// I'm capturing it here for future reference. | |
package main | |
import ( | |
"errors" | |
"fmt" | |
) |
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
brew install apple-gcc42 openssl libyaml libffi | |
xcode-select --install | |
export CC=/usr/local/bin/gcc-4.2 | |
export CFLAGS='-g -O2' | |
export RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` | |
export CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` | |
# I had to edit the svn repo URL in /usr/local/Cellar/ruby-build/20160913/share/ruby-build/1.8.7-p375 and change the URL from http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7 to https://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7 | |
rbenv install 1.8.7-p375 |