Skip to content

Instantly share code, notes, and snippets.

View c-spencer's full-sized avatar

Chris Spencer c-spencer

View GitHub Profile
@c-spencer
c-spencer / Cake.coffee
Created March 1, 2012 14:47
watch script for cake compile with selected files
fs = require 'fs'
coffee = require 'coffee-script'
uglify = require 'uglify-js'
option '-w', '--watch', 'watch files for changes'
task 'build:js', 'Build the javascript files', (options) ->
compileCoffeeFiles = (files, callback) ->
container = {}
@c-spencer
c-spencer / request.coffee
Created March 9, 2012 19:30
jQuery ajax wrapper
request =
base: (type, params, callback) ->
$.ajax _.extend({
dataType: 'json'
type: type
success: (data) -> callback null, data
error: (data) -> callback data or JSON.stringify(arguments)
}, params)
get: (params, callback) -> @base 'GET', params, callback
post: (params, callback) -> @base 'POST', params, callback
window.undo_tracking_labels = {}
class Sysdea.Undoer
constructor: (@label) ->
if @label? and !undo_tracking_labels[@label]
undo_tracking_labels[@label] = 0
@actions = []
push: (action) ->
if @label and @actions.length == 0
undo_tracking_labels[@label]++
@actions.push action
@c-spencer
c-spencer / JSMatrix.coffee
Created May 1, 2012 08:58
JS Implementation of SVGMatrix
# JSMatrix is API Compatible with SVGMatrix
PI_DEG = Math.PI/180
class JSMatrix
constructor: (@a, @b, @c, @d, @e, @f) ->
# Multiplication of direct parameters
_mult: (a, b, c, d, e, f) ->
new JSMatrix(
**** DEOPT: JSMatrix._rotate at bailout #12, address 0x0, frame size 24
[deoptimizing: begin 0x222a3c2bad1 JSMatrix._rotate @12]
translating JSMatrix._rotate => node=64, height=16
0x7fff5fbfee28: [top + 56] <- 0x222a3c49311 ; rax 0x222a3c49311 <a JSMatrix>
0x7fff5fbfee20: [top + 48] <- 0x79eadf046a1 ; [esp + 56] 0x79eadf046a1 <Number: 0.05483113556160755>
0x7fff5fbfee18: [top + 40] <- 0x3476cf386e2a ; caller's pc
0x7fff5fbfee10: [top + 32] <- 0x7fff5fbfee40 ; caller's fp
0x7fff5fbfee08: [top + 24] <- 0x222a3c492d9; context
0x7fff5fbfee00: [top + 16] <- 0x222a3c2bad1; function
0x7fff5fbfedf8: [top + 8] <- 5.480367e-02 ; xmm2
// Source Table
{
1: 11,
2: 13,
3: 99,
4: 5,
5: 7,
10: 6,
15: 16,
67: 123,
gcc `pkg-config pangocairo --cflags --libs` pangocairotest.c -o pangocairotest
...
(gdb) run
Starting program: /Users/chris/Dev/node-canvas/pangocairotest
...
Program received signal EXC_BAD_ACCESS, Could not access memory.
(defmethod euler-problem 11 [_]
(let [number-grid
[ 8 2 22 97 38 15 0 40 0 75 4 5 7 78 52 12 50 77 91 8
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 4 56 62 0
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 3 49 13 36 65
52 70 95 23 4 60 11 42 69 24 68 56 1 32 56 71 37 2 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 3 45 2 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 2 62 12 20 95 63 94 39 63 8 40 91 66 49 94 21
(ns euler.problem-eleven
(:refer-clojure :exclude [==])
(use clojure.core.logic))
(def grid [ 8 2 22 97 38 15 0 40 0 75 4 5 7 78 52 12 50 77 91 8
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 4 56 62 0
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 3 49 13 36 65
52 70 95 23 4 60 11 42 69 24 68 56 1 32 56 71 37 2 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 3 45 2 44 75 33 53 78 36 84 20 35 17 12 50
@c-spencer
c-spencer / preprocess-schema.clj
Last active December 10, 2015 05:28 — forked from anonymous/preprocess-schema.clj
Simple template expansion meta-definitions for Datomic
(defn extract-key [m k]
(when-let [value (k m)] [(dissoc m k) value]))
(defn expand-entry-id [entry]
(if (keyword? (:db/id entry))
(update-in entry [:db/id] d/tempid)
entry))
(defn expand-schema-entry [entry templates]
(if (and (map? entry) (:meta/templates entry))