Skip to content

Instantly share code, notes, and snippets.

Kristian Lein-Mathisen kristianlm

  • Adellica
  • Norway
Block or report user

Report or block kristianlm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kristianlm
kristianlm / chicken-scheme-opengl-hello-world.scm
Created Feb 17, 2012
chicken scheme - opengl hello world in 35 lines (gl, glu, glut)
View chicken-scheme-opengl-hello-world.scm
(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 Feb 24, 2012
hello-world from Chicken Scheme with Box2D
View gist:1898187
(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
Building Chipmunk for Android: An Android NDK module for Chipmunk Physics Engine
View Chipmunk.mk
# 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 Aug 19, 2012
how to do nested loops in C -> Elegant Scheme
View gist:3397261
;; 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 Nov 19, 2012
Running ViennaCL on Amazon GPU cluster (cg1.4xlarge)
View gist:4108390
[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 Dec 1, 2012
emacs compiling rudel with elpa fails
View gist:4185312
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 Feb 2, 2013
Missionaries and Cannibals problem, a solution in Scheme
View missionaries.scm
;; 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 Sep 1, 2013
testing chicken-mongo's bson
View gist:6407121
(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 Jan 2, 2016
embedding chicken, extending the hello-jni example
View Android.mk
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 Jan 25, 2014
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
View hell.properties
# 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
You can’t perform that action at this time.