This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> | |
//takes a filename as 1st argument | |
//opens it, and mmaps the whole thing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.actors.Actor | |
import scala.actors.Actor._ | |
import java.net.{InetAddress,ServerSocket,Socket,SocketException} | |
import java.io._ | |
case class Start(m:String) | |
case class Request(s:Socket) | |
object Qbert extends Actor { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> def List(op:(Double,Double)=>Double, n:Double*) = n.reduceLeft(op(_,_)) | |
List: ((Double, Double) => Double,Double*)Double | |
scala> List(_+_,1,2,List(_*_,3,3)) | |
res32: Double = 12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'functional.php'; | |
mail( | |
"alan.dipert@gmail.com", | |
"Simplerochester.com Submission", | |
implode( | |
"\n", | |
map( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |