Skip to content

Instantly share code, notes, and snippets.

@bellbind
bellbind / webgl-texture-img.html
Created Oct 23, 2009
[WebGL] Texture example by img tag
View webgl-texture-img.html
<!DOCTYPE html>
<html>
<head>
<script>//<!--
// WebGL texture example
top.CanvasFloatArray = top.CanvasFloatArray || WebGLFloatArray;
var gl;
var program;
@bellbind
bellbind / gzopen-for-karmic.php
Created Oct 30, 2009
[php][snippet]workaround for ubuntu kermic buggy release version
View gzopen-for-karmic.php
<?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 Nov 2, 2009
[Python][library] simple heapq implementation
View heapqueue.py
# 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 Nov 12, 2009
[Go][library]A* path search: astar.go
View 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 Nov 12, 2009
[Go] Example for astar.go gist:233012
View astar_main.go
// 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 Dec 2, 2009
[c#][windows]X-Mouse setting tool on Windows 7/Vista
View XMouse.cs
// [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")) {
View sakura.groovy
// 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 Dec 9, 2009
[python]Spreadsheet style lazy evaluator
View sscalc.py
__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 Dec 13, 2009
[python] base64 encoder/decoder
View bas64conv.py
"""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 Dec 13, 2009
[c#]snippet for access system key map
View KeyMap.cs
// 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";