Skip to content

Instantly share code, notes, and snippets.

@edeustace
edeustace / ItemTransformer.scala
Created January 10, 2014 15:24
A simple json transformer based on play-json transforms
package org.corespring.platform.json.transformers
object ItemTransformer extends JsonTransformer(
"taskInfo.title" -> "title",
"taskInfo.subjects.primary" -> "primarySubject",
"taskInfo.subjects.related" -> "relatedSubject",
"taskInfo.itemType" -> "itemType",
"taskInfo.gradeLevel" -> "gradeLevel",
"otherAlignments.keySkills" -> "keySkills",
@edeustace
edeustace / remove_namespaces.scala
Created December 26, 2013 14:20
scala remove namespaces
val xml = <item name="ed" test="true"
xmlns="http://www.somenamespace.com"
xmlns:xsi="http://www.somenamespace.com/XMLSchema-instance">
<blah>
<node>value</node>
</blah>
</item>
import scala.xml._
@edeustace
edeustace / kill_play.bash
Created December 20, 2013 11:17
kill all play processes
ps aux | grep play | grep -v -E 'grep play' | awk '{ print $2 }' | xargs kill -9
@edeustace
edeustace / Function.bind.polyfill.js
Created December 4, 2013 12:29
A polyfill for function.bind for IE8
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
{
"name": "drag-and-drop",
"organization": "corespring",
"corespring-container-version": "0.0.1",
"version": "0.0.1",
"dependencies": {
"client": {
"angular-dragdrop": {
"bower_target": "latest",
"file" : "src/angular-dragdrop.js"
"session": {
"_id": {
"$oid": "526e5f4d30045f27468d9ad1"
},
"components": {
"2": {
"answers": {
"choice": "1",
"landingPlace": "1"
}
@edeustace
edeustace / static_server.js
Last active December 21, 2015 08:38 — forked from ryanflorence/static_server.js
Server large files with a stream.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
#!/usr/bin/env ruby
# Deletes buckets that match a given regex.
# Params:
# s3-key
# s3-secret
# regex
#
# Dependencies: aws-sdk ~> '1.11.3'
object partialFunctions {
case class Request(mode: String, item: Option[String] = None, session: Option[String] = None)
def someItem(m:String) : PartialFunction[Request, String] = {
case Request(_, Some(item), None) => m + "its some item: " + item
} //> someItem: (m: String)PartialFunction[partialFunctions.Request,String]
def someSession : PartialFunction[Request, String] = {
case Request(_, None, Some(session)) => "its some session: " + session
@edeustace
edeustace / less_converter.rb
Created August 16, 2012 18:12 — forked from jasongraham/less_converter.rb
A Jekyll plugin to convert a .less file to .css
module Jekyll
# Compiled LESS CSS into CSS. You must specify an empty YAML front matter
# at the beginning of the file.
# .less -> .css
class LessConverter < Converter
safe true
priority :low
pygments_prefix "\n"
pygments_suffix "\n"