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
#include <stdio.h> | |
int fib(n) { | |
if ((n == 0)||(n == 1)) { | |
return n; | |
} else { | |
return fib(n-1) + fib(n-2); | |
} | |
} | |
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
(define (compile io-port) | |
(display "(display \"") | |
(let loop ((c (read-char io-port)) | |
(compile-state "normal")) | |
(if (not (eof-object? c)) | |
(begin | |
(loop (read-char io-port) (handle-token c compile-state))) | |
(if (equal? compile-state "normal") | |
(begin | |
(display "\")") |
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
(define lambda-cache (make-hash-table)) | |
(define (add-to-cache args) | |
(let ((fn (car args)) | |
(a (cadr args))) | |
(hash-table-set! lambda-cache args (fn a)) | |
(hash-table-ref lambda-cache args))) | |
(define (dynamic-call . args) |
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
# from: http://www.informit.com/articles/article.aspx?p=683059&seqNum=36 | |
class String | |
def levenshtein(other, ins=2, del=2, sub=1) | |
# ins, del, sub are weighted costs | |
return nil if self.nil? | |
return nil if other.nil? | |
dm = [] # distance matrix | |
# Initialize first row values | |
dm[0] = (0..self.length).collect { |i| i * ins } |
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
#include <stdio.h> | |
#include <string.h> | |
#include "mongoose.h" | |
#include <chibi/eval.h> | |
static void *callback(enum mg_event event, | |
struct mg_connection *conn, | |
const struct mg_request_info *request_info) { |
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
def lit(src) | |
eval src.split("\n").delete_if { |l| l[0]!='>' }.map {|l| l[1,l.length] }.join("\n") | |
end | |
lit <<src | |
This is a big wall of text with no Ruby code... | |
Does this work? | |
1 1 + . | |
I bet it didn't... maybe the following works: |
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
# -*- coding: utf-8 -*- | |
pairs = [["あ","a"], | |
["か","ka"], | |
["さ","sa"], | |
["た","ta"], | |
["な","na"], | |
["は","ha"], | |
["ま","ma"], | |
["や","ya"], |
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
#!/bin/sh | |
INBOX="/path/to/Maildir/cur" | |
SPAM="/path/to/Maildir/.spam/cur" | |
cd $INBOX | |
for i in `find ./ -type f -mmin -2` | |
do | |
echo "Testing $i" | |
if (cat $i | spamassassin | grep 'X-Spam-Flag..YES') | |
then echo "$i is spam" | |
mv $i $SPAM |
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
# This doesnt handle padding or non ascii, but its a rough implementation based on the wikipedia description | |
module RobBase64 | |
def self.encodebyte(byte) | |
case byte | |
when 0..25 then (byte+65).chr | |
when 26..51 then (byte-26+97).chr | |
when 52..61 then (byte-4).chr | |
when 62 then "+" | |
when 63 then "/" |
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
# -*- coding: utf-8 -*- | |
class Base256 | |
def initialize | |
@list = [['aardvark','adroitness'],['absurd','adviser'],['accrue','aftermath'],['acme','aggregate'],['adrift','alkali'],['adult','almighty'],['afflict','amulet'],['ahead','amusement'],['aimless','antenna'],['Algol','applicant'],['allow','Apollo'],['alone','armistice'],['ammo','article'],['ancient','asteroid'],['apple','Atlantic'],['artist','atmosphere'],['assume','autopsy'],['Athens','Babylon'],['atlas','backwater'],['Aztec','barbecue'],['baboon','belowground'],['backfield','bifocals'],['backward','bodyguard'],['banjo','bookseller'],['beaming','borderline'],['bedlamp','bottomless'],['beehive','Bradbury'],['beeswax','bravado'],['befriend','Brazilian'],['Belfast','breakaway'],['berserk','Burlington'],['billiard','businessman'],['bison','butterfat'],['blackjack','Camelot'],['blockade','candidate'],['blowtorch','cannonball'],['bluebird','Capricorn'],['bombast','caravan'],['bookshelf','caretaker'],['brackish','celebrate'],['breadline','cellulose'],['br |