Skip to content

Instantly share code, notes, and snippets.

// import de.sciss.file._
val fmtIn = new java.text.SimpleDateFormat("'B'HH'h'mm'm'ss's'ddMMMyyy'.wav'")
val fmtOut = new java.text.SimpleDateFormat("yyMMdd_HHmmss'.wav'")
def rename(dir: File, prefix: String): Unit = {
require(dir.isDirectory)
dir.children.foreach { fIn =>
try {
val date = fmtIn.parse(fIn.name)
/* We've run into a few common pitfalls when dealing with Futures in Scala, so I wrote these three helpful
* classes to give some baked-in functionality.
*
* I'd love to hear about other helpers you're using like these, or if you have improvement suggestions.
* [email protected] / @connerdelights
*/
import scala.concurrent.{ExecutionContext, CanAwait, Awaitable, Future, Promise}
import scala.concurrent.duration.Duration
// does this work out?
trait Txn[S <: Sys] {
def newVar[A](init: A): S#Vr[A]
}
trait Var[Tx, A] {
def get(implicit tx: Tx): A
def set(value: A)(implicit tx: Tx): Unit
}
// libraryDependencies += "net.databinder.dispatch" %% "dispatch-core" % "0.9.4"
import dispatch._
val q = url("http://www.freesound.org/api/sounds/search")
.addQueryParameter("q", "barking")
.addQueryParameter("api_key", "074c0b328aea46adb3ee76f6918f8fae")
val p = Http.configure(_ setFollowRedirects true)(q OK as.String)
p() // -> this needs to be fed into a JSON parser
@Sciss
Sciss / macro-ret.scala
Created July 2, 2012 17:00 — forked from retronym/macro-ret.scala
macro with computed return type
scala> def retImpl(c: Context)(b: c.Expr[Boolean]): c.Expr[Any] = {
| import c.universe._
| val Literal(Constant(bool: Boolean)) = b.tree
| if (bool) c.reify(0) else c.reify(false)
| }
retImpl: (c: scala.reflect.makro.Context)(b: c.Expr[Boolean])c.Expr[Any]
scala> def ret(b: Boolean) = macro retImpl
ret: (b: Boolean)Any
@Sciss
Sciss / sfnet2github.sh
Created April 19, 2012 21:47 — forked from stwalkerster/sfnet2github.sh
SourceForge.net svn repo to github git repo import script

Licence (MIT Licence)

Copyright (c) 2011 Simon Walker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@Sciss
Sciss / gist:1995057
Created March 7, 2012 18:44 — forked from ryo1kato/gist:1949096
SSH key fingerprint
require 'base64'
require 'digest/md5'
ssh_pubkey='AAAAB3NzaC1yc2EAAAABIwAAAQEAxCw2nrIcdQ+7/tKy+6fk1qmICpl2qa8jxCLoG3pnGniDUUIOtRdEfnpHNHYWfwBVYIdGD5bmcFnXEfoxRjR2VpLXNeY/8PlCG5lARuQqkc720ZfoxsEQo3m+ixV4ylbuQfo8eDrELrn+MWiPluh699lWyvgZ/6oTW1nf2gsKabG+nV8uLvr7Znr230S8o8vhgo6O3cmfLGcfApUnG9kce1YOlz1D9F2x6vzDSO2W3s5/UTBmDvLj3Cza+yzmLp2fzAw97FL6LLwS2cLaVUayc6pZKqN+4Gu9LDPXFl4jkD2xzPTp7cuKdrJFaDsIa0OHzG+yVlDvWi8FkdU9O+xiuw=='
fingerprint = Digest::MD5.hexdigest(Base64.decode64(ssh_pubkey)).scan(/../).join(':')
puts fingerprint