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 $ivy.`net.databinder.dispatch::dispatch-core:0.13.1` | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.Future | |
import dispatch._, Defaults._ | |
val svc = url("http://httpbin.org/ip") | |
def get() = Http.default(svc OK as.String) | |
def getAndTime(idx: Int) = { |
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
/** | |
* Like Future.sequence but but limits the parallelism to only process so many futures at once. | |
* Useful if you have lots of future operations but dont want to overload something with too many at once. | |
*/ | |
def gatherUnordered[A, B](parallelism: Int, | |
xs: Seq[A])(fn: A => Future[B])(implicit ex: ExecutionContext): Future[Seq[B]] = { | |
def go(todo: Seq[A], inprogress: Seq[Future[B]], acc: Seq[B]): Future[Seq[B]] = { | |
if (inprogress.size < parallelism && todo.nonEmpty) { | |
val numToAdd = parallelism - inprogress.size | |
val (toStart, stillTodo) = todo.splitAt(numToAdd) |
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
{sealed trait Tree | |
case object EmptyTree extends Tree | |
case class Leaf(label: String, popularity: Double) extends Tree | |
case class Node(popularity: Double, left: Tree, right: Tree) extends Tree | |
implicit val treeOrdering = new Ordering[Tree] { | |
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
package com.mgl.digital.dataservices.utils | |
import com.datastax.driver.core._ | |
class PreparedStatementBuilder(session: Session) { | |
private var statementCache: Map[String, PreparedStatement] = Map() | |
def insertInto(table: String): Insert = |
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 play.api.libs.ws._ | |
def get(url: String): Future[WSResponse] = { | |
val split = url.split("/") | |
val hostname = split(0) | |
val path = "/"+split(1) | |
def getHosts = Try(InetAddress.getAllByName(hostname).map(_.getHostAddress).toSeq) | |
def executeRecovering(triedHosts: Seq[String] = Nil): Future[WSResponse] = { |
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
#!/bin/bash | |
ps aux | grep java | |
for PID in `pidof java` | |
do | |
echo | |
echo "jmap -heap $PID" | |
jmap -heap $PID | |
done |
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
#!/bin/bash | |
# | |
# Notify of Homebrew updates via Notification Center on Mac OS X | |
# | |
# Author: Chris Streeter http://www.chrisstreeter.com | |
# Requires: terminal-notifier. Install with: | |
# brew install terminal-notifier | |
TERM_APP='/Applications/Terminal.app' | |
BREW_EXEC='/usr/local/bin/brew' |
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
package com.stephenn.roguelike.util | |
import javax.imageio.ImageIO | |
import java.io.File | |
import java.awt.image.BufferedImage | |
object SpriteSplitter { | |
def main(args: Array[String]) { | |
val sprites = split(loadImage("assets/nethack-3.4.3-32x32.png"), 1280/32, 960/32) |
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
describe('underscore', function(){ | |
it('shouldnt execute immediately', function(){ | |
var hasHappened = false; | |
var fn = underscore.debounce(function(){ | |
hasHappened = true; | |
}, 100); | |
expect(hasHappened).toBe(false); |
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
#!/bin/bash | |
MSG=`sudo apt-get --yes dist-upgrade` | |
MSG_HEADING='sudo apt-get --yes dist-upgrade' | |
GmailSend.py -u [email protected] -p bla -t [email protected] -s "server update" -b "$MSG_HEADING \n\n $MSG" |