Skip to content

Instantly share code, notes, and snippets.

View swannodette's full-sized avatar

David Nolen swannodette

View GitHub Profile
(app/start callback-map {})
#import <Foundation/Foundation.h>
// ============================
// MyClass
// ============================
@class YourClass;
@interface MyClass : NSObject
{
(ns littlesis.names
(:require [net.cgrand.enlive-html :as html]))
(def *base-url* "http://blog.littlesis.org/2010/02/18/sources-allege-goldman-sachs-and-john-paulson-are-partnering-in-speculative-attacks-o\
n-greece/")
(defn fetch-url [url]
(html/html-resource (java.net.URL. url)))
(defn entry [node]
(import [java.security MessageDigest])
(def *sha1* "SHA-1")
(def *abc* (.getBytes "ABC"))
(def *abc-sha1* "3c1bdbb26f358bab27f267924aa2c9a3fcfdb8")
(defn start-message-digest [type]
(MessageDigest/getInstance type))
(defn update-message-digest [#^MessageDigest md bytes]
(def *section-sel* {[:h2] [:ul]})
(defsnippet section-model "tutorial/template2.html" *section-sel*
[{:keys [title links]}]
[:h2] (content title)
[:ul] (content (map link-model links)))
; Amaturish Clojure version of uniprot mapping function by @sjcockell
; Improved a bit by David Nolen
; http://blog.fuzzierlogic.com/archives/339
; http://gist.github.com/329730
(ns uniprot
(:use [clojure.contrib.duck-streams])
(:require [clojure.contrib.str-utils2 :as s])
(:import java.net.URLEncoder))
(defn- url-encode [param] (URLEncoder/encode param))
(def m (ref {}))
(defn str-to-int [m s]
(or (@m s)
(dosync
(alter m assoc s (count @m))
(@m s))))
;; this file is a walkthrough of Moustache features, a web framework for Clojure
;; http://github.com/cgrand/moustache/tree/master
;; Moustache allows to declare routes, apply middlewares and dispatch on http methods.
;; Moustache is compatible with all frameworks built on Ring, including Compojure
(ns demo
(:use net.cgrand.moustache)
(:use [ring.adapter.jetty :only [run-jetty]])) ;; hmmm Ring without servlets
(def post-resource
(app ["view" slug] {:get get-post}
["new"] {:get new-post}
["new"] {:post save-post}
["edit" id] {:get edit-post}))
(ns test-code)
(defn foo [x y]
(+ x y))
(foo z) ; line number
(foo 1 2 3) ; line number is 1
(defn bar [x]
(foo x "bar"))