Hyperion

October 3rd, 2008 10:53 AM by Luke Maciak
Hyperion

Hyperion by Dan Simmons is a rather interesting book. It is really an analogy of short stories taking place in the same universe, and connected with common narrative. The individual pieces could be read alone, outside the novel without losing to much. You can think of them as flashbacks which help to develop the main characters, give them back stories, and show you different aspects of the portrayed world. Each of them also adds a piece to the over-arching mystery of the planet Hyperion.

This backwater planet lying on the outskirts of the galaxy spanning empire played a key role in the lives of the 7 pilgrims returning to it for the last time as the galaxy spanning is on a brink of devastating world. It is a home to some of the universe’s impenetrable mysteries such as the vast, empty labyrinth of unknown origin underneath it’s surface, mysterious monuments called the Time Tombs which generate anti-entropic field (which evades understanding by modern science) that seems to be propelling them back in time and the almost mythical, fearsome, bloodthirsty beast known as the Shrike.

No one really knows what the Shrike is, since almost no one who have seen it lives long enough to tell anyone about it. But the creature has been also known to grant requests to it’s worshippers who go on a pilgrimage to the Time Tombs and put their life on the line. When the story begins Hyperion is about to be invaded, the Time Tombs seem to be opening and the shrike goes on a rampage decimating the population of the planet. The cult of Shrike carefully selects 7 very special pilgrims and sends them to face the beast.

Since the pilgrimage is a long and ardours trip they decide to share their stories with each other and figure out what exactly makes them so special. Simmon’s takes great lengths to keep each flashback unique by giving it distinct mood, flavor, tone and language. The narrative style shifts quite drastically depending on the subject. So for example the Soldier’s Tale is told by a third person, omnipotent narrator in a very structured and linear way. The Poets Tale on the other hand is first person narrative with flowery (and often crude) language, with many tangents, asides and soliloquies. The end result is a curious but rather interesting mix that offers the reader wide variety of experiences.

The quality of the individual stories varies. All are well written and interesting, but some will definitely stand out and lodge themselves in your memory. My favorite was probably the Scholar’s Tale which was a mix of all the right stuff. Moving story about parenthood, terrible heart wrenching loss, crisis of faith and trying to cope with a mysterious terminal disease destroying life of one’s only child. The Priest’s Tale also made a great impact on me - eerie, disturbing and soaked in mystery. The Soldier’s Tale on the other hand left me cold. I felt like it did very in terms of character development, and the ending killed whatever suspense it managed to build with a rather pointless combat scene. Nevertheless it contained interesting insights to the Outster culture, the organization of military in the human Hegemony, it’s customs and strategies. The Poet’s Tale was good, but in my opinion was a bit jumbled and lacked a disturbing hook or twist evident in most of the other pieces. Still, it provided great background on the history of the Hyperion universe, the destruction of Earth (eaten by a wormhole produced in a LHC experiment btw) and colonization of the planet Hyperion. Even if you hate the main character, you will keep reading it to find out more about the universe.

I did not care much for the Detective’s Tale on either. It was essentially an old-school Gibsonian cyberpunk detective story, complete with the silly notion of cyberspace, scheming AI’s and a murder mystery in the middle of it all. While I do not despise this genre, I’m not a big fan of it either. But once again, while this particular part of the book was of average quality (at least IMHO) it did add new insights to what makes Simmons’ universe tick.

The book is closed with the Consul’s Tale which is a slight departure from the other other tales in the book. The focus is shifted off he planet Hyperion here and revolves around the issues of innocence lost due to progress, colonialism and features an interesting spin on the twin paradox. Instead of twins, however we star crossed lovers one of whom is a shipmate on a star cruiser traveling at relativistic speeds, while the other stays planet-bound. One stays young while the other one ages naturally. Strangely moving and sad piece. It is actually a verbatim re-print of Simmons’ short story which appeared in the anthology “Prayers to Broken Stones” and later became a seed for the Hyperion universe.

If you like a good Scifi with a dash of mystery and touch of supernatural I highly recommend this book. I believe that you will find at least one story inside of it’s covers which will either move you, disturb you or stay with you in some way.

Firefox 3 Thumb Button brings up Save As dialog

October 2nd, 2008 11:07 AM by Luke Maciak

This has been driving me nuts since I have upgraded to Firefox 3.0.1 on my laptop like a month ago. I’m still running Gutsy on that thing, and only the beta version (which crashes a lot) is in the repositories. So I pretty much did the same thing as back when FF 2.0 came out and I was running dapper. I snagged the statically linked linux binary from the website, dumped it into /opt/firefox and un-installed the old version. It works fine with a single exception - my thumb button was acting weird as hell.

This requires some explaining. I’m using Logitech VX Revolution wireless mouse and the btnx to detect and remap all the additional buttons on the mouse. I configured it so that the back and forward thumb buttons are set to emulate the Alt+ left arrow key and Alt+ right arrow key. These are of course Firefox shortcuts for Back and Forward controls.

To tell you the truth, I actually forgot how to press the back and forward buttons on the FF chrome. I just never do it. At home I am using MS Sidewinder mouse which also has convenient thumb buttons. I always use them while browsing because it is just so much faster than anything else. Faster than keyboard shortcuts because when I’m browsing one of my hands is usually holding the mouse. So thumb buttons are perfect for quick flicking back and forward between pages and I miss them when I’m forced to use a mouse which doesn’t have them.

Ever since I started using FF 3.0.1 on my laptop the back thumb button started doing something weird. In addition to sending the browser the “Back” signal it would also invoke the “Save As” dialog. Yes, it would just pop up in the middle of the screen. Attempting to use the dialog would be futile however. I tried to actually save whatever it was asking me to save several times, but Firefox never actually produced any files as a result of using this particular dialog.

It was nothing more than a constant annoyance. Every time I tried to go back a page, I would have to cancel this dialog. It was actually more annoying than clicking the buttons manually, or taking my hand off the mouse do do the Alt+ Left Arrow thing. Since then I have reconfigured btnx dozens of times, and kept searching Google for a possible solution. No luck. Eventually I figured out this had to be some Firefox setting and started digging in about:config.

Through bunch of trial and error tests, and good amount of luck I finally managed to identify the culprit. If you have this problem, all you have to do is to set:

middlemouse.contentLoadURL = false

From mozilla knowledge base:

Background:

This preference determines how to handle middle clicks in the content area. It was split off from middlemouse.paste, which now handles middle clicks in text fields only.

Possible values and their effects:

True: Load the contents of the clipboard as a URL. (Default for Linux/Unix.)

False: Handle middle-clicks normally. (Default for all but Linux/Unix.)

I actually never, ever use this feature because 90% of the time the thing in my clipboard is not a loadable URL. Besides, since I switch between platforms a lot, I generally don’t get used to platform specific features like that.

I have no clue why this particular setting kept picking up the Back Thumb button as some sort of “Save As” invocation. Note that this was not happening in FF 2.x, so go figure. Setting it to false solved the issue for me. I can browse like a normal person again.

Hopefully this post will help some other poor soul frustrated by this issue. )

Vim Tips

October 1st, 2008 10:54 AM by Luke Maciak

Hey kids! Guess what time it is? It’s time for some Vim Tips!

What? Don’t make that face! Vim is awesome! Don’t give me that “B-b-but mistur Luke, we don’t use vim!” That won’t work with me again! You know damn well you should be using it. What is your lame excuse today? Is it “vim is to hard”? Suck it up you babies. Real men and women use vi and that’s that! There is only one excuse that I’m willing to accept, and that excuse is “I use Emacs”. So, how many of you whining babies use emacs? One person? Ok, you are excused - you can go sit over there. Your exercise is to write an elisp macro to do something interesting.

The rest of you, STFU and listen. No, I don’t care you use Eclipse on a daily basis. Just get the viPlugin and you will have the combined power of Vi and Eclipse at your fingertips. How awesome is that. No, don’t shrug - it’s fucking awesome, and you are gonna like it, right now! There, that’s better.

Ok, question from the back row. Yes, you - the guy with the stupid face. You use word? You know what - get the fuck out! Just get out and never come back. Actually, on the second thought wait. Sit your ass down and try the ViEmu thing. I tested it a while ago and it was pretty cool. Unfortunately it tad expensive and I could not justify purchasing it since I only use Word when I’m forced to. Still, it might work for you.

Anyways, this might be the first post of a series. I’m going to use it to drop little bits of vim lore that I want to remember for the future.

How do I use Vim input methodology for my text boxes in Firefox?

I think I mentioned it before but I use the It’s All Text! plugin. It puts a tiny little button next to all the textarea elements on the page. Pressing that button opens up the textarea contents in your editor of choice. For me that’s gVim but just about anything will do.

Hey, emacs guy - did you hear that? That one will be useful for you too. Write it down. MS Word guy, STFU! You don’t get to say anything!

There is another plugin out there called MozEx which seems to be doing something very similar. I haven’t tested it but it seems like it will also let you use vim for textareas.

I use It’s All Text! and my HTML doesn’t get highlighted

That’s because the plugin saves your buffer as a txt file. I got around this by simply forcing all text files to highlight as if they were HTML. It doesn’t really affect normal .txt files, but if you plug some HTML into one of them, it will look nice. If you want to do the same, just paste this into your .vimrc

au BufRead,BufNewFile *.txt setfiletype html

Luke, why is this post so long? How many words have you typed so far?

I don’t know, let me check…

g<Ctrl+g>

I typed 520 words so far. I’m like halfway done so stop whining. Anyway, this is how you do it. Select some text, then press g and then Ctrl+G and you will see bunch of useful information in the status line. For example, the number of words you have typed so far. Cool, eh? It’s especially useful if you are trying to meet some word count requirement. Which, I usually don’t do very often as you might have noticed. I start typing, and then stop when the post seems like it’s done.

Heh, I wonder how many times you typed the word “vim” in this post?

Again, not sure, but let me check…

:%s/vim //gin

I typed it exactly 7 times. Yep, it’s another nifty trick - you can use the good old regular expressions in a non-standard way. For example the n modifier will prevent the replacement taking place in the regex above. Instead vim will simply print out the number of matches on the status line.

Finally, last tip of the day:

How do I delete everything from the cursor up to but not including a specified character sequence?

A little specific, isn’t it? But it is useful when you want to delete a big chunk of text. I mean, yes there is always the good old dt command which deletes till the first occurence of a character that follows it. There is also d) which deletes the whole sentence and d} which deletes the whole paragraph but this let’s you be very, very specific. Here is how you do it:

d/char-sequence

That is, you press d (or c if you just want to switch to insert mode), then press ‘/’ to enter search mode, enter a character sequence, and hit return. This also works with other commands so you can also do:

v/char-sequence

That’s all I have for now. I hope you enjoyed this quick batch of Vim tips. And if you didn’t I don’t care. The emacs guy over there seems happy because he found out It’s All Text! plugin and the MS Word guy is crying cause I called him names. Eh…

There might be more of these. )

Hacking in Hollywood

September 30th, 2008 11:28 AM by Luke Maciak

I said this before, and I’ll say it again - I can’t stand Hollywood movies about hackers or hacking. I just can’t deal with that shit. The classic Hackers is possibly the single notable exception to this rule. And that’s because this movie is actually a clever satire - it takes the popular culture image of a hacker, and the average Joes concept of what hacking is, turns it up to 11 and then ads a dash or realistic jargon, or real references here and there. It is a ruthless caricature poking fun at the hipster image of a hacker existing in the media and the so called “hacker culture” perpetuated by script kiddies who think they are 1337. I have no clue whether or not this satirical layer was added intentionally, or whether it simply emerged because later Hollywood productions tried to imitate it. In ether case the sheer badness of the film caused an integer overflow and as a result it became good again. And I guess it’s all that matters.

Of course a if you manage miss the joke completely you can still enjoy the movie as a campy, off-beat fun ride. Everyone wins. End result is a cult classic loved by computer professionals and clueless people alike - often for very different reasons. Few others have ever accomplished anything similar. In most cases any attempt to portray “hacking” on the silver screen ends up in a massive load of epic fail. As an example I give you a scene from the movie Swordfish:

Can anyone explain to me what is going on in here? Cause to me it kinda looks like this guy is playing some sort of 3d puzzle game. He is typing on the keyboard like a madman, cursing, jumping around and etc… In the meantime his (obligatory) multiple screen rig is showing some funky animation depicting cubes of shimmering code falling into place, scrolling text and lots of blinking lights. It’s silly!

Most Hollywood movies depict hacking this way. Some sort of abstract, incomprehensible activity that apparently involves a lot of frantic typing without using a space bar. But it doesn’t need to be this way. Here is a hacking scene from the matrix. Watch closely on what shows up on Trinity’s monitor:

Did you catch it? You can clearly see the characteristic output of Nmap (a very popular port scanning tool), and then exploits the very real, but also very old ssh vulnerability to take control of the remote system. This depiction was so realistic, that the British Computer Society felt compelled to release a joint statement at the time, urging movie goers not to attempt to emulate it.

To a lay person both scenes would look equally incomprehensible and cryptic right? In both cases we see characters type stuff on the keyboards, and see some scrolling commands and text output that is really not essential to the story. The Hollywood produces usually assume that since an average person doesn’t know the first thing about hacking they might as well make the activity visually pleasing.

The thing is that people do know how hacking looks like. Anyone who uses their computer for more than browsing Myspace and chatting on AIM knows that what you see in the Swordfish scene (or the scenes from the Hackers movie for that matter) are totally fictitious. Unless you are a lumberjack and live in a log cabin in a middle of a forest with no electricity you probably know a programmer, sysadmin, or an IT guy of some sort. Or at the very least you may know that computer whiz kid from the neighborhood who fixes your laptop whenever you infect it with to much spyware.

There is a certain way computer interfaces look, and there is a certain flow to a typical computer operation. I think that most movie goers these days realize that “hacking” into a computer system involves activities such as running programs, typing in commands, and for example looking stuff up on the internet. Most people realize that this whole “typing really fast, to control some 3d animation on the screen” thing is incredibly silly. In fact I have seen it parodied, joked about and made fun of in mainstream media well outside the usual geek circles.

So why does Hollywood insist on insulting our intelligence this way? Why do they show us shiny animation assuming that we wouldn’t understand what was going on in the first place. Some people will probably argue that showing “real hacking” would be irresponsible. I would naturally laugh, and explain the concept of full disclosure to these people. Think about this logically:

  1. No one says that Hollywood needs to show new, cutting edge zero day vulnerabilities
  2. Besides, a zero day vulnerabilities would be old news long before the official move premiere
  3. Including an old vulnerability in a blockbuster movie would possibly make people nervous and force them to finally patch their systems - so it would be a benefit for everyone
  4. No one says you need to show a step by step tutorial - what Matrix did was perfect - they made up a script with a made up name, and then stated it is exploiting the ssh crc32 vulnerability

Showing just glimpses of real exploits, or inessential bits of code is not irresponsible, or dangerous. It is no more dangerous than showing your average episode of Myth Busters on TV. After all, Myth Busters use real physics and chemistry principles to make things blow up like every week. You know - the stuff you could look up in your high school physics/chemistry book - they use that stuff. How is using basic, common knowledge computer science and computer security principles to do privilege elevation or remote exploits any different?

All I’m asking is this: if your movie revolves around hackers, hacking, security exploits or programming, please, please, please hire a technology consultant and for god’s sake listen to him. Ask him to write down a list of technical jargon terms the characters should know, and pointers on their usage. Have him write sample lines the characters could say while hacking/programming. Have him work with the post-production team to create appropriate visuals. That’s it! One guy, few hours of work. Whatever you will need to pay this dude is probably insignificant to the amount of money you spend for the CGI, pyrotechnics and the stunt work.

Seriously, if you know nothing about computers why do you think you can write and/or direct a good movie about hackers and/or programmers? When you are making a movie about police men, soldiers, firemen, lawyers or salesmen you probably bring in a specialist who explains to you and the actors how the things are done in his profession, makes sure you use an appropriate lingo, and don’t make huge blunders. No one seems to be doing that for computer related stuff though. It seems that it is easier to just make stuff up instead.

JQuery Tablesorter: List of Builtin Parsers/Sorters

September 29th, 2008 11:27 AM by Luke Maciak

On of my users tried to explain a bug to me today. Apparently the results on the search page would not sorting properly. Or they were sorting but not by date but by half or a quarter of the date. Or at all. Or they would sort correctly, but sometimes they didn’t and only half sort them. Needless to say, I was thoroughly confused and since this was not one of those “just read the error message to me” issues, I decided to visit the desk of the person who was complaining.

When I got there, I got a small demonstration. “Watch this!” she said, as if she was going to do some trick and I got scared for a second that she will do something that we could not have predicted, and inadvertently crash the whole application due to some hidden bug. You know the type of the bugs - the ones that are completely missed in code review, overlooked in testing and only come out when a user starts clicking buttons you didn’t even put into the design somehow. Fortunately she just typed a query into a search form, and tried to sort the results by date. Then she triumphantly pointed at the screen: “See! That’s what I mean”.

She was right. The results were indeed getting sorted according to the date column, but the algorithm was wrong. Instead of sorting by date, the table was sorted alphabetically/numerically with the obvious results. So I went back to my desk to figure out what went wrong.

The sorting was done by the Tablesorter Plugin so I assumed that the algorithm was right started digging in our code first. I soon figured out what was causing the issue: blank date values!

It’s simple, to avoid clutter missing dates are simply not displayed. So a table will look a bit like this:

<tr><td>05/25/08</td> <!-- snip --> </tr>
<tr><td>08/01/08</td> <!-- snip --> </tr>
<tr><td></td>         <!-- snip --> </tr>
<tr><td>12/11/07</td> <!-- snip --> </tr>
<tr><td>11/10/07</td> <!-- snip --> </tr>

If there are not blank cells in the column, tablesorter script correctly recognizes it as a date column. If it sees blank cells, it reverts back to a text sorting algorithm. Since only some queries would produce blank cells like that, this issue went unnoticed for quite a while. I guess we trusted tablesorter to do the identification thing properly.

The fix was trivial - force the tablesorter to treat date columns as date columns no matter what they contained. You pretty much have to specify the data type for each column:

  $(document).ready(function() 
  { 
    $("#myTable").tablesorter(
    {
       headers:
       {  
         0 : { sorter: "shortDate"  },
         1 : { sorter: "shortDate"  },
         2 : { sorter: "shortDate"  },
         6 : { sorter: "shortDate"  },
         13 : { sorter: "shortDate"  },
         14 : { sorter: "shortDate"  },
         16 : { sorter: "shortDate"  },
         17 : { sorter: "shortDate"  },
         19 : { sorter: "shortDate"  }
       }, 
       widthFixed: true,
       widgets: ['zebra']
    }); 
  });

Btw, guess how I knew that I needed to use the “shortDate” keyword? Because I looked at the tablesorter.js code naturally. Initially I tried “date” but of course that did not work. Next I stared at the online documentation for 20 minutes before I decided it was pointless, so I just downloaded un-minified version of the script, and scanned through it looking for parsers and their names.

Tablesorter is a great plugin, but it really could use more in-depth documentation. While I was digging around in the code, I decided to write down the names of all the parsers for future reference. Here they are:

  • text
  • integer
  • currency
  • floating
  • ipAddress
  • url
  • isoDate
  • percent
  • usLongDate
  • shortDate
  • time

The auto detection in the script works pretty well most of the time. It can however fail for simple reasons such as blank lines. I’m surprised that the list above was nowhere to be found on the page. Oh well… It’s here if you need it.