Archive for the ‘General’ Category

xkcd: A few favourites – Part 2

Sex sells.

Following my earlier post, titled ANASLEX, I did some monitoring.  My site traffic has spiked considerably.  This, based on a simple (intentional) misspelling.  Sure seems to be a lot of dyslexic folks out there looking for something other that Ana’s Lexus.

ANASLEX

So, who wants in?

For my truly dyslexic friends, that Ana’s Lex.  Get your minds out of the gutter.

Dell’s customer service stinks.

I have been trying for the last 4 hours to speak to a human being at Dell.  I have tried the sales dept.  I have tried placing a new order.  I have tried customer service – all 4 sub-options.  I have tried accounts.  Damn, I even tried the section for government officials.  Dell’s telephone system is an inescapable abyss of incorrectly routed calls to dead lines, incorrect mailboxes and in one case, the sounds of dogs barking in the background.  I shit you not.

A sign of things to come?  If so, I will likely cancel my order and purchase my laptop elsewhere. (If I’m lucky enough to get through to them, that is)

Dell, please get your act together, sort out your telephone system and for the love of small animals, SOMEONE PHONE ME ABOUT MY ORDER.

xkcd: A few favourites – Part 1

 

Your IDE's colour may vary.

 

Hunting for the ideal laptop

I am in the process of hunting for a laptop.  I’ve looked at countless offers from various vendors.  As with any purchase one makes, the usual barrage of “sweet deals” from every.single.person.you.know has accompanied the exercise.   Everyone and their uncle can get a great deal.   You gotta love capitalism. (Thank you, though – your offers served as good yard sticks)

The following specs have been the influencing factors:

CPU
Intel Core 2 Duo
- 2.2GHz or above. (Looking at around 2.5GHz)
- Preferably 800MHz FSB.
- Preferably 4MB+ cache.

Memory
2GB (1 x 2048)

Screen
17″ Wide.
- I don’t mind 1440×900 , though I would prefer larger (1680×1050) if it falls within budget, but this is not a “must”

GPU
I can live with the crappy Intel X3100, but would prefer an nVidia chipset.

HDD
Since I have a desktop with 1TB+, size not an issue, 250GB would be perfect, but 160GB is fine too.

Extras
DVD Writer, Wireless – essential.
Bluetooth – Nice to have

Software
If possible, I don’t even want an OS. I’m not going to be using windows, so would rather not have to pay for it.  Thing is, most vendors have to supply a Microsoft OS.   Sucks, but oh well.

At this point, the Dell Vostro 1710 is looking good.  The “best” option comes with nV GPU, and can be further customised to meet the above spec exactly.  As cool extras, it has a 1920×1200 screen, 6MB cache, nvidia gpu, biometric fingerprint reader, built in webcam and bluetooth.

Another contender is the HP 6820.  I think, however, that the Dell packs more punch.  Apart from that, HP never got back to me, so they can sit on a stick and rotate.

I would very seriously consider the HP 6830, but that’s not been released yet.  Looks awesome.

While writing this post, I came across the Dell Studio 17.  It looks decent enough, but at the time of writing I am unable to customise my own nor get a price.  I’ll have to make some calls tomorrow.

I’ll post an update in the coming days.

Sources of inspiration

Browsing around the other day I came across Komodo Media.  Wow.  What a stunning site and awesome source of inspiration.  Rogie King, maintainer, showcases his talents in a remarkably eye-catching way.

Rogie goes the extra mile by nicely commenting his source code, so aspiring web geeks like me can learn from those who evidently know what they’re doing.

Be sure to play with the foliage-o-meter.

PHP howto – Alternating background colours for table rows

Often when writing something for the web, you’ll need to output data in a table (or, for CSS zealots, nicely formatted <div>’s).  In order to improve readability, you might want to colour every second row differently. This is really easy:

$counter = 1;
while($counter < 10) {

    //set bgcolor
    $bgcol = ($counter % 2 == 1) ? "#ececec" : "#ffffff";

    //write the output html
    echo "

Your content goes here...


";

    //increment the counter
    $counter++;
}

The above code is merely to illustrate the idea behind alternating rows.  I’ve used a very short conditional that checks if the current row is even or odd.  Based on that result, it sets the background colour variable to either #ffffff or #ececec.  Once the loop has run, the counter is incremented, and we start over.

By the way, the line:

    $bgcol = ($counter % 2 == 1) ? "#ececec" : "#ffffff";

is equivalent to using:

    if ($counter % 2 == 1) {
        $bgcol ="#ececec";
    }
    else {
        $bgcol = "#ffffff";
    }

Some extensions to make this code better are things like inserting real data (from a call to a database), replacing the table code with <div>’s, replacing the bgcolour values with a particular style class, and writing to a string/file/etc instead of echoing the results.  Another cool thing (if in a user-based environment) is to add a subsequent if statement that checks to see if the row being processed matched the currently logged on user – this way you can show a user that the row in question belongs to them by defining a third bg colour and highlighting it differently to the rest.

A slightly more real-world example of how the code may look is:

$sql = "SELECT id, name, surname FROM person";
$result = mysql_query($sql);
$counter = 1;

while($row = mysql_fetch_array($result)) {

    //set class
    $classname = ($counter % 2 == 1) ? "dark-div" : "light-div";

    //write the output html
    echo "
". $row['id'] ."
". $row['name'] ."
". $row['surname'] ."
"; //increment the counter $counter++; }

And in next week’s issue, how to assemble a nuclear bomb from ordinary household items! ;-)

Make me a sandwich!

A beginner’s take on developing a Facebook application

Grab your popcorn, coffee, blowup doll, whatever it is that passes time, and settle in for a lengthy post!

Being relatively new to the world of PHP development, as well as the associated technologies (MySQL, CSS, etc), I’m going to ask that you bear with me while I ramble on about things that, for many of you, may seem entirely trivial.  My reasoning for doing this is because a) repeating what I’ve learned reinforces the lessons, and b) someone else may find it beneficial.  The level of detail and technical jargon I use will vary.  Sorry.  So, without further ado, here goes…

The application is a platform for users to submit pick up lines (guys) and seduction tips (girls).  Users are allowed to vote on content added by the opposite sex (IE, guys may vote for seduction tips, and girls for pick up lines) as well as being able to comment (on either type).

The above requirements are quite straightforward.  The implementation thereof, is interesting.  While the application is really simple, a lot of users never get to see what’s really going on behind the scenes.  Here’s a quick rundown:

The first thing we do is grab the user’s sex from their profile.  This allows us to automatically present the correct input forms when they wish to post a pick up line / seduction tip.

Submitting

When the user submits a pick up line / seduction tip, it needs to be cleaned of any potentially harmful code (like bad JavaScript).  This is done by stripping out any illegal characters from their submission.

Once we have the submission, we give it a unique tracking id, so we can find it again later on.  We also record the pertinent details such as who made the submission (in this case, the user’s unique Facebook ID), the date and time, and the type of submission (pul/tip).  All of this is done behind the scenes, on the fly.  This information is then added to our database as a new record.

Formatting

Having hundreds of lines of content stored in a database is all good and well, but we need a way to display it.  For this I wrote a simple function (Yeah Tyler, simple ;-) ) which could be called in a number of ways, depending on how we wished to display the content.  For example, listing the 10 most recent entries, whether they be pick up lines or seduction tips.  Or, more specifically, displaying all the entries of a single user.  Or a random selection.  Or the 5 most voted (more on voting in a bit!) for pick up lines, tips, or both.

Once the function is called (and provided with its criteria) it will send the data (encapsulated in named <div> tags) back to the calling file, which then applies any CSS styling we need (to make it pretty!) and pushes it to the browser.  The data it sends back include:

  • the author
  • date and time
  • number of votes for the item
  • the actual text of the item
  • number of comments.

Voting

Users are allowed to vote for content submitted by the opposite sex.  They may only vote once per item, but can vote on as many items as they like.  A few things need to happen here.  When the pick up line / seduction tip is displayed, a voting badge is (think Digg) is attached to it.  This badge is generated along with every pul/tip that gets sent back to the browser.  Every time a line is displayed, we need to check if a) the current user is allowed to vote for this item (opposite sex?) and b) if they are allowed to vote, have they voted for this item before? If so, we disable voting for that item.  If not, we provide a button with will then enable them to vote.

When a user votes for an item, we need to record some more details.  We need to know

  • who the vote is coming from (the user’s Facebook id)
  • which item the vote is for (the unique tracking id I mentioned earlier)
  • the date and time of the vote

1 & 2 are important in terms of avoiding duplicate votes in the system.

Ranking

Once we have a table full of votes, we can use the information to do some form of ranking on our items.  A few possibilities include ranking based on:

  • Overall number of votes per user
  • Overall number of votes per item
  • Most active users (who’s doing the voting)

Commenting

Quite similar to voting in terms of code and structure, but a bit more simple.  Here there are less constraints.  A user can comment on any item, and more than once.  Here we record the following:

  • who the comment is coming from (the user’s Facebook id)
  • which item the comment is for (the unique tracking id I mentioned earlier)
  • the date and time of the comment
  • the actual comment itself (the text)

And that’s pretty much it!  There are a bunch of other cool bits and pieces, but that would make this an (even more) exceptionally long post.