Skip to content

Instantly share code, notes, and snippets.

View wecing's full-sized avatar
🍄
Growing mushrooms

Chenguang Wang wecing

🍄
Growing mushrooms
View GitHub Profile
@wecing
wecing / closure.2.ir
Created April 8, 2014 06:04
IR of closure.lisp, phase 2
<build-in "display" $-3>
<build-in "+" $-7>
func #22 {
$-4 <- getupval 1
$-5 <- getupval 0
$-6 <- getarg 0
$23 <- deref $-4
$24 <- deref $-5
$16 <- funcall 3 $-7 $23 $24 $-6
}
@wecing
wecing / minimal.ir
Last active August 29, 2015 13:57
raw ir of minimal
$-1 "x"
$-2 "y"
$-3 "f"
$-4 "display"
$-5 "+"
$-6 "foldl"
$-7 "acc"
$-8 "v"
$-9 "eqv?"
$-10 "car"
@wecing
wecing / closure.py
Last active August 29, 2015 13:56
assembly level closure implementation (inspired by upvalues)
def f1():
x = 1
def f2():
y = 2
def f3():
return x+y
return f3
return f2
f1:
@wecing
wecing / t.html
Created August 30, 2013 19:03
Android 4.3 default browser bug
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>T</title>
<style>
body {
margin: 0; padding: 0;
@wecing
wecing / index.html
Created August 1, 2013 20:28
YUI charts bug demo
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Index</title>
</head>
<body>
<div id="chart-div" style="width:400px;height:400px;"></div>
<script src="http://yui.yahooapis.com/3.11.0/build/yui/yui-min.js"></script>
@wecing
wecing / t.py
Created July 27, 2013 19:29
That's why I dislike Haskell sometimes...
# this won't work because python's lambda doesn't have real pattern matching
return reduce(lambda ((acc, prev_nl), (line_idx, (x, nl))): (acc + [([x], line_idx+1)] if prev_nl else acc[:-1]+[(acc[-1][0]+[x], acc[-1][1])], nl), enumerate(lines_nl), ([], True))
@wecing
wecing / yang-yin-expanded.scm
Created March 31, 2013 07:48
"yang-yin" Expanded
(let* ((yin
((lambda (cc) (display #\@) cc) (call/cc (lambda (c) c))))
(yang
((lambda (cc) (display #\*) cc) (call/cc (lambda (c) c)))))
(yang yin))
snapshot A:
(let* ((yin
((lambda (cc) (display #\@) cc) _))
@wecing
wecing / yin-yang-expanded.scm
Last active December 15, 2015 15:09
the call/cc "yin-yang" puzzle's execution expanded
(let* ((yin
((lambda (cc) (display #\@) cc) (call-with-current-continuation (lambda (c) c))))
(yang
((lambda (cc) (display #\*) cc) (call-with-current-continuation (lambda (c) c)))))
(yin yang))
snapshot A:
(let* ((yin
((lambda (cc) (display #\@) cc) _))
@wecing
wecing / gist:5236053
Created March 25, 2013 09:49
My Emacs configure file (Mar. 25, 2013)
(add-to-list 'load-path "~/.emacs.d/")
;;; ; command=>meta
; (setq mac-command-modifier 'meta)
; for aquamacs: fullscreen
(global-set-key (kbd "<M-f12>") 'ns-toggle-fullscreen)
;;; scratch mode
(setq initial-major-mode 'text-mode)
@wecing
wecing / b.java
Last active December 14, 2015 10:59
344 VideoStore bug?
else if (t.equals("fastsearch")) {
/* same as search, only faster (and single words only) */
if (st.hasMoreTokens()) {
String movie_word = st.nextToken(); // !!!!!!!!!!!!!!!!!!!!!!!!!
System.out.println("Fast Searching for the movie '"
+ movie_word + "'");
q.transaction_fastSearch(cid, movie_word);
} else {
System.out.println("Error: need to type in movie title");
}