ericgehrman.com

Uncategorized

Reordering an Array in PHP for an Image Gallery

by on Jun.06, 2011, under Uncategorized

Say I have a homepage image rotator (as seen here), and grabbing the images in any logical order (by date, by name) is not an option. Well, its time to make an array and shuffle it!

The following code snippet grabs all the image files within a certain directory, turns them into an array (using the readdir function, which un-modified would order them according to the timestamp on the server), and then randomizes it.

Check it out:


$image_dir = "$_SERVER[DOCUMENT_ROOT]/images/home"; // directory on server
$image_relative_path = '/images/home'; // path to images relative to script
$file_types = array('jpg','jpeg','gif','png');
$image_time = '10000'; // seconds each image will display (10000 = 10 seconds)

if ($handle = opendir($image_dir)) {
$dir_array = array();
$count = 0;
while (false !== ($file = readdir($handle))) {
if($file!="." && $file!=".."){
$dir_array[$count] = $file;
$count = $count + 1;
}
}
// ive got my array, now lets Randomize it!
shuffle($dir_array);

$i = (int)(0);
while ($i < $count){
$image_rotation .= /add html around this: '.$image_relative_path.'/'.$dir_array[$i].' ;
$i = $i + 1;
}
closedir($handle);
}

The code uses a jQuery plugin called innerfade to create a cool UX. Enjoy!

Leave a Comment more...

Domains for sale.

by on Jan.28, 2011, under Uncategorized

Today, I got an interesting email for one of the domains I own.

it reads:

Hey, my name is Seth Chilcutt with Secured Premium Domains.
nosarahouserentals.com will be available for purchase soon.
Since you own nosarahouserental.com, I think you may be interested in nosarahouserentals.com.

It is recommended to eliminate any confusion to nosarahouserental.com, to own both the singular/plural versions of the domain.

Your purchase will be a one time fee only that includes one year of complimentary registration.
You also have the option to forward nosarahouserentals.com to nosarahouserental.com at no cost.
After purchasing nosarahouserentals.com you will never be charged again by Secured Premium Domains.

If you do have an interest in purchasing nosarahouserentals.com, please visit:
http://www.securedpremiumdomains.com/prioritysales/04fqSp1m9j3d

Once nosarahouserentals.com is ready for purchase, one of my account specialists will contact you.

Thank you and have a good day.

To which, I responded:

Hey, my name is Eric Gehrman.
nosarahouserental.com will be available for purchase soon.
Since you own nosarahouserentals.com, I think you may be interested in nosarahouserental.com.

It is recommended to eliminate any confusion to nosarahouserental.com, to own both the singular/plural versions of the domain.

Your purchase will be a one time fee only that includes one year of complimentary registration.
You also have the option to forward nosarahouserental.com to nosarahouserentals.com at no cost.
After purchasing nosarahouserental.com you will never be charged again by Creative Empire.

If you do have an interest in purchasing nosarahouserental.com, please email:
xx@ericgehrman.com

Once nosarahouserental.com is ready for purchase, one of my account specialists will contact you.

Thank you and have a good day.

I haven’t gotten a response yet. I’ll let you know when I do.

Leave a Comment more...

It’s been too long -

by on Aug.04, 2010, under Uncategorized

Since I’ve posted up here. What’s been going on you ask?

Well….

I am finally working at a great place, springbox. I absolutely love it too! I’m surrounded by dynamic, passionate, and skilled people. Everyone here brings a great asset to the table and I truly enjoy coming to work everyday! Oh, and their work is pretty good too.

I am still rocking out crossfit, or rather sicfit as it is being called now. The dogs are happy, Amber is beautiful. And I bought a tablesaw. Hopefully the next post will be pictures of something I build!

Anyways, figured I’d open the door for a flood of new posts. Enjoy!

-E

Leave a Comment more...

I’m a Mac now, Apparently

by on Aug.04, 2010, under Uncategorized

Originally posted 5/04/2009:

So I did it. I sold my old trusty IBM thinkpad and purchased a 6 month old black macbook. Here are my first thoughts:

THIS THING IS AWESOME.

Other thoughts? Besides the obvious, I’m REALLY happy with this laptop. I bought a program called Parallels which basically is a virtual machine where I can run windows (any version) on top of the Mac OSX.

This means that I can have my trusty Visual Studio and MS SQL Server running on my mac. Woo Hoo!! This mac runs pc stuff way better than, well, my pc does. Crazy isnt it? Besides the expensive price tag (which I think now is TOTALLY worth it), I can’t really find anything wrong with this badboy. I upgraded to 4GB of RAM for $40 from newegg. This thing is a hoss.

Visual studio had one thing where I had to figure out – When you step into while debugging, the f11 button was set on mac osx to show the desktop. I went into system preferences and unchecked that as a default key, and whallah! I’m stepping thru just fine now.

Also, the fine folks over at zagg make an invisibleshield for the macbook too; keeping it ever so pretty.

So anyways, if anyone is wondering whether or not to make the switch, I say DO IT!!! It’s totally worth it! I love it :)

Leave a Comment more...

Im at the start

by on Nov.02, 2008, under Uncategorized

Here at the start on staten island. I’m glowing!

So freakin excited. The crowds are crazy. About to get corraled. Yipee!!!

This is awesome.

E

Leave a Comment : more...

Saturday, before ACL

by on Sep.26, 2008, under Uncategorized

Oh, so if none of you are doing anything Saturday morning before ACL… come join me on my 20 mile run. See you there!

Leave a Comment more...

Gehrmans of the Internet, Unite!

by on Sep.11, 2008, under Uncategorized

So, I received an email last night – about someone named Kali Gehrman that added me as a friend on Facebook. Kali, huh? Turns out Kali took it upon herself to add every Gehrman on Facebook as a friend in an effort to figure out who we were / if we are related. I actually admire her for doing this.

Ya see, Gehrman isn’t a very common name. I’ve often googled the name “Gehrman” to see who was out there. Of course, my blog comes up (hopefully it will be higher in the list after this posting). But I’m intrigued by the amount of other Gehrmans that are out there. For instance, there is Dale Gehrman, an artist. There is the Gehrman Animal Hospital in Minnesota. Jody Gehrman is an author. Steve Gehrman apparently runs a software company in California (being a techy apparently is a Gehrman skill). And don’t forget to check out the Gehrman Family Website (My family’s website, although a little biased towards my brother Scott).

Anyways, whoever all these Gehrmans are – The email from Kali definitely has gotten me thinking about whether we are all related from some distant distant past. Would be very cool if that was the case! I look forward to figuring this all out! I’ll let you know what I find. :)

Oh, and thanks, Kali. I dont know you…. But I think you’ve initiated something very cool!

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!