This file contains hidden or 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 | |
# -*- ruby -*- | |
# twitter command line client | |
# That's What I Call Lame | |
# 09nov2008 +chris+ | |
require 'json' | |
require 'open-uri' |
This file contains hidden or 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
(ns org.apache.http.examples | |
"Basic HTTP Server. | |
A quick port of http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpServer.java to Clojure" | |
(:import (java.io File OutputStreamWriter InterruptedIOException IOException) | |
(java.net ServerSocket URLDecoder) | |
(java.util Locale) | |
(org.apache.http.protocol BasicHttpProcessor HttpContext BasicHttpContext HttpRequestHandler HttpRequestHandlerRegistry HttpService ResponseConnControl ResponseContent ResponseDate ResponseServer) | |
(org.apache.http ConnectionClosedException HttpEntity HttpEntityEnclosingRequest HttpException HttpRequest HttpResponse HttpServerConnection HttpStatus MethodNotSupportedException) | |
(org.apache.http.entity ContentProducer EntityTemplate FileEntity) | |
(org.apache.http.impl DefaultConnectionReuseStrategy DefaultHttpResponseFactory DefaultHttpServerConnection) |
This file contains hidden or 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
(ns tiger | |
(:import ( org.apache.commons.net.ftp FTP FTPClient)) | |
(:require [com.github.kyleburton.sandbox.ftp :as ftp]) | |
(:use [ clojure.contrib.str-utils :as str])) | |
(def *tiger-ftp-url* "ftp://anonymous:user%[email protected]/geo/tiger/TIGER2008/") | |
(ftp/list-all *tiger-ftp-url*) | |
(ftp/list-files *tiger-ftp-url*) | |
(ftp/list-directories *tiger-ftp-url*) |
This file contains hidden or 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/ruby | |
# Trivial little twitter script | |
# Pass it a list of names as command line arguments | |
# and it will return a list of all people who follow everyone in the | |
# list. | |
# A person is implicitly assumed to follow themselves, so if foo follows | |
# bar and bar follows foo then common_followers foo bar would include | |
# both foo and bar in the output, but if bar did not follow foo it | |
# would include neither. |
This file contains hidden or 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
package retweetrec | |
import scala.xml.XML | |
import java.net.URL | |
import java.io.InputStream | |
object ReTweetRec { | |
def getFollowers(id: String) = { | |
val data = new URL("http://twitter.com/followers/ids/" + id + ".xml").getContent |
This file contains hidden or 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
""" | |
Simple forking echo server built with Python's SocketServer library. A more | |
Pythonic version of http://gist.github.com/203520, which itself was inspired | |
by http://tomayko.com/writings/unicorn-is-unix. | |
""" | |
import os | |
import SocketServer | |
class EchoHandler(SocketServer.StreamRequestHandler): |
This file contains hidden or 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/ruby | |
RLSP_VERSION = "1.4.1" | |
class Lambda | |
attr_accessor :args, :body | |
def initialize(args=[],body="") | |
@args = (args.class == Array) ? args : [args] | |
@body = body | |
end |
This file contains hidden or 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
(defprotocol Matchable (match [me matcher])) | |
(defmacro data [name & constructors] | |
`(do | |
(defprotocol ~name) | |
(defprotocol ~(symbol (str "match-"name)) | |
~@(for [[const & args] constructors] | |
`(~(symbol (str "match-"const)) [_# ~@args]))) | |
~@(for [[const & args] constructors] |
This file contains hidden or 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
(defn listify [orig-list] | |
"Turns (1 2 3 ...) into (1 (2 (3 (...)))) using continuation passing style." | |
(loop [lst orig-list cont identity] | |
(if (= () lst) | |
(cont ()) | |
(recur (rest lst) | |
(fn [insert] | |
(cont (cons (first lst) | |
(list insert)))))))) |
This file contains hidden or 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
(defn xseq [t] | |
(when t | |
(concat (xseq (:l t)) [(:root t)] (xseq (:r t))))) | |
(defn xconj [t v] | |
(cond | |
(nil? t) {:root v :l nil :r nil} | |
(< v (:root t)) {:root (:root t) :l (xconj (:l t) v) :r (:r t)} | |
:else {:root (:root t) :l (:l t) :r (xconj (:r t) v)})) |
OlderNewer