Skip to content

Instantly share code, notes, and snippets.

<a href="#" onclick="play('flute');">Flute</a>
<a href="#" onclick="play('piano');">Piano</a>
<script src="https://rawgithub.com/mudcube/MIDI.js/dev/build/MIDI.js" type="text/javascript"></script>
<script src="https://rawgithub.com/mudcube/MIDI.js/dev/inc/jasmid/stream.js" type="text/javascript" ></script>
<script src="https://rawgithub.com/mudcube/MIDI.js/dev/inc/jasmid/midifile.js" type="text/javascript"></script>
<script src="https://rawgithub.com/mudcube/MIDI.js/dev/inc/jasmid/replayer.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () {
case class HistogramEntry[T](value: T, count: Int)
implicit class RichSeq[T](ts: Seq[T]) {
def histogram[U](f: T => U): Seq[HistogramEntry[U]] =
ts.groupBy(f)
.map { case (u, us) => HistogramEntry(u, us.size) }
.toSeq
.sortBy(_.count)
}
//earlier:
//var clickEventType=((document.ontouchstart!==null)?'click':'touchstart');
$('.instrument').live(clickEventType, function(ev) {
ev.preventDefault();
instrumentSelected($(this).data('instrumentname'), $(this).data('instrumentclef'));
});
function instrumentSelected(instrumentName, clef, onSuccess) {
mixerValues = { instrument:instrumentName, clef:clef };
hoverValues = {};
$.ajax({
type: 'GET',
cache: false,
url: '/app/' + instrumentName + '/levels',
dataType: 'json',
success: function(data) {
currInstrumentAllLevelData = data;
//Goals:
// 1. Brief but non-crazy declarations of enums
// 2. easy binding to and from Strings
// 3. Namespacing, so that you don't have enum members floating at the top level
// 4. allow for additional state within each member
// 5. nice toString
//put the type outside of of the object, allowing you to import CardSuit._
sealed abstract class CardSuit(val name: String) extends EnumMember
//put it in an object to namespace it - ala CardSuit.Hearts
statically typed companion objects:
https://gist.github.com/4692921
http://blogs.msdn.com/b/dsyme/archive/2013/01/30/twelve-type-providers-in-pictures.aspx
import java.text.NumberFormat
import scala.util.Try
object Conversions extends App {
object StandardConversions {
implicit val strToInt = (s: String) => s.toInt
}
object I18NConversions {
implicit val strToInt = (s: String) => NumberFormat.getIntegerInstance().parse(s).intValue()
i assume this is startup?
=INFO REPORT==== 15-Dec-2012::04:27:02 ===
Limiting to approx 16284 file handles (14653 sockets)
=INFO REPORT==== 15-Dec-2012::04:27:02 ===
Memory limit set to 29049MB of 72622MB total.
=INFO REPORT==== 15-Dec-2012::04:27:02 ===
Disk free limit set to 1000MB
@adamrabung
adamrabung / VersionedAssets.scala
Created November 28, 2012 18:34
Implementation of James Roper's Play 2 versioned assets w/o scala 2.10 dependency
package controllers
import play.api.mvc.PathBindable
import play.api.Play
import java.net.JarURLConnection
import Play.current
import java.io.File
import com.google.common.cache.CacheBuilder
import com.google.common.cache.CacheLoader
import java.net.URL
scala> case class Address(street:String)
defined class Address
scala> case class Person(name:String, address:Address)
defined class Person
scala> val p1 = new Person("rick", Address("the street where rick lives street"))
p1: Person = Person(rick,Address(street street))
scala> val Person(_, Address(ricksStreet)) = p1