Skip to content

Instantly share code, notes, and snippets.

@m2ym
m2ym / eval-in-lexenv.lisp
Created March 14, 2012 08:46
eval-in-lexenv
(defmacro m (&environment env)
(sb-int:eval-in-lexenv '(n) env))
(macrolet ((n () "Hello!")) (m))
; => "Hello!"
@m2ym
m2ym / walker-and-lexenv.lisp
Created March 14, 2012 07:53
Walker and lexical environment
(in-package :cl-user)
(#+sbcl
sb-walker:walk-form
#+allegro
excl::walk-form
`(let ((x 1))
(declare (fixnum x))
:marker)
nil
@m2ym
m2ym / session+anything.el
Created February 13, 2012 15:20
Workaroud for collision between session.el and anything.el
(when (require 'session nil t)
(mapatoms
(lambda (symbol)
(let ((name (symbol-name symbol)))
(when (and (string-match "^anything-" name)
(string-match session-globals-regexp name))
(pushnew symbol session-globals-exclude))))))
@m2ym
m2ym / bf-jit.c
Created February 9, 2012 14:29
Brainfuck Interpreter using libjit
#include <stdio.h>
#include <memory.h>
#include <jit/jit.h>
struct bf_loop {
jit_label_t start;
jit_label_t end;
struct bf_loop *parent;
};
typedef struct bf_loop *bf_loop_t;
diff --git a/popwin.el b/popwin.el
index 2d8619e..2c628b7 100644
--- a/popwin.el
+++ b/popwin.el
@@ -496,6 +496,8 @@ the popup window will be closed are followings:
(and other-window-selected
(not minibuf-window-p)
(not popwin:popup-window-stuck-p)))
+ (setq this-command 'popwin:close-popup-window)
+ (run-hooks 'pre-command-hook)
@m2ym
m2ym / .mongorc.js
Created January 19, 2012 13:57
.mongorc.js
DBCollection.prototype.sample = function () {
return this.find().skip(Math.floor(Math.random() * this.count())).limit(1).next();
}
@m2ym
m2ym / try.rb
Created January 15, 2012 20:40
Yet another Object#try and Object#try_to
class Try
(instance_methods - [:object_id, :__send__, :to_s]).each {|m| undef_method m }
def initialize(object) @object = object end
def method_missing(method, *args, &block)
return nil unless @object.respond_to? method
@object.send(method, *args, &block)
end
end
@m2ym
m2ym / acl-yacc-example.lisp
Created December 22, 2011 09:30
Example usage of Allegro CL's yacc module
(in-package :cl-user)
(eval-when (:compile-toplevel :load-toplevel :execute)
(when (find-package :quicklisp)
(quicklisp:quickload '(:anaphora :cl-ppcre)))
(require :yacc))
(defpackage :calc
(:use :cl :anaphora :excl.yacc))
(in-package :calc)
@m2ym
m2ym / my-macrolet.lisp
Created December 3, 2011 08:09
My Macrolet
(in-package :cl-user)
(defmacro my-macrolet (&environment env bindings &body body)
(let* ((local-macros
(loop for (name lambda-list . body) in bindings
for macro-lambda = (sb-cltl2:parse-macro name lambda-list body)
for macro-fun = (sb-cltl2:enclose macro-lambda env)
collect `(,name ,macro-fun)))
(new-env (sb-cltl2:augment-environment env :macro local-macros)))
(sb-cltl2:macroexpand-all `(locally ,@body) new-env)))
@m2ym
m2ym / .xkeyremap
Created November 17, 2011 12:47
My xkeyremap configuration
#-*-ruby-*-
device /AT Translate|HHKB/
key C-M-S-q { quit }
# swap number keys
key[_1] = exclam, _1
key[_2] = at, _2
key[_3] = numbersign, _3