This file contains 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
def getOrCreate[A](m: JMap[Any, Any], key: Any, create: A): A = { | |
if (m.containsKey(key)) m.get(key).asInstanceOf[A] | |
else { | |
m.put(key, create) | |
create | |
} | |
} | |
def storeAtPath(m: JMap[Any, Any], path: Seq[String], values: Seq[Any]) { | |
path.toList match { |
This file contains 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 scalaz._, Scalaz._ | |
val expected = "foo".node("bar".leaf, "baz".node("qux".leaf)) | |
val loc = expected.loc | |
loc.firstChild | |
loc.firstChild.right |
This file contains 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
/*** | |
scalaVersion := "2.11.6" | |
libraryDependencies ++= Seq("org.scalaz" %% "scalaz-core" % "7.1.0") | |
*/ | |
// Code listing for http://devth.com/2015/thrush-cond-is-not-a-monad/ | |
object Main extends App { | |
import scalaz._, Scalaz._ |
This file contains 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
// Running this code: | |
// scala -Dscala.color -feature -classpath ~/.m2/raptor2/org/scalaz/scalaz-core_2.11/7.1.2/scalaz-core_2.11-7.1.2.jar typeclass.scala | |
import scalaz._, Scalaz._ | |
import scala.language.implicitConversions | |
import scala.language.postfixOps | |
object Typeclass { | |
class C(val name: String) |
This file contains 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 context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain); | |
var loader:BulkLoader = new BulkLoader("loadmystuffplskthxbye"); | |
loader.add( someS3Url, { context: context } ); // WIN |
This file contains 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
$gateway->setCharsetHandler("mbstring","UTF-8","UTF-8"); |
This file contains 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
/** Implicit class to add idiomatic Scala methods to the | |
* InterProcessReadWriteLock read/write lock */ | |
implicit class RichInterProcessReadWriteLock(lock: InterProcessReadWriteLock) { | |
private def acquireAndRelease[A](mutex: InterProcessMutex, fn: => A): Either[Throwable, A] = | |
Try { | |
// blocking operation | |
mutex.acquire() | |
logger.info(s"Lock obtained: $mutex") | |
Right(fn) | |
}.recover { case e => |
This file contains 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
require 'rubygems' | |
require 'sinatra' | |
require 'tempfile' | |
get '/audio' do | |
text = params['text'] | |
temp_file = Tempfile.new 'mp3' | |
# generate mp3 to temp file |
This file contains 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
require 'rubygems' | |
require 'sinatra' | |
require 'app.rb' | |
run Sinatra::Application |
This file contains 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
# Simple SVN apache config by devth.com | |
# Place in /etc/apache2/sites on OS X Server | |
# Adding or removing permissions for a user is as simple as adding or | |
# removing them from "svn_users" group in Workgroup Manager | |
<Location /svn> | |
DAV svn | |
SVNParentPath /Library/Subversion/Repositories | |
<Limit GET HEAD OPTIONS CONNECT POST PROPFIND PUT DELETE PROPATCH MKCOL COPY MOVE LOCK UNLOCK> | |
Require group svn_users |