Skip to content

Instantly share code, notes, and snippets.

@r-moeritz
r-moeritz / pretty-literals.lisp
Created June 24, 2011 10:30
pretty hash table & vector literal syntax for common lisp
;;;; pretty-literals.lisp - pretty hash table & vector literal syntax
;;;; inspired by and uses code from http://frank.kank.net/essays/hash.html
(in-package #:pretty-literals)
;; vector literal syntax using brackets
(set-macro-character #\[
(lambda (str char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil))
@otobrglez
otobrglez / car.rb
Created August 23, 2011 12:26
Experimenting with observer pattern (publish/subscribe pattern) in Ruby
# Simple Car class. Nothing special here...
class Car
attr_accessor :brand
attr_accessor :model
attr_accessor :year
def initialize(brand, model, year=2011)
@brand, @model, @year = brand, model, year
end
@cslarsen
cslarsen / free-body.mp
Created January 7, 2012 10:40
Free body diagram with frictional forces made in MetaPost
% MetaPost free body diagram with frictional forces
%
% Placed in the public domain by the author; Christian Stigen Larsen
% 2011-10-07
%
% To render:
% $ mptopdf free-body.mp
%
beginfig(1)
@nyuichi
nyuichi / list-monad.lisp
Created October 14, 2012 00:08
Monad framework for Common Lisp
;;; List Monad
(defmethod bind ((m list) f)
(apply #'append (mapcar f m)))
(defmethod fmap ((m list) f)
(mapcar f m))
@bnyeggen
bnyeggen / SizeOf.java
Last active December 10, 2015 13:08
Unsafe-based sizeof
// A simpler method than reflection-based traversal, using Unsafe
public static Unsafe getUnsafe() {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
return (Unsafe) f.get(null);
}
public static long sizeOf(Object o) {
Unsafe u = getUnsafe();
@serialhex
serialhex / Makefile
Created October 12, 2016 15:00
Makefiles on Windows!!!
#define macros
EXE = executable.exe
SRC = src
BIN = bin
INT = obj
INCL = include
OCV_INC = "$(OPENCV_DIR)\..\..\include"
OCV_LIB = "$(OPENCV_DIR)\lib\opencv_world310.lib"
@commander-trashdin
commander-trashdin / currying.lisp
Last active June 11, 2020 17:25
My attempt at making almost first-class currying in CL.
(defun intern-gen-sym (&optional str)
(if str
(intern (format nil "intern-g~a~s" str (incf *gensym-counter*)))
(intern (format nil "intern-g~s" (incf *gensym-counter*)))))
(define-condition recursive-currying-lambda (error)
((datum :initform "Cannot curry lambda with 0 arguments" :allocation :class)))