Genuine Solutions

If you can explain it to me, I can code it for you

callback-websocket – creating RESTful services over a WebSocket

Some time ago I started a side project where pushing data to users as fast as possible was a major requirement. Being easily accessible (i.e. not separataly installable) was another, so naturally, I thought this is the time to check out WebSockets.

The trouble of multiple connections

It started off great, I saw that at least two latest versions of most common (desktop) web browsers supported them, Java had a stable WebSockets API etc. But as I cracked on coding, I saw that I was using my fast full-duplex communications channel only for pushing data from the server to the client. For every client side request I still relied on the good old AJAX querying my JAX-RS endpoints.

I began wondering if there was some way to channel all of my communications through the existing WebSocket, as it seemed pointless to create additional connections to my server. As I began poking around I found this cool AngularJS WebSocket service example. The trouble was, that I had no way to intelligently handle these requests on the server.
Continue reading »

How to get notifications from your terminal

Last weekend, when I was on the bus trying to push my code over a flaky 3G connection, I started searching for a way to get a notification when my commands in terminal finished. It’s just frustrating to start a push, then continue working on something else, only to discover half an hour later that the push failed because of some network error.

Luckily I found this cool project called terminal-notifier. It’s a command-line tool to send Mac OS X User Notifications. Using it is simple, just add it to your path and type:
Continue reading »

How to run parameterized junit arquillian tests

Arquillian is an awesome tool for testing java apps written in the EE ecosystem. It allows you to run your tests within the actual application server, so you don’t have to mock your services or dependencies. Instead you use them exactly the same way you use them within your application. For more information about Arquillian please see this awesome getting started guide.

However, because of the way Arquillian works with JUnit (as a special runner) you cannot use many JUnit’s advanced features (there can only be one @RunWith annotation). Namely I was missing the ability to run parameterized tests or theories. After a quick search I found this gist – an example how to achieve the parameterized test behaviour in Arquillian via JUnit Rules.

JUnit Rules are special inceptors for your tests that allow you to redefine the behaviour of every @Test method. For more info and examples of @Rule usage see the JUnit Rules wiki guide.

The rule written by Aslak Knutsen works, but I found that it doesn’t support running my tests in client mode. As an example let’s say I wanted to test that some resources in my application are properly gzipped. To test this, I would list the resource files I want to test and then iterate over them. Make a request and see if the response is gzipped – sounds like a parametrized test.

To achieve this I rewrote Aslaks gist adding support for client mode and a nice way to declare where to inject parameters with the @Parameter annotation. You can find the full gist here, but let’s just quickly see what the end result looks like:

Continue reading »

Quicky: Sane keyboard shortcuts to navigate OS X Mavericks Finder tabs

The default shortcut for next tab in OS X Mavericks Finder is “^ + ⇥” and “^ + ⇧ + ⇥” for previous tab. I think it’s rather clunky. Something like “⌥ + →” and “⌥ + ←” would be much better, here’s how to change it:

Continue reading »

“The Night Watch” – James Mickens

“However, the most important person in my gang will be a systems programmer. A person who can debug a device driver or a distributed system is a person who can be trusted in a Hobbesian nightmare of breathtaking scope; a systems programmer has seen the terrors of the world and understood the intrinsic horror of existence.

The systems programmer has written drivers for buggy devices whose firmware was implemented by a drunken child or a sober goldfish. The systems programmer has traced a network problem across eight machines, three time zones, and a brief diversion into Amish country, where the problem was transmitted in the front left hoof of a mule named Deliverance.

The systems programmer has read the kernel source, to better understand the deep ways of the universe, and the systems programmer has seen the comment in the scheduler that says “DOES THIS WORK LOL,” and the systems programmer has wept instead of LOLed, and the systems programmer has submitted a kernel patch to restore balance to The Force and fix the priority inversion that was causing MySQL to hang.

A systems programmer will know what to do when society breaks down, because the systems programmer already lives in a world without law.”

Continue reading »

“Close to the Machine” – Ellen Ullman

I’ve managed to stay in a perpetual state of learning only by maintaining what i think of as a posture of ignorant humility. This humility is as mandatory as arrogance. Knowing an IBM mainframe – knowing as you would a person, with all its good qualities and deficiencies, knowledge gained in years of slow anxious probing – is no use at all when you sit down for thw first time in front of a UNIX machine. It is sobering to be a senior programmer and not know how to log on.

There is only one way to deal with this humiliation: bow your head, let go of the idea that you know anything and ask politely of this new machine, “How do you wish to be operated?”. If you accept your ignorance, if you really admit to yourself that everything you know is now useless, the new machine will be good to you and tell you: here is how to operate me.

The geek culture – inside out

surely you're joking mr feynman

How would you describe a geek? A long haired, socially awkward man with glasses? Maybe, but maybe it’s something totally different. I believe the stereotype described above is too outdated and shallow. For once I’d like you to hear about true geek culture from the inside out.

Richard P. Feynman was an american physicist whose life memories where gathered into a book titled “Surely you’re joking Mr. Feynman”. At our company (ZeroTurnaround) vacation in Crete our CEO Jevgeni Kabanov held up a copy of the book and called it “the geek bible“. As I had just read the book I began wondering about geek culture in general and what would be the fundamental pillars of it.

First of all I’d say that the preliminary signs of a geek aren’t the looks nor the profession (Feynman was a physicist not a computer scientist!), but are the enormous amounts of curiosity and passion they have in life! The ability to be fascinated by the littlest or weirdest of things that only a few others may know or care about. Almost every geek I know has huge amounts of passion towards something, anything, that they enjoy doing.

Aside from being a Nobel Prize winning theoretical physicist, Feynman was also an excellent painter and drum player. He had his own gallery at the basement of his house, where he often painted nude models and he also took part in the drum battles of Brazilian favela music schools!

I think another big part of being a geek is being suspicious and even a little paranoid at times, but of course in a good way. There’s a story about Feynman involving neutron-proton coupling. At that time everybody knew it was T, but according to Feynman’s calculations and thoughts it should have been V. Instead of buckling under and admitting defeat, he actually started to look for WHY everybody thought it was T. He ended up with one paper published years ago, where a scientist had done some experiments and found the result to be T. Since then, EVERY scientist considered the coupling to be T, but Feynman actually looked at the paper and found that the evidence presented was extremely weak and wrongly interpreted! Continue reading »