Encoding Mail Subjects Properly When Sending Mail With PHP

It is one of the most common bugs in Russian web applications. Nowadays coders do not forget to add Content-type header to mail messages, but many of them forget (or don't know) that this header affects he messag body only. They think, if they specified proper encoding for body, mail client will use it for Subject, too.

Which is totally wrong, of course.

I am speaking about Russian developers, because I only receive mail in Russian and English, and English messages for obvious reasons do not suffer from this problem. I'm sure that other languages suffer as much as Russian do.

So, enough dull talk. What should proper mail Subject be? If encoded if consists of the parts separated by special characters:

=?{original text encoding}?{encoding method}?{encoded subject}?=

So, if you want, for example, to send mail in UTF-8, your message subject should be converted like that:


Do not do other people's mistakes.

(Use their experience to make your own ones.)

Nov. 02, 2007 // 14:01 | Comments (0)

Major Changes, or The Song Remains The Same

I've been saving this for one of those Fool's Days, but it actually came true. Remeber me “complaining” about not getting office job and been stuck to freelance?

Right! I got the job. The very same one that I didn't get in August. The guy they hired instead of me then didn't appear to meet the requirements, so they contacted me again. Oddly enough, I received another proposal at the same time. I even talked to the second company, took their test job, finished it and sent back (they didn't reply, however), but it was something about Windows, AutoCAD, Visual C++ and lots of other things I don't really want to mess around with. I've forgotten my umbrella at their office, by the way :-)

So, now for almost two weeks already I work in a local web hosting company. Our (wow, apparently, it feels pretty cool when you say say “we” talking about your company) website is completely in Russian, because we are targeting Russian customers only, though, with got one client from Greece, as far as I know. In fact, there are only two people busy with hosting here: we are a part of bigger company. I'll tell you more about the company later as there's just not too much to say right now.

I promise to summarize my impressons about working in company and freelancing when it will a month since I started working: at November, 19.

And I'm not going to quit freelance. I'll just freeze it for a while and get back to it later, in smaller amounts, of course.

As new job consumes significantly less time and there are more interesting and challenging work here, I hope I will post articles more frequently hereinafter. I'm still what I am – a web developer and Unix admin, so more work – more experience – more articles.

See you soon.

Oct. 31, 2007 // 21:34 | Comments (0)

The Hell of Non-Self-Documenting Code

There were a lot of buzz about self-documenting code a while ago, and there will probably be much more. I'm not that big fan of it (neither am I a fan of anything but music), but it is really helpful sometimes.

Do you hate lack of documentation as much as I do?

Plenty of languages are more self-documenting than they seem to be. On the other side, the thing that seem self-documenting, aren't always like that.

Take php. Imagine there's a torrent tracker software written in php:

function announce($passkey, $info_hash) {
//plenty of code here
    return bEncode($resp);

Pretty obvious, isn't it. Sure. But.

But what?

It is so obvious only if you use some framework to route HTTP requests to your classes and methods. It that case yes, any (awaited) GET parameter has a corresponding function argument, and you can easily see what is passed to /announce.

But what if the application is built like “old-style”: one atomic action – one file? I have to admit, that this style has it's advantages, among some weaknesses.

The worst thing about it is that you have to document it. If you don't – you forget what should be submitted to this particular script. Or, if you remember, a serial killer who reads your code, doesn't know what input does this piece of code wait for.

Use MVC frameworks if you are too lazy to write comments. Please!

Oct. 06, 2007 // 05:17 | Comments (0)

GetAFreelancer Introduces MasterCard Debit Card Payments

I have never taken GetAFreelancer (GAF) too seriously. Most projects there are “clone a site”, “data entry”, “register XXX gmail accounts”, or just the projects that aren't interesting or too cheap for me.

Yesterday GAF did something that a) makes me treat them as a more serious company; and b) lets them attract more possible service providers and, consequently, buyers. The concurrency is good for a professional (I already have a draft of article about that, will post it sooner or later), so I guess, I'll pay more attention to jobs listed there.

GetAFreelancer debit card

But let's get back to the point of this blog post. GetAFreelancer announced that they partnered with Payoneer and will now provide pre-paid MaterCard debit cards for their payments. I couldn't find any commission charges mentioned on their site yet, though. Probably there'll be just regular payoneer commission on every withdrawal.

Anyway, that is great news. While RentACoder promises to start iKobo (another pre-paid debit cards system) payments for more than a year without any result, GAF intoduced this kind of payment. Probably that will finally make RAC move.

Sep. 11, 2007 // 01:52 | Comments (2)

Illusion Of Overworking

I've actually written this article a couple day's ago, but due to changes in my blog engine I tried to make, it was lost (yeah, I'm a loser, I know it) and I didn't want to type it again at that moment. But finished all the work for today, read lots of everything and still sleepless, I decided to try to post it again. Wish me good luck! Well... at least some luck, please!

We love so much speaking of been overworked and underpaid.

I work so much and so well! I should have been paid more!

And, hell yes, we love speaking of our families who do not value your work.

I work so much to give them everything! Why don't they understand, I'm working now! Do they really need to bother me so many times a day? I do that for them, and they cry for attention!

Recognize yourself?

Are you really that busy? Yes, I know that myself. I am, too. Are you tired? Sure! Staring at your monitor all day round! Oh, our poor red eyes!

Are you tired of working? Are you sure? Are you really working? How do you spend the day?

Checking email every 10 minutes. Updating rss feeds four times an hour. Endlessly reading and commenting and writing and surfing and downloading and searching for something else to download. A lot of time. And your eyes! And your neck! And your spine!

Updating your software. Every single day. Every single piece of software you use and some pieces that you used only a couple times and even a few pieces you never ever used! Then googling and reading and commenting and reading again to solve problems appeared after upgrade. Your eyes. Your nerves. Your fingers!

Chatting with your good old friends online. Yeah, yeah, they're friends, you need them, they need you, you're having fun. You should be relaxing, why do you pretend you're working?

How much time do you really have for your actual work after all those things? That's why you work so much and get paid accordingly. That's why your family scream and should and want you to turn you face to them.

So please, guys, STOP fooling me and yourselves. Work, bastards! If you need more money, work more and better and for those who can pay more.

Work when you have to work. Do not pretend you're working when you're not. Kiss your wife or girlfriend. Don't miss your son's first step and your daughter's first wedding.

When have you seen your parents last time?

Aug. 14, 2007 // 05:50 | Comments (0)

Prototype.js Effects May Fail in New Firefox

<Update> Please, excuse me for too much buzz. The problem was actually with changes in CCS I made. at the same time as I updated Firefox. I couldn't even imagine that problem could be caused by that, as i just added a couple classes that DO NOT interfere with damaged page in any way. I was mad when I found it.

The CSS provided by some designer I don't know (my cliend hired him to make layout, and I received ready-made layout from my client) and he's a damn lucky guy. Sometimes I want to kill all the lame coders. The only thing that stops me is upderstanding that I also do lame things more or less frequently.

I am very thankful for feedback provided by everyone who commented this article and especially to jQuery developer Rey Bango who contacted me directly. Sorry again for misspelling your name, Rey!

The original article follows. </Update>

There is a feature in called Spy at one of my sites. It was inspired by digg's spy and, in fact, I borrowed some code from there.

TorrentMan Spy was introduced more that a year ago and worked nearly flawlessly until now. Two days ago everything was fine, but today my client reported a bug at that page: instead of moving “endless tape” of items the items just desappeared one by one untill the page was empty. Firebug shown a lot of errors around the line 1300 of prototype.js, mostly too much recursion at 1294.

My first reaction was: “Who is that son of a bitch who made changes to production scripts behind my back?”. Then I saw all the related files intact since last summer and reminded that I've updated Firefox to just yesterday. And so did my client.

A few breakpoints helped me to locate the root of all evil. I have a code like that to make new item appear at the top of the list:

newItem.style.display =  'none';
spytable.insertBefore(newItem, oldItem);
new Effect.Appear(newItem);

Stepping in i finally came to that to much recursion error at line 1294.

I'm unsure yet if it's a bug or a feature, and if it's a bug I don't know yet if it's my bug or prototype.is'. I suspect it could be my bug, as I'm not a big JS Guru, and digg spy still works flawlessly, though it uses older prototype.js and FadeIn effect instead of appear. I had to turn eye-candy off until I fix it.

If it's really a prototype.js bug, I'll file a bug report and write more here.

Check your javascript, don't leave your users one-to-one with broken pages.

Aug. 02, 2007 // 17:51 | Comments (7)

RentACoder Criticism

When I used RentACoder, I only worked on relatively small projects, mostly fixes to someone else's unprofessional work. And found my best client (and just a great guy, too) there, so I never had any complaints abot RAC. I could never say or even think that RentACoder is bad or unfair.

I haven't, but someone definitely has.
Someone kamen in his Be Wise With RentACoder blog gives lot of critisim to RAC, talking about unfair large projects management and spamming Technorati by RAC staff.

I can't tell you if those things are true or false, it's up to you to decide. I just try to show you both sides. Anyway, you should be wise with everything.

Jul. 25, 2007 // 18:13 | Comments (16)