blog.autopsy.se

basically; it sucks. everything sucks. but.. in a good way..

Archive for October, 2008

my powersupply sucks! (really) but my friends rocks!

My server at home went down on Friday evening.. I guess it was the power supply or a power outage, probably the latter. However, it did not restart when the power went back on. I know I set the BIOS to start the computer when the power came back. But it did not.

So my very best friend went to my apartment and resetted the power, and it worked! Thank god! I would not managed without my server at home, neither would my colleagues..

posted by ube in Rants and have No Comments

my macbook sucks! really!

My MacBook has started to behave badly. I'm staying at a hotel for 5 more months (no it's not really nice) and the internet connection is NATed (free though). So I want to access my macbook from work. It's quite easy; just set up a ssh tunnel back to the mac. But the last two days it has frozen after I left my room. So this means that I can't download my tv-series to my mac from the office. Which means that I have to wait until I get home and my collegues starts downloding Swedish Idol which means that I just get about 20kb/s compared to 300kb/s.

I'm about to go and get myself a new laptop, probably a MBP or a MBA, haven't decided just yet. Luckilly I'm in Montreal where there is a Apple Store four blocks from the hotel so I can go down there and get a new one in a heartbeat. But I have to wait, no matter how much I want a new computer I'll have to see what's being released on October 14th..

posted by ube in Rants and have No Comments

validating user names sucks!

You know when you're writing any application, and you want to restrict the characters in the user name? Instead of checking for non allowed characters, look for allowed. Sounds strange? Not really, you'll understand:

function checkname($string, $allowed) {
$allowed = "/[$allowed]/s";
$string = preg_replace($allowed, "", $string);
if ( $string )
return FALSE;
else
return TRUE;
}

So what you'll do is remove all allowed characters, and if there are any left in the string the user has chosen an invalid username. Ofcourse it's regexp that does the trick. Using the code:

if ( ! checkname($input, "A-Za-z0-9_\.") )
echo "Invalid username!";
else
echo "Ok, lets go!

We're allowing A-Z, a-z, 0-9, underscore and dots in the username.

posted by ube in PHP and have No Comments

javascript and timers sucks!

Have been trying to get my head around timers in javascript. And I guess i know how it works now. My approach:

<script>
var timer;
function whatever() {
if ( timer )
clearTimeout(timer);
alert("you just wasted 15 seconds of your life..");
timer = startTimeout('whatever()', 15000);
}
</script>

and in the html:

<body onLoad="timer = startTimeout('whatever()', 15000);"> yada yada..

this will generate an annoying popup (if I made the example correct..) every 15 seconds..

Why I need this? Well, on tv.autopsy.se I want to update the search cloud continuously without having to do some reloads. And I also have a timer that waits 4s to insert data into the database for the search cloud. Neat, huh?

posted by ube in Javascript and have No Comments

“first post” sucks!

Standard first post..

posted by ube in Uncategorized and have No Comments