Skip to content

Instantly share code, notes, and snippets.

View vestige's full-sized avatar

Makoto Yonezawa vestige

View GitHub Profile
Function.prototype.method = function(name, func)
{
this.prototype[name] = func;
return this;
};
String.method('deentityify', function()
{
var entity = {
quot: '"',
var serial_maker = (function () {
var prefix = ' ';
var seq = 0;
return {
set_prefix: function (p) {
prefix = String(p);
},
set_seq: function (s) {
seq = s;
@vestige
vestige / gist:946323
Created April 28, 2011 13:15
tkbjs63
var mammal = function (spec) {
var that = {};
that.get_name = function () {
return spec.name;
};
that.says = function () {
return spec.saying || '';
};
return that;
@vestige
vestige / gist:968449
Created May 12, 2011 13:05
oparts.js
var eventualiy = function (that) {
var registry = {};
that.fire = function (event) {
var array,
func,
handler,
i,
type = typeof event === 'string' ? event : event.type;
if (registry.hasOwnProperty(type)) {
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
Array.method('reduce', function(f, value) {
var i;
for (i = 0; i < this.length; i += 1) {
value = f(this[i], value);
}
@vestige
vestige / gist:1082534
Created July 14, 2011 14:18
LT_timer
# -*- coding: utf-8 -*-
require 'readline'
require 'gnomecanvas2'
require 'timer'
require 'timerserv'
require 'drb/drb'
class Timer
def initialize
@seconds = 60 * 3
@vestige
vestige / tkbjs_match.js
Created September 22, 2011 13:13
tkbjs
document.writeln("");
document.writeln("Hello tkbjs");
Function.prototype.method = function(name, method) {
if (!this.prototype[name]) {
this.prototype[name] = method;
return this;
}
}
String.method('entityify', function () {
document.writeln("");
document.writeln("Hello tkbjs");
document.writeln("============");
var text = 'and in it he says "Any damn fool could';
var pos = text.search(/["']/);
document.writeln(pos);
@vestige
vestige / MyController.rb
Created November 4, 2011 14:50
MacRuby Spike
class MyController < NSWindowController
attr_writer :button, :text
attr_accessor :words
def clicked(sender)
puts "Button clicked!"
@text.StringValue = "hello!"
@words.StringValue = "0"
end
@vestige
vestige / timer.rb
Created November 5, 2011 15:39 — forked from Watson1978/timer.rb
MacRuby : Sample of NSTimer
# -*- coding: utf-8 -*-
framework "Cocoa"
class AppDelegate
def initialize
# NSTimer の初期化
@timer = NSTimer.scheduledTimerWithTimeInterval(1.0,
target:self,
selector:"output:",
userInfo:nil,