Suspend and hibernate in Linux

May 29th, 2010 Open Source

By Andrew Smith

Suspend and hibernate have been a sad story on Linux for a very long time. Typically the hardware makers are blamed, saying “oh they all do it differently none of it’s documented”. That may be true but it’s a bunch of horseshit anyway – hardly any of the hardware that works at all or perfectly in Linux is the same or is documented.

A couple of days ago I upgraded to Slackware 13.1. I left suspend as the last thing to set up, as it wasn’t working at all in 13.0 and barely working in 12.2. And you know what? It works now, it just works. I could hardly believe it. No messing with ACPI options, no hooks to remove my USB modules, no fancy keyboard configuration. I just press my FnF5 and it goes to sleep.

That was pretty impressive to begin with. And then I tried to hibernate. One try and I realised I needed an extra resume=/dev/sda5 in my lilo.conf. That one change.. and.. hibernate also works.

I am shocked. In a good way. Suspend is a must on a laptop and hibernate is really nice to have. Thanks, whomever fixed this!

For reference: I have an HP G50 and Slackware 13.1 comes with the kernel 2.6.33.4

Certificate expiry

March 24th, 2010 Open Source

By Andrew Smith

At some point in the distant past I’ve set up my own email server, running Sendmail for SMTP and the UWO imapd server for IMAP. Part of the setup process is creating certificates – so that you can have a secure tunnel for free, using self-signed certs.

Like a good boy I followed the instructions to the letter. Now I’m presented with a message box in Thuderbird saying “your certificate expired”. Eh? Why? Oh, I know – it’s because you’re supposed to have an expiry date on your own generated certs, because bla proper bla security bla I know better bla. I never got the bla bla part, never had any use for it. And now I ran into the problem I knew I would run into eventually.

Security, expiry? Did these guys think? I’ll tell you something – I can still get to my email using Thunderbird. It just puts up an annoying warning and makes me click continue every time. What sort of security is this expiration providing? If anything, security is worse now.

I must have created this setup a long time ago (likely 5 years) – because today I would never do something I believe is stupid just because someone “who knows better” said so. Oh I’m glad I made that decision.

Oh Google, WTF?

March 11th, 2010 Uncategorized

By Andrew Smith

I have to do research for school. I’ve been told many a time don’t use Google. Now Google is giving me a reason to be pissed off.

When the search results come back with PDF files – I don’t get to see the link to the PDF where it actually sits, the link I get is in this form:

http://www.google.ca/url?sa=t&source=web&ct=res&cd=3&ved=0CBcQFjAC&url=http%3A%2F%2Fwww.perforce.com%2Fperforce%2Fconferences%2Fus%2F2009%2FPresentations%2FCohen-CodeReview-slides.pdf&ei=XJWZS4-IMIGSNpSexHo&usg=AFQjCNE2L5ejvkMYs4RMS4mZu9v7nZO9iA

Are you joking? What is the purpose of this? Is it to make me google it every time? Is it to track when I click on the results? Did some asshole think this protects IP? Rather than reformatting that URL for my records I might decide using the library is easier.

Remember how good you are

January 12th, 2010 Safe For Seneca

By Andrew Smith

I’ve been reading about literate programming, and was reminded that most programmers don’t write comments in their code. Whether to write them or not is a question that’s asked all the time, in all circles – starting in school and all the way to teams of masters of the known universe like Linus (who I’m assuming is responsible for this).

In school I thought comments are good. I’ve seen a few people who felt the same change their mind once they started writing real software, and I was tempted to drop it myself, but I didn’t.

I’ve had the same arguments with myself that you’re thinking of now. Should I document design, exceptions, explain what complicated code does, go over the assumptions, etc.? This post is not about that, it’s about something I’ve realised a few days ago – a thought that may be slightly original.

Writing comments in my code makes me feel good. I’m not a design freek and my code goes through a couple of iterations before it’s even checked into version control, often followed by more restructuring when flaws are found. And then I write comments.

I look over a piece of code and think – what the hell is this doing, here? Oh – that’s to handle the weird case of an idiot unplugging the USB stick before it’s done. Comment. Man this function is long and hard to read. Several comments throughout telling a story (this being possible explains why it’s all in one function). Wow, at this moment I can actually grasp how the entire subsystem works – comments on top of the class and every function. Why is this a member variable and not a local one? Oh yeah, I remember – that’s bizarre but it works. Comment.

Did I manage to explain it? As I read my code I remember all the interesting, strange, unfortunate, and neat things I’ve done. And I write it down in plain english. I feel empowered when I can explain something that appears to be a terrible mess. I think this is why I still do write comments. And I know they’re useful because when I go back to my code a month later I can actually figure out what’s where using them.

Maybe it will work for you too?

APNG is still alive

January 11th, 2010 Open Source, Safe For Seneca

By Andrew Smith

I’ve been running my more-or-less regular backup of littlesvr.ca, and found that yet again the online APNG assembler data directory is the one taking most of the time. Turns out that even though I cleared it a few months ago there is over 4GB of PNG files in there (half of that – 5800 APNG files).

That’s really interesting – it means APNG usage has actually grown in the last year. Partly that might be explained by ongoing support in Firefox, but surely that’s not the only explanation. I don’t know what’s really driving the growth. I just know it isn’t me.

On the one hand it’s great that people took over (e.g. Max Stepin has been diligently maintaining the APNG patch for well over a year now) but on the other hand it’s sad that the project survived without me – I guess I wasn’t that important :)

I have been feeling sad about such things lately. I always do my best to bootstrap a project and then pass it on to someone else to maintain. This way I can keep doing new and exciting things while expanding the breadth of my knowledge and skills, and increasing the impact I have overall. But damn it’s depressing when I’m in between projects. I feel useless – not wanted and not needed.

Should I just accept that there is only so much one can do in a lifetime, and specialise in some irrelevant field? Become normal? What a dreadful thought.

Oh my god, don’t use plural forms

November 17th, 2009 Open Source, Safe For Seneca

By Andrew Smith

There is a magic thing called gettext. It’s magic because it allows some random Joe on the internet with no experience in programming to translate your application into his language. He does this by editing a .po file, then sends it to you, and you just include that file in your build system.

Ok there is some plumbing you need to enable that, but really it’s worth it.

In one of my applications I followed the advice in the gettext manual and used plural forms for messages. That is rather than saying “%d file(s)” the string had two forms: “%d file” (if %d is 1) and “%d files” (if %d is not one). This is specified in the po file like so:

“Plural-Forms: nplurals=2; plural= n!=1;\n”

msgid “%d file”
msgid_plural “%d files”
msgstr[0] “”
msgstr[1] “”

But of course different languages have different singular/plural rules. For example in Russian 0, 1, 2, and 5 have different plural forms. That means the russian translator has to figure out how this whole system works in order to translate strings with plural forms.

These translators are volunteers. That they do it at all is amazing. Having them read the gettext manual (which doesn’t have a lot of examples like it should) is disrespectful and unproductive. You will get fewer translations of not-as-good quality if you use plural forms.

I know, I learned this the hard way. One of my programs uses plural forms and another doesn’t. I have spent way too much time explaining to people how this works, and I am sure some of them ignored what I said and just gave me whatever compiles.

And believe me figuring this out isn’t easy. I mentioned the russian example – honestly I have no idea what the rules are exactly (who ever thinks of these things?) and I speak russian, and I maintain the application. How can I ask Joe random to understand this?

There you go. Use plural forms at your own peril. The gettext manual lies, plural forms are not a good thing and the problems they cause are bigger than the one problem they solve. I have just got a new translation, and guess what – the two strings with plural forms are untranslated. So I have to get a headache explaining this yet again, while kicking myself in the head for buying into the gettext dogma.

So this is why they top-post

November 5th, 2009 Safe For Seneca, Uncategorized

By Andrew Smith

In newsgroups and many mailing lists top-posting (putting your reply above the text you’re replying to) is a big no-no. You’ll get flamed even if what you say is very useful, constructive, and nice. I’ve never quite understood the zealotry, but I figured: whatever, it sort of makes sense – someone says something, and then you reply to it.

But in regular email I have noticed many, many people write their reply at the top of the message. Until recently I had no idea why.

Last week I got a Blackberry. It’s a nice device, but it has a really small screen compared to a computer. When you open an email on a smartphone, you want to read what matters (the reply in most cases) right away. Scrolling to where the reply begins is painful and very time consuming.

Hm, I nearly posted something educational rather than inflamatory on my blog.. Now if I can just find a way to write blog posts from my Blackberry I may actually post more than once per month. And don’t give me that retarded Twitter crap.

Easy but impossible way to get rid of spam

October 14th, 2009 Safe For Seneca, Uncategorized

By Andrew Smith

I’ve been pondering how one may be able to get rid of spam. Not just what comes into my mailbox, but most spam everywhere. And I found such a simple solution it’s amazing I haven’t heard of it before. But of course it will never happen, so that probably explains it.

Spammers rely on that sending even extremely large volumes of spam is nearly free. It takes some effort to find a nice relay and/or create a small botnet, but following that every message a spammer sends is free. I don’t have the statistics handy, but the ‘positive’ response to spam is something like one for every hundred thousand messages sent.

Now imagine it cost five cents to deliver an email. That means to send 100k of messages the spammer would have to pay 5000$, which would make the business not feasible. How easy a solution is that!

And yeah, I know – gmail filters all the spam for you, and the wrong infrastructure is there, and some people would actually mind paying 5 cents to send an email, but I think it’s a great idea anyway, even though it is unlikely to happen in this form in my lifetime.

Slackware 13 knows how I feel

September 15th, 2009 Open Source, Safe For Seneca

By Andrew Smith

Here’s a stupid post, it’s been a while. I’ve upgraded Slackware from 12.2 to 13.0 and now it is messing with me. Believe it or not the stupid thing knows when I’m annoyed and pisses me off even more. Here’s how it works:

Sometimes my pointer starts jumping all around the screen, for no good reason. That’s not entirely unexpected, I have a crappy wireless mouse – but sometimes it gets on my nerves. When it does the first thing I do is stop moving and breathing, to see if it moves on its own or it goes nutz. No, it doesn’t do anything when I freeze.

So I take it easy, and use the mouse for a few seconds normally – but then it starts messing with me again. I slam my hand on the table, put a firm hand on top of the mouse, and deliberatly move it down – and it’s like it dares me to slide it all the way off the table, the pointer keeps jerking back up. Repeat, same thing.

Hardware problem? I thought so too, and replaced the wireless USB mouse with a wired PS2 mouse. Same problem.

You’ll never guess what it was. Turns out Slackware 13 treats my Microsoft Sidewinder steering wheel as a mouse. So when I press the pedals, it moves the mouse. When I deliberatly move the mouse down I at the same time (without thinking) press the gas pedal, which moves the pointer back up. Great stuff :)

Stop giving out my email address you twats

July 29th, 2009 Uncategorized

By Andrew Smith

Some people don’t get this, and they’ll never read this blog post, and there are too many of them to contact individually, so this is just me complaining with no purpose.

When I give you my email address – I give you my address. I only give it to people because I have no desire to filter spam manually, and I have an even lesser desire to have automation delete important mail.

It’s ok if you share it with someone who would like to get in touch with me. It’s not ok to put it into any website that’s not a webmail. I recently got an invitation to facebook. Now facebook knows my address, and I have a feeling some place somewhere it publishes it, or it gives it out to third-party marketers. Or maybe facebook is unusually nice, but you get my point. Do you know what happens as soon as an email address is available in plain text on a public website? I get start getting spam, that’s what.

I have disposable addresses – asmithXX and I bounce the number whenever the ammount of spam becomes unbearable. It does happen. my asmith15 (which is published all over the net on mailing list archives and such) now gets 200 spam messages a day, I stopped reading it completely.

Why do you have to fuck up the one address that doesn’t have a number, the one address that cannot be changed unless I change my name? You insensitive pricks.

Yes no kidding – I feel strongly about this. But no, this isn’t the only thing bothering me right now. Expect another post once I figure out how I can express my dissapointment without giving out any details I would rather keep to myself.