Skip to content

Instantly share code, notes, and snippets.

View mccraigmccraig's full-sized avatar

mccraigmccraig of the clan mccraig mccraigmccraig

View GitHub Profile
@mccraigmccraig
mccraigmccraig / gist:212493
Created October 18, 2009 00:16
clojure : early version of alex's puzzle solver
(defstruct board :size :values :value-index :all-transitions)
(defn create-board
"create a board of a given size"
[size]
(assert (> size 0))
(let [values (vec (range 1 (inc size)))
value-index (reduce (fn [h i] (assoc h (values i) i)) {} (range 0 (count values)))
all-transitions (reduce (fn [t n] (assoc t n (set values))) {} values)]
(struct-map board
@mccraigmccraig
mccraigmccraig / puzzle.clj
Created October 18, 2009 13:10
clojure : alex's puzzle solver
(ns puzzle)
(defstruct board :size :values :value-index :constraints)
(defn create-board
"create a board with given size and constraints"
[size constraints]
(assert (> size 0))
(let [values (vec (range 1 (inc size)))
value-index (reduce (fn [h i] (assoc h (values i) i)) {} (range 0 (count values)))
(defn multi-split-with
"Returns a lazy collection of lists which elements ..."
[pred coll]
(let [[head tail] (split-with pred coll)
tail-without-seps (drop-while (complement pred) tail)]
(lazy-seq
(if (seq tail-without-seps)
(cons head (multi-split-with pred tail-without-seps))
(list head)))))
@mccraigmccraig
mccraigmccraig / mail_decode_fail
Created October 21, 2010 15:24
mail fails to decode encoded addresses
>> puts m.to_s
Date: Thu, 21 Oct 2010 16:28:20 +0100
From: craig mcmillan <victorianexercises@gmail.com>
To: =?UTF-8?B?ImNyYWlnIOaXpeacrOWbvSI=?= <craig@trampolinesystems.com>
Message-ID: <4CC05C14.6030501@mccraig.net>
Subject: =?UTF-8?Q?big_in_=E6=97=A5=E6=9C=AC=E5=9B=BD?=
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8;
format=flowed
@mccraigmccraig
mccraigmccraig / gist:3093582
Created July 11, 2012 21:14
mark an emacs window as unavailable for other content
;; pin windows
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not"
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window
(not (window-dedicated-p window))))
"Window '%s' is dedicated"
"Window '%s' is normal")
{"status":200,
"data":
{"longitude":0.1537217,
"name":"AUTONOMY SYSTEMS LIMITED",
"postcode":"CB4 0WZ",
"last_revenue_year":2010,
"last_tweet":null,
"colocated":["03857576","03879840","04255000","07117553","03266657","04031841","06063523","05212691","04217293","06917673","03008226","03781249","04858580","03891934","02926171"],
"directors":[
{"name":"Mr Roberto Adriano Putland",
@mccraigmccraig
mccraigmccraig / gist:3794445
Created September 27, 2012 14:52
wrapping/unwrapping with cascalog defparallelagg
(use 'cascalog.api)
(use 'cascalog.playground)
(require '[clojure.tools.logging :as log])
(require '[clojure.pprint :as pp])
(bootstrap)
(defn vectorvector
[& vals]
[(apply vector vals)])
#!/usr/bin/env sh
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
@mccraigmccraig
mccraigmccraig / profile.boot
Last active April 14, 2016 12:54
boot s3-wagon-private repository credentials from gpg or environment
;; ; specify S3 repositories with something like
;;
;; (set-env!
;; :wagons '[[s3-wagon-private "1.2.0"]]
;; :repositories #(concat % [["releases" {:url "s3p://your-s3-wagon-bucket/releases/"
;; :username [:env/aws_access_key :gpg]
;; :passphrase [:env/aws_secret_key :gpg]}]
;; ["snapshots" {:url "s3p://your-s3-wagon-bucket/snapshots/"
;; :username [:env/aws_access_key :gpg]
@mccraigmccraig
mccraigmccraig / profile.clj
Last active March 14, 2017 11:53
boot profile to retrieve encrypted passwords from gpg or env
;; ; specify S3 repositories with something like
;;
;; (set-env!
;; :wagons '[[s3-wagon-private "1.2.0"]]
;; :repositories #(concat % [["releases" {:url "s3p://your-s3-wagon-bucket/releases/"
;; :username [:env/aws_access_key :gpg]
;; :passphrase [:env/aws_secret_key :gpg]}]
;; ["snapshots" {:url "s3p://your-s3-wagon-bucket/snapshots/"
;; :username [:env/aws_access_key :gpg]