Compiling RunIt on Fedora 20

- 1 min read

I had dowloaded RunIt. Then ran

package/compile

It errored with:

./compile runit.c
./load runit unix.a byte.a -static
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make: *** [runit] Error 1

To fix I needed to run

sudo yum install glibc-static

Bash function to switch Java versions

- 2 mins read
setjava() {
	if [ "$1" = "-q" ]; then
                local quiet=true
                shift
        fi

	local jdk=~/Applications/Java/jdk1.$1
        if [ ! -d "${jdk}" ]; then
                echo Jdk not found: ${jdk}
                return 1
        fi
	export JAVA_HOME=${jdk}
        export PATH=${JAVA_HOME}/bin:${PATH}
        if [ -z "${quiet}" ]; then
                java -version
        fi
}

export -f setjava

I have symlinks for all major versions of Java so that in IntelliJ and the command line I can upgrade minor Java versions just by changing the symlink:

Error: Invalid or corrupt jarfile

- 2 mins read

I was creating a Jar via the Java API’s and I couldn’t get it to run my main class:

 $ java -jar foo.jar
Error: Invalid or corrupt jarfile foo.jar

Running it via the class path worked fine:

 $ java -cp foo.jar Bar
Hello world!

So now I knew it was something to do with the manifest file but it wasn’t being caused by

  • The 65535 file limit (See Zip64 and Java 7 ).
  • The 72 bytes limit per line
  • Missing newline at the end of the Main-Class (Displays “no main manifest attribute, in foo.jar”
  • A blank line before Main-Class (Displays “Error: An unexpected error occurred while trying to open file foo.jar”

So after scratching my head for a while I tried comparing a working jar with the failing jar:

Git Config

- 1 min read

My .gitconfig contains

[user]
        email = dan@bodar.com
        name = Daniel Worthington-Bodart
[color]
        ui = true
[alias]
        ci = commit
        co = checkout
        st = status -sb
        nuke = !git checkout -f && git clean -f -d
[push]
        default = current

Wat? Scala

- 1 min read

As I got quoted recently in “Scala — 1★ Would Not Program Again” I though I finally should write up a little Wat moment we had recently:

So does anyone know “wat” the following Scala code returns? (Value and Type)

List(1,2,3).toSet()

A Set<Int> containing 1,2,3?

Nope how about I give you a clue, there are 2 bugs in this one line:

  1. A type inferencing bug where it chooses Set<Any>
  2. A bug where the brackets are used for both calling the Set.apply method and constructing Unit, notice there no space between the “toSet” and “()”

Yup you guessed it, it returns: