Skip to content

Instantly share code, notes, and snippets.

View fogus's full-sized avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
(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)
(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%40host.com@ftp2.census.gov/geo/tiger/TIGER2008/")
(ftp/list-all *tiger-ftp-url*)
(ftp/list-files *tiger-ftp-url*)
(ftp/list-directories *tiger-ftp-url*)
#!/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.
(atom)
(car)
(cdr)
(cond)
(cons)
(eq)
(quote)
(atom)
(car)
(cdr)
(cond)
(cons)
(eq)
(quote)
object Lunar extends Baysick {
def main(args:Array[String]) = {
10 PRINT "Welcome to Baysick Lunar Lander v0.9"
20 LET ('dist := 100)
30 LET ('v := 1)
40 LET ('fuel := 1000)
50 LET ('mass := 1000)
60 PRINT "You are drifting towards the moon."
object Lunar extends Baysick {
def main(args:Array[String]) = {
10 PRINT "Welcome to Baysick Lunar Lander v0.9"
20 LET ('dist := 100)
30 LET ('v := 1)
40 LET ('fuel := 1000)
50 LET ('mass := 1000)
60 PRINT "You are drifting towards the moon."
fn( reduce
[?f $?lst]
if(empty?($?lst)
call(?f)
else
call(?f first($?lst)
reduce(?f rest($?lst)))))
reduce(_(1 2 3 4 5) +)
fn( reduce
[?f $?lst]
if(empty?($?lst)
call(?f)
else
call(?f first($?lst)
reduce(?f rest($?lst)))))
reduce(_(1 2 3 4 5) +)
fn( reduce
[?f $?lst]
if(empty?($?lst)
?f()
else
?f(first($?lst)
reduce(?f rest($?lst)))))
reduce(_(1 2 3 4 5) +)