Skip to content

Instantly share code, notes, and snippets.

@draftcode
draftcode / lscolors_convert.scm
Created January 10, 2009 14:46
Convert FreeBSD's LSCOLORS to FSF's LS_COLORS
#!/usr/bin/env gosh
(use srfi-1)
(use srfi-13)
(define (even-odd-map f-even f-odd lis)
(if (null? lis)
'()
(cons (f-odd (car lis))
(cons (f-even (cadr lis))
@draftcode
draftcode / locationchanger.sh
Created January 11, 2009 05:32
Change location following SSID
#!/bin/bash
## Settings
# locations (use to be used Location name here)
ATHOME="home"
ATWORK="titech"
# detect HOME
ATHOME_SSID="home_router_ssid"
ATWORK_SSID="titech-pubnet"
(define (gcd n m)
(cond ((= n 0) m)
((= m 0) n)
((> n m) (print (remainder n m)) (gcd (remainder n m) m))
((< n m) (print (remainder m n)) (gcd (remainder m n) n))))
; {{{
(define (poly-remove0 l)
(if (null? (cdr l)) l
find /opt/local/share/texmf-* $HOME/.texmf-var -name ls-R -depth 1 -exec cat {} \; | grep .sty | sort
#!/opt/local/bin/gosh
; 切符の足して10になるアレを解く
(use srfi-1)
(define Op '(Add Sub Mul Div))
(define (make-expr l r)
(map (lambda (x) (list x l r)) Op))
(define (evaluate expr)
(cond ((number? expr) expr)
@draftcode
draftcode / lexgen.scm
Created August 5, 2010 01:51
lexer generator written in scheme
#!/usr/bin/env gosh
(use srfi-1)
(use srfi-13)
;; {{{ utility functions
(define (unique-list eq l)
(if (null? l) l (lset-adjoin eq (unique-list eq (cdr l)) (car l) )))
(define (make-pair l)
(if (= (length l) 2) (list l)
#include <stdlib.h>
#include <stdio.h>
struct list {
int val;
struct list *next;
};
struct list *newlist()
{
fun {Flatten Xs}
case Xs
of nil then nil
[] X|Xr andthen {IsList X} then
{Append {Flatten X} {Flatten Xr}}
[] X|Xr then
X|{Flatten Xr}
end
end
#!/usr/bin/env ruby
require 'rake'
module FileWatchHandler
def execute
EM.stop_event_loop
end
alias :file_modified :execute
alias :file_moved :execute
(define-syntax b
(syntax-rules ()
((b) 1)))
(define-syntax a
(syntax-rules ()
((a) (b))))
(define-syntax b
(syntax-rules ()