Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
# Continually query google scribe using the first result returned creating abstract collective sub-conscious poetry
use LWP::Simple;
use JSON;
sub get_scribble {
my ($query, $last_sel) = @_;
my $cnt = get("http://scribe.googlelabs.com/suggest?client=gs&hl=en&q=".URI->new($query)."&s=c&callback=gsjc2");
if ($cnt) {
@hhutch
hhutch / pallet.snippets.clj
Created July 20, 2011 14:15
Pallet snippets that are useful
(defn nodes-in-group
"Build a list of nodes in a given security-group"
[security-group]
(filter #(= (% 0) security-group)
(map #(vector (pallet.compute/group-name %)
(pallet.compute/primary-ip %)
(pallet.compute/id %)
(pallet.compute.jclouds/node-locations %) )
(pallet.compute/nodes srvc))))
@hhutch
hhutch / core.cljs
Created July 28, 2011 07:53
Goofing around with clojurescript. I actually forgot I was "writing javascript" at one point.
(ns cancan.core
(:require
[goog.dom :as dom]
[goog.graphics :as graphics]
[goog.graphics.Path :as Path]))
(defn style-elem
"Style an element"
[element attrs]
(dom/setProperties element
(ns guitst
(:require
[goog.dom :as dom]
[goog.editor.Field :as goog-editor-field]
[goog.editor.plugins.BasicTextFormatter :as basic-text-formatter]
[goog.editor.plugins.RemoveFormatting :as remove-formatting]
[goog.editor.plugins.UndoRedo :as undo-redo]
[goog.editor.plugins.ListTabHandler :as list-tab-handler]
[goog.editor.plugins.SpacesTabHandler :as spaces-tab-handler]
[goog.editor.plugins.EnterHandler :as enter-handler]
@hhutch
hhutch / cron-s3-rsync.clj
Created October 25, 2011 15:21
create a script with stevedore, schedule it with cron
(defn install-backup-scripts
"Creates a script in stevedore and installs it as a shell script in the administrative user's home dir
and installs it as a cron. This will override the crontab."
[request]
(let [administrative-user (:username (pallet.session/admin-user request))
admin-home-dir (str "/home/" administrative-user)
raw-instance-id (-> request :target-node (pallet.compute/id))
instance-id (apply str (interpose "_" (clojure.string/split raw-instance-id #"/")))
instance-group (-> request :target-node (compute/group-name))
s3-dir (str "/mnt/s3logstore/" instance-id "." instance-group)
@hhutch
hhutch / README.txt
Created November 11, 2011 17:00
Clojurescript + NodeJS + Commander CLI + Core.Match
;; You do have Clojurescript, right?
;; First Install NodeJS
;; Then install npm (node package manager)
;; Then install Commander.js https://github.com/visionmedia/commander.js
$ cljsc src/cljs-demo/pizza.cljs '{:optimizations :simple :pretty-print true :target :nodejs}' > pizza.js
$ ./pizza.js --help
Usage: pizza.js [options]
Options:
@hhutch
hhutch / meter.cljs
Created November 11, 2011 19:38
NodeJS + Node Multimeter in Clojurescript
(ns cljs-demo.multimeter
(:require [cljs.nodejs :as node]))
(def multimeter (node/require "multimeter"))
(defn start [& _]
(let [multi (multimeter. node/process)]
(. multi (on "^C"
#((. (.charm multi) (cursor true))
(.. multi (write "\n") (destroy))
@hhutch
hhutch / hacklog.textile
Created November 20, 2011 13:37 — forked from candera/hacklog.textile
Hack Log

This is my score for the “One Hundred Days of Hacking” game. Rules here.

Date Score Commit Comment
23/12/2011 1 3ce034fcef cljs-closure-demos
9/12/2011 18 OH NO!!
8/12/2011 17 a96b9e546e cljs-closure-demos
7/12/2011 16 1ec55ea6d3 cljs-closure-demos
6/12/2011 15 cad1abbe98 cljs-closure-demos
5/12/2011 14 89b9a6e50e straw
4/12/2011 13 df6f5f8028 straw
@hhutch
hhutch / booklog.textile
Created December 21, 2011 05:11
Book Log

An hour a day reading.
Score is number of days consecutively meeting the per day requirement.
Chapters is the chapters read that day.
Pages is the range of pages read that day.

Date Score Chapters Pages Book Notes
26/01/2012 25 1.1-2.1 * Babbit
25/01/2012 24 4.2 218-240 Postsingular
24/01/2012 23 3.2-4.1 158-217 Postsingular
23/01/2012 22 3.1-3.2 125-157 Postsingular
@hhutch
hhutch / gist:1549014
Created January 2, 2012 02:18
TV Log

New Year’s Resolution: Don’t watch TV.

Rules:
No Movies. No Television shows.

Exceptions:
Tech related video podcasts. News related podcasts. Videos of Lectures. Tutorials. short youtube videos.

The ‘spirit’ of the rules:
Don’t watch things that take up all of your attention and exclude doing anything else.