This link
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
Got this working under jruby 1.6.5 with trinidad as a webserver (webbrick doesn't seem to work) |
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
class TryIt | |
def []=(k,v) return "I'm a return value, if I'm not returned where do I go?" end | |
end | |
t = TryIt.new | |
puts(t['blah'] = "It would be slightly surprising if I were returned, right?") | |
#=> "It would be slightly surprising if I were returned, 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
/* | |
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* | |
* - Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. | |
* |
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 java.io._ | |
import java.nio._ | |
import java.nio.channels._ | |
/* | |
Initially I wanted to explore the nio api for file access and I ended up coming across a SO article | |
saying that nio isn't faster than just plain 'ol FileOutputStream. Curious about this I came up with | |
a benchmark suite and quickly found that is indeed true. After a couple of iterations I was able to | |
beat the default, but clearly it's not easy or obvious. |
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
// We're trying to express a future that can timeout but I don't | |
// want to use Await and block the current thread. I need to return | |
// a future that is either timed out or the value of the completed future | |
import concurrent.ExecutionContext.Implicits._ | |
import concurrent.Future | |
import concurrent._ | |
import concurrent.duration._ | |
import akka.pattern.after | |
import scala.util.{Try, Success, Failure} |
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
# from .git_functions | |
function git_helpers_clean_remote() { | |
remote=$1 | |
git ls-remote -h $remote | | |
git show-ref --heads --exclude-existing | | |
cut -f 2 | xargs git push --delete $remote | |
} | |
# from .gitconfig | |
[alias] |
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
/* | |
The general idea is to handle timeouts as a message instead of using callbacks or worse yet, blocking | |
the actor (as I do below) | |
*/ | |
val system = ActorSystem() | |
val myactor = system.actorOf(Props[MyActor]) | |
val someotheractor = system.actorOf(Props[SomeotherActor]) | |
class MyActor extends Actor with ActorLogging { |
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
class EchoActor extends Actor with ActorLogging { | |
val cluster = Cluster(context.system) | |
override def preStart() { cluster.subscribe(self, classOf[LeaderChanged]) } | |
override def postStop() { cluster.unsubscribe(self) } | |
def receive = { | |
case state: CurrentClusterState => log.info(s"State is $state") | |
case LeaderChanged(leader) => log.info(s"Leader is $leader") | |
case msg => { |
OlderNewer