Skip to content

Instantly share code, notes, and snippets.

// By weepy
function diff(b,a) {
var d={}
// additions
var tb = typeOf(b)
var ta = typeOf(a)
if(ta != tb)
return b
require 'rubygems'
require 'hpricot'
require 'open-uri'
class Spiderz
#root should be like http://www.google.com (i.e. with http://)
def initialize(root)
@followed = {}
@root = root
var HookManager = function() {
this.list = {};
this.hookTable = {}
}
HookManager.prototype = {
add: function(n, type, fn, priority, off) {
if(typeof type != "string")
log("Cannot add type as hook: " + n)
// border-radius
// Jonah Fox
// MIT Licensed
// Use like : $(".myClass").borderRadius() will attempt to apply curved corners as per the elements -moz-border-radius attribute
// Good:
// - supports textured forgrounds and backgrounds
// - maintains layouts
// - very easy to use
// - IE6 and IE7
// Bad:
// border-radius
// Jonah Fox
// MIT Licensed
// Use like : $(".myClass").borderRadius() will attempt to apply curved corners as per the elements -moz-border-radius attribute
// Good:
// - supports textured forgrounds and backgrounds
// - maintains layouts
// - very easy to use
// - IE6 and IE7
// Bad:
def post_redirect_to url, params
inputs = params.map do |param, val|
"<input id=\"#{param}\" name=\"#{param}\" type=hidden value=\"#{val}\"></input>"
end.join
script = "<script>window.onload = function() { document.forms[0].submit() }</script>"
render :text => "<form action=#{url}>#{inputs}</form>" + script , :layout => false
end
function fill(sq, end_condition) {
var matrix = {}
var queue = [sq]
while(queue.length > 0) {
var sq = queue.shift()
var ns = neighbours(sq, matrix)
if(end_condition ( ns ) {
return true
}
queue = queue.concat(ns)
/* Hooks */
var Hooks = function() {
this.list = {};
this.hookTable = {};
this.hookNum = 0;
}
Hooks.prototype = {
add: function(names, fn, priority, off) {
@weepy
weepy / coding style.js
Created July 20, 2009 08:46
PFJS Coding Guidlines
/*
GENERAL
* tab-spacing: 2 (spaces)
* One file per class / concept (they can always be concatenated)
* Each class should avoid being dependent on another
BRACES
if {
doStuff()
#!/bin/bash
# Inspired by http://blog.fiveruns.com/2008/9/24/rails-automation-at-slicehost
RUBYGEMS="rubygems-1.3.5"
RUBYGEMS_URL="http://rubyforge.org/frs/download.php/60718/$RUBYGEMS.tgz"
PASSENGER_VERSION="2.2.5"
THIS_HOST="www.yourhost.com"
APP_NAME="my_new_app"