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
| (use '[clojure.java.shell :only [sh]]) | |
| (def version "0.1.1") | |
| (defn clean? [] | |
| (empty? (:out (sh "git" "diff-index" "HEAD")))) | |
| (defn tagged? [version] | |
| (let [tag (.trim (:out (sh "git" "describe" "--tags" "--exact-match") ""))] | |
| (= tag version))) |
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
| (defun slime-redirect-stdout () | |
| (interactive) | |
| (slime-interactive-eval | |
| "(System/setOut (java.io.PrintStream. (org.apache.commons.io.output.WriterOutputStream. *out* \"UTF-8\" 8192 true)))")) | |
| (add-hook 'slime-connected-hook 'slime-redirect-stdout) |
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 mocked [x] (Exception. "should not be called")) | |
| (defn withmocked [x] (mocked (inc x))) | |
| ;.;. [31mFAIL[0m at (NO_SOURCE_FILE:1) | |
| ;.;. Expected: 3 | |
| ;.;. Actual: #<Exception java.lang.Exception: should not be called> | |
| (facts "Fails if mocked is called twice" | |
| (let [x 2] | |
| (mocked 3) => 3 | |
| (withmocked x) => 3 |
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
| (use 'midje.sweet) | |
| (defn mocked [x] "ERROR: THIS SHOULDN'T HAVE BEEN CALLED") | |
| (defn handler [r] | |
| (let [body (mocked (get-in r [:params :id]))] | |
| {:status (if (re-find #"ERROR" body) 500 200) | |
| :body body | |
| :content-type "text/plain" | |
| } |
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
| # Source accepts the protocol s3:// with the host as the bucket | |
| # access_key_id and secret_access_key are just that | |
| s3_file "/var/bulk/the_file.tar.gz" do | |
| source "s3://your.bucket/the_file.tar.gz" | |
| access_key_id your_key | |
| secret_access_key your_secret | |
| owner "root" | |
| group "root" | |
| mode 0644 | |
| end |
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
| (function(exports){ | |
| // your code goes here | |
| exports.test = function(){ | |
| return 'hello world' | |
| }; | |
| })(typeof exports === 'undefined'? this['mymodule']={}: exports); |
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
| ;; autosave | |
| (defun full-auto-save () | |
| (interactive) | |
| (save-excursion | |
| (dolist (buf (buffer-list)) | |
| (set-buffer buf) | |
| (if (and (buffer-file-name) (buffer-modified-p)) | |
| (basic-save-buffer))))) | |
| (add-hook 'auto-save-hook 'full-auto-save) |
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
| (require '[net.cgrand.enlive-html :as html]) | |
| (defn render [e] (apply str (html/emit* e))) | |
| (defn strip-classes | |
| "Remove class attribute from all elements" | |
| [file] | |
| (-> | |
| (html/html-resource file) | |
| (html/at [(html/attr? :class)] (html/remove-attr :class)) | |
| (render))) |
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
| // For clojurescript autorecompile: https://gist.github.com/johnbintz/9498860 | |
| module.exports = function(grunt) { | |
| // Load Grunt tasks declared in the package.json file | |
| require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
| // Configure Grunt | |
| grunt.initConfig({ | |
| // grunt-express will serve the files from the folders listed in `bases` |
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/bash | |
| DNAME=$(basename $(pwd)) | |
| if [ -n "$1" ]; then | |
| NAME="$1" | |
| if [ "$NAME" != "$DNAME" -a -d ~/projects/"$NAME" ]; then | |
| cd ~/projects/"$NAME" | |
| fi | |
| else | |
| NAME=$(basename $(pwd)) |