Piping to stdout and file simultaneously

Just another note to self here:

./[program] [arguments] | tee [filename.txt]

Run program with arguments, use pipe “|” and the program named “tee” to output do both stdout and a particular file. Great for logging terminal programs.


  • -a Appends the output to the end of File instead of writing over it.
  • -i Ignores interrupts.

Since it’s a GNU-core utility, “man tee” gives a manual of the program.


More Barcodes

I’ve been working more with my barcode application and am finally close to a working solution.

Adding start and stop characters is more or less dependent on which charset you want to use, unless you’re going to use special characters or some other special functionality, you’ll be using Code128 B – which supports most normal alphanumeric characters and punctuation characters in the ASCII table. The rest is just basic String concatenation, which you can do in LibreOffice Calc or through programming.

The first stretch was developing the checksum method in Java, which was pretty easy thanks to the information provided by wikipedia here.

What I did was simply to make an array with the characters listed for Code 128 B, disregarding special characters since I won’t be using them anyway. The array looks a little something like this…

private String code128B_table[] = {
" ","!","\"","#","$"," %","&","'","(",")","*","+",",","-",".","/",
private String code128_table[] = code128B_table;

With the Array in place, all I needed to do to calculate the checksum was write this method:

* Calculates the checksum
* @param input String input for calculating checksum
* @return the checksum in integer form
public int checksumInt(String input) {
int checksum = STARTCODE;
for(int i = 0; i < input.length(); i++) {
int value = charNumber(input.charAt(i));
if(value < 0)
return value;
int position = i+1;
checksum += (value * position);
return checksum % 103;

* Helper function for checksumInt
* Finds the number of the particular character using the Code128B table
* @param c
* @return
public int charNumber(char c) {
for(int i = 0; i < code128_table.length; i++) {
if(code128_table[i].charAt(0) == c)
return i;
System.out.println("Could not find " + c);
return -1;

But wait, there’s more. The checksum itself isn’t enough, it needs to be in the form of a character, but since we already have the table for Code128B in array form, we just convert the integer to character for printing.

* Converts calculated checksum into character
* @param i calculated checksum
* @return character for printing checksum
public char checksumChar(int i) {
if(i < 95)
return (char) (i + 32);
return (char) (i+ 100);

Since the computers come with Norwegian keyboards and the barcode scanner will read barcodes as if receiving keyboard input, I had to do a few cheap hacks to remap the characters according to Norwegian keyboards, this isn’t a problem with alphanumeric data, but characters like { [ ] and } will read on a computer set with  a Norwegian keyboard layout as receiving the letters Æ Ø and Å or some other character because of this, I made a function with way too many if/else tests rather than using a HashMap or other key-value pair since it just seemed simpler to write at the time.

The class file is available on github here.

Beginning Barcodes

About a year ago, I made a bit of an impulse buy on eBay and purchased a barcode scanner for a little less than a dollar (little did I know that shipping and handling would cost me 9 dollars more, but 10 bucks isn’t really anything to worry about).


Why you ask?

Because for some reason I thought it might be a good idea to have a barcode scanner available so I could learn a bit about programming applications using barcodes.

What have I learned so far?

Well there’s a lot of talk on how you need permission to use certain barcodes. Especially EAN and UPC seem to be regulated if you want to distribute your product, but EAN is only the tip of the iceberg.

Some of the simplest barcodes to work with today can be installed as fonts and these include Code 39, Code 93 and Code 128.

But you can’t just download a font and think it’ll work like that – barcodes usually need some way of knowing where to start and stop reading, so the name “Studio Black” would have to be written “ÌStudioÂBlack{Δ to work in Code 128.

Luckily, several websites, like this one, can help translate for you.

So how does this work?

Barcodes are actually an incredibly simple and efficient input method and isn’t really all that different from a computer keyboard. Think of it as a mix between a keyboard and a scanner. When it reads any barcode it supports, your computer will pretty much only act as if it received keyboard input in the form of a string or number.

Some barcodes support alphanumeric data (like Code 39 and Code 128), which means it can contain both text and numbers, while others are simply numeric (like EAN and UPC).

Because of this, programming an application that reads barcodes require next to nothing extra and you can probably just use the same old text fields and forms as always. The USB barcode scanner I have is pretty simple to use and drivers were as easy and automatic as when connecting a keyboard or mouse – just plug and play.

In the long run, the biggest hassle is probably getting familiar with the legal issues of it all.

You can find the fonts for the different barcode systems:

Here: Code 39

Here: Code 93 and

Here: Code 128

As of yet I’ve had the best luck using Code 128, with the type of barcode scanner you can find for about 10 bucks off eBay. My model is called X-9100 and works like a charm.

By the way, make sure to never use bold or italic with barcode fonts, they mess up everything.

Mounting shared folder

mkdir ~/Documents/VBShared


mount -t vboxsf VBShared /home/$USER/Documents/VBShared

Save this as a file, such as “mount.sh”

$ chmod +x mount.sh

$ sudo ./mount.sh

I’m writing this as a reference for every time I make a new Virtualbox guest linux machine

Install guest additions.

Make sure settings have a shared folder set with automount enabled.

Run script at startup.


For systems without an X-Server:

Make sure sufficient packages are installed. Build essential is useful.

Click on “insert guest additions CD image”

sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run

Good News Everyone

Finally got my answer today, and was accepted as an illustrator on my first attempt. Lucky me, now I’m off to Sweden, and then maybe I’ll try uploading a few illustrations for my portfolio there.

I really should spend more time working on that portfolio, hopefully I’ll have a better acceptance rate on both music and illustration as the competition seems a little steep in the photography section.

Learned a bit more on working with isometric projection in illustrator, especially using the “line” tool and creating lines at predefined metric lengths and in the angles 330, 30 and 150. Maybe I should elaborate on that sometime.


I didn’t know how much fun it would be to play around with orthographic projection once you get the hang of it in Illustrator.

Things I’ve learned:

1. The “polygon” tool makes foor a perfect hexagonal shape, which is pretty much the outline of an isometric square.

2. Just remember isometry is basically a rectangle with 30 90 90 30 degrees angles, and use the shear tool to either 30 or 330 degrees (i.e. 330=-30)

3. It’s quite simple to just make anything two dimensional and then use the “shear” tool using the rule of thumb I mentioned in point no. 2.

4. Isometric projection is a great way to sketch ideas to use for more “realistic” perspectives, since projectional systems using distortion has a tendency to hide and distort details. That way, using orthographic projection makes for a great way of making “visual notes” to use later on.

There seems to be a certain demand for it on iStock even though there are already thousands of files available, maybe I’ll try my luck with a few isometric drawings if my first application as an illustrator isn’t accepted.

Kind of feels like I’m playing Sim City again, only not just playing a game while doing it, but actually working on something productive.

There’s something impersonal about this way of presenting things, you know, reminiscent of technical drawings and whatnot, but then again, I really do enjoy the “video game graphics” feel of isometric perspective.

After I finished this drawing I came to think of the problem of elipses and other difficult shapes and finally found this tutorial extremely helpful:

How to create advanced isometric illustrations using the ssr method

Especially worth noting is scaling everything to 86.602% then shearing according to which axis you want it in (+/-30 degrees etc.). So as a little note to self, 86.602% is worth remembering when working with isometric projection.

Such a long time!

It’s almost half a year since I last said anything here.

Why? Because I’ve just moved back to Norway that’s why – been looking for a job, working part-time at an old job, and collecting, always collecting stuff.

And in the spirit of what I enjoy collecting, I thought I’d comment on what type of drafting equipment I’ve had a hard time getting a hold of.

1. Staedtler Mars Lumograph:

Best artist pencils around, 4H really IS 4H and 8B really is black. From experience I’ve had luck getting them at Akademika in Oslo, as well as I’ve found they sell them at the “Pen Store” in Stockholm. Otherwise they seem to have a meager collection of a few at the Ark book store at Egertorget in Oslo as well as Zinkvit in Uppsala.

2. Rotring and Koh-i-Noor Rapidograph/Isograph:

Probably best bet is to get them on Amazon.

3. Beam compass:

Again, the UK seems to have the best selection of illustration and drafting equipment.

4. Bristol Board:

I’ve actually found a great little Art Supply store in Ski that sells original Bristol Board in A4 and A3. Otherwise, Letraset seems to offer a similar type of paper – only a bit more expensive at stores such as Clas Ohlson and Panduro.

5. Flexible Curves:

Another product I’ve yet only found at the Torso Art Supply store in Ski, how strange to find what your looking for right under your nose while looking far and wide for this stuff.

As for light tables – they sell them in stores now, but at ridiculout prices. Alternatively you could use an old flat screen computer monitor or TV set as a light table, or just get a simple plexiglass plate. Personally I was in luck finding one in the trash one day (that’s 1895 NOK worth of light table for free).

For those of you who live in Scandinavia, I suggest trying out the Swedish ebay: www.tradera.se and search for “passare”, and you might not find a beam compass for sale at all times, but at least they sell some really nice sets for a reasonable price.

I’ve been going through the Cheeseman-Meyer book on Perspective to check for good drafting equipment, as there’s a little list there on practical drawing equipment for descriptive geometry.

I think that’s all for now…


Flying Cars

Finally got around to the finish line here.

Not exactly pleased with the result, but it’ll do for now, learned a few more illustrator tricks I should make better use of next time. I guess the point of this excercise was to see if I could make up a scene from scratch by drawing freehand and using perspective for scenery.