Skip to content

Instantly share code, notes, and snippets.

View candera's full-sized avatar

Craig Andera candera

View GitHub Profile
@candera
candera / gist:1279385
Created October 11, 2011 20:47
spec failures
1) Refine search can search for income ranges
Failure/Error: page.number_of_leads.should == initial_results
expected: 876
got: 68 (using ==)
# ./spec/acceptance/refine_search_acceptance_spec.rb:147:in `block (2 levels) in <top (required)>'
2) Refine search can search for home value
Failure/Error: page.number_of_leads.should == initial_results
expected: 876
@candera
candera / gist:1279418
Created October 11, 2011 20:58
More spec failures
1) Refine search can refine the search with sliders for zipcode radius and age
Failure/Error: results_for_18_to_22_year_olds.should < results_for_30_mile_radius
expected: < 12416
got: 12416
# ./spec/acceptance/refine_search_acceptance_spec.rb:54:in `block (3 levels) in <top (required)>'
# ./app/models/setting.rb:63:in `with_temp_setting'
# ./spec/acceptance/refine_search_acceptance_spec.rb:22:in `block (2 levels) in <top (required)>'
2) Refine search can search for income ranges
@candera
candera / gist:1284476
Created October 13, 2011 15:15
Solve a 3x3 grid puzzle: all rows must add to 15
(use 'clojure.math.combinatorics)
(def possible-answers (permutations (range 1 10)))
(defn sum-els [coll a b c]
(+ (nth coll a)
(nth coll b)
(nth coll c)))
(defn right-answer [coll]
@candera
candera / conj-outline.txt
Created October 21, 2011 15:26
Conj 2011 Talk Outline

-*- mode: org -*-

Outline

Two-sentence summary of the talk:

When we are asked to do performance optimization of a system, we need to ensure that we are taking a model-based, stochastic approach. An “optimization loop” is a process that will guide you through using your model to improve the performance of your system.

@candera
candera / hs_err_pid26414.log
Created November 18, 2011 16:03
sbt error 2011-11-18
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0xb4c1ef2c, pid=26414, tid=3077864304
#
# JRE version: 6.0_22-b22
# Java VM: OpenJDK Server VM (20.0-b11 mixed mode linux-x86 )
# Derivative: IcedTea6 1.10.4
# Distribution: Ubuntu 11.04, package 6b22-1.10.4-0ubuntu1~11.04.1
# Problematic frame:
@candera
candera / hacklog.textile
Created November 18, 2011 22:02
Hack Log

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

Date Score Activity Comment
2012-Jan-12 50 e23834f4 one: update deps script
2012-Jan-11 49 b751984d artifact: start conversion to ClojureScript
2012-Jan-10 48 55d91b66 artifact: upgrade to Clojure 1.3
2012-Jan-09 47 5a17473d artifact: convert to enlive
2012-Jan-08 46 7302bd9b artifact: change to new UI
2012-Jan-07 45 3fb262fe artifact: professor board development
2012-Jan-06 44
@candera
candera / stats.sh
Created January 22, 2012 13:35
Podcast stats script
#!/bin/bash
s3cmd sync s3://thinkrelevance-podcast-logs/ .
for i in "001" "002" "003"; do
echo "Episode $i: " `grep "ThinkRelevance-$i" * | wc -l`
done
@candera
candera / test.html
Created February 2, 2012 18:54
Test of geolocation HTML
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function watchLocation(successCallback, errorCallback) {
successCallback = successCallback || function(){};
errorCallback = errorCallback || function(){};
// Try HTML5-spec geolocation.
var geolocation = navigator.geolocation;
@candera
candera / statemachine.clj
Created June 3, 2012 03:34
RESTful state machines
(defn update [state event-name]
;; current state id | event-name | action
;;
(match [(:status state) event-name]
[:waiting :prepare] #(assoc state :foo f3)
[:ready :delete] #(assoc state :bar 19)
[_ _] (throw (ex-info "Boom: roasted" {:reason :invalid-transition :event-name event-name}))
))
@candera
candera / interop.clj
Created October 12, 2012 21:13
Trying to call ApplicationServices via JNA
(def eventcount (atom 0))
(def i khordr.ApplicationServicesLibrary/INSTANCE)
(def eventTap (.CGEventTapCreate
i
khordr.ApplicationServicesLibrary$CGEventTapLocation/kCGSessionEventTap
khordr.ApplicationServicesLibrary$CGEventTapPlacement/kCGHeadInsertEventTap
0
khordr.ApplicationServicesLibrary$CGEventType/kCGEventKeyDown
(reify khordr.ApplicationServicesLibrary$CGEventTapCallback
(onevent [this _ _ event _] (swap! eventcount inc) nil))