Skip to content

Instantly share code, notes, and snippets.

View hashmal's full-sized avatar

Jérémy Pinat hashmal

View GitHub Profile
@hashmal
hashmal / maize.rb
Created December 1, 2012 17:05
Maize
#!/usr/bin/env ruby
require 'ap'
RUNTIME = "
rem:
add $8, %rdi
ret
dup:
@hashmal
hashmal / gist:2360441
Created April 11, 2012 16:41
Convert key codes to ASCII characters
;set z, 0x9010
set z, 0x8000
:loop
jsr raw_key
ife x, 0
set pc, loop
ife x, 0x8
set pc, onkey_del
jsr code2ascii
set [z], x
@hashmal
hashmal / gist:1401335
Created November 28, 2011 18:03
OpenGL 3.2 Core Profile, GLFW, Mac OS X Lion [FIXED]
// The following code doesn't work on Mac OS X Lion
// (I don't know for other platforms):
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <GL/glfw.h>
char *VS = "#version 150\n in vec2 position; void main() {gl_Position = vec4(position, 0.0, 1.0);}";
@hashmal
hashmal / gist:1299245
Created October 19, 2011 18:43
OpenGL 3.2 Core Profile, GLFW, Mac OS X Lion
// The following code doesn't work on Mac OS X Lion
// (I don't know for other platforms):
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <GL/glfw.h>
char *VS = "#version 150\n in vec2 position; void main() {gl_Position = vec4(position, 0.0, 1.0);}";
@hashmal
hashmal / gist:1115159
Created July 30, 2011 03:29
Ruby Quine
_=%(_=%();puts _.insert 4,_);puts _.insert 4,_
@hashmal
hashmal / gist:877697
Created March 19, 2011 18:38
Quick and dirty mixins in Lua
Mixin = {}
Mixin.__index = Mixin
Mixin.__mixins = {Mixin}
function Mixin:__index (method)
for i=#getmetatable(self).__mixins, 1, -1 do
local m = getmetatable(self).__mixins[i][method]
if m then return m end
end
end
@hashmal
hashmal / gist:874792
Created March 17, 2011 17:54
[Lua] Print table contents recursively
-- Print contents of `tbl`, with indentation.
-- `indent` sets the initial level of indentation.
function tprint (tbl, indent)
if not indent then indent = 0 end
for k, v in pairs(tbl) do
formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
print(formatting)
tprint(v, indent+1)
else
@hashmal
hashmal / gist:803816
Created January 31, 2011 09:25
Playing with CoffeeScript, do funny things with mixins.
# Swappable Mixins in CoffeeScript
# ================================
# This is experimental. Not tested. It's just a toy, and I'm very new to
# javascript/coffeescript. Be warned.
# Usage
# -----