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 | |
| 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 |
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
| // === 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 |
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
| 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 |
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
| # 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 |
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 "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 |
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 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. |
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 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")))) |
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
| ;; 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))) |
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 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)))) |
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
| 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 } |