Emil Hernvall

This page is a collection of various experiments I've done throughout the years. Most of what you'll find here are weekend projects, but a few are a bit more extensive.

Although not as much nowadays, I used to be an active member at Stack Overflow. You can check out my profile to the right.

 

Projects

This is an incomplete list of things I've done throughout the years. It's not representative of my professional, but does convey a good picture of my interests. The major themes are graphics programming, network programming and programming languages.

pacman (2017)

A pacman clone in javascript. Originally conceived as a way to explore the utility of immutable state representation in a stateful application like a game.

Hermes (2016)

A DNS server written in Rust, with a built-in web server for managing zones. Written as an exploration of the language as well as the details of the protocol. Quite an extensive project, which supports most of the features expected in a DNS server except for spoofing mitigation. Neither heurestic mitigation nor DNSSEC is currently supported, although I'll likely resume development at some point.

expiler (2014)

This is an experiment with generating java bytecode. After playing around with the asm library for a bit and gaining a better understanding of java bytecode, I decided to implement a simple program which parses mathematical expressions and converts them into executable java classes.

Ray tracer (2013)

A simple experiment and learning project, written in C++. Uses the phong reflection model to shade objects, with full support for reflections. The source code only depends on libgd2. I used this project to render the picture of earth at the top of this page.

This is to some extent just a C++ port of the Amiga Juggler reimplementation, which kinda shows from the structure of the code, but there's a few enhancements of my own. For instance, support for multiple lights. Further work on this project will probably attempt to introduce an acceleration data structure, and some way of loading scenes from disk.

UglyLang (2012-)

Toy programming language. It's currently implemented in Java, but I dream of bootstrapping it eventually. Current all execution is interpreted. The language as such is characterized by its static type system, which guarantees type safety. It's a cross between the functional and imperative paradigms. The current lack of support for generic programming combined with the strict type safety limits its usability, although I'm hoping to resolve that eventually.

Tregmine (2011-)

Plugin for the bukkit minecraft server, that provides most of the features needed to run an economy/survival server. It's a collaboration with a number of other developers, for the Tregmine minecraft server.

3D Engine (2011)

Experiment with software rasterization. Written mostly as a learning project, and horrendously unoptimized. When I started out with this, I had no experience whatsoever in 3d programming, and thus I spent some time documenting my research as a diary, which is available in the repository. (I did have a solid understanding of basic linear algebra, though.)

The major feature I never got around to would be texture mapping, which will probably be added at some point. Still, it'd be hard to argue that this project is suited for any real life applications, even after that's done.

SassyBarista (2011-2012)

A java implementation of the SASS language, which is a superset of CSS. Based on a JavaCC grammar. See link for a more complete description.

FatCat (2010-2011)

A java implementation of an irc server. It was designed in a way that would make it easy to add other protocols, with a core that simply manages the server state. The only other protocol that I ever tried adding was minecraft support, by embedding it in bukkit, and wrapping the mc-related state in a protocol handler. It worked pretty well, and turned out really cool.

fatcat has a completely asynchronous network thread using java.nio. There's currently no support for linking other servers, and also no services. I have some wild ideas about expanding fatcat with distributed linking support, and using something like vector clocks to synchronize state, but I'm not sure when I'll get around to that.

Candify (December 2010)

A visualizer framework for spotify, using the official libspotify. Includes some simple FFT-based visualizers, that doesn't work nearly as well as I'd hoped. This is entirely due to my severely lacking understanding of signal processing. The addition of some type of online filter would probably result in a lot more recognizable beats. It does look pretty nice, though. Uses the windows DirectDraw API.

Collapsible (October 2010)

Horrendously ugly tetris clone. WinApi and DirectDraw. My first and final attempt at doing game graphics.

Calculator (2009)

A java program that evaluates arbitrary mathematical expressions. Also includes some primitive plotting capabilities. I wrote this before I had spent any time whatsoever researching parsing. If I redid it today, I'd probably use ANTLR or a recursive descent parser. This project used a completely ad-hoc approach, which turned out surprisingly robust. Features a really crappy math shell.

Cropper (August 2008)

Simple program to crop images quickly. Written using WinApi and GDI+. I wrote this to optimize my photo editing workflow, since it felt a bit too painful to launch a full image editor every time I simply wanted to crop an image. This is my attempt to solve that specific problem in a really lightweight way.

Project Euler Solutions (2008)

Solutions for the hundred first Project Euler or so. Some problems have several solutions, and not all of them might work. A few problems (probably less than five) have partial solutions that doesn't give the correct answer.

This repository contains solutions in several different languages. Most of them are written in python, since I started doing Project Euler solutions as a way of learning that language. However, there are some solutions I've done in C as a way of practicing low-level optimization, and there's a few in Haskell which I also did for learning purposes. Warning: My Haskell is pretty awful.

Mosaic (2008)

A small unix program that constructs an image mosaic from a source image and a collection of smaller images (mosaic bricks). There's a few major issues with this program:

  1. It does not attempt to avoid putting identical tiles next to each other.
  2. It's O(n) in the number of tiles. A better idea would be to use something like kd-trees to quickly find a tile close to a pixels color in 3d RGB space.

ImageRetarget (2007)

An implementation of the seam carving algorithm I did back when it was first released. I was absolutely fascinated by the paper, and implemented it in both PHP and Java. This repository contains only the java-version, which has some interesting quirks. For instance, I'm calculating the energy of the image using a literal interpretation of the method in the paper rather than using a simple sobel transform. This involves interpolating the pixels as a cubic equation and calculating the partial derivatives. As far as I can tell, this has no real advantages over the sobel approach, but it's a rather beuatiful over-complication.

Experiments and snippets

Smaller projects and experiments I've done, of somewhat varying quality.

PlaylistCopy
Very small program for copying the contents of a .m3u playlist to a specified target directory.
Quad Tree in Java
An implementation of a Quad Tree, originally written for use in a Minecraft Server. Optimized for efficiently looking up which of a set of rectangles that a point in 2d space belongs to. Only supports a sub set of operations right now.
HQX bindings for PHP
The HQX library provides an algorithm for scaling pixel graphics with superior quality compared to standard interpolation methods.
Sudoku Solver in C
Using the naive substitute-and-permute approach.
Date diff implementation for PHP
Decoder for the EA .big-format
Used it to retrieve the videos for Red Alert 3. A really basic format, that was quite simple to reverse engineer.
Base64 encoder and decoder in Java
Finding the most popular word in a file
Using linked lists and merge sort (C)
Using a hash set (C)
In Java
Some different implementations of a word counter that I wrote as part of an argument with a friend.
Some basic code for parsing and generating wave-files
Parser in C
Tone generator in C
Recursive mkdir in C
Tiny java/swing app for language learning
Indexing spellchecker in PHP
Find a way to reverse a hand of five cards by moving three cards
setuid() to another user and give group members write permission to files with certain extensions.
Prime Sieves
Basic
Smart
Experiment with encoding data as sound
Transforms a data file to a series of beeps of different frequencies, that can be decoded back into the original file.

Contact

You can get in contact with me using my gmail. My username is emil.hernvall.