Skip to content

Instantly share code, notes, and snippets.

(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)
@kurtharriger
kurtharriger / recipe.rb
Created October 26, 2012 18:58 — forked from peplin/recipe.rb
S3 File Resource for Chef
# 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
@kurtharriger
kurtharriger / pom2proj.clj
Created March 28, 2012 17:15 — forked from thickey/pom2proj.clj
Convert Maven pom.xml file to Lein project.clj
(ns pom2proj
(:require [clojure.xml :as xml]
[clojure.zip :as zip]
[clojure.java.io :as io]
[clojure.data.zip.xml :as zx])
(:use [clojure.pprint :only [pprint]]))
(defn- text-attrs
[loc ks]
(map (fn [k]
@kurtharriger
kurtharriger / .tmux.conf
Created January 23, 2012 22:34
My TMUX configuration file -- krainboltgreene
###############################################################################
#
# Prefix is set to ` (backtick).
# Doubling the prefix switches to last window.
#
#######################################
#
# Key bindings
# ============
# Tab down-pane
@kurtharriger
kurtharriger / base64.js
Created October 24, 2011 21:29 — forked from stubbetje/base64.js
Base64 encode and decode in javascript
var Base64 = {
characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ,
encode: function( string )
{
var characters = Base64.characters;
var result = '';
var i = 0;
do {
#!/bin/bash
PASTEL='{
"Ansi 0 Color" = {
"Blue Component" = 0.3097887;
"Green Component" = 0.3097887;
"Red Component" = 0.3097887;
};
"Ansi 1 Color" = {
"Blue Component" = 0.3764706;
(require 'moz)
;;; Usage
;; Run M-x moz-reload-mode to switch moz-reload on/off in the
;; current buffer.
;; When active, every change in the buffer triggers Firefox
;; to reload its current page.
(define-minor-mode moz-reload-mode
"Moz Reload Minor Mode"
(use '(incanter core processing))
;; simple interactive Processing example taken from processingjs.org website:
;; http://processingjs.org/source/basic-example/processingjs_basic-example.html
;; set up variable references to use in the sketch object
(let [radius (ref 50.0)
X (ref nil)
Y (ref nil)
(require 'clojure.main)
(defn file-repl [filename]
(let [log (java.io.FileWriter. filename)
logout (fn [#^java.io.Writer out]
(proxy [java.io.Writer] []
(write
([x]
(.write log x)
(.write out x))