This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Enum { //DIY enum type | |
| import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia | |
| type EnumVal <: Value //This is a type that needs to be found in the implementing class | |
| private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values | |
| //Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal | |
| private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS} | |
| val oldVec = get |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var BASE64_MARKER = ';base64,'; | |
| function convertDataURIToBinary(dataURI) { | |
| var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length; | |
| var base64 = dataURI.substring(base64Index); | |
| var raw = window.atob(base64); | |
| var rawLength = raw.length; | |
| var array = new Uint8Array(new ArrayBuffer(rawLength)); | |
| for(i = 0; i < rawLength; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays | |
| abstract class Sorter { | |
| def sorted(a: Array[Int]): Array[Int] | |
| } | |
| object SimpleSorter extends Sorter { | |
| def sorted(a: Array[Int]) = { | |
| Arrays.sort(a) | |
| a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf8 -*- | |
| from flask import Flask, redirect, url_for | |
| from markdown import markdown | |
| import os | |
| import re | |
| # create the app | |
| # TODO: load config/template from files, with fallbacks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object XmlHelpers { | |
| val docBuilder = | |
| javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder() | |
| } | |
| class NodeExtras(n: Node) { | |
| def toJdkNode(doc: org.w3c.dom.Document): org.w3c.dom.Node = | |
| n match { | |
| case Elem(prefix, label, attributes, scope, children @ _*) => | |
| // XXX: ns |
NewerOlder