Skip to content

Instantly share code, notes, and snippets.

call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set nocompatible
colorscheme desert
tab all
set mouse=a
.code64
.section .text
.global thread_context_switch
# from thread: rdi = interrupt_stack_frame*, rsi = registers_t*
# to thread: rdx = const interrupt_stack_frame*, rcx = const registers_t*
thread_context_switch:
# store general purpose registers to *rdi
mov %r15, 0(%rdi)
mov %r14, 8(%rdi)
mov %r13, 16(%rdi)
@rikusalminen
rikusalminen / gist:1012156
Created June 7, 2011 12:42
quickfix keybindings
noremap <silent> <leader>qw :botright cwindow<cr>
noremap <silent> <leader>qo :botright copen<cr>
noremap <silent> <leader>qc :cclose<cr>
noremap <silent> <leader>qq :cc!<cr>
noremap <silent> <leader>qn :cnext<cr>
noremap <silent> <leader>qp :cprev<cr>
noremap <silent> <leader>lw :botright lwindow<cr>
noremap <silent> <leader>lo :botright lopen<cr>
noremap <silent> <leader>lc :lclose<cr>
@rikusalminen
rikusalminen / gist:1106628
Created July 26, 2011 12:24
multithreaded glx
#include <stdbool.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <GL/glxext.h>
#include <GL/gl.h>
GLXContext glXCreateContextAttribsARB(
Display *dpy, GLXFBConfig config,
@rikusalminen
rikusalminen / gist:1171039
Created August 25, 2011 16:05
timespec arithmetic
#define NS_IN_SEC 1000000000
// I bet there's a subtle overflow bug somewhere here
static inline struct timespec timespec_add(const struct timespec * restrict a, const struct timespec * restrict b)
{
unsigned long nsecs = (a->tv_nsec % NS_IN_SEC) + (b->tv_nsec % NS_IN_SEC);
struct timespec result = {
a->tv_sec + b->tv_sec + (a->tv_nsec / NS_IN_SEC) + (b->tv_nsec / NS_IN_SEC) + (nsecs / NS_IN_SEC),
nsecs % NS_IN_SEC
};
@rikusalminen
rikusalminen / fold_excersizes.hs
Created October 20, 2011 09:03 — forked from pimeys/fold_excersizes.hs
strToInt and StrToDouble
import Data.Char
strToInt :: String -> Int
strToInt ('+':xs) = strToInt xs
strToInt ('-':xs) = - strToInt xs
strToInt xs =
foldl step 0 xs
where
step acc x = acc * 10 + (digitToInt x)
strToInt _ = undefined
@rikusalminen
rikusalminen / YaJSON.hs
Created February 17, 2012 18:10
JSON parsing with Parsec
module YaJSON where
import Text.Parsec
import qualified Text.Parsec.Token as Token
import qualified Text.Parsec.Language as Language
import qualified Data.Map as Map
language = Language.javaStyle
lexer = Token.makeTokenParser language
@rikusalminen
rikusalminen / Riku
Created April 2, 2012 17:56
LUFA joystick test
/*
LUFA Library
Copyright (C) Dean Camera, 2012.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
@rikusalminen
rikusalminen / Joystick.c
Created April 2, 2012 17:56
LUFA joystick test
/*
LUFA Library
Copyright (C) Dean Camera, 2012.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
@rikusalminen
rikusalminen / shader.frag
Created June 13, 2012 11:08
Simple GLSL lighting
#version 150
layout(std140) uniform Camera
{
mat4 view_matrix;
mat4 projection_matrix;
} camera;
layout(std140) uniform Light
{