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
#!/bin/sh | |
# clean pkg and src | |
for x in $(ls); do | |
if [ -d "$x/src" ]; then | |
rm -rf $x/src; | |
fi; | |
if [ -d "$x/pkg" ]; then |
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
(defn fibs [] | |
"Generate a lazy sequence of fibonacci numbers" | |
(lazy-cat '(0 1) | |
(map + (fibs ) (rest (fibs ))))) | |
(println (take 20 (fibs ))) |
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
(define (subsets s) | |
(if (null? s) | |
(list null) | |
(let ((rest (subsets (cdr s)))) | |
(append rest (map (lambda (x) | |
(cons (car s) x)) | |
rest))))) | |
(subsets '(1 2 3)) |
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
#!/bin/env python | |
""" tryton_shell: A dirty shell for Tryton to quickly interact with it | |
usage: tryton_shell.py [-h] --config CONFIG --database DATABASE | |
arguments: | |
--config CONFIG Tryton config file. | |
--database DATABASE Tryton database. |
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
# Drop all test_* databases in Postgres | |
function dropalldb() | |
{ | |
for db in `psql -l | cat | egrep -o "test_[0-9]*"`; do | |
echo "Dropping " $db | |
dropdb $db; | |
done; | |
} |
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
import threading | |
def threadify(func): | |
"A decorator to run a function asynchronously" | |
def run(*fargs, **fkwargs): | |
threading.Thread(target=func, args=fargs, kwargs=fkwargs).start() | |
return run | |
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
# -*- coding: utf-8 -*- | |
""" | |
test_sale | |
Test Sale | |
:copyright: (c) 2013-2014 by Openlabs Technologies & Consulting (P) Limited | |
:license: BSD, see LICENSE for more details. | |
""" | |
import unittest |
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
; Purely functional implementation of Set data structure | |
(define set-init | |
(lambda (x) #false)) | |
(define (set-add set x) | |
(lambda (y) | |
(if (= x y) | |
#true | |
(set y)))) |
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
(define (seq lst last) | |
(if (empty? lst) | |
0 | |
(if (< last (first lst)) | |
(max (add1 (seq (rest lst) (first lst))) | |
(seq (rest lst) last)) | |
(seq (rest lst) last)))) |
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
open Core.Std | |
type tree = Empty | Node of int * tree * tree | |
let rec largest_bst t = | |
let min_exn (lst:int list) : int = | |
Option.value_exn (List.min_elt lst ~cmp:Int.compare) | |
and max_exn (lst:int list) : int = | |
Option.value_exn (List.max_elt lst ~cmp:Int.compare) | |
in |