Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Downey hiredman

View GitHub Profile
@hiredman
hiredman / clojurebot.clj
Created Nov 22, 2008
irc bot for #clojure
View clojurebot.clj
;;
;; Thus spake the master programmer:
;; "Though a program be but three lines long, someday it will have to be
;; maintained."
;;
;;
;; [01:30] <uhelp> lexxan: Since Mon May 2 17:22:46 2005,
;; there have been 0 modifications and 0 questions.
;; I have been awake for 7 minutes and 36 seconds
;; this session, and currently reference 19
View google-notebook.clj
(import '(org.xlightweb.client HttpClient)
'(java.net URL URLEncoder)
'(javax.net.ssl SSLContext)
'(java.util Date)
'(org.xlightweb PostRequest GetRequest))
(def base-url "https://www.google.com/notebook/")
(def params {"service" "notebook"
View gist:29575
refs/heads/master^@44bf79070b689ae3e96adbcae4c3c97abaf59ac4
refs/heads/master^@44bf79070b689ae3e96adbcae4c3c97abaf59ac4
refs/heads/master^@44bf79070b689ae3e96adbcae4c3c97abaf59ac4
refs/heads/master^@44bf79070b689ae3e96adbcae4c3c97abaf59ac4
bzr: ERROR: exceptions.TypeError: 'Tree' object is not iterable
Traceback (most recent call last):
File "/usr/local/lib/python2.5/site-packages/bzrlib/commands.py", line 893, in run_bzr_catch_errors
return run_bzr(argv)
File "/usr/local/lib/python2.5/site-packages/bzrlib/commands.py", line 839, in run_bzr
@hiredman
hiredman / clojurebot.clj
Created Dec 3, 2008
svn info for clojurebot
View clojurebot.clj
(def svn-command "svn -v --xml --limit 5 log https://clojure.svn.sourceforge.net/svnroot/clojure")
(defn svn-summaries
"takes output of clojure.xml/parse on svn's xml log, returns
a vector of [rev-number commit-message]"
[tag-map]
(map (fn [x]
[(.parseInt Integer (:revision (:attrs x)))
(first
(:content
View xmpp.clj
(ns hiredman.xmpp
(:import (org.jivesoftware.smack XMPPConnection ConnectionConfiguration
RosterListener PrivacyListManager
PacketListener)
(org.jivesoftware.smack.packet Presence Presence$Type)
(org.jivesoftware.smack.filter PacketFilter)))
(defstruct xmpp :connection :chats)
(defn connect [jid pass]
View beans.clj
(ns hiredman.beans)
(defn -it [& _]
[[] (ref {})])
(defn setter [tis nam tat]
(dosync
(commute (.state tis)
assoc nam tat)))
View sandbox.clj
;; need a java policy file that allows all or enabling the security manager will
;; lock you out
;;
;; grant {
;; permission java.security.AllPermission;
;; };
(System/setSecurityManager (SecurityManager.))
View gist:37639
rant codeBase "file:${{java.ext.dirs}}/*" {
permission java.security.AllPermission;
};
grant {
permission java.security.AllPermission;
};
View sandbox.clj
(ns hiredman.sandbox
(:import (java.util.concurrent FutureTask TimeUnit TimeoutException)
(java.io File FileWriter PushbackReader StringReader)))
(def *bad-forms* #{'eval 'catch 'try 'def 'defn 'defmacro 'read 'Thread. 'send 'send-off 'clojure.asm.ClassWriter.})
(defn enable-security-manager []
(System/setSecurityManager (SecurityManager.)))
;;;;;;;; Chousuke
View foo.clj
(defn dd [x]
(print (str "<dd>" x "</dd>")))
(defn next_button []
(print "<dd class=\"next\"><input class=\"next\" value=\"Next\" type=\"submit\" /></dd>"))
(defn attribute_printer [attrs]
(foreach [attrs :as [k v]]
(if (and (not= k "") (not= "" v))
(print (str k "=\"" v "\"")))))
You can’t perform that action at this time.