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
| (import '(java.io BufferedReader IOException InputStream InputStreamReader OutputStreamWriter) | |
| '(java.net URL URLConnection URLEncoder) | |
| '(sun.misc BASE64Encoder)) | |
| (def update-url "https://twitter.com/statuses/update.xml") | |
| (defn creds [username password] | |
| (.trim (.encode (BASE64Encoder.) (.getBytes (str username ":" password))))) | |
| (defn twitter [username password text] |
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
| build/hiredman/astro.class: hiredman/astro.clj build/.clojure build/.tagsoup | |
| ${CLOJURE} -e "(compile 'hiredman.astro)" | |
| build/version: | |
| echo ${VERSION} > build/version | |
| astro.jar: build/hiredman/astro.class build/version | |
| jar cevf hiredman.astro astro.jar -C build/ . > /dev/null | |
| @du -hs astro.jar |
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
| (import '(javax.swing JFrame JTextArea JPanel UIManager SwingUtilities JScrollPane BoxLayout) | |
| '(java.awt.event ActionListener KeyAdapter) | |
| '(java.io StringReader PrintWriter PushbackReader Writer StringReader OutputStreamWriter) | |
| '(java.awt GridLayout FlowLayout) | |
| '(java.util.concurrent LinkedBlockingQueue ArrayBlockingQueue) | |
| '(clojure.lang IDeref Associative LineNumberingPushbackReader)) | |
| (. UIManager (setLookAndFeel (. UIManager (getSystemLookAndFeelClassName)))) | |
| (defn fn->kl [fun] |
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
| (def a (into-array Byte/TYPE | |
| (let [a (java.util.ArrayList. (map byte (range 6000)))] | |
| (java.util.Collections/shuffle a) | |
| a))) | |
| (set! *warn-on-reflection* true) | |
| (defn byte-array-contains? [coll key] | |
| "scans a byte array for a given value" | |
| (let [c (int (count coll)) |
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 get-url [x] | |
| (with-open [a (-> (doto (-> x URL. .openConnection) | |
| (.setRequestProperty "User-Agent" "clojurebot")) | |
| .getInputStream InputStreamReader. BufferedReader.)] | |
| (loop [buf (StringBuilder.) line (.readLine a)] | |
| (if line | |
| (recur (doto buf (.append line)) (.readLine a)) | |
| (.toString buf))))) |
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
| (import '(java.util.concurrent BlockingQueue SynchronousQueue ArrayBlockingQueue)) | |
| (defstruct token :count :value) | |
| (defn thread-factory | |
| ([#^BlockingQueue in term pred #^String name #^BlockingQueue out] | |
| (.start | |
| (Thread. | |
| (fn [] | |
| (let [t (.take in)] |
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
| *default host=CHANGE_THIS.FreeBSD.org | |
| *default base=/var/db | |
| *default prefix=/usr | |
| *default release=cvs tag=RELENG_7 | |
| *default delete use-rel-suffix | |
| *default compress | |
| src-all |
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 sig [x] | |
| (:sig (meta (resolve x)))) | |
| (defmulti type-of (comp type first list)) | |
| (defmethod type-of :function [thing & _] (sig thing)) | |
| (defmethod type-of java.util.List [expr & a] | |
| (conj (map #(type-of % (first a)) (rest expr)) |
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 hiredman.zip | |
| (:import (java.util.zip ZipEntry ZipOutputStream ZipInputStream) | |
| (java.io ByteArrayInputStream ByteArrayOutputStream))) | |
| (defn pad-to-8 [string] | |
| (if (> 8 (count string)) | |
| (recur (.concat "0" string)) | |
| string)) | |
| (defn zip-string [string] |
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
| #/bin/sh! | |
| mkdir AOT_TEST | |
| cd AOT_TEST | |
| mkdir foo | |
| mkdir classes | |
| echo "(ns foo.bar (:gen-class)) (defn -main [] (println \"foo\"))" > foo/bar.clj | |
| $1 -cp $2:./classes:. clojure.main -e "(compile 'foo.bar)" | |
| $1 -cp $2:./classes:. foo.bar | |
| rm -rf foo | |
| rm -rf classes |