This file contains 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
import Html exposing (text, div, Attribute) | |
import Html.Attributes exposing (style, draggable) | |
import Html.Events exposing (..) | |
import Signal exposing (map, mailbox) | |
import Json.Decode as Json exposing (value) | |
mb = mailbox "None" | |
messageOn : String -> Signal.Address a -> a -> Attribute | |
messageOn name addr msg = |
This file contains 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 with-local-redefs-fn | |
[a-var its-new-value func] | |
(cast clojure.lang.IFn @a-var) | |
(alter-meta! a-var | |
(fn [m] | |
(if (::scope-count m) | |
(update-in m [::scope-count] inc) | |
(assoc m | |
::scope-count 1 | |
::thread-local-var (doto (clojure.lang.Var/create @a-var) |
This file contains 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)) |
This file contains 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 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 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 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 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 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 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 |