Skip to content

Instantly share code, notes, and snippets.

@yuanmai
yuanmai / gist:3525188
Created August 30, 2012 09:57
Bowling Score in PicoLisp
(de frame @
(when (next)
(link
(make
(if (= 10 (link (arg)))
(apply link (head 2 (rest)))
(when (= 10 (+ (arg) (link (next))))
(link (car (rest))) ) ) ) )
(pass frame) ) )
@yuanmai
yuanmai / gist:3447359
Created August 24, 2012 08:10
Self changing picolisp
;; http://software-lab.de/doc/faq.html#interpreted
(de incMe ()
(do 8
(printsp 0)
(inc (cdadr (cdadr incMe))) ) )
: (incMe)
0 1 2 3 4 5 6 7 -> 8
: (incMe)
@yuanmai
yuanmai / gist:3291295
Created August 8, 2012 01:42
Google map fitBounds
// Make an array of the LatLng's of the markers you want to show
var LatLngList = array (new google.maps.LatLng (52.537,-2.061), new google.maps.LatLng (52.564,-2.017));
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds ();
// Go through each...
for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) {
// And increase the bounds to take this point
bounds.extend (LatLngList[i]);
}
// Fit these bounds to the map
(set! *print-length* 10)
(set! *print-level* 4)
@yuanmai
yuanmai / trace.clj
Created July 17, 2012 13:48
5x5 Tic Tac Toe
:-:-:-:-:-
:-:-:-:-:-
:-:-:-:-:-
:-:-:-:-:-
:-:-:-:-:-
move :X [1 0]
0 plies generated by AI (by far)
:-:-:-:-:-
:X:-:-:-:-
@yuanmai
yuanmai / gist:3108472
Created July 14, 2012 00:39
protocol defaults
(def greeting-defaults {:hello (fn [who] (str "hello " who))})
(defprotocol Greeting
(hello [who]))
(defrecord Person [name])
(extend Person
Greeting
greeting-defaults)
@yuanmai
yuanmai / gist:3103732
Created July 13, 2012 08:49
update-in vector
(def a {:k [1 2]})
(update-in a [:k 1] (constantly :ha))
@yuanmai
yuanmai / gist:3057776
Created July 6, 2012 02:49
replace call in bat file
sed 's/call //g' call-mvn.bat | sh
@yuanmai
yuanmai / gist:2994352
Created June 26, 2012 08:20
git svn add remote branch
git config --add svn-remote.newbranch.url https://svn/path_to_newbranch/
git config --add svn-remote.newbranch.fetch :refs/remotes/newbranch
git svn fetch newbranch [-r<rev>]
git checkout -b local-newbranch -t newbranch
git svn rebase newbranch