Skip to content

Instantly share code, notes, and snippets.

View kristianlm's full-sized avatar

Kristian Lein-Mathisen kristianlm

View GitHub Profile
@kristianlm
kristianlm / chicken-scheme-opengl-hello-world.scm
Created February 17, 2012 13:00
chicken scheme - opengl hello world in 35 lines (gl, glu, glut)
(begin
(require-extension gl)
(require-extension glut)
(require-extension glu)
(glut:InitDisplayMode (+ glut:DOUBLE glut:RGBA glut:DEPTH))
(glut:InitWindowSize 400 300)
(glut:CreateWindow "gl hello world"))
(begin
@kristianlm
kristianlm / gist:1898187
Created February 24, 2012 05:57
hello-world from Chicken Scheme with Box2D
(require-extension coops bind cplusplus-object )
#>
#include <Box2D.h>
// is there a way to access c++ class-fields without these
// two silly helpers?
float getBodyPositionX (b2Body* b) { return b->GetPosition ().x; }
float getBodyPositionY (b2Body* b) { return b->GetPosition ().y; }
<#
@kristianlm
kristianlm / Chipmunk.mk
Created May 7, 2012 15:56
Building Chipmunk for Android: An Android NDK module for Chipmunk Physics Engine
# This makefile will let the Android NDK build a
# libchipmunk.so to go with your 2D Android game.
# download the Chipmunk sources and do
# $ cd <chipmunk-physics>
# $ git checkout Chipmunk-6.0.3 # if you downloaded from source
# $ mkdir -p modules/chipmunk && cd modules/chipmunk
# $ cat >Android.mk <<EOF
LOCAL_HOME := $(dir $(lastword $(MAKEFILE_LIST)))
@kristianlm
kristianlm / gist:3397261
Created August 19, 2012 19:51
how to do nested loops in C -> Elegant Scheme
;; I can't seem to convert this neat little
;; C code into elegant Scheme:
;;
;; // I didn't test this:
;; int c[20][20]
;; for (int x = -10 ; x < 10 ; x++)
;; for (int y = -10 ; y < 10 ; y++)
;; c[x+10][y+10] = x + y;
@kristianlm
kristianlm / gist:4108390
Created November 19, 2012 00:50
Running ViennaCL on Amazon GPU cluster (cg1.4xlarge)
[ec2-user@ip-10-33-4-246 grub]$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 01)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 3D controller: nVidia Corporation GF100 [Tesla S2050] (rev a3)
00:04.0 3D controller: nVidia Corporation GF100 [Tesla S2050] (rev a3)
00:05.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)
@kristianlm
kristianlm / gist:4185312
Created December 1, 2012 21:46
emacs compiling rudel with elpa fails
Leaving directory `/home/klm/.emacs.d/elpa/eieio-1.4'
Compiling file /home/klm/.emacs.d/elpa/eieio-1.4/eieio-comp.el at Sat Dec 1 21:29:38 2012
Entering directory `/home/klm/.emacs.d/elpa/eieio-1.4/'
In byte-compile-file-form-defmethod:
eieio-comp.el:95:30:Warning: reference to free variable `bytecomp-outbuffer'
eieio-comp.el:96:35:Warning: reference to free variable `outbuffer'
In end of data:
@kristianlm
kristianlm / missionaries.scm
Created February 2, 2013 17:57
Missionaries and Cannibals problem, a solution in Scheme
;; This is the missionaries & cannibals problem solved in Scheme.
;; The code is not as elegant as it could have been
;; (lacking recursion, in the spirit of Scheme, in many places).
;; It is also not very generic. Also does no optimization and
;; will apply search paths back and forth.
;; It works however, and should be relatively readable.
(use srfi-1)
@kristianlm
kristianlm / gist:6407121
Created September 1, 2013 20:34
testing chicken-mongo's bson
(use bson mongo)
(define (mak n)
(if (> n 0)
`((int . 1)
(double . 1.5)
(false . #f)
(nested ,@(mak (sub1 n))))
"the end"))
@kristianlm
kristianlm / Android.mk
Last active January 2, 2016 01:19
embedding chicken, extending the hello-jni example
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
HELLO_JNI_PATH := $(LOCAL_PATH)
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := hello-jni.c
LOCAL_SHARED_LIBRARIES := chicken
include $(BUILD_SHARED_LIBRARY)
@kristianlm
kristianlm / hell.properties
Created January 25, 2014 16:54
Reading http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader) and trying to create a challenge properties file for your Java properties-file parser
# this is a comment. see
# http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader)
! this too. and empty lines are allowed
# this is an space-indented comment
#this is a tab-indented and space-indented comment
# key separators include any unescaped "=", ":" or ws.
key1=value