Skip to content

Instantly share code, notes, and snippets.

function tableize(wrapper, row, field, data, columns) {
return $("<"+wrapper+"/>").append(
A(data).map(function() {
var ret = $("<"+row+"/>");
$.each($.map(this, function(prop) {
for(c in columns) {
if(columns[c] == prop) {
return prop;
}
}
function tableize(data, selector) {
return $("<table/>").append(
A(data).find(selector).map(function() {
var ret = "<tr/>";
$.each(this, function(k,v) { ret += "<td>"+v+"</td>" });
return ret + "</tr>";
}).get().join("")
);
}
def parseParams(path:String):Map[String,Array[String]] = {
for {
pair <- path.split('/').toList.tail.zipWithIndex.filter(part => placeholders.exists(place => part._2 == place))
} yield (parts(pair._2) -> Array(pair._1))
}
//[error] /Users/alan/Projects/scala/step/./src/main/scala/Step.scala:34: type mismatch;
//[error] found : List[(String, Array[String])]
//[error] required: Map[String,Array[String]]
//[error] pair <- path.split('/').toList.tail.zipWithIndex.filter(part => placeholders.exists(place => part._2 == place))
import scala.actors.Actor
import scala.actors.Actor._
import java.net.{InetAddress,ServerSocket,Socket,SocketException}
import java.io._
import scala.xml._
//case classes
case class Request(s:Socket)
// actor definition
@alandipert
alandipert / componentize.rb
Created June 25, 2009 17:51 — forked from anonymous/componentize.rb
ruby script for turning golf component tree into components.js
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
# given a components directory, poop a components.js to stdout
raise(ArgumentError, "target dir is required") unless cdir = ARGV[0]
exts = ["css", "html", "js", "res"]
puts "jQuery.golf.components="+Hash[*exts.collect{|e|
def bit
"%0160b" % to_i(16)
end
def distance(word1, word2)
word1, word2 = word1.bit, word2.bit
distance = 0
word1.chars.zip(word2.chars) do |char1, char2|
puts "#{char1} | #{char2}"
distance += 1 unless char1 == char2
<?php
include 'functional.php';
mail(
"alan.dipert@gmail.com",
"Simplerochester.com Submission",
implode(
"\n",
map(
<?php
function lambda() {
if(func_num_args() > 1) {
$func = func_get_arg(1);
if($func[strlen($func)-1] != ';')
$func = $func.';';
return create_function(func_get_arg(0), 'return '.$func);
} else {
$func = func_get_arg(0);
#!/usr/bin/env bash
# On Macs, you need to install growlnotify: http://growl.info/documentation/growlnotify.php
# and put it in your PATH somewhere.
function usage() {
echo "tailnote file [regex]"
echo
echo "Tail a file and show notifications using Growl or Mumbles for lines matching regex."
echo "If a regex is not provided, this will notify about all lines."
echo
; minihttpd, tiny barebones clojure web server
; http://alan.xen.prgmr.com/
(ns alandipert.minihttpd
(:use [clojure.contrib.duck-streams :only (reader writer read-lines spit to-byte-array)]
[clojure.contrib.str-utils :only (re-split str-join re-gsub)])
(:import (java.net ServerSocket URLDecoder)
(java.io File)))
(def codes {200 "HTTP/1.0 200 OK"