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
View ota.sh
expected="c109d23ad00e8a50cf33ae1c3d811b2cd7a0bafe"
fn=index.html
curl -s google.com/$fn > /$fn.part
cs=`sha1sum /$fn.part | cut -d " " 1`
if [ "$cs" == "$expected"] ; then
echo "checksum ok $cs"
mv /$fn.part /$fn:$cs
@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)
View Android.mk
# build nanomsg for Android's aosp
# hope this is useful for someone! :D
LOCAL_PATH := $(ANDROID_BUILD_TOP)/external/nanomsg/src
include $(CLEAR_VARS)
LOCAL_SRC_FILES := core/epbase.c core/sock.c core/poll.c \
core/symbol.c core/ep.c core/pipe.c \
core/sockbase.c core/global.c devices/device.c \
@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 / rotating colored square ortho.scm
Last active Dec 28, 2015
CHICKEN glls example on android
View rotating colored square ortho.scm
(use sdl2 miscmacros (prefix opengl-glew gl:) glls-render gl-utils gl-math)
;; unhappy REPL on Android? (import (prefix opengl-glew gl:))
(define window (create-window! "sokoworld" 0 0 640 480 '(resizable opengl)))
(gl-attribute-set! 'context-major-version 3)
(gl-attribute-set! 'context-minor-version 0)
(gl-create-context! window)
(gl:init)
@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
View chicken-scheme-jwt.scm
(use matchable hmac sha2 base64 tweetnacl)
(define (base64url-decode m) (base64-decode (string-translate m "-_" "+/")))
(define (base64url-encode m)
(string-trim-right ;; remove = padding (not used/needed in jwt)
(string-translate (base64-encode m) "+/" "-_") #\=))
(define (hs256 secret) (hmac secret (sha256-primitive)))
;; b64header ignored! (read https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/)
View test.patch
modified hello-world.c
@@ -1,6 +1,5 @@
#include <stdio.h>
int main() {
- fprintf(stderr, "Goodbye, ");
- fputs("World!\n", stderr);
+ fprintf(stderr, "Goodbye, World!\n");
return 0;
}
@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)))
You can’t perform that action at this time.