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 / 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
# -----
@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: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:1115159
Created July 30, 2011 03:29
Ruby Quine
_=%(_=%();puts _.insert 4,_);puts _.insert 4,_
@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: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: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 / maize.rb
Created December 1, 2012 17:05
Maize
#!/usr/bin/env ruby
require 'ap'
RUNTIME = "
rem:
add $8, %rdi
ret
dup:
@hashmal
hashmal / demo.mz
Created December 1, 2012 18:44
Maize Demo
program main -> X is
0x08 fibonacci
end
-- Renvoie (R) le Nieme element de la suite de fibonacci.
-- PRECONDITION: N >= 0
program N fibonacci -> R is
take N 0x00 0x01 restore N
@hashmal
hashmal / gist:4190663
Created December 2, 2012 19:48 — forked from javan/gist:1168475
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen