Skip to content

Instantly share code, notes, and snippets.

@lamberta
lamberta / demo-cffi.lisp
Created October 18, 2009 02:53
use C shared lib with cffi
;;;building a C shared library,
;;;and calling it in Common Lisp with CFFI
(require :asdf)
(asdf:load-system :cffi)
(defpackage :cffi-user
(:use :common-lisp :cffi))
(in-package :cffi-user)
@lamberta
lamberta / gist:212583
Created October 18, 2009 06:58
save sbcl core as an executable
;;;save sbcl core as an executable
;;;http://www.sbcl.org/manual/Saving-a-Core-Image.html
(sb-ext:save-lisp-and-die "myexec" ;file name
:executable t ;create a standalone executable
:toplevel 'main ;function to run when core is resumed
:purify t) ;purifying gc to move dynamic objs to static space
@lamberta
lamberta / gist:217730
Created October 24, 2009 20:42
vecto example - draw text, circle, line
;;vecto example
;;draw text, circle, and some lines
(require :asdf)
(asdf:load-system :vecto)
(defparameter *font* "/home/billy/.fonts/Consola.ttf")
(defun draw-it (file)
(vecto:with-canvas (:width 200 :height 200)
@lamberta
lamberta / toon-shader.cl
Created October 24, 2009 23:34
cl-opengl, load toon shader
;;cl-opengl, load toon shader
(require :asdf)
(asdf:load-system :cl-opengl)
(asdf:load-system :cl-glu)
(asdf:load-system :cl-glut)
(defun file->string (path)
"Sucks up an entire file from PATH into a freshly-allocated string,
returning two values: the string and the number of bytes read."
(with-open-file (s path)
@lamberta
lamberta / 01-hello-shapes.html
Created October 25, 2009 16:13
Intro to Canvas - BuffaloLab demo
<html>
<head>
<script type="text/javascript">
function draw () {
var canvas = document.getElementById("my_canvas");
var ctx = canvas.getContext("2d");
rect(ctx);
triangle(ctx); //on square
circle(ctx); //on tri
@lamberta
lamberta / .emacs
Created October 27, 2009 21:29
using a git repo as a todo list
;;add to your .emacs
(defun git-commit-file-and-push (&optional commit-msg)
"Commit current file and push to git repository."
(interactive)
(if (null commit-msg)
(setq commit-msg (read-from-minibuffer "Commit message: ")))
(if (buffer-modified-p (current-buffer))
(if (y-or-n-p "Save modified buffer? ")
(save-buffer)))
@lamberta
lamberta / gist:223133
Created October 31, 2009 16:14
mplayer audio boost
mplayer -af volume=20:0 mediafile
@lamberta
lamberta / facedetect.c
Created November 10, 2009 02:23
basic OpenCV face detection
/** Basic OpenCV example for face detecion.
* Handles a still image or a video file.
**/
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
void detect_faces (IplImage*, CvHaarClassifierCascade*, CvMemStorage*);
void cleanup (char*, CvHaarClassifierCascade*, CvMemStorage*);
void print_help (char*);
@lamberta
lamberta / camshifting.c
Created November 11, 2009 05:18
OpenCV example for face detection with Haar and tracking with CamShift.
#include "camshifting.h"
/* Create a camshift tracked object from a region in image. */
TrackedObj* create_tracked_object (IplImage* image, CvRect* region) {
TrackedObj* obj;
//allocate memory for tracked object struct
if((obj = malloc(sizeof *obj)) != NULL) {
//create-image: size(w,h), bit depth, channels
obj->hsv = cvCreateImage(cvGetSize(image), 8, 3);
#grep through files,
#search list titles which start with ':'
#replace colons with tabs
#return file name, line number, title
grep -n -e '^:.*text' ./* | sed 's/:\+/\t/g'