Skip to content

Instantly share code, notes, and snippets.

@nrh
nrh / comp.pl
Created November 8, 2010 04:36
#!/usr/local/bin/perl -w
use Benchmark qw(:all);
use YAML::Syck qw();
use YAML::XS qw();
my @files = ( 'large.yaml', 'medium.yaml', 'small.yaml' );
my $count = $ARGV[0] || 1000;
@sixman9
sixman9 / glCube13vTriangleStripFragC.txt
Created March 2, 2011 16:02
How to draw a cube using 13 Triangle Strip vertices.
How to draw a Cube with OpenGL's Triangle strip (non-Vertex buffer object example, 13 vertices)
gl.glBegin(gl.GL_TRIANGLESTRIP);
gl.glVertex(100,100,−100);
gl.glVertex(100,300,−100);
gl.glVertex(300,300,−100);
gl.glVertex(300,300,−300);
gl.glVertex(300,100,−300);
@daurnimator
daurnimator / pointer.lua
Created April 5, 2011 01:28
A small library that will let you use luajit cdata how you would hope.
local ffi=require"ffi"
local topointer
local pointer_mt
local key_address , key_ctype , key_cdata , key_methods = {},{},{},{}
local function ispointer ( ob )
return getmetatable ( ob ) == pointer_mt
end
local function denormalise ( ob )
@od0x0
od0x0 / gist:965399
Created May 10, 2011 21:17
How I Load a .ogg into OpenAL Using stb_vorbis
typedef struct{
ALuint ID;
stb_vorbis* stream;
stb_vorbis_info info;
ALuint buffers[2];
ALuint source;
ALenum format;
@matthewmccullough
matthewmccullough / gist:988077
Created May 24, 2011 03:02
Visualize Git Orphans via gitk and log
# Put this in your .gitconfig file under the alias section
orphank = !gitk --all `git reflog | cut -c1-7`&
# Then run it by typing 'git orphank' on the command line.
# A text version of the same is
orphanl = !git --pretty=oneline --abbrev-commit --graph --decorate `git reflog | cut -c1-7`
@veritech
veritech / gist:1224664
Created September 18, 2011 03:02
Brute force HTTP password cracker
#!usr/bin/python
#Linksys WRT54G router brute force
#http://www.darkc0de.com
#d3hydr8[at]gmail[dot]com
import threading, time, random, sys, urllib2, socket
if len(sys.argv) !=4:
print "Usage: ./linksysbrute.py <server> <user> <wordlist>"
sys.exit(1)
@stevedonovan
stevedonovan / loader.lua
Created October 19, 2011 09:52
A Custom Lua module loader for Lua 5.2
-- This allows a more restricted module() style; the key feature
-- is that each module is loaded in a custom environment, and the actual module
-- table is a copy of that environment after initial load.
-- clone _G so that globals from the program don't invade the module
local lua_libs = {}
for k,v in pairs(package.loaded._G) do
lua_libs[k] = v
end
@davidm
davidm / meta-interpolate.lua
Created November 4, 2011 03:42
Lua metaprogramming using custom searcher with string interpolation example
--[[
The following example illustrates string interpolation [1]
by way of a preprocessor that runs as a customer searcher
function in package.loaders.
Tested in Lua 5.2.0-beta.
Depends on
file_slurp https://gist.github.com/1325400 (for loading files simply)
luabalanced https://github.com/davidm/lua-balanced (for Lua parsing)
@rorydriscoll
rorydriscoll / Shader.glsl
Created November 26, 2011 00:14
Shader experiment
// bind gloss {label:"Gloss", default:0.5, max:1, step:0.01}
// bind cdiff {label:"Diffuse Colour", r:0.6, g:0.0, b:0.0}
// bind cspec {label:"Specular Colour", r:0.3, g:0.3, b:0.3}
// bind lightstrength {label:"Light Strength", default:3, max:100, step:0.1}
// bind envtop {label:"Environment Top", r:0.0, g:0.2, b:0.4}
// bind envmiddle {label:"Environment Middle", r:0.2, g:0.2, b:0.2}
// bind envbottom {label:"Environment Bottom", r:0.01, g:0.1, b:0.01}
// bind refractiveindex {label:"Refracive Index", default:1.5, max:3, step:0.1}
// bind normalmap {label:"Normal Map", default:false}
// bind diffuse {label:"Diffuse", default:true}
@provegard
provegard / ssdp-test.py
Created December 5, 2011 21:52
Small SSDP server/client test in Python
#!/usr/bin/python
# Python program that can send out M-SEARCH messages using SSDP (in server
# mode), or listen for SSDP messages (in client mode).
import sys
from twisted.internet import reactor, task
from twisted.internet.protocol import DatagramProtocol
SSDP_ADDR = '239.255.255.250'