Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @namespace cn.orz.pascal
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2/jquery.js
// @include http://d.hatena.ne.jp/*
// ==/UserScript==
$(function(){
var node = $("/html/body/div");
node.css("background-color","orange");
alert(node[0]);
});
# -*- coding: utf-8 -*-
require 'open-uri'
require 'uri'
require 'tmpdir'
require 'fileutils'
require 'digest/md5'
id = "koduki"
sound = '/usr/share/sounds/purple/receive.wav'
// ==UserScript==
// @name url2thum
// @namespace pascal.orz.cn
// @include http://*.2ch.net/*
// ==/UserScript==
var ExObject = function(){
var obj = this;
this.replace_html = function(filter){
obj.innerHTML = filter(obj.innerHTML);
class ArrayList implments List{
private Object[] buff = null;
private int last = 0;
public ArrayList(){ this(128); }
public ArrayList(int n){
buff = new Object[n];
}
public add(Object o ){
if (last == buff.length) {
class ArrayMap{
class Entry{
Object key;
Object value;
Entry(object k, object v){
this.key = k;
this.value = v;
}
}
@koduki
koduki / fib.c
Created February 24, 2009 17:13
#include <stdio.h>
int fib(n){
if (n < 2) return n;
else return fib(n-2) + fib(n-1);
}
int main(){
int n = 39;
printf("39 : %d\n", fib(n));
}
# -*- coding: utf-8 -*-
require 'webrick'
include WEBrick
module Termtter::Client
add_command /^serv\s*$/ do |m,t|
Thread.new do
serv = WEBrick::HTTPServer.new(:Port => 2110)
# -*- coding: utf-8 -*-
require 'webrick'
include WEBrick
module Termtter::Client
add_command /^serv\s*$/ do |m,t|
Thread.new do
serv = WEBrick::HTTPServer.new(:Port => 2110)
fib(0) -> 0;
fib(1) -> 1;
fib(N) -> fib(N - 2) + fib(N - 1).
@cache = {}
def fib(n)
if @cache.has_key? n
@cache[n]
else
r = (n == 0) ? 1:
(n == 1) ? 1:
fib(n-1) + fib(n-2)
@cache[n] = r
r