Skip to content

Instantly share code, notes, and snippets.

@bellbind
bellbind / webgl-texture-img.html
Created October 23, 2009 10:57
[WebGL] Texture example by img tag
<!DOCTYPE html>
<html>
<head>
<script>//<!--
// WebGL texture example
top.CanvasFloatArray = top.CanvasFloatArray || WebGLFloatArray;
var gl;
var program;
@bellbind
bellbind / gzopen-for-karmic.php
Created October 30, 2009 01:52
[php][snippet]workaround for ubuntu kermic buggy release version
<?php
// workaround no "gzopen" problem on ubuntu karmic's php5 5.2.10.dfsg.1-2ubuntu6
if (!function_exists("gzopen") && function_exists("gzopen64")) {
function gzopen($file, $mode) {
return gzopen64($file, $mode);
}
}
?>
@bellbind
bellbind / heapqueue.py
Created November 2, 2009 14:00
[Python][library] simple heapq implementation
# heap queue simple implementation
def heappush(heap, val):
cur = len(heap)
heap.append(val)
while cur > 0:
parent = (cur - 1) // 2
if heap[parent] <= heap[cur]: break
heap[cur], heap[parent] = heap[parent], heap[cur]
cur = parent
@bellbind
bellbind / astar.go
Created November 12, 2009 16:07
[Go][library]A* path search: astar.go
// A* lib port from pythonic A*: http://gist.github.com/147645
package astar
import "container/heap"
import "container/vector"
// position data for A*: e.g. start and goal.
type Location interface {
Equals(other Location) bool;
// Returned value should be unique for each location value.
@bellbind
bellbind / astar_main.go
Created November 12, 2009 16:09
[Go] Example for astar.go gist:233012
// 8g astar.go
// 8g -I . astar_main.go
// 8l -o astar_main astar_main.go astar.go
package main
import "fmt"
import "math"
import "strings"
import "astar"
@bellbind
bellbind / XMouse.cs
Created December 2, 2009 16:27
[c#][windows]X-Mouse setting tool on Windows 7/Vista
// [X-Mouse setting tool on Windows 7/Vista]
// build on 64bit .NET 3.5:
// c:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe XMouse.cs
// or on 32bit .NET 3.5:
// c:\Windows\Microsoft.NET\Framework\v3.5\csc.exe XMouse.cs
using Microsoft.Win32;
class XMouse {
static void Main(string[] args) {
if (args.Length == 0 || !(args[0] == "on" || args[0] == "off")) {
@bellbind
bellbind / sakura.groovy
Created December 6, 2009 23:19
[groovy]play midi
// groovy sakura.groovy
import javax.sound.midi.*
// compose sequence
ticks = 16
// compose utils
def addNote(track, pitch, start, duration=ticks, velocity=64) {
// pitch: C=60, D=62, E=64, F=65, G=67, A=69, B=71, ...
// start: absolute time
@bellbind
bellbind / sscalc.py
Created December 9, 2009 13:02
[python]Spreadsheet style lazy evaluator
__doc__ = """Spreadsheet style lazy evaluator
"""
from collections import defaultdict
import traceback
__all__ = ["Sheet"]
class Sheet(object):
"Spreadsheet style lazy evaluation calculator"
def __init__(self, empty=0):
@bellbind
bellbind / bas64conv.py
Created December 13, 2009 04:58
[python] base64 encoder/decoder
"""base64 module (programming training)"""
n2ch = "".join([
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"abcdefghijklmnopqrstuvwxyz",
"0123456789+/",
])
ch2n = dict(zip(n2ch, range(len(n2ch))))
def separate(seq, size):
return (seq[i:i+size] for i in range(0, len(seq), size))
@bellbind
bellbind / KeyMap.cs
Created December 13, 2009 18:22
[c#]snippet for access system key map
// access key maps
using Microsoft.Win32;
class KeyMap {
static void Main(string[] args) {
// Windows7 does not support Keyboard Layout in CurrentUser
//var root = Registry.CurrentUser;
//var subkey = @"Keyboard Layout"; // for CurrentUser
var root = Registry.LocalMachine;
var subkey = @"SYSTEM\CurrentControlSet\Control\Keyboard Layout";