FlameSauce

Carl Crowder’s blog

Ok, say you’re writing a website. You have a layout, possibly planned on paper, possibly just in your head. I imagine it has columns. And those columns probably are a similar height. Unless you memorized a variety of niche CSS functionality, and can flex your float-fu, you are pretty much going to, at some point, think “fuck this” and use tables. If you don’t write a lot of websites, that’s a justifiable response.

The thing is that tables Just Work™ and it’s a hell of a lot easier because tables usually work in all browsers to enough of an extent that you can forget about CSS hacks to fix the other stuff.

CSS purists will scoff; they will say that the layout belongs in the CSS, the content in HTML. Table-based design crosses that line, and it’s bad. Not that the end user gives a shit but whatever. It’s not best practise.

To that end, I’m glad to see that the whole problem has been addressed by inserting table-based layouts into the CSS spec.

Now, instead of writing

<table>
  <tr>
    <td>thing 1</td>
    <td>thing 2</td>
  </tr>
</table>

you can change all of that to DIVs! Then, in CSS, you say it’s a TD or a TR. Woo!

Glad we sorted that one out.

  • 0 Comments
  • Filed under: Uncategorized
  • Things I Hate part 3

    People who use “lol” as punctuation:

    “wot r u up to today lol”

  • 2 Comments
  • Filed under: Uncategorized
  • Things I Hate part 2

    Paying a dentist £45 to inflict pain on me.

  • 0 Comments
  • Filed under: Uncategorized
  • Things I Hate part 1

    TV shows where the scientist / programmer explains something and the main character says “I don’t care how you did it, just tell me”. With not so subtle subtexts of “You damn nerds aren’t cool enough to be part of the story.”

  • 0 Comments
  • Filed under: Uncategorized
  • Hooray for another exciting chance to watch overpaid, average players serve up some insipid, uninspired drivel for us as England take on the Czech Republic tonight.

    In a week where it was announced that Frank Lampard would be receiving £151,000 per week for his ability to spank it high and wide of the goal, I finally realised that I can’t stand watching the England international football team. Posers and also-rans to a man. Bah.

    DPsychoS” on the BBC football blog summed it up in a comment perfectly (comment #30):

    “Are these players really worthy of our attention considering what we have seen over the past 2 weeks. There we have seen Olympians with not much money and depending on their families to survive and still bring in success while these footballers swim in their own money and bring in poor performances. Its becasue they do not care while the Olympians do.

    It has been said that the money goign into cycling sailing and rowing has reaped the rewards. Well with all the money the FA have, surely not only should England qualify but win every tournament every time.

    It will be a boring draw and the players will have their excuses ready.”

    Quite.

  • 2 Comments
  • Filed under: Uncategorized
  • Pietersen? No!

    Apologies for people who read this blog who don’t care about cricket. You will probably want to go read something else right about now.

    For the other (ie, Ian), I say this: Pietersen is not captain material.

    Vaughan should never have stepped down. He is tactically aware, magnanimous in victory and frank in defeat. His ability with the bat has been called into question recently but so what. Who will replace him?

    Strauss is short of runs and form. He may get better with the captaincy, but it’s a gamble.

    Flintoff? Disgraced when falling off a pedelo at the world cup and showed his inability in getting thrashed 5-0 in Oz.

    Robert Key? Apart from 221 against the Windies, he averages 21 in test cricket. Aside from that, how can he get the respect of the rest of the players from the off?

    Collingwood? “Resigned” the ODI captaincy. England need more people like him but it seems he hasn’t got enough flair.

    Alastair Cook? Too young, too inexperienced. Has he ever been captain?

    But Pietersen? He’s all ego. The South Africans have sussed that out, and everyone else will. He puts himself in front of the team. He has no awareness of field settings, he’s to impatient to, for example, grind down the oposition with spin bowling and accurate pace bowling. He has one method: attack. And that won’t be good enough to win matches against anyone.

    I’m sorry but there’s noone to replace Vaughan and that’s the main reason he shouldn’t have gone.

  • 7 Comments
  • Filed under: Uncategorized
  • Comment your damn code already

    There’s been a few posts recently extolling the virtues of terse, or indeed non-existent, comments in code. Apparently, if you need to comment your code, you suck as a programmer because you can’t handle writing clear, concise, self-explanatory code.

    I call bollocks. There is one extremely important reason for commenting your code which is this: you comment what your code is supposed to be doing, then you write the code.

    It’s much easier to write a sentence explaining what you plan to do than it is to write the code to do it.

    Once, I was debugging some code that a colleague of mine wrote. It came down to a constant, where he wanted to do something every 30 minutes, using this:

    private static int WAIT_FOR =  1945800;

    Which is 30 * 60 * 60 * 1000 - ie, 30 hours. It took me ages to work out what was wrong. It would have been helped a lot if a comment had explained what the constant was for! Ever since that, if I have a constant which deals in time, I comment it saying “30 minutes”. If I screw up my math, at least the comment says what I meant.

    As another example, I recently tracked down a bug in Hibernate. I spent ages finding it, and when I did I was only half certain. The code didn’t have comments documenting its intention, so I wasn’t 100% sure of my fix.

    Similarly, there is a bug in Javassist related to Java 1.6. stack maps. I think I know what’s wrong, the fix seems simple, but because they have no comments at the particular point of the bug, I don’t know if my fix is right or if the bug is elsewhere. By not explicitly documenting the intention, bugs become harder to understand.

    It’s entirely possible to overdocument, I agree with that. For example:

    public int getCount() {

    return count;

    }

    That’s obvious what it does, and you don’t need a comment really. Why say “Returns the count”? It’s stupid.

    Comments as a list of steps in the method are a good thing - for one, it’s easier to read comments than code, and it’s also a nice verification of what the original coder meant. Documenting intentions makes your code much simpler to anyone who might have to maintain or debug it down the line, with no harm to yourself. Just do it.

  • 11 Comments
  • Filed under: Uncategorized
  • Java Web Start sounds like a nice idea, and it is: allow people to download and install apps through their browser, but which don’t run within the browser. It’s similar to Zero Install, in a way. As Java applets have a default memory limit of around 96Mb, it’s very useful for larger applications, especially 3D graphics ones which use jMonkeyEngine.

    There is already a tutorial on the jME site to get your app going in Web Start. This wasn’t around when I tried to get this working! There are still a few gotchas I encountered when trying to get it going which they don’t mention.

    1) Signed jars

    Apparently, the LWJGL jar is no longer signed by default. My version was. You can include separate JNLP files to separate jars signed with different keys but I found Web Start barfed a bit. Eventually I just unsigned all the jars and re-signed them with my own key. See my previous post about how to unsign jars.

    2) Native library path

    They don’t mention it in the tutorial, so perhaps it’s not actually an issue. However, I distinctly remember spending ages trying to work out why the app wasn’t able to find the native libraries I packaged with it. By adding this line:

    <property key="java.library.path" value="." />

    it worked. No idea why.

    3) Put the jar with your app in at the top of the resources list

    The main class specified in the “application-desc” section is searched for in the first jar referenced in the “resources” section - if you don’t put your main jar first, it won’t find the main class and will die.

    4) Request all permissions

    Make sure you specify

      <security>
          <all-permissions/>
      </security>

    to get permissions to read and write to disk and access the hardware. If you follow their tutorial you will probably have just cut and paste it, but if you write your own JNLP from scratch, make sure you remember it or you will get all sorts of “OMG NOT ALLOWED” errors from Java.

  • 0 Comments
  • Filed under: Software
  • Unsigning a Jar

    In order to get privileged access to the filesystem or other system resources when running a Java program as an Applet or a Web Start App, you need to sign the jar files containing the code. There are plenty of explanations of how to do this on t’interwebs.

    However, the signing tool doesn’t seem to have an option to unsign a Jar. WTF? Is it the case that noone in the history of Java development has signed a Jar in the wrong way and needed to try again? Or does everyone just go “oops, oh well, I’ll generate a new jar”?

    Recently I wanted to deploy a Web Start application using jMonkeyEngine. It uses the light-weight Java gaming library (LWJGL), which uses native libraries to access the graphics card. The lwjgl jar I got was signed already so that you didn’t need to bother with that. However, I needed to include my own signed jars for different reasons.

    If you try and run a Web Start app with jars signed by a mixture of keys, it bitches at you and refuses to start. I tried various workarounds but I couldn’t get it to work; eventually I decided to just unsign the sodding jar and sign it myself.

    When you sign a jar with a key with a particular alias, say “fred”, it creates two files in the META-INF directory of the jar. One is called “FRED.SF” and one called “FRED.DSA” (or whatever your key name is). It also adds lines to the MANIFEST.SF file with a list of class names and hashes of the contents. If you want to unsign the jar, you just need to remove any .DSA and .SF files, and the list of hashes from the manifest, and lo! it is done.

    If you’re lazy, here’s a bash script which will do it for you: unsign. Simply call it with the name of the jar you want to unsign.

  • 1 Comment
  • Filed under: Uncategorized
  • I use Thunderbird as my mail client, and also as my RSS reader, cos it’s pretty funky. One of the benefits of it, just like Firefox, is that you can install extensions to add functionality.

    Recently I installed enigmail to be able to read the encrypted emails Seb, James, Helmy and Svend kept sending me. During setup, it made some changes to my config to allow it to process the mail correctly, and one of the things it did was to stop my RSS feed entries from rendering as HTML for some reason.

    There’s not an obvious setting to turn this on or off in Thunderbird as far as I can make out, and I couldn’t spot many posts on the intertubes of people having the same problem, so I’m not sure if it was just an isolated case.

    Anyway, here’s how I fixed it: open up the preferences dialogue ( Edit -> Preferences in Linux ). Click the “Advanced” tab and click “Config Editor…”. You’ll get something similar to about:config in Firefox.

    Type “mailnews.display.html_as” into the filter, you should have one result. Change the value (by right clicking and selecting “modify”) to 0. From now on, when you click an RSS entry in the reader, it should display as HTML again.

    See here for a list of the values and what they mean.

  • 4 Comments
  • Filed under: Stuff