Get a REPL On Your Current Java Project

I like to test things out interactively, so I love working with languages that provide a REPL. I’m currently working on a Java project, but Java doesn’t have a REPL. Several languages built on top of the JVM do have them, and these langauges can access the Java classes on their classpaths. Groovy, Scala and Clojure are just three such examples, that I happen to work with.

I got this tip from this response on a Stackoverflow.com post. His tip was for Scala, which looks like this:

scala -cp target/classes:`/usr/bin/mvn \
dependency:build-classpath \
| grep "^[^\[]"`

The bit between the backticks runs a Maven goal that outputs the jars that your project depends on, and then extracts just the list of fully-qualified jar files to append to the Scala classpath. If you want to use Groovy for your REPL, it would look like this:

groovysh -cp target/classes:`/usr/bin/mvn \
dependency:build-classpath \
| grep "^[^\[]"`

Similarly, if you’d rather use Clojure, do this:

java -cp target/classes:`/usr/bin/mvn \
dependency:build-classpath \
| grep "^[^\[]"`:/path/to/clojure.jar clojure.main

(Note: In the examples above, I’ve split the code across multiple lines for clarity. In reality, it can be all on one line.)

That Insipid “Ancient Aliens” Show

O, how I hate that stupid “Ancient Aliens” show on the “History” channel. Tonight, as I was scrolling through the channel guide, I happened to see the info for an episode that was about to go off. The title of this episode was, “The Satan Conspiracy”, and the description was

Ancient texts indicate that Satan may have been an extraterrestrial…

Um… yeah, if you believe what the bible says about Satan, that he exists at all, and where he came from, then of course he’s an extraterrestrial. Because what is an extraterrestrial? According to dictionary.com, it’s, “outside, or originating outside, the limits of the earth”. That sounds like what the bible says about Satan, God, angels, pretty much everyone who wasn’t created on the Earth. Of course, I think Satan, “the devil”, “Beelzebub”, etc., are just allegories for evil, and not an actual being, but this still really annoys me.

I’m really ready for idiotic shows like this (and those celebrating semi-literate rednecks) to run their course and go away.

im-not-saying-its-aliens-but-its-aliens

Conway’s Game of Life, In Go

About a week ago, I decided to implement Conway’s Game of Life in Go. There was no particular reason, other than that I was bored, I wanted to do something else with Go, and I had never tried to implement Life before.

For those who don’t know, Life is a zero-player “game” in which an ecosystem is seeded, and then plays out all by itself. Once begun, each generation follows these basic rules:

  1. Any live cell with fewer than two live neighbors dies, as if caused by under-population.
  2. Any live cell with two or three live neighbors lives on to the next generation.
  3. Any live cell with more than three live neighbors dies, as if by overcrowding.
  4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

That’s it. You start it up, and then sit back and watch for patterns to emerge. So far, I have a version that uses a portable curses-like library for console graphics. It runs on OSX, and should definitely run on Linux. The page for termbox-go says that it will run on Windows, but I haven’t tried it. I plan to build a “prettier” version using Gtk+, but that will take a little while, since I don’t know Gtk+ (yet!).

Here’s a screenshot of the current version running:

Screen Shot 2013-08-17 at 9.01.52 AM

If you want to see the code, it’s on github.

Now I Know: Aces High

From today’s edition of the Now I Know newsletter, this bit of interesting stuff:

In ordinal rank, the ace in a deck of playing cards is lower than the two — it’s the one, after all. But in most card games, the ace plays as the high card, trumping the King. Why? According to Wikipedia, this use became popular after the French Revolution, with the ace symbolizing the rise of the commoner over the monarchy.

Are You a Southeast Uker?

Do you play the ukulele? Have you always wanted to? Do you live in or near Atlanta, GA? The Southeast Ukers are a group of ukulele players who get together twice a month to play and sing together. We meet at the Waikikie Hawaiian BBQ restaurant on the 1st and 3rd Sundays of each month. It doesn’t matter if you’ve been playing for 20 years, 20 minutes, or just played air uke in the shower, we would love for you to join us.

For more details, check out our Meetup.com group

The Southeast Ukers

 

I Just Voted For Obama

I just voted to kill babies, bankrupt our grandchildren, turn “the greatest healtcare system in the world” into a giant socialst death panel, outlaw the saying of “Merry Christmas,” institute Sharia Law, implement the “Gay Agenda,” and burn the Constitution while dressed as Thomas Jefferson in drag. Or something like that.