Archive for November, 2008

Two Programming Polls for the Weekend

Friday, November 28th, 2008

Fridays are usually reserved for my entertainment/fun stuff posts and I was initially supposed to post a review of something or other, but I got lazy. So instead I decided to to a poll. It is also a nice choice for Fridays because it will stay on top of the blog for 3 days allowing it to gather more responses until it is pushed down and off the front page.

This is a tech related blog (well, more or less - I tend to branch out more and more) and I have tons of very technical posts here aimed at software developers, and talking about particular programming languages. I know that not all my regular readers are programmers though. I also know that I have some regular readers who never, ever But it would be nice to see what kind of languages are people who visit here using on a day to day basis. I think we did something similar before but not in a form of a poll. This time around I want to know what language you actually use on a daily basis. The stuff you use for work. We all have favorite languages, but these are not always the ones we use at work. So tell me about the language you need to use for better or for worse right now.

I'm currently coding in:
  • Add an Answer
View Results

Please be nice with the write-in option. If I see too much of Chuck Norris I’m going to disable it. Use it wisely!

Done? Ok, now tell me about your favorite language. The one that you wish you were using at work. Your go-to language for all side projects. Or perhaps the language you wish you had time to learn better. I want to see if the two polls sync up significantly or if there is a wide disparity between them:

I wish I was coding in:
  • Add an Answer
View Results

Unfortunately my sample size is pretty small as most polls get under a 100 votes so we might not see any interesting patterns emerging out of this exercise. But there is always a chance that by some random fluke Digg or Redit will bubble this up to the front page and we get more votes before the server catches on fire and melts down. So digg me up if you can!

Oh, and if you are not a programmer and you don’t plan to be, hit the polls too so that I can see comparatively how many people come here for the off-color humor and randomness that I seem to deliver in between my programming related posts. )

Happy Thanksgiving

Thursday, November 27th, 2008

Happy Thanksgiving folks! Today’s post is postponed due to laziness and family related activities. Also, I need a better Thanksgiving meme to post here. In the meantime here is the good old Sesame Street one:

sesamestreetthanksgiving.jpg

Happy shopping tomorrow! I’m sleeping in - fuck Black Friday.

Hmm… I guess I owe a word of explanation to my international viewers. You probably know what Thanksgiving is, but if you didn’t I just linked to a wiki entry that should explain it. Black Friday on the other hand is the traditional first day of the Christmas shopping season and most US stores like to do major promotional sales to attract shoppers. A lot of people get up at 4AM or earlier hunt for best deals and beat the crowds. In other word madness!

Madness? This is Spartaaaa!

That’s why I’m sleeping in - I don’t want to get kicked in the chest by a sales hungry housewife.

Anyways, we shall return to regularly scheduled programming tomorrow!

Free Email Services Look Unprofessional

Wednesday, November 26th, 2008

I can’t help it, but every time I see a yahoo or hotmail email address on a resume, or a piece of official correspondence I cringe. It just looks incredibly unprofessional and tacky! I’m sorry if that offends you in some way but its true and I’m pretty sure I’m not the only one who thinks this way. If you know any recruiters or HR people, ask them about it. Some probably don’t care, while others will probably agree with me. It’s a turnoff! It makes you seem cheap, even if you try to be all business like and actually sign up using your real name rather than a nickname of some sort. Most people these days know better than to put their HotStuff69 or TheRealGangsta email address on official documents but it happens too.

I use Gmail for my personal mailings but I feel the same way about it too. If you put it on a resume, it looks tacky. Yes, I understand that there is a notable difference between a typical hotmail user and a typical Gmail user. The later tend to be more clueful as a rule. Possibly because Gmail was for the longest time an invitation only service. Even now it employs a non-standard, more involved sign-up procedure that gives them a bit more control over their user base. So while Gmail address is slightly more tolerable, it is still frowned upon (at least by me).

Don’t think that you’re off the hook Mr. @comcast.net amd Ms. @optonline.com! The fact that you actually figured out how to use your ISP’s email service just means you are a tiny bit smarter than the average internet user. You see, most of the folks out there sign up for free email services because they can’t figure out how to access their ISP based mail, or they don’t know they have it. Its great that you have figured it out, but it is still not your email! It belongs to the people who sell you your internet connection. It does not represent you, and you should not use it.

There are 3 types of emails I consider appropriate for resume’s and official correspondence and/or paperwork:

  1. Business email, but only if you own the company or are representing it company in some capacity.
  2. School (.edu) email but only if you are a student, faculty member or a recent graduate.
  3. Non-free, personal email from a domain name you own - but only if the domain includes your name.

And yes, it is a little bit restrictive. For example, putting your current work email address on your resume while you are out job hunting is probably a stupid idea. Not only can it get you in trouble at your current job (but since you are looking for a new one, then you probably don’t care) but it also shows prospective employee that you are willing and able to use company resources for personal business. Probably not the impression that you want to give to a potential employer. That’s what I mean about representing the company in some capacity.

Then again if you are a one-man consulting firm, or a successful business owner the rules here are a bit more lax. In such circumstance using your company domain name may add weight and prestige to your name even if the matter at hand doesn’t directly involve your company.

School emails are fine, unless you have graduated like 6 years ago and you are no longer affiliated with the school in any way. Why the hell would you still be using their mail system at that point?

How do you make yourself look semi-professional when you can’t really use your work email, and you are not a student? Get a domain name. It looks 100 million times better when your email looks like yourfirstname@yourlastname.com, something@firstnamelastname.com or some variation on that theme. I do understand that all of the John Smiths out there might have trouble setting that up. But that’s the idea, and it looks very impressive and speaks volumes about your level of professionalism.

It does cost money, but not a lot. For example, if you go with Google Apps registering a .com domain will only cost you $10 a year. This works out to be less than a buck per month, and you get a full suite of Google applications including Gmail, Google Docs, Google Chat and Google Sites - all configured and ready to go. So you actually don’t need to pay for hosting and email. Just buy a domain name through Google and enjoy awesome personalized email!

No Google is not paying me to say this (I wish they did though). I just don’t think you can find a better deal at the moment. I mean, you can probably buy a domain name for roughly the same price from Godaddy or NetworkSolutions or wherever. But they will charge you extra for the Whois anonymisation (which Google does for free) and you will still need to buy some email hosting service. If you go through Google it’s all free, and it works “out of the box” (so to say). It’s no harder than signing up for Yahoo or Hotmail - but you get so much more out of the deal. Not to mention that IMHO Gmail has possibly the best Webmail interface out there.

For me, registering your own domain and setting up a personalized email address is an investment. And it’s not just for you. If you actually get lucky and you can register your last name as your domain, you can easily hook up your whole family with super easy-to-remember accounts following the firstname@lastname.tld pattern. This way your friends and relatives no longer have to remember something as silly XxJohnSmith5691xX - in the end, everyone wins.

Serializing Javascript Objects into Cookies

Tuesday, November 25th, 2008

A while ago I mentioned that my school gives students and faculty Novel NetDrive accounts. This means we can all publish simple websites on their service, but get no server side scripting. This makes that space great for teaching students HTML but relatively useless for everything else.

O previously described how to get a semi-presentable website constricted without server side includes. This is a sort of follow up to that article showing you more tricks. The big issue you get working in a client-side only environment is persistence. The only way to accomplish it is to use cookies. So I set out to see what exactly can I store in a cookie.

It turns out I can store just about anything in there. For example the code below generates a Javascript object with few fields and functions, and then stores it in a cookie:

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
 
		var obj = new Object();
		obj.a = "foo";
		obj.b = "bar";
		obj.ab = function(){return this.a+this.b;};
		obj.show = function(){alert(this.ab());};
 
		var src = obj.toSource();
 
		$.cookie("testcookie", src);
 
		temp = $.cookie("testcookie");
 
		nobj = eval(temp);
		nobj.show();
	});
</script>

The toSource function does most of the work here. It serializes an object into a string which can be then deserialized using the eval function. Note that this will work on stand alone functions too, since in Javascript they are first class objects. Neat, eh?

I’m using Klaus’ Hartl’s jQuery cookie plugin because the native Javascript handling of cookies is it is retarded and error prone. It basically returns all the cookies you set as a single string containing semi-colon separated list. As you can imagine, retrieving serialized objects which are bound to contain lots of semi-colons can be problematic. Klaus’s code was not designed for this sort of thing but it uses the encodeURIComponent method to escape special characters. Which works out great because it escapes the ‘;’ character inside of the serialized objects making them easy to retrieve.

I probably don’t need to tell you that the example above is a very, very bad coding practice. You really don’t want to eval any code that might have been tampered with. Since we are storing our object in a cookie which can then be modified on the client machine, we are really opening ourselves for abuse. So while storing functions inside cookies is possible, I would not recommend it.

What you want to do is to serialize your objects into JSON, and the safely parse it back while making sure you are actually getting back JSON object rather than random code. There is a really good plugin that does this for you. So your code will look something like this:

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript" src="jquery.json.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
 
		var obj = new Object();
		obj.a = "foo";
		obj.b = "bar";
 
		var src = $.compactJSON(obj);
 
		$.cookie("testcookie", src);
		temp = $.cookie("testcookie");
 
		nobj = $.secureEvalJSON(temp);
		alert(nobj.a + nobj.b);
 
	});
</script>

The secureEvalJSON method is much safer than just running eval on arbitrary code. The pluging also has an “unsafe” eval version, but I would not recommend using it unless you can guarantee the cookies haven’t been tampered with (and in most cases you can’t).

There is a small caveat you need to keep in mind. The space you have to work in is very limited. Fore example, IE only allows you to store around 4KB of data per domain. This is not per cookie, but a total space you have for all your name-value cookie pairs. This means that sticking a huge JSON object (or many smaller ones) into a cookie just won’t work. IE will silently drop cookies that exceed this limit. So use this technique sparingly, and if you can, compress the data as tightly as possible.

Worrying Trends

Monday, November 24th, 2008

Video game market has two big segments. On one hand we have the console market (Xbox, Playstation, Wii) and the PC market. The console segment is doing great and is constantly growing and going through changes. Wii for example was able to capture whole new demographic for Nintendo (good for them!). PC segment on the other hand…

Well, it’s like this. DRM, DRM, DRM, FUCK YOU YOU THIEVES, YOU ONLY GET 3 ACTIVATIONS! Pretty much like that. Buying a PC game these days is like getting slapped in the face. Hi, thank you for shopping, enjoy your game and **SMACK** that’s for stealing you fucker. If I find my game on the Internets I will come to your house and rape your mom! Understood? Ok, have a great day now.

So we have this never ending debate titled “is PC gaming dead yet?”. I now argued both sides of this discussion. There are plenty of reasons to expect PC gaming to remain vibrant for years to come. On the other hand though, there are legitimate reasons to be concerned about it. I’m not going to reproduce these arguments here (go read the relevant posts you lazy bum), I just wanted to point out that there are valid points on both sides. Game market for the PC is still doing well, but that may or may not last.

pc_vs_console.jpg

Some people say good riddance. These folks gave up on video gaming on their PC, uninstalled Windows (I hope, I mean what other possible reason than gaming would you have to keep that horrid OS on your machine) and nowadays do their gaming from their living room couch. They tell me they are happier this way. They don’t need to deal with DRM, they can actually share their games with friends, rent them, or even sell them after they get bored. Selling video games! Imagine that. I almost forgot that this is even possible. I don’t own consoles, and I’m pretty used to the fact that games these days are locked so tight you can’t even play them on your PC.

These folks can actually go and buy used games at like half the price. Hah! We can’t even return the game back to the store if we don’t like it. But I do remember that I owned a PS1 back when dinosaurs still roamed the earth, and I did get bunch of brand new (less than 6 months old) games for practically nothing from the used game bin.

Perhaps the grass is indeed greener on the other side?

But it’s not. When you buy a console, you enter a locked down proprietary, tightly controlled environment. That means no mods, no trainers and no indy stuff. There is virtually no such thing as open video game engines and getting the Development Kit usually involves paying large sum of money, and swearing an oath of silence and non-disclosure. It is a very different environment to live in, and one that sort of frightens me.

Oh, and you know that awesome, vibrant second sale market for console games I talked about? You know, the fact you can buy used games dirt cheap, or sell your collection back to the store when you get sick of it? Well, the big boys out there have plans to seriously undercut it. You can read the slashdot article (or the original one if you want to be rebellious and prove you are not just another slashbot) but let me reproduce the gist of it here:

You buy a game and you get an activation code. You need to use this code to unlock parts of the game at which point it binds it to your console. But it’s not like the PC online activation crap. Oh no, these guys are so much nicer about it. They will even allow you to sell it back. It’s just that the next person won’t be able to play the locked parts of the game which might be, oh - I don’t know - the final boss. Or maybe everything but the first level. If you buy a used copy and want access to the locked parts you will simply have to go online and buy your own activation code for a modest price (eg. the price of a brand new game).

In other words, the console game developers re-discovered the shareware distribution model and are planning to use it to make the second sale market, which was bothering them since the day one, disappear.

So don’t tell me the life in the fairy tale land of consoles is so awesome. The game companies on that side of the fence are as greedy and as deranged as on this side. They just haven’t figured out the best way to rip you off yet. So the ball is in your court. Will you let them do this? Of course you will. It’s like telling PC gamers to boycott games because of DRM. Everyone agrees and then runs to the store to get the game, or downloads it. Sigh…

Am I surprised? Not at all. I sort of seen it comming. This trend started long time ago around the time when Bethsheda came up with the horse armor mod for Oblivion. I could not believe the actually planned to sell this stuff. Who would buy it? After all, you can make your own fucking horse armor in the editor. And then I realized that Xbox version ships with no editor and won’t let you use mods. Crafty, I thought. Very crafty. I wonder when this sort of thing becomes a norm. It seems that this time is coming soon.

It seems that no matter which segment of the video game market you belong to you will end up being fucked. I don’t get it. Where is this hostility towards customers coming from. This shit would never fly in any other place other than our little video game ghetto. Oh wait. Never mind. Music and movie industries are pulling stuff like that too, quite successfully lately. What is going on here?

Why do we let these companies fuck us over and over again. Why do we allow them to treat us like shit? What is it about digital goods that makes us believe that their behavior is justified? Because, let’s face it. It is our fault. We are allowing this to happen by giving these people our money. Can we stop? Please?