Skip to content

Instantly share code, notes, and snippets.

@sebs
sebs / jenkins.sh
Created February 9, 2011 19:12
setup jenkins ubuntu 10.10 mini
#!/bin/sh
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo echo "deb http://pkg.jenkins-ci.org/debian binary/" > /etc/apt/sources.list.d/jenkins.list
sudo aptitude update
sudo aptitude install jenkins
@teamon
teamon / specs.scala
Created January 31, 2011 16:50
Scala specs cheatsheet
// === Basics
a must beMatching(bar)
a must be matching(bar)
a must not be matching(bar) // negation
// === Any object
a must_== b
a must_!= b
@LauJensen
LauJensen / gist:789530
Created January 21, 2011 10:52
First cut at interface for CASE
clojureql.core> (project (table :t1)
[:id (case :wages
(<= :wage 5) "low"
(>= :wage 10) "high"
:else "average")])
SELECT t1.id,CASE
WHEN (wage <= 5) THEN low
WHEN (wage >= 10) THEN high
ELSE average
END AS wages
@briandealwis
briandealwis / gist:782862
Created January 17, 2011 13:55 — forked from spullara/gist:782523
One-liner to turn jar with Main-Class into executable shell script
# turn a jar with a Main-Class into a stand alone executable
(echo '#!/usr/bin/env java -jar'; cat blahblah.jar) > blah
# turn a jar with a particular main clas into a stand alone executable
(echo '#!/usr/bin/env java -jar package.MainClass'; cat blahblah.jar) > blah
@hugoduncan
hugoduncan / gist:765278
Created January 4, 2011 19:41
Local git clone resource
(ns "blah"
(:require
[pallet.resource :as resource]
[pallet.execute :as execute])
(resource/deflocal git-clone
"Clone a git repo"
(git-clone*
[request repo]
(execute/local-script ;; in 0.4.0-SNAPSHOT
@abhin4v
abhin4v / ascii-bar-chart.clj
Created December 28, 2010 22:34
Prints a horizontal ASCII bar chart for the data given. Written in Clojure.
(defn ascii-bar-chart
"
Prints the horizontal ASCII bar chart for the data given.
Handles both positive and negative values.
Use it to visualize data in the REPL.
Arguments:
data: a seq of key value pairs. the chart is printed in the order of this seq.
keys should be strings (or have a proper toString method).
values should be numbers.
@folsen
folsen / svd.clj
Created December 27, 2010 18:12
A word-problem game from a swedish newpaper solved in clojure
(ns svd.core
(:use
clojure.contrib.combinatorics)
(:require
[clojure.contrib.duck-streams :as ds]
[clojure.contrib.str-utils :as str]))
(defn wordlist []
(set (map #(re-find #"[^/]*" %) (ds/read-lines "sv_se.dic"))))
@jkk
jkk / karma.clj
Created December 22, 2010 05:04
karma.clj
;; re http://groups.google.com/group/clojure/browse_thread/thread/55faa29db75192d0
(ns user
(use [clojure.java.io :only [reader]]))
(def re-vote #"([A-z]{1,16})(\+\+|\-\-)")
(defn extract-votes
[line]
(map rest (re-seq re-vote line)))
(ns com.snowtide.clojure.memoize)
(defn- mutable-memoize
[f #^java.util.Map map]
(fn [& args]
(if-let [e (find map args)]
(val e)
(let [ret (apply f args)]
(.put map args ret)
ret))))
@casualjim
casualjim / ScalatraWebSocket.scala
Created December 18, 2010 21:15
WebSocket support for scalatra
package com.mojolly.websocket
import org.scalatra._
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
import org.eclipse.jetty.websocket.{WebSocket => ServletWebSocket, WebSocketFactory}
import akka.util.Logging
import java.io.UnsupportedEncodingException
import org.eclipse.jetty.websocket.WebSocket.Outbound
import collection.mutable.{ HashSet, SynchronizedSet }