Saturday, October 24, 2015


When downloading files from websites, there are usually MD5 and SHA-1 checksums pasted on the site next to the download link. The reason for these checksums is so one can verify the integrity of the downloaded file. Once the file has been downloaded, you run a local hash of the file and verify that your checksum matches the one pasted on the site. Should they match, you know that the file hasn't been tampered with or you downloaded an incorrect file (though there is a minute chance of a hash collision).

Now this sounds like a really easy way to guarantee that you have downloaded the correct file from a website, but how many people actually run a local hash and check their checksums? I know I don't do it (even though I know I should), and I am willing to bet a lot of other people don't do this either. I looked online for solutions and there seems to be an abundance of utility tools to do this, even Windows has some built in commands.

However, I download things on multiple computers that run multiple OSes and none of these utilities seem to be able to run on all of my devices - and I like programs which run the same on everything. So, this is why I've decided to start my crypto-tool project - a cross-platform crypto tool. It is built in Java (which runs on most all devices) and will allow me to have the same process of checking checksums on every device I use.

The program currently comes with a command line interface which allows the user to generate checksums for input strings and files. It currently supports the following hash algorithms:
  • MD2
  • MD5
  • SHA-1
  • SHA-256
  • SHA-384
  • SHA-512
And to run the program, the user just needs to specify the hash algorithm to use and the file(s) and/or string(s) to generate the checksum for:

 S:\Workspaces\Github - Java\crypto-tool\latest-build>java -jar crypto-tool-cli-0.0.4-jar-with-dependencies.jar hash -ha MD5 -f input.txt -s "Command line string to hash." -s "And another string."  
 MD5 hash of [Command line string to hash.] is: 4354cb305345dc2582f1aefef124df47  
 MD5 hash of [And another string.] is: a3482fe6387ebb8cc20ea5aa713c3b8a  
 MD5 hash of file [input.txt] is: 632e60b155c9a24d3cf47f072532b440  

I feel like this is a good start to the project, however I have some plans to enhance this utility:

  • Add checksum verification
  • Add encryption/decryption of files/strings
  • Add a graphical user interface in addition to the command line interface

Saturday, September 19, 2015

The Joy of Clojure

So I recently started to look at the programming language Clojure and picked up a copy of The Joy of Clojure to help me learn. The book is extremely well laid out and easy to follow provided you have some programming knowledge - however knowledge of Clojure itself is not needed to work through the book.

Once I started to wrap my head around how everything is a function in Clojure, I really started to like some of the choices which were made when designing this LISP-style language. One thing that I find very helpful is the fact that we can chain any number of parameters into any function call. One example would be to add multiple numbers:
 // Java  
 1 + 2 + 3 + 4  
 // Clojure  
 (+ 1 2 3 4)  
In this example, '+' is the function we're calling and we're using '1', '2', '3', and '4' as the parameters to the function. Another advantage of the fact that everything is a function is there is no such thing as order of operations:
 // Java  
 1 * 2 + 3 / 4  
 // Clojure  
 (+ (* 1 2) (/ 3 4))  
Even in this trivial example, we can see the power of having each operation be its own function with its own parameters. In the Java code, we need to remember that there are implicit parenthesis around the '1 * 2' and '3 / 4' to make sure they get evaluated BEFORE the addition. In Clojure, we just use parenthesis to ensure each operation has the proper parameters we wanted.

So far I have only worked through the opening few chapters in the book but am already liking how the language works, looks, and interacts with Java. I have a GitHub repo setup where I am working through the examples and writing comments of things I feel are important. I look forward to working through more of this book in the near future.

Friday, July 17, 2015

Spring Boot

I recently did a presentation on Spring Boot - what it is and how to use it. And for my presentation, I made a simple REST server sample project[1]. The project consists of a few REST endpoints, a couple of data entity classes, and an in-memory H2 database.

Feel free to check out the documentation[2] if you're interested in setting up a very simple REST server with Spring Boot.

  • [1] -
  • [2] -

Thursday, May 28, 2015

Tv Show Tracker - On Heroku

I recently decided that I should start testing out my tv show tracker website out in "the real web" instead of just local development. So to help me along I chose to use Heroku, which is a PaaS - platform as a service. The advantage of using a PaaS is that they manage your actual box, upgrades, security, etc. for you. All you have to do is build and deploy your site according to their guidelines.

After going through their documentation of how to deploy a Scala application, I have successfully deployed tv-show-tracker on Heroku. However, this was not as straight-forward as the documentation made it out to be - especially when I'm using spray instead of just a quick HTTP server like their example uses. So I thought I'd go through some of the things I had to do to get my site up and running on their platform.

First, lucky for me, I already had my site fully utilizing sbt so I had most of the config and dependencies working as they want you to. However, I did have to add an sbt plugin:
 addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0")  
After that was added, I had to add the following to my build.sbt file:
 import NativePackagerKeys._  
Heroku utilizes this native packager and foreman to run Scala applications which is not something I was doing when I would run it locally.

Secondly, I had issues connecting to my PostgreSQL database. They went through some of the steps, however I felt some things were lacking. In the end, my database connection looks like:
 val dbUri = new URI(System.getenv("DATABASE_URL"))  
 val username = dbUri.getUserInfo.split(":")(0)  
 val password = dbUri.getUserInfo.split(":")(1)  
 val db = Database.forURL(s"jdbc:postgresql://${dbUri.getHost}:${dbUri.getPort}${dbUri.getPath}", driver = "org.postgresql.Driver", user = username, password = password)  
This connection setup uses slick, where their example just had a regular database connection.

Next, I had issues seeing the data in my database. I was lucky enough to come across this stack overflow question which helped me solve my problem - look at my data on my local install of pgadmin. Now, the accepted answer is what I used to get it working, however not all steps are properly documented in that answer.

To get all of the information needed to fill out the pgadmin server, you first need to run:
 heroku config  
If you have the database add-on installed, it will spit out a database url that we need. We just need to know how to decipher this long url and break it into the individual parts:
 DATABASE_URL: postgres://user:password@server:port/database  
Once we know how the url is broken down (example above), you just plug each part into pgadmin (like the SO answer says) and you can see your data on your local install of pgadmin.

Lastly, I had issues with my site properly binding to the host and port and being able to hit the url from my computer.

For the port, I tried putting in 8080 and 5000 (from the example) but neither seemed to work. I eventually found this documentation which explains that I need to get the port from a system variable - PORT.

I also had issues with the hostname I was supposed to connect to. I tried "localhost" and my site's url but neither of those worked. Then I came across this SO answer which showed I needed to use "". This allows the app to bind to the localhost and accept incoming traffic from my sites Heroku url.
So, in the end my connection looks like:
 val myPort = Properties.envOrElse("PORT", "8080").toInt // for Heroku compatibility  
 IO(Http) ? Http.Bind(service, interface = "", port = myPort)  
This allows my app to get the proper port from Heroku or use a default of 8080 if I'm running locally.

All in all, this turned out pretty well seeing that I was able to go from my local setup to running on Heroku in just a few hours. There were a few hiccups along the way, but it seems like other people have ran into the issues I experienced before and I was able to use the answers given to them.

Saturday, May 16, 2015

Tv Show Tracker - Basic Pages

As I noted on my previous post, I am currently working on a site to track the tv shows I watch. I have been working quite a bit, have a few main pages working, and thought I should write an update.


  • /
  • /index 
  • /shows
  • /searchshow
  • /show
    • Request parameters:
      • showName
  • /searchseason
  • /season
    • Request parameters:
      • showName
      • number
  • /notfound
This is the base url. It just re-directs to /index.

The main landing page of the site. On this page the user can choose to list all shows, search a specific show, or search a specific season of a show

Lists all shows recorded in the database. Each show is a link to the individual show's page which displays extra information about the show itself.

This page allows the user to search for a specific show. If a show is found, the user is directed the show's page. If the show is not found, a not found page is displayed.

Displays information about a specific show. The show name is passed in via a request parameter.

This page allows the user to search for a specific season in a show. If the season is found, the user is directed to the season's page. If the season is not found, a not found page is displayed.

Displays information about a specific season of a shot. The show name and number are passed in via request parameters.

Indicates to the user that the information requested was not found.

Next Steps

  • Episodes. These need to be added to individual seasons so that they can be tracked as watched.
  • Watched indicator. There needs to be an indicator on each episode, season, and show to let the user know if they've watched it already.
  • Currently watching. There needs to be a way for the user to indicate which show they are currently watching. This way they can easily check when they've watched a particular episode and see which episode is next to watch.
  • Data. The site needs to add the ability to insert episodes, season, and shows. Currently the few shows and seasons are hard-coded. The user needs to be able to add an episode, season, and show from the site. If it is already in the database, the site will indicate that to the user.

Monday, April 27, 2015

Tv Show Tracker

I watch a lot of tv shows and keeping track of which shows/seasons/episodes I have watched can be a daunting task if I don't stay on top of it. At any one time I am watching more than 1 show, but sometimes as much as 5 different shows in a given week. To help myself keep track of these things, I have been using a Google Doc Excel sheet which tracks my shows, seasons, and episodes I have been watching.

This is obviously not ideal because I have to do a lot of manual work and it's very archaic. So, for this reason, I have started tv-show-tracker. The idea behind this project is to make a more robust solution than all of my manual labor to keep my items in order. Right now this is in the very early stages, however the end goal could help me out quite a bit. I would eventually like to be able to:

  • Enter a show I would like to watch
  • Have it import all of the seasons and episodes
  • Keep track of which shows I'm currently watching and what episode I'm on
  • Allow multiple users to use this based on a login
Seeing that this site is an "easier" project (database layer, a couple of endpoints to hit, and a presentation layer) I decided to use a full Scala stack. Not only will this help me learn Scala better, but also get used to the open source projects Scala has because I'm choosing to use true Scala projects - not Java ones. The projects I've chosen to use on this site are:

As noted above, this is in very early stages of development, however that doesn't mean I am not making good progress. So far I have successfully wired up all of these projects and have the proof of concept working:
  • URL endpoints with request parameters - e.g."Shows"
  • Parse the request parameters and search the database
  • Return the "Show" and its "Seasons"
  • Render the results to the user
There's obviously a lot of work still to go, but now that I have a proof of concept working the rest should start to fall into place quicker - I just need to nail down the database schema and then work up the stack.

Friday, April 24, 2015

Scala Shell

I've recently been working on a new side project - scala-shell. As one might guess, this is a shell written in Scala. The idea behind this side project is to help further my Scala knowledge and dive into some more advanced topics such as:

  • Creating a GUI
  • Files and directories
  • Parsing user input
  • Processes
  • Packaging using sbt
I haven't had a lot of time to work on scala-shell, however I currently have the following items completed:
  • Creating a GUI
  • Packaging using sbt
  • Parsing user input
  • A few basic commands
    • exit
    • pwd
    • ls
  • Printing an error on invalid input

I realize that there's still a long ways to go to make this a "usable" shell, however I feel that it's coming along quite nicely and am happy with my current progress.