Skip to content

Instantly share code, notes, and snippets.

extern crate regexp;
static VARIANTS : [&'static str, ..9 ] = [
"agggtaaa|tttaccct",
"[cgt]gggtaaa|tttaccc[acg]",
"a[act]ggtaaa|tttacc[agt]t",
"ag[act]gtaaa|tttac[agt]ct",
"agg[act]taaa|ttta[agt]cct",
"aggg[acg]aaa|ttt[cgt]ccct",
"agggt[cgt]aa|tt[acg]accct",
import System.Environment
multiple x n = x `mod` n == 0
multiple3or5 x = multiple x 3 || multiple x 5
problem n = sum $ filter multiple3or5 [1.. n - 1]
main = do
args <- getArgs
if length args == 1 then
putStrLn . show $ problem $ (read (head args) :: Int)
@JustAPerson
JustAPerson / README.md
Last active August 29, 2015 14:16 — forked from anonymous/README.md

Termal

Termal is a library for developing terminal applications using Termbox. Termbox is an ncurses-like library with a very simple API. Termal aims to enable the easy construction of complex interfaces.

Installation

@JustAPerson
JustAPerson / stuff.tl
Last active August 29, 2015 14:19
Tifflang Stuff
def true: zap
def false: swap zap
def and: dup i
def or: swap [dup] dip [] cons dip i
def not: ['false 'true] dip i
def xor: [dup 'not dip] dip i
def zero: zap []
def one: [i] cons
### Keybase proof
I hereby claim:
* I am JustAPerson on github.
* I am justaperson (https://keybase.io/justaperson) on keybase.
* I have a public key whose fingerprint is 152C BA67 C94B A770 02EE A3A4 FF7D A5FA 4B3B 039E
To claim this, I am signing this object:
@JustAPerson
JustAPerson / brain86.rs
Last active August 29, 2015 14:22
Brainfuck compiler
// Brain86
// This program compiles well-formed brainfuck code to x86 assembler.
// Requires rust nightly, nasm, and ld
//
// An interesting sample program:
// https://raw.githubusercontent.com/JustAPerson/brainrust/master/tests/mandelbrot.bf
//
// $ rustc brain86.rs
// $ cat mandelbrot.bf | ./brain86 > mandelbrot.s
// $ nasm -f elf64 mandelbrot.s
.PHONY: run
run: build
qemu-system-i386 bin/vos.bin
.PHONY: build
build: bin bin/vos.bin
bin/vos.bin: bin/util/mkdisk bin/boot/alpha.bin
ld -Lbin/boot/ -o $@ -T src/boot/boot.ld
@JustAPerson
JustAPerson / class.lua
Created January 30, 2012 03:38
custom class system
local type = type;
local function deepcopy(obj)
local new = {};
local type, constant = type, "table";
for i,v in pairs(obj) do
if type(v) == constant then -- if type == "table"
new[i] = deepcopy(v);
else
new[i] = v;
function copy(t)
local type, const = type, "table";
local new = {};
for i, v in next, t do
if type(v) == const then
new[i] = copy(v);
else
new[i] = v;
end
end
@JustAPerson
JustAPerson / args.lua
Created April 4, 2012 22:12 — forked from SunsetTech/args.lua
Number of arguments in function -- Extended with number of upvalues
function int(t)
return t:byte(1)+t:byte(2)*0x100+t:byte(3)*0x10000+t:byte(4)*0x1000000
end
function num_args(func)
local ok, dump = pcall(string.dump,func)
if (not ok) then return -1 end
local cursor = 13
local offset = int(dump:sub(cursor))
cursor = cursor + offset + 13