Browse > Home / Archive by category 'Programming'

| Subcribe via RSS

PHP to Assign Secret Santa

December 12th, 2009 | No Comments | Posted in Programming

Because I’m nerdy I decided to write a quick PHP script to handle the assigning of people for my family’s Secret Santa. It’s short, simple, and not-error checked or bug proof in the least.

  1. <?php
  2. echo "Christmas Secret Santa<br>\n";
  3.  
  4. //Build the two arrays. I could in theory use a single array and double it but I was lazy and just defined it twice.
  5. $giver = array('Rudolph','Donner','Blitzen','Santa');
  6. $receiver = array('Rudolph','Donner','Blitzen','Santa');
  7.  
  8. //Randomize the two arrays
  9. shuffle($giver);
  10. shuffle($receiver);
  11.  
  12. //We're going to iterate through the giver array for the individuals.
  13. foreach ($giver as $g) {
  14.  //Make sure that the giver and the receiver are not the same person
  15.  while ($receiver[0] == $g) {
  16.   //Shuffle the array to randomize it.
  17.   shuffle($receiver);
  18.  }
  19.  //Grab the first person off the receiver array
  20.  $r = $receiver[0];
  21.  //Echo out the result
  22.  echo $g." – ".$r."<br>\n";
  23.  //Remove that first person from the array, so we only have ungifted people remaining.
  24.  $receiver = array_slice($receiver,1);
  25. }?>

So nerdy. Maybe later I’ll do it as a javascript snippet.

Web Design Primer

July 2nd, 2009 | No Comments | Posted in Programming

This post originated with a comment I made in a discussion about web design on Hacker News concerning what skills someone should have to be a good web developer. At the time I wrote a quick five minute response listing a few things that I felt were important skills for new web developers to have for website design. These are things that I wish I had had a better grasp on when I entered the world of professional web development.

First I need to clarify the difference between web design and web development. Web design tends to lean towards the user interface and the actual website. Web development refers to the underlying code, and the inner workings of a site. There’s a good amount of overlap but they often get used as synonyms when they’re not; I wanted to clarify their meanings to those who may be fuzzy on the differences.
More »

StumbleUpon’s Exciting Progress

June 29th, 2009 | No Comments | Posted in Programming

Link shorteners seem to be the whipping boy of the Internet right now, everywhere I turn someone is griping about their evils, and their faults, and how they are going to be the downfall of the Internet. And yet, Digg, StumbleUpon, Bit.ly, Facebook and others are all working on this in various ways.

Digg and Facebook both use iframe wrappers to put a toolbar at the top of the window, offering the user enhanced functionality but in turn cloaking the content owner’s site and generally being uncool. Site owners, ones who are serious about blogging and building their following, usually dislike this as they feel that they lose credit or value from the links and traffic.
Stumble Upon More »

jQuery Expand All

October 14th, 2008 | 1 Comment | Posted in Programming, jQuery

Here’s another lunchtime jQuery snippet as the last one proved semi-popular. This one came about today as I needed to expand on an existing expand/collapse functionality to allow users to expand or collapse all of the objects with this functionality.
More »

jQuery snippet: How to make links break frames

October 3rd, 2008 | 2 Comments | Posted in Programming

Here’s a quick lunch time post to share a simple snippet.

It’s no new technology to have a page break out of frames when they’re not supposed to be in frames. But what if you do want the page to appear in a frame and only break the frame if a link is clicked? Well then we turn to our trusty jQuery and use this little code snippet:

  1. if (top.frames.length != 0) {
  2.    $("a").click(function(){
  3.       this.target = "_parent";
  4.    });
  5. }

Why would you want to do this? That’s a fair question. For one of our clients at work they embed the header from their site onto the page for a site which sells merchandise for them. Now, we could have created a separate header but then when the header gets updated it needs to be changed in two places. This way it’s just one header file to maintain.

Hopefully this saves other developers ten minutes of their lives.