ScalaHub

Scala Client for MaxMind Geo-IP

You are here

scala-maxmind-geoip is a Scala wrapper for the MaxMind Java Geo-IP library.

Besides the friendly Scala syntax, you get configurable LRU caching out of the box. And if you are using SBT there’s built-in automagical update to the latest MaxMind GeoLiteCity.dat and Java client library version.

Quick usage example:

1
2
3
4
5
6
7
val geoDbFile = new java.io.File(getClass.getResource("/maxmind/GeoLiteCity.dat").toURI())
val ipGeo = new IpGeo(dbFile = geoDbFile, lruCache = 100, memCache = false)

for (loc <- ipGeo.getLocation("204.232.175.78")) {
  println(loc.countryCode)   // US
  println(loc.countryName)   // United States
}

scala-maxmind-geoip is written by Alexander Dean from SnowPlow Analytics.

Scalaj-time - a Scala Wrapper for Joda Time

Alarm clock

scalaj-time is a scala convenience wrapper around the Joda time libraries.

It provides more pleasant syntax operators: addition, subtraction and comparison, and also, fields are now available in the Scala convention, without the “get” prefix.

Here’s some example usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
import org.scala_tools.time.Imports._

DateTime.now // returns org.joda.time.DateTime

DateTime.now + 2.months // two months from now

DateTime.nextMonth < DateTime.now + 2.months // true

DateTime.now to DateTime.tomorrow // returns an org.joda.time.Interval

(1.hours + 25.minutes + 15.seconds).millis // returns org.joda.time.Duration

9.months + 3.days // returns org.joda.time.Period

scalaj-time is created by Jorge Ortiz from scalaj.

Scala-ssh - Remote Shell Access via SSH

scala-ssh provides remote shell access via SSH for your Scala applications.

Besides remote execution of shell commands, you get access to stdin, stdout and stderr, private key authentication and host configuration via code or from resource file.

Here’s a simple example of how to use the API:

1
2
3
4
5
SSH("repl.scalahub.com") { client =>
  client.exec("scala --version").right.map { res =>
    println("And the scala version is... [drums]... \n" + res.stdOutAsString())
  }
}

scala-ssh is written by Mathias from Spray.io.

Scalatron - Learn Scala With Friends

Bots

Scalatron is a programming game in which bots, written in Scala, compete against each other in a virtual arena.

Sounds like fun! How would that work?

…get together with some friends, set up a server, attach a projector, order some pizza and start hacking! A Scalatron hack-a-thon may be the quickest and most entertaining way to get a group of programmers into Scala.

The rules of the game are clearly explained in the docs, so you can figure out how to code the Master bot with his Mini-bots and their interactions with Fluppet, Snorg, Zugar, and Toxifera.

You can also checkout these samples to get a better feeling on how a bot would get coded.

A Scalatron evening sure sounds like fun, so checkout if there’s one happening in your area, or maybe even host one?

Travis CI - Continuous Integration for Your Open Source Scala Project

Travis CI logo

Do you have an open source project written in Scala? (Well done!) Travis CI offers a hosted continuous integration for the open source community, and they support Scala projects.

Setting up continuous integration with GitHub is super-easy. Simply add a .travis.yml file to your project, telling Travis that it’s written in Scala, and optionally defining the Scala version to use. That’s it! Travis is pretty smart and will figure out by itself if you chose SBT or Maven :)

1
2
3
4
language: scala
scala:
   - 2.8.2
   - 2.9.2

Then, simply log in to travis-ci.org with your GitHub account and enable continuous integration for your project from the Travis profile page.

Once authorized to your GitHub account, Travis will add a commit hook that builds your project each time you commit code. A nice touch is adding the Travis CI build status to your README file by using the build status images, like the one below.

Travis build status

Goose - Article Extractor

Goose is an article extractor written in Scala. Point it to an url and it will extract the plain text of the article, along with the main image, embedded movies and meta information that it finds (tags, publish date). Awesome stuff, right?

Here’s an example of how to use it (It’s this simple!):

1
2
3
4
5
6
val goose = new Goose(new Configuration)
val article = goose.extractContent(url)

println(article.cleanedArticleText)
println(article.title)
println(article.tags)

Checkout the live demo page where you can play with parsing an url of your choice.

Goose is created by Jim Plush from Gravity.com Maven/SBT dependency is available in MavenCentral for quick use in your project.