Skip to content

Instantly share code, notes, and snippets.

@bellbind
bellbind / bf.py
Created Jul 9, 2009
[Python] brainf**k interpreter with AST
View bf.py
import sys
class Engine(object):
"""Brainf**k interpreter.
usage:
bf = Engine()
bf("++++++++++++++.")
"""
def __init__(self):
pass
@bellbind
bellbind / ubiquity-alc.js
Created Jul 10, 2009 — forked from anonymous/x
[Ubiquity] eijiro dict search by alc
View ubiquity-alc.js
/*
* 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 Jul 10, 2009 — forked from anonymous/x
[Ubiquity] eval JS snippet then show result object
View ubiquity-eval.js
/* 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 Jul 10, 2009
[Ubiquity] show coloring pane
View ubiquity-color.js
/*
* 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 Jul 11, 2009
[php][library][amazon]make AWS Signed URL
View amazon_sign_api.php
<?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 Jul 15, 2009
[Python][library] A* path search
View astar.py
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 Jul 16, 2009
[GAE] 1File Wiki App
View wiki.py
# -*- 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 Jul 17, 2009
[greasemonkey] Add target of links which have different domains from the page
View add_target_of_links.user.js
@bellbind
bellbind / lighting.html
Created Oct 21, 2009
[WebGL] modelview 3d example with no libraries
View lighting.html
<!DOCTYPE html>
<html>
<head>
<script>//<![CDATA[
// WebGL example
top.CanvasFloatArray = top.CanvasFloatArray || WebGLFloatArray;
var gl;
var program;
@bellbind
bellbind / texture.html
Created Oct 22, 2009
[WebGL] Texture example by 2d canvas
View texture.html
<!DOCTYPE html>
<html>
<head>
<script>//<!--
// WebGL texture example
top.CanvasFloatArray = top.CanvasFloatArray || WebGLFloatArray;
var gl;
var program;