PC Nerding

The cheapest JS URL shortener ever

After my previous article about shortening urls using htaccess, today I’m posting a little JS snippet that will allow to shorten urls, using a JSON array to store shorter and longer urls. The script will look in url parameters for a short url and redirect to the associated longer url. Have a look:

<!-- // Function declaration
function shorturl_redirect() {
	// This JSON array contains all the shorturl/url pairs
	var urls =[	{ "shorturl":"?lndm" , "redirect":"" },
			{ "shorturl":"?example" , "redirect":"" },
			{ "shorturl":"?twitter" , "redirect":"" },
	// Get the url parameter
	var shorturl =;
	// If there's no url parameter stop script execution
	if(!shorturl || 0 === shorturl.length) { return; }
	// Now the function will look though urls array and if a valid shorturl is found it will redirect the browser to the longer url
	for(i = 0; i < urls.length; i++) {
		if(shorturl == urls[i].shorturl) {
// Function call
// -->

Now for an example, if you point your links to or the script redirect your browser to this site homepage.

Some quick notes:
- It will work on any hosting/subdirectory/webpage/cms/browser combination, unless the visitor is actively blocking JavaScript (eg. NoScript plugin on Firefox). All php cms still need to be fully loaded by the hosting environment before serving the script.
- I suggest placing this snippet (or .js file) between head tags, ideally you want the browser to stop loading html and go to the provided link.
- You can wrap the code into a JS anonymous function, since the code needs to be executed only once.
- The script is really small in size: the above example is only 834 bytes including comments. Byte size will vary according to your array size and url lenghts, for example I made an array with 50 entries and it was 5,3kb.
- It does not require additional libraries, eg. jQuery, or additional url shortening services, eg. or Yourls.
- Depending on the behavior you may want, you could change window.location.replace with window.location.href . For more information read here.


One note about the Windows Phone store

(title pun was intended)
TL;DR: It’s awful. With almost no official apps, crap alternatives and lots of copyrighted stuff.

A the beginning of this month, due to a good offer and my lack of self control, I bought a Nokia Lumia 630. I was an avid Android user until something like a couple of years ago, then I just bored myself out of this idiotic mania and right now I spend 90% of my phone time calling or texting and the other 10% using GPS or browsing the web for a quick info. I don’t usually play games, I don’t listen to radio or music except maybe 3 or 4 song monthly on Spotify. I know you don’t care about me and I’ll get to the point.
It’s the worse store I ever seen in any device. EVER!

Remember that iPhone ad where the speaker goes “need to sync your calendar with your microwawe? There’s an app for that!“, I’m taking this to the extreme, but you get the idea. This same ad may cover Android devices, too. But when it comes to Windows Phone, it’s the total opposite.
Once you start searching or browsing the app store, you’ll soon realize how much the developers and Microsoft itself didn’t care about this store.
There no official apps for what one could consider daily use apps, like YouTube or dropbox. Oh, little correction, there’s official an app for YouTube which really looks like a browser shortcut to the mobile version of this site, as opening YouTube inside IE looks and feels exactly the same.
There are really no browser alternatives, all the browser in the store are built on top of the provided IE and all of them MUST allow ads, but that’s Microsoft’s fault because of some corporate war bullshit.
Thanks to this same corporate war bullshit you get absolutely zero official Google apps: no gmail, no gmaps, only a crap Google search tile. Fortunately the builtin mail app works with gmail and Nokia’s Here Maps works great, and there are some alternative apps for both Google’s Mail and Maps, called metro mail and gmaps respectively.

But the best part of this store is it’s half assed piracy. Sounds like I’m telling you a joke, but it’s not.
You can search for chrome and you will find a browser called Google Chrome, using Chrome’s copyrighted logo and filled with ads, made by some random guy. Like the other stores, there are some console emulators, but with quick a look in the most played games section of the store you will surely find apps for Metal Slug Advance and different Pokemon versions (all from GBA era), which clearly use an “app” excuse to package an emulator and a rom. Microsoft developer and app policies states that apps that violates copyright are not allowed and will not pass the app validation process, and while most emulator are/may be legal, rom distribution is not. But obliviously they don’t really care, they seems to allow all of this, this way MS can claim they have over 300k apps without looking ridiculous compared to iOS and Android 1M+ stores. I know in those 1M apps there is an huge pile of shit but at least there are some great apps for every need, in Windows phone store as of now I only found the huge pile of shit and only an handful of quality apps.
To this day I still haven’t found an app that allows me to access a file on a samba/cifs share and open it with another app (eg. playing a video from a NAS), on Android this worked quite well since the 2.x era, while a Windows Phone still misses the possibility to access a Windows share (or any other kind of share, for that matter). This may be an OS limitation rather than an app problem and I hope MS will find a solution soon.

While Microsoft doesn’t seem to care about it own store, I have to say something about Microsoft made apps: they work great. Included maps app work flawlessly, Internet Explorer is fast (but competition does not exists, so one can’t really compare) and works on every site I tried, from how little I used Office it seems to work well, MS Authenticator can be used exactly the same way as Google’s one and MS/Nokia camera and ocr apps really do wonders compared to Android ones.

In conclusion the phone and the OS work fast and as intended when using basic smarthphone features (messaging, quick browsing and navigation) thanks to the builtin apps, but when you need a quality app or something more advanced you are completely fucked. A revisited slogan for WP could be: “Need to —? There’s no app for that and if there is it’s complete crap. Fuck you.”.
I’m ok with this shitty OS, but if you are an Android or iOS user, the ones who like to have an app for everything, I won’t recommend a Windows Phone to you, unless you don’t care about ditching some features.

PC Nerding

Reading white text on black background

This will be a quick post.
If you, like me, really can’t read white text on black background (or can’t read purple on slighty darker glittering purple. Yes, I’m talking to you, MySpace nostalgic!) I have a quick solution for you: don’t and avoid headaches . If a site has a crap color setting, you probably can find the same copy-pasted content on other sites. If can’t find the same content on properly colored sites, use the awesome Web Developer Toolbar, available for both Firefox and Chrome (Opera too, in case your are looking for other NON-IE alternatives 🙂 ).

Once this plugin is installed and activated a new toolbar will appear. From there open the Disable menu and activate the Disable Page Colors option. Et voilà! Everything will transform into a bland black text on white background. Don’t let a bad developer decision turn you down on content!