Skip to content

Instantly share code, notes, and snippets.

Avatar

Moritz von Göwels the-kenny

View GitHub Profile
View gist:243175
(defn get-stream []
(let [conn #^java.net.HttpURLConnection
(http-connection "http://stream.twitter.com/1/statuses/sample.json")]
(.setDoInput conn true)
(.setRequestProperty conn
"Authorization"
(str "Basic " (base64/encode-str
"USERNAME:PASSWORD")))
(.getInputStream conn)))
View gist:249745
diff --git a/src/couchdb/client.clj b/src/couchdb/client.clj
index 4567df0..e4ccb82 100644
--- a/src/couchdb/client.clj
+++ b/src/couchdb/client.clj
@@ -154,12 +154,12 @@
([server database]
(when-let [database (validate-dbname database)]
(map :id (:rows (:json (couch-request (str server database "/_all_docs")))))))
- ([server database options]
+ ([server database & [options]]
@the-kenny
the-kenny / .emacs
Created January 1, 2010 17:16
pbcopy & pbpaste for Emacs
View .emacs
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)
View 1*
swank.util.io.proxy$java.io.StringWriter$0 cannot be cast to java.io.PrintWriter
[Thrown class java.lang.ClassCastException]
Restarts:
0: [ABORT] Return to SLIME's top level.
Backtrace:
View 4*
swank.util.io.proxy$java.io.StringWriter$0 cannot be cast to java.io.PrintWriter
[Thrown class java.lang.ClassCastException]
Restarts:
0: [ABORT] Return to SLIME's top level.
Backtrace:
0: clojure.lang.Compiler$InstanceFieldExpr.<init>(Compiler.java:920)
1: clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:798)
2: clojure.lang.Compiler.analyzeSeq(Compiler.java:4592)
View gist:267299
; SLIME 20091016
user> ;; How to break swank-clojure
nil
user> ;; This is a clean repl started with M-x swank-clojure-project, nothing was required until now
nil
user> (do
(set! *warn-on-reflection* true)
(set! *print-level* 4)
(set! *print-length* 30))
30
View gist:273526
(let [x (+ (foo a b)
(bar c d))]
(print x))
View Mathematik.java
int fib(int n) {
//Spezielfaelle bei n < 3
// fib(0) == 0, fib(1) == 1, fib(2) == 1
if(n == 0)
return 0;
else if(n == 1 || n == 2)
return 1;
// Variablendeklarationen
// f = aktuelle fibonaccizahl,
View *slime-repl clojure*
user> (use 'vijual)
nil
user> (draw-tree [[:north-america [:usa [:miami] [:seattle] [:idaho [:boise]]]] [:europe [:germany] [:france [:paris] [:lyon] [:cannes]]]])
+------------+ +--------+
| north | | europe |
| america | +----+---+
+------+-----+ |
| +---------+---------+
+ | |
| +----+----+ +---+----+
View *slime-scratch*
(reduce #(if (and (string? %2) (string? (last %1)))
(conj (vec (drop-last %1)) (str (last %1) %2))
(conj %1 %2))
[] [1 2 "foo" "bar" 42 5])