This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; List Monad | |
(defmethod bind ((m list) f) | |
(apply #'append (mapcar f m))) | |
(defmethod fmap ((m list) f) | |
(mapcar f m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) | |