Skip to content

Instantly share code, notes, and snippets.

View guicho271828's full-sized avatar
🤣
Lemonodor fame is but a hack away!

Masataro Asai guicho271828

🤣
Lemonodor fame is but a hack away!
View GitHub Profile
(defun event-p (x) t) ;; constantly t
(defun key-p (x) t) ;; constantly t
;; w/o defpattern
(match event
((and (sdl:event- (type (eq :key-down-event)))
;;^^^^^^^^^^ this specify the container type
;;^^^^ this is a slot
;; ^^^^^^^^^^^^^^^^^^ and this specifies the type of the slot.
(sdl::key- (key (eq :sdl-key-z)) state)))
@guicho271828
guicho271828 / test-timeout.lisp
Created July 27, 2014 10:24
test-timeout.lisp
(defun run-sleep (n)
(sb-ext:run-program
"sleep" (list (princ-to-string n))
:search t :wait nil :output t :error :output))
;; assume fiveam
(test async-shell
;; pass!
@guicho271828
guicho271828 / test.lisp
Last active August 29, 2015 14:04
hightlight use-/def-/in-
(use-syntax :annot
(cl-syntax:use-syntax (%_!$&=~^-[]+*?/<>.:annot))
(cl-syntax:use-syntax (%_!$&=~^-[]+*?/<>.:annot aaa) aaa)
`(cl-syntax:use-syntax (`,%_!$&=~^-[]+*?/<>.:annot aaa) aaa)
(defun (defun (cl:defun aaa (aaa) bbb)))
(defo (defun (cl:defun aaa (aaa) bbb)))
(use-defo (defun (cl:defun aaa (aaa) bbb)))
@guicho271828
guicho271828 / doubling-qsub.sh
Last active August 29, 2015 14:05
iterative resource allocation
#!/bin/bash
dir=$(dirname $(readlink -ef $0))
cg=/sys/fs/cgroup
mem=250000 # 250MB
maxmem=2000000 # 2GB: *8
time=225 # 3.75 min = 30/4
maxtime=1800 # 30 min
options=
debug=false
@guicho271828
guicho271828 / interrupt.lisp
Last active August 29, 2015 14:07
interrupt
(defun run ()
(tagbody
(handler-bind ((condition
(lambda (c)
(declare (ignore c))
(go :escape))))
(restart-bind ((my-continue
(lambda ()
@guicho271828
guicho271828 / Makefile
Created January 14, 2015 12:44
Makefile for converting C header files with GCC extensions into CFFI binding using SWIG
.PHONY: all clean
# .PRECIOUS: %.i1 %.i2 %.i3
LD = -I/usr/include -I/usr/include/linux
headers = $(shell ls *.h)
$(info $(headers))
lisp = $(patsubst %.h,%.lisp,$(headers))
@guicho271828
guicho271828 / big-table.lisp
Created February 19, 2015 18:58
figure for ICAPS15
(defun %length-distribution (&optional used)
(let ((path
(merge-pathnames
(format nil "output/~(~{~a-~}dist~@[-used~]~).pdf"
*set-dirs* used)))
(*solver-blacklist* '(fffd fffdtl mv2 mv2tl)))
(includegraphics (namestring path))
(let ((hist (associative-array 2)))
(dolist (s (solvers))
(dolist (d (domains))
@guicho271828
guicho271828 / typevar.lisp
Last active August 29, 2015 14:15
introducing typevar into common lisp
(with-typevar <coordinate> (<t>) (<vector-+>)
(defstruct <coordinate>
(x 0 :type <t>)
(y 0 :type <t>))
(declaim (ftype (function (<coordinate> <coordinate>) <coordinate>) <vector-+>))
(defun <vector-+> (v w)
(match* (v w)
(((<coordinate> x1 y1) (<coordinate> x2 y2))
(<coordinate> (+ x1 x2) (+ y1 y2))))))
; (definstance (ord string)
; (defun = (x y) (string= x y))
; (defun > (x y) (string> x y)))
(PROGN
(FTYPE =/STRING/STRING STRING STRING BOOLEAN)
(DEFUN =/STRING/STRING (X Y) (STRING= X Y))
(DEFINE-COMPILER-HINT =
(X Y &ENVIRONMENT #:ENV1822)
(STRING STRING BOOLEAN)
(IF (AND (FORM-TYPEP X 'STRING #:ENV1822) (FORM-TYPEP Y 'STRING #:ENV1822))
typedef union
{
struct
{
int __lock;
unsigned int __futex;
unsigned long long int __total_seq;
unsigned long long int __wakeup_seq;
unsigned long long int __woken_seq;
void *__mutex;