Pages

Monday, August 14, 2006

Gallery effort - not of coding importance

I decided to throw togather a page that contained the collection of my capes. Funny thing is that I haven’t taken a picture of me in all of them.

There is a also a picture of me with my star on, which I “earned” at work the other day.

I figured if you were going to make a fool out of yourself online, you better do it properly.

I’m also just started some meaningful categories. I don’t know if I should go back through my posts and fix them up.

-= Comments
1. Andrew B Coathup | August 14th, 2006 at 7:51 pm
If I was recruiting and googled your name (along with Swinburne) it would bring me to Byte Club (well a cached copy of the forum) and eventually pictures of your cape.

(I always do this for prospective employees, finding nothing is worse than nearly anything you can find)

I would laugh, and think this guy is a bit of a nut, but I would read your blog and you would have already created a positive impression.

Get the rest of your photos up.

2. pimaster | August 17th, 2006 at 12:50 am
I’ve had a lot of different views about acknowledging the cape. The guys at Herald and Weekly times would say that it is something that I would have to discuss, because that is who I am.

I had a long discussion with someone from Telstra, who said that it was like sleeping with a teddy. It’s something you did when you were younger, but you should grow out of it.

The funny thing is: at the time I had just bought my code monkey which now sleeps at my bed head. And I divulged this information and he wasn’t impressed again.
I tried to ask why you would stop doing something unless you had a good reason. If wearing a cape or sleeping near a monkey puts a smile on your face every now and then, why stop?

There is also the other thing: It is who I am. If I stop being the "hero" I enjoy being, what is left for me?

I’m glad you approve of the move. For future reference, if any prospective employer comes across this comment, if you don’t like me in the cape then the chances are that I wouldn’t like the environment that I’d be working in and this blog has saved us both a lot of potentially wasted time.

Tuesday, August 8, 2006

Stupid spammers

Sorry people. Looks like my account has been the target of some spam lately.

I have upped the rules on commenting. Hope I haven’t caused too much pain in the latest comments list

-= Comments
1. Matthew Delves | August 7th, 2006 at 11:32 pm
Have been doing just that for a while. I too hate spammers and think they are the scum of the Earth.

2. Zooba | August 7th, 2006 at 11:57 pm
Same here. I’ve started disabling comments on posts after they’ve been up for a while. This seems to be an automatic feature of some software, I wonder if WordPress has something similar?

3. Thushan Fernando | August 8th, 2006 at 8:28 pm
spammers suck, most are bots, i’ve kept mine disabled from last year but only recently enabled mine again after i realised some bots dont quite understand the need to travel to another link to post a comment (previously we used .TEXT which had a post comment form on the page much like ByteClub does now…) moderation does help but occasionally several bots will navigate through and find a post form….

someone should start a WoS (War on Spammers)

Saturday, August 5, 2006

Can’t use regex as response

Must abuse posting privledge
I think I hold the key to Xavier’s problem

<([^/][^>]*?[^/])>(?!.*?</\1>)

-= Comments
1. Xavier | August 4th, 2006 at 3:45 pm
This will incorrectly match normal tags too though?
Input:blah
Output: blah

2. Xavier | August 4th, 2006 at 3:48 pm
Oh wait, I get it now. It will also match unclosed divs and such, which (I think) I want the parser to do because it closes them properly, where as it closes img tags as if they were divs, which is wrong.

I want it to only match img,input,…whatever I put in my post

3. pimaster | August 4th, 2006 at 10:12 pm

<((?:br)|(?:img)|(?:hr)|(?:script))[^/]*?>

Althought the script one isn’t handled well since sometimes it can be part of a pair, and sometimes it isn’t.

You could try pairing it with the orignal !\1 check, but I had trouble when there were two open scripts and only 1 close script.

Thursday, August 3, 2006

Attempt at pretty code

I don’t think I’ve got it shorter, it does look slightly different.
I was aiming for something clean, but there is a small problem about renaming the first version.
This also doesn’t leave an original someName. Everything would return someName_1 and so on.
It probably needs a check incase there is no . in the file name.
[php]
$VERSION_SEPARATOR = ‘_’;
$EXTENSION_SEPARATOR = ‘.’;

function getNextFileVersion( $fileName, $toDirectory )
{
$toDirector = dirname($toDirector) . DIRECTORY_SEPARATOR;

$versionPos = strrpos( $fileName, $VERSION_SEPARATOR);
$extensionPos = strrpos( $fileName, $EXTENSION_SEPARATOR, $versionPos);

if( $versionPos > 0 )
{
$version = substr($fileName, $versionPos + 1, $versionPos + $extensionPos - 1);
}
$iCantThinkofABetterNameForARandomHack = ‘’;
if( false == is_numeric( $version ) )
{
$version = 1;
$versionPos = $extensionPos;
$iCantThinkofABetterNameForARandomHack = $VERSION_SEPARATOR;
}
$name = substr($fileName, 0, $versionPos);
$ext = substr($fileName, extensionPos) . $iCantThinkofABetterNameForARandomHack;

while( file_exists( $toDirector . $name . $version . $ext )
{
$version++;
}
return $name . $version . $ext;
}

- Edit a little bit later
I was hoping to add a track back to Mark, but it didn’t work the first time….

-= Comments
1. Mark | August 3rd, 2006 at 10:53 am
hmm, so that’s what a real programmers code looks like..

I still prefer the explodes / implodes to break into arrays.. rather than using substrings - I guess it’s just personal preference.

I really like this part.. It makes the looping part of the code very small. It’s a little more readable too with good variable names as opposed to my obscure arrays $file_name_parts and $file_name_inner_parts

while( file_exists( $toDirector . $name . $version . $ext )
{
$version++;
}

Will your version handle a filename with other ‘_’s in it.. e.g. my_broken_filename_with_too_many_underscores.jpg?

2. pimaster | August 3rd, 2006 at 4:15 pm
I think so. Didn’t get around to testing it. If I wrote it in java I would have included JUnit tests.

Have they come out with PUnit framework yet?

I only used substrings because I thought it would have made it shorter.
I was thinking of using a regular expression, but my mind was wandering
implode vs substring could be personal. I was thinking that substring might be quicker. (But I might be splitting hairs)