Skip to content

Instantly share code, notes, and snippets.

self.pr = function() {
var literal = "["
for (var i=0; i<self.length; i++)
literal += (i != self.length-1) ? self[i]+", " : self[i]+"]"
return literal
}
>> def foo (bar)
>> "#{bar} baz"
>> end
=> nil
>> (0..5).collect &method(:foo)
=> ["0 baz", "1 baz", "2 baz", "3 baz", "4 baz", "5 baz"]
>> method(:foo)
=> #<Method: Object#foo>
@clindsey
clindsey / JavaScript Random Hex Color
Created July 23, 2008 23:27
JavaScript Random Hex Color
(Math.round(0xFFFFFF * Math.random()).toString(16) + "000000").replace(/([a-f0-9]{6}).+/, "#$1").toUpperCase();
@beastaugh
beastaugh / cleanup.rake
Created July 23, 2008 23:33
Delete minified and concatenated CSS and JS files
require 'find'
require 'rubygems'
require 'rake'
desc "Remove minified CSS and JS files from this directory and its children."
task :killmin do
Find.find(File.dirname(__FILE__)) do |path|
if FileTest.directory?(path)
if File.basename(path)[0] == ?.
Find.prune # Don't look any further into this directory.
self.eq = function(other) {
// Is self equal to other?
if (self.length !== other.length) return 0
var equal = 1
for (var i=0; i<self.length; i++) {
if (self[i] !== other[i]) equal = 0
}
return equal
}
@hotchpotch
hotchpotch / autopagerize_for_haiku.user.js
Created July 23, 2008 23:37
Autopagerize for haiku
// ==UserScript==
// @name Autopagerize for haiku
// @namespace http://rails2u.com/
// @include http://h.hatena.ne.jp/*
// @include http://h.hatena.com/*
// ==/UserScript==
var THRESHOLD = 800;
var w = unsafeWindow;
# Author: Dirceu Pereira Tiegs <dirceutiegs@gmail.com>
#
# Script usado para gerar nomes de tavernas
#
class Array
def pick
self.sort_by {rand}[0]
end
end
class def
end
jin mishuku