Skip to content

Instantly share code, notes, and snippets.

@bellbind
bellbind / bf.py
Created July 9, 2009 11:52
[Python] brainf**k interpreter with AST
import sys
class Engine(object):
"""Brainf**k interpreter.
usage:
bf = Engine()
bf("++++++++++++++.")
"""
def __init__(self):
pass
@bellbind
bellbind / ubiquity-alc.js
Created July 10, 2009 03:48 — forked from anonymous/x
[Ubiquity] eijiro dict search by alc
/*
* for Ubiquity 0.5
*/
CmdUtils.CreateCommand({
names: ["alc"],
icon: "http://www.alc.co.jp/favicon.ico",
homepage: "http://d.hatena.ne.jp/bellbind/",
author: {name: "bellbind", email: "bellbind@gmail.com"},
license: "GPL",
description: [
@bellbind
bellbind / ubiquity-eval.js
Created July 10, 2009 03:59 — forked from anonymous/x
[Ubiquity] eval JS snippet then show result object
/* eval for Ubiquity 0.5 */
CmdUtils.CreateCommand({
names: ["eval"],
icon: "chrome://ubiquity/skin/icons/favicon.ico",
homepage: "http://d.hatena.ne.jp/bellbind/",
author: {name: "bellbind", email: "bellbind@gmail.com"},
license: "GPL",
description: "evaluate script",
help: "evaluate script",
arguments: [{role:"input", nountype: noun_arb_text}],
@bellbind
bellbind / ubiquity-color.js
Created July 10, 2009 04:07
[Ubiquity] show coloring pane
/*
* Ubiquity 0.5 example
* changes from 0.1.8:
* - name:String -> names:[String]
* - takes:{String:RegExp} -> arguments:[{role:String, nountype:RegExp}]
* - preview&execute:function(Element, arg)
* -> preview&execute:function(Element, {argname:arg,...})
*/
CmdUtils.CreateCommand({
@bellbind
bellbind / amazon_sign_api.php
Created July 11, 2009 05:41
[php][library][amazon]make AWS Signed URL
<?php
// Create Signed Amazon REST API URL from old unsigned URL
// Amazon API requires signature from 2009-08-15.
// You can get sign key from management page of your AWS Access Key.
// See signature spec:
// https://affiliate.amazon.co.jp/gp/associates/help/t126/a13?ie=UTF8&pf_rd_t=501&ref_=amb_link_84046416_5&pf_rd_m=AN1VRQENFRJN5&pf_rd_p=&pf_rd_s=center-1&pf_rd_r=&pf_rd_i=assoc_help_t126_a9
//
function amazon_sign_api($key, $url) {
$pattern = '/^([^:]+):\/\/([^\/]+)([^\?]+)\?(.*)$/';
preg_match($pattern, $url, $result);
@bellbind
bellbind / astar.py
Created July 15, 2009 11:06
[Python][library] A* path search
def astar(init, goal, nexts,
distance=lambda path: len(path),
heuristic=lambda pos: 0):
import heapq
queue = []
init_score = distance([init]) + heuristic(init)
checked = {init: init_score}
heapq.heappush(queue, (init_score, [init]))
while len(queue) > 0:
score, path = heapq.heappop(queue)
@bellbind
bellbind / wiki.py
Created July 16, 2009 15:09
[GAE] 1File Wiki App
# -*- coding: utf-8 -*-
"""
One File Wiki Script for Google AppEngine
"""
import cgi
import re
import urllib
# use_library() from GAE 1.2.3
from google.appengine.dist import use_library
use_library("django", "1.0")
@bellbind
bellbind / add_target_of_links.user.js
Created July 17, 2009 08:25
[greasemonkey] Add target of links which have different domains from the page
@bellbind
bellbind / lighting.html
Created October 21, 2009 14:05
[WebGL] modelview 3d example with no libraries
<!DOCTYPE html>
<html>
<head>
<script>//<![CDATA[
// WebGL example
top.CanvasFloatArray = top.CanvasFloatArray || WebGLFloatArray;
var gl;
var program;
@bellbind
bellbind / texture.html
Created October 22, 2009 11:19
[WebGL] Texture example by 2d canvas
<!DOCTYPE html>
<html>
<head>
<script>//<!--
// WebGL texture example
top.CanvasFloatArray = top.CanvasFloatArray || WebGLFloatArray;
var gl;
var program;