Skip to content

Instantly share code, notes, and snippets.

@flyingmachine
flyingmachine / arenas.clj
Created June 15, 2012 02:05
routing for noir
(ns routey.views.arenas
(:require [routey.views.common :as common]
[noir.content.pages :as pages])
(:use noir.core
hiccup.core
hiccup.page-helpers
routey.views.routes))
@flyingmachine
flyingmachine / gist:3390402
Created August 18, 2012 23:52
Installing Ruby after upgrading from Snow Leopard to Mountain Lion

After you've done the steps below it will be as if you did an upgrade rather than a clean install. Your home directory will be there, as will your applications.

  1. Back up system to an external HD (I used Super Duper)
  2. Install mountain lion clean: http://eggfreckles.net/notes/installing-mountain-lion-clean/
  3. At the end of the install, transfer files back from my external HD
  4. Remove everything in /usr/local with sudo rm -Rf /usr/local/*
  5. Follow these instructions: http://jfire.io/blog/2012/03/02/xcode-4-dot-3-homebrew-and-ruby/
  6. I had trouble with ree/1.8.7 so I had to follow these instructions: http://stackoverflow.com/questions/11664835/mountain-lion-rvm-install-1-8-7-x11-error/11666019#11666019
(if (or (equal system-name "DH.local")
(equal system-name "DH.mba2"))
(setq initial-frame-alist '((top . 0) (left . 0)
(width . 177) (height . 47)))
(setq initial-frame-alist '((top . 0) (left . 0)
(width . 187) (height . 77))))
@flyingmachine
flyingmachine / robot.js
Created December 5, 2012 13:30
Jabroney
function Robot(robot) {}
// well, we need to do something...
// whenever our robot is idle, this method gets called.
Robot.prototype.onIdle = function(ev) {
var robot;
robot = ev.robot;
robot.ahead(20);
robot.rotateCannon(45);
var r = robot.position.x % 2
@flyingmachine
flyingmachine / example-usage-after.clj
Created December 16, 2012 21:33
so far, only used in a web app when I want to update a subset of available fields. eg when changing a password
(defentity user
(has-many post)
(has-many comment)
;; todo move user param transform function here
(prepare
(fn [attributes]
(-> (transform-when-key-exists
attributes
{:password #(creds/hash-bcrypt %)
@flyingmachine
flyingmachine / ns
Created January 21, 2013 00:36
A few YASnippet snippets for clojure's nrepl-mode
#name: ns
# --
(in-ns '${1:name})
#!/usr/bin/env ruby
# Simple, not robust script for pairing sql fields to values
# example usage: pbpaste | ./sql_pairs.rb
sql = STDIN.read
# sql = %{INSERT INTO "users" ("username", "email") VALUES ('joe schmoe', 'joe@schmoe.com')}
begin
@flyingmachine
flyingmachine / dissipation.clj
Created February 6, 2013 15:42
dissipation in two languages
(defn dissipation
[decrements]
(let [size (count decrements)]
(loop [acc []
sum size
acc-position 0
decrements decrements]
(cond
(= size (count acc))
acc
@flyingmachine
flyingmachine / gist:5735498
Last active December 18, 2015 05:49
Woohoo! Wrote my first emacs key binding!
(defun nrepl-start-http-server ()
(interactive)
(nrepl-load-current-buffer)
(nrepl-set-ns (nrepl-current-ns))
(nrepl-interactive-eval "(def server (-main)) (println server)"))
(eval-after-load 'nrepl
'(define-key clojure-mode-map (kbd "C-c C-v") 'nrepl-server))