Archive for the ‘Uncategorized’ Category

A quick tip with how boolean expressions are handled in PHP

Wednesday, August 25th, 2010

I can’t say this is specific to PHP, but this is another thing I see in code a lot, that kind of drives me nuts.


if ($some_var == 3) {
   return TRUE;
} else {
   return FALSE;
}

Because the == is a logical operator, the operation returns a boolean value. Boolean expressions like this always return TRUE or FALSE.

Ie, your code could be simplified to:

    return ($some_var == 3);

It works with more complex examples as well:

    return ( some_fun() && $some_var == 3 || $foo == 'bar');

God, it seems like a lot of my posts are just complaining about the way other people write code. You’d think it’s almost as if I write perfect code. I now must take the time to admit that this is not the case. Also, I can’t claim that coders who write in the style I just called out are wrong. I just don’t like it. :)

Welcome to the new host

Monday, August 9th, 2010

You may have experienced some down time earlier today.

I’ve moved to a new hosting solution!

It’s not permanently settled, I’ve still got a lot of configuration to do, so service may be intermittent.

Thanks!

Feedback wanted on email regex

Sunday, July 18th, 2010

I just wrote an email regex. If you don’t know much about regular expressions, don’t use this regular expression on your website. I’m not claiming this regex to be amazing. I just sat down to write one, and I want some feedback.

If anyone can analyze it, and maybe tell me what I am not thinking about, I’d appreciate it. That’s all I want: to know what I am NOT thinking about. My hope is, the insight from others may help me get better with this type of problem. I’m not a regex rookie, I just thought it would be a nice exercise. Gah.

There, now that all of that defending myself (probably for nothing) is out of the way, here it is:

/^[a-z0-9]+[a-z0-9-_.]*\@[a-z0-9]+[a-z0-9-_.]*\.([a-z]{2,4}|museum|travel)$/i

I purposely ignored the top level domains along the lines of XN–MGBERP4A5D4AR, because, well, I don’t want email from people on those domains?

Thanks!

Theorem #1

Wednesday, July 7th, 2010

There exists an MD5 (or any other hashing algorithm, which produces fixed-length strings) sum, such that for some 32 character hexidecimal “string” (32 characters, when used with MD5), a, and another string, b of unknown length and character set, where the sum of the concatenation of a and b is identical to a.

There just has to be. It may just be nearly impossible to find.

In much simpler terms, I’d state it like this:

$a = md5($some_string); //give me some 32 character hexidecimal "string"
$b = $message_from_god;
$c = md5($a . $b);

if($a === $c) { //a and c are exactly identical!
   die('The world will now shatter to pieces.");
}

Make sense? I can’t prove it, but I feel like it HAS to be true, for b of unlimited length.

New focus: nothing

Tuesday, June 1st, 2010

So, I’ve decided to ditch the whole ‘Look at me, I’m a web developer: here is some useless PHP code!’ theme that I had going on with my blog. Quite a few reasons. First, it was lame. Second, nobody really wants to read that. Third, I struggled to think of things to write about. More complex examples would just take too much time; I’d probably lose focus before completing anything (If only you could see my ‘Drafts’ folder).

Instead, from now on, I will probably make some more pointless posts that nobody wants to read, but I will hopefully enjoy more. After all, this blog really is just about me, right?

Worth Blogging About

Monday, November 23rd, 2009

Well, I thought I’d take a moment to bring up some news. Saturday, I officially made my first move towards becoming a successful affiliate marketer, with my first day of profit. It was only about $20 worth of profit, but, I hope to see that number grow, especially as the holiday shopping season kicks into full gear.

Perhaps, as I see more success, I’ll make more posts about my affiliate marketing ventures. Yeah, one of those guys.

One Month Milestone

Wednesday, November 18th, 2009

It’s now been over one month since I started this blog.  Just thought I’d point that out.  Have I made any valuable posts yet? I’d like to think so, but thats up for you to decide.  Aside from my blog, I’ve been working diligently on a few side projects, and some extra pages for my SeanJordan.me domain.

I’m that kind of person that always has 4,000 “entrepreneur” ideas going on in the back of my mind.  As I start unrolling some of these, I’ll be sure to let you in on them.  I have a good one coming up that I’d like to share, so be sure to stay tuned.  I’ll share as much as I can on my process of packaging up the finished product, how I market it, and any success I have.

It’s been one whole month, and I’m just now getting to 10 posts.  I’d hoped I would do better, I’ll try to in the future!

To all my readers, I’m sorry.

Wednesday, October 28th, 2009

This one goes out to all my readers.  Its been almost two weeks since I set up this blog and I’m just now posting my second post.  To make matters worse, this isn’t even a relevant post.  I will say I started a couple drafts, and soon I should have a real content-related post up.  I just wanted to take the time and say, “I haven’t forgotten about you.”

So here it is, I’m sorry readers of my blog.  I’ll now call each of you out by name, to show my sincerity:

Googlebot 2.1 – You were my first loyal reader. Thanks for your continued support!
Joker – You shared that awesome link about iPhones via the comments section.  I am eternally grateful! Thanks again!

It’s got that new blog smell

Friday, October 16th, 2009

Hi.  Nice to meet you. My name is Sean Jordan, and I make web sites.  I’d like to use this blog as a way to share some tips, great scripts, cool websites, and any other randomness I feel fitting.