Skip to content

Instantly share code, notes, and snippets.

@edeustace
edeustace / index.js
Created July 8, 2014 12:48
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
@edeustace
edeustace / index.js
Created July 8, 2014 12:48
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
@edeustace
edeustace / defmulti_key_as_dispatch_value.clj
Created June 15, 2014 13:34
Use the first key in a map as the dispatch value for defmulti
; Example of using the first key in a map as the dispatch value for defmulti
(defmulti foo (fn [x] (first (map key x))) )
(defmethod foo :a [x] ["a -> " x])
(defmethod foo :b [x] ["b -> " x])
(defmethod foo :default [x] ["default -> " x])
(println (foo {:a "a"}))
(println (foo {:b "b"}))
@edeustace
edeustace / TopologicalSorter.scala
Created June 5, 2014 10:46
Another topological sorter in scala
package com.ahum
import scala.annotation.tailrec
object TopologicalSorter {
def sort[T](nodes: (T, Seq[T])*): Seq[(T, Seq[T])] = {
type DepNode = (T, Seq[T])
@edeustace
edeustace / gist:8843304
Created February 6, 2014 12:33
start play app in console.
import play.api._
new StaticApplication(new java.io.File("."))
@edeustace
edeustace / rm.sh
Last active August 29, 2015 13:56
remove folders older than 10 days
find . -maxdepth 1 -ctime +30 -type d | xargs rm -f
2014-01-20 16:21:30,193 - [ERROR] - from akka.actor.ActorSystemImpl in play-akka.actor.default-dispatcher-2
Uncaught error from thread [play-akka.actor.default-dispatcher-5] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled
java.lang.ExceptionInInitializerError: null
at views.html.layouts.main$.apply(main.template.scala:104) ~[prizeo.prizeo-2.0-SNAPSHOT.jar:2.0-SNAPSHOT]
at views.html.Application.index$.apply(index.template.scala:48) ~[prizeo.prizeo-2.0-SNAPSHOT.jar:2.0-SNAPSHOT]
at views.html.Application.index$.render(index.template.scala:198) ~[prizeo.prizeo-2.0-SNAPSHOT.jar:2.0-SNAPSHOT]
at views.html.Application.index.render(index.template.scala) ~[prizeo.prizeo-2.0-SNAPSHOT.jar:2.0-SNAPSHOT]
at controllers.Application.renderIndex(Application.java:130) ~[prizeo.prizeo-2.0-SNAPSHOT.jar:2.0-SNAPSHOT]
at controllers.Application.indexCached(Application.java:113) ~[prizeo.prizeo-2.0-SNAPSHOT.jar:2.0-SNAPSHOT]
at controllers.Application.index(Application.java:94) ~[prizeo.prizeo-2.0-SNAPSHOT.jar
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
angular.module('initial-data', []).factory('Stuff', [function(){
return {
stuff: {}
}
}]);
angular.module('my-app.controllers', ['initial-data']).controller('MyController', ['$log', 'Stuff', function($log, Stuff){
$log.info(Stuff.stuff);
}]);
@edeustace
edeustace / test.scala
Created January 10, 2014 17:23
Java -> scala conversion of nested types
package org.corespring
import org.specs2.mutable.Specification
import scala.collection._
class JavaConversionsSpec extends Specification {
import scala.collection.JavaConversions._
def contributors : java.util.Map[String, java.util.Collection[String]] = new java.util.HashMap[String,java.util.Collection[String]]()