Skip to content

Instantly share code, notes, and snippets.

View nyuichi's full-sized avatar

Yuichi Nishiwaki nyuichi

View GitHub Profile
@nyuichi
nyuichi / gist:3011564
Created June 28, 2012 14:02
Closure Conversion
(define (f)
(let ((x 0))
(let ((up (lambda () (set! x (+ x 1)) x))
(dn (lambda () (set! x (- x 1)) x)))
(cons up dn))))
(define g (f))
((car g)) ;=> 1
((car g)) ;=> 2
@nyuichi
nyuichi / init.el
Created July 21, 2012 04:44
emacs
(global-set-key "\C-h" 'delete-backward-char)
;;; Misc
(tool-bar-mode 0)
(show-paren-mode 1)
(global-linum-mode 1)
(setq column-number-mode t)
(setq indent-tabs-mode nil)
(setq make-backup-files nil)
@nyuichi
nyuichi / gist:3261210
Created August 5, 2012 02:38
JS2JSX translator regexp
_\(\w+\): function \(.+\) {$
function \1\2 {
\(\w+\): function \(.+\) {$
function \1\2 {
_function\s-
function _
$function
@nyuichi
nyuichi / gist:3320261
Created August 11, 2012 03:01
delimited continuation in post increment
// 後置インクリメントは限定継続を使って表せるし、
// 逆に限定継続の一番身近な例が後置インクリメント
// http://www.kmonos.net/pub/Presen/fltv/FLTV.pdf
class BigInt {
BigInt&/<noreturn> operator++(int) {
var f = rest_of_full_expression();
var g = after_full_expression();
var r = f(*this);
this->incr();
g(r);
@nyuichi
nyuichi / gist:3320473
Created August 11, 2012 03:40
amb operator
;;; amb stuff
;; stack of cc.
(define fail '())
;;; nondeterminsm macro operator
(define-syntax amb
(syntax-rules ()
((_) ((pop! fail)))
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
@nyuichi
nyuichi / gist:3376570
Created August 17, 2012 06:51
Gentoo Prefixインストールログ: 1.7でこけた
 * Package: app-shells/bash-4.2_p36
 * Repository: gentoo_prefix
 * USE: bootstrap elibc_Darwin kernel_Darwin net prefix userland_GNU x64-macos
 * FEATURES: nostrip preserve-libs
>>> Unpacking source...
>>> Unpacking bash-4.2.tar.gz to /Users/yuichi/Library/Gentoo/var/tmp/portage/app-shells/bash-4.2_p36/work
* Applying bash42-001 ...
 [ ok ]
* Applying bash42-002 ...
 [ ok ]
@nyuichi
nyuichi / gist:3377469
Created August 17, 2012 09:41
env FEATURES="-collision-protect" emerge --oneshot sys-apps/portageでコケる
>>> Emerging (1 of 32) sys-devel/gnuconfig-20120116
* gnuconfig-20120116.tar.bz2 RMD160 SHA1 SHA256 size ;-) ... [ ok ]
>>> Unpacking source...
>>> Unpacking gnuconfig-20120116.tar.bz2 to /Users/yuichi/Library/Gentoo/var/tmp/portage/sys-devel/gnuconfig-20120116/work
dyld: Library not loaded: /Users/yuichi/Library/Gentoo/usr/lib/libbz2.1.dylib
Referenced from: /Users/yuichi/Library/Gentoo/bin/bzip2
Reason: image not found
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
* ERROR: sys-devel/gnuconfig-20120116 failed (unpack phase):
@nyuichi
nyuichi / gist:3424743
Created August 22, 2012 11:42
v8benchmark on JSX
options | original(js) | --disable-type-check | --release
----------------+---------------+-----------------------+------------
Richards | 14975 | 7120 | 13905
DeltaBlue | 18883 | 10288 | 22123
RayTrace | 20752 | 28638 | 31534
RegExp | 3658 | 3781 | 3770
Splay | 5700 | 5680 | 5729
NavierStokes | 21095 | 21179 | 21327
(higher is better)
@nyuichi
nyuichi / error.log
Created August 23, 2012 12:03
nodejs.jsx
O-02551-MAC:example nishiwaki.yuichi$ jsx --run cat.jsx
fs.js:381
var r = binding.read(fd, buffer, offset, length, position);
^
Error: EAGAIN, no more processes
at Object.fs.readSync (fs.js:381:19)
at Function._Main.main$AS (/private/var/folders/9c/fvg4rhxn5c57ptdjzv3t69c95jvdwl/T/cat.jsx.73524.13953608600.js:119:18)
at Object.JSX.runMain (/private/var/folders/9c/fvg4rhxn5c57ptdjzv3t69c95jvdwl/T/cat.jsx.73524.13953608600.js:178:15)
at /private/var/folders/9c/fvg4rhxn5c57ptdjzv3t69c95jvdwl/T/cat.jsx.73524.13953608600.js:214:5