Guide « Matt’s Blog

Matt’s Blog Just another weblog

12Jun/16Off

Printable Ethereum Yellow Paper

I've generated a printable version of the Ethereum Yellow Paper. It features a white background. The original can be found here.

Filed under: Ethereum No Comments
29Mar/14Off

sbt-dependency-graph in project/build.scala

In an earlier post, I mentioned how to include sbt-dependency-graph in your Scala project. I found the documentation a bit confusing on how to add this capability when using project/build.scala. Here is a reference for how this is done: see this link.

Filed under: scala No Comments
8Dec/13Off

My Scala Notes

I've been working with Scala recently and just wanted to make this post about some tips that I'd like to remember.

Annotating Test Classes
When writing Scala tests, it's convenient to annotate them such that Eclipse is able to recognize how to execute the test from the "Run" menu. We can enable this by annotating the test class with a @RunWith statement. The IDE unfortunately doesn't seem to recognize that @RunWith and JUnitRunner are required imports when subsequently performing an "organize imports" operation. As a result, it's best to specify the fully qualified class name as shown on line two.

@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class MyScalaTest extends FunSuite {
 
...
 
}

Testing Exceptions in scalatest
Below is an example of verifying that code under test throws an exception.

test("throws an exception") {
    intercept[Exception] {
        throw new Exception("hi")
    }
}

Working with Eclipse on Windows and Linux Console
I like to use eclipse, emacs, and the console during coding sessions. On my Windows machine I run Eclipse and access the source files over a network drive. This setup requires that my development life cycle be cross-platform compatible. To enable this workflow, it's convenient for sbt to generate the eclipse project file with all the required dependencies. This is done by adding,

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")

to the plugins.sbt file and running sbt eclipse. Note, the version of the plugin will vary depending on your Scala version. It's best to visit the project page and try the latest version. Now, it's also helpful to add the following configuration to your build.sbt file,

// puts library dependencies in the lib_managed directory
retrieveManaged := true

This will download all dependencies to the project directory and the eclipse .project file will be able to reference them locally (as opposed to the ivy repo).

mvn dependency:tree in sbt?
There will come a time when you'll need to fight through dependency issues. One tool I frequently use is mvn dependency:tree. The equivalent of this command in sbt is enabled by including the following plugin,

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

and the following to build.sbt,

net.virtualvoid.sbt.graph.Plugin.graphSettings

The dependency tree can be generated by typing,

sbt dependency-tree

See this page for some more info.

Tagged as: No Comments
8Oct/12Off

Perfect Ubuntu 12.04 Server sources.list

It turns out that my Ubuntu 12.04 Server edition installation had an incomplete sources.list file. It only referenced packages from the CD-ROM. At this site, I found an complete sources.list file that contains the various package types that are supported by Precise Pangolin,

# deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/main/binary-i386/
# deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/restricted/binary-i386/
# deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ precise main restricted
 
#deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/main/binary-i386/
#deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ dists/precise/restricted/binary-i386/
#deb cdrom:[Ubuntu-Server 12.04 LTS _Precise Pangolin_ - Release amd64 (20120424.1)]/ precise main restricted
 
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://de.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ precise main restricted
 
## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates main restricted
 
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://de.archive.ubuntu.com/ubuntu/ precise universe
deb http://de.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates universe
 
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://de.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-updates multiverse
 
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://de.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
 
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
 
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner
 
## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
# deb http://extras.ubuntu.com/ubuntu precise main
# deb-src http://extras.ubuntu.com/ubuntu precise main

Filed under: Guide No Comments