Skip to content

Instantly share code, notes, and snippets.

View candera's full-sized avatar

Craig Andera candera

View GitHub Profile
@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 / hundred-day-hacking.md
Created November 16, 2011 14:57
100 Days of Hacking

One Hundred Days of Hacking

Objective

Get better at some aspects of creating software by doing them more regularly.

Inspiration

A friend of mine, as a way to "level-up" her young daughter at violin, set a goal that the child would practice every single day for 100 days, without a break. This seems like such a good idea that I decided to steal it.

@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 / Interception-xy.cs
Created March 2, 2012 15:38
Shows how to interoperate with interception.dll from C#.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace kchordr
{
public static class ScanCode
{
@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))