Geeks On PHP Episode 14

This week Stephen and I talk about user defined functions in PHP and why they matter. This is a precursor to our upcoming series on OOP in PHP.

Functions are the key to reusable code and thus should be used as often as it makes sense. Duplicating code is a big no no and should avoided at all costs, this is where functions come into play. Just last week I was working on a script that pulled back two different data sets (as arrays) and needed to do essentially the same thing to these two sets. Rather than duplicate the code twice I just converted my logic to a function and boom I was off an running with no duplication what-so-ever.

function fnXML_Body($adata)
{
  $sxml_body = NULL;
  $i = 0;
  foreach($adata as $arow)
  {
    foreach($arow as $svar=>$sval)
    {
      switch($svar)
      {
        case "slabel":
          $slabel = $sval;
          break;
        case "ivalue":
          $ivalue = $sval;
          break;
      }
      if($i < 2)
        $sslice = "isSliced=\"1\"";
      else
        $sslice = NULL;
    }
    $sxml_body .= "\n";
    $i++;
  }
  return $sxml_body;
}

Using the function above I can call pass a new data array to it as many times as I need to in a script without duplicating any code. The function accepts the data array, does some parsing and returns the XML that I need to generate a 3D Pie Chart.

The call to this function would be as follows:

  $sxml_body = fnXML_Body($adata);

In the next couple weeks we are going to kick off a series on object oriented programming with PHP which will include all the basics as well as the tools needed to build a small web application from start to finish. We will be featuring a special guest for this series, it’s going to be very exciting and something you definitely don’t want to miss.

Follow both Stephen and Myself on Twitter and also subscribe via Tunes!

Enjoy the show and as always, stay geeky!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

- Nicholas

  • Share/Bookmark

Read Users' Comments (1)

Geeks On PHP – Episode 9

After a long wait, Geeks on PHP – Episode 9 is finally out!  As I mentioned in a previous post we are now on a weekly recording schedule and will be releasing a new episode every Sunday evening unless otherwise specified.

In this exciting episode we discuss lots of information and things to think about *before* you start building your database or writing your application.  We also touch on SQL statements, database schema design and how they relate to your PHP applications.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Also, subscribe to us on iTunes and leave us your comments: [ Launch iTunes ]

Follow us on Twitter :
Nick : http://www.twitter.com/niczak
Stephen : http://www.twitter.com/darthweef

- Nicholas

  • Share/Bookmark

Read Users' Comments (0)

Geeks on PHP : Episode 8 : MySQL vs. PostgreSQL

This week we dive into the debate that has raged since the first database went online, MySQL or PostgreSQL ..

Stephen is a MySQL guy, while Nick is a PostgreSQL guy, and together they share the pros and cons of both, and why the debate that has raged is not likely valid anymore.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Also, subscribe to us on iTunes and leave us your comments: [ Launch iTunes ]

Follow us on Twitter :
Stephen : http://www.twitter.com/darthweef
Nick : http://www.twitter.com/niczak

  • Share/Bookmark

Read Users' Comments (0)

Geeks On PHP : Episode 7 – Looping through while, for and foreach

At the heart of every redundant thing you do, is a loop.

Even the greeks knew it.  When Sisyphus pissed off the gods, they stuck him in a while loop

while($gods == “pissed”) {

$sisyphus = “Roll rock up a hill”;

}


Granted the greek gods were a bit tempermental, but like the greeks, your application will execute these types of statements to output data, count, and do all sorts of things that are even, at times, incredibly futile and redundant.  Also like gods, while loops can be tempermental, and when hastily constructed can leave Sisyphus pushing his rock for all of eternity.

Wondering who Sisyphus is ? http://en.wikipedia.org/wiki/Sisyphus

PHP Manual on Control Structures: http://us2.php.net/manual/en/language.control-structures.php

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Also, subscribe to us on iTunes and leave us your comments: [ Launch iTunes ]

Follow us on Twitter :
Stephen : http://www.twitter.com/darthweef
Nick : http://www.twitter.com/niczak

  • Share/Bookmark

Read Users' Comments (1)

$deep = $this->geeks->thoughts() – Episode 1.

How Comic Con made me love being a geek again.

ftlog_geek_podcast

Last week (July 23,24,25,26) was Comic Con and it was such an awesome, geek invigorating experience for me, that I had to share it as the first episode.

So I talk about Comic Con, the people, the Geek love, and the re-awakening of something that I thought died along time ago.

I also briefly talk about the maturation of Geek Culture and why some of that may not be a great thing.

I reference my Flickr Stream from Comic Con .. so if you want to check that out , it is here : [ Flickr ]

Hope you enjoy!

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

  • Share/Bookmark

Read Users' Comments (2)

New Audio podcast coming to For The Love of Geeks

So, I have been wrapped up in so many projects that I have not been keeping up with the Geek blog, and for that I apologize, but in an effort to make up for that I am going to be launching a new audio podcast for the geek blog called $deep = this->geeks->thoughts();

ftlog_geek_podcast

If your not a programmer then the humor in title of the podcast will likely escape you, and maybe it will even if you are a programmer, but fear not, this cast will not be limited to programming, and most likely won’t focus on that much at all, since there is soon to be a PHP podcast coming to the site as well.. It really will be me talking about random geek topics.  Comics, movies, games, computers, tech, photography, whatever.

It may not even always be me.  I will open the cast up to Allen and Nick to do as well, whenever they feel the compulsion.

So you’re thinking, why in gods name would I want to sit and listen to you ramble on about geek stuff.  Well, you might not, and if not that’s cool, but truth be told the three of us are pretty knowledgable, and even have a decent sense of humor, so you might just find that we entertain and educate you, and you will more then likely share quite a few of our views, and when you don’t let us know, we love discussion.

So for what’s worth, it will be here on a indeterminate schedule with no real set length other then a guarantee that it won’t go more then 10 minutes or so.

You will be able to find the podcast here, and I will be pushing the feed to iTunes as well.

  • Share/Bookmark

Read Users' Comments (1)

Geeks using Twitter.

Today when I went to get my coffee, I walked into a conversation between the two baristas who were discussing how much they hate Twitter. One of them knew I was a huge twitterer, and so they brought the conversation to me and wanted me to accept that Twitter was going to destroy the fabric of society as we know it.

twitter

People who get Twitter love it, and those that don’t get it, figure that people who twitter are morons. Such is how our society breaks things down I suppose. While Twitter has certainly found itself squarely in the mainstream, I think that it hasn’t really been able to accurately describe to people what it is, and I think a large reason for that is that people use it differently. Some use it as a marketing tool – we call them spammers, others use it to make friends and connections and to learn, some people use it detail the minutia of their lives – we call them annoying.

A side effect of a successful site like Twitter, are sites devoted to making Twitter more interesting. Sites like Tweeteffect.com will tell you how your tweets effect your followers, and whether people are following or unfollowing you based on what you tweet. Twitpic.com allows you to post a picture with your tweet, which will add flavor to your daily posts. Twitterfeed.com allows you to plug your blog postings on your twitter feed, for instance, about 10 minutes after I post this, it will appear in my feed automatically.  The question becomes, how do I determine who I want to follow, and how can I know what they use twitter for, and will I enjoy following their tweets?

Today we ran across a newer site today called Mr.Tweet [ mrtweet.net ], which I think will help answer these questions.  This site is particularly interesting since it not only gives you an idea of how you use twitter, but also how the people you follow use it.  It will also spend a few days analyzing your tweets, your feed, and your followers feeds and give you some pretty good recommendations about who you should follow.  It gave us a interesting picture about how us three geeks use Twitter.  For instance, first look at Nicholas [ twitter.com/niczak ].

Nicholas is a single dad, who works in a full-time job in Reno Nevada.  His tweets will reflect two main locations, His office, and his home.  He also helps his young son manage his own twitter account.  He is however, very conversational for someone who is actually doing work, since he uses an app called tweetdeck, and he is able to monitor twitter throughout the day and remain involved.   His stats look like this :

picture-4

Next we can take a look at my stats [ twitter.com/darthweef ]. I am a married business owner, who works from my house and doesn’t answer to anyone through out the day on how I spend my time.  So I can occasionally get caught up in Twitter with out it doing any damage to my career.  I also have a little more freedom to be out and about during the day, and so my tweets will reflect happenings at home, at the local coffee shop, or  wherever I happen to be.  I also do quite a bit of twitpic’ing since my iPhone / twitterfon make it very convienient.  Since I get a little more caught up in twitter at times, my conversational aspect is way high, but I tend to stay in my 3 or 4 groups of people that I follow so my connections are lower.  Here are my stats :

picture-3

Our other Geek is Allen [ twitter.com/allen099 ]

Allen, is what I would label a mobile twitterer.  He is “professional traveler” right now, and rarely sitting at a computer, and most of his tweets go to and from his blackberry. Being in NY, he is out wandering the city alot, and so he has a little more time to be interactive, with his followers, and to discuss more of the world around him. His stats are unavailable since he has yet to register on Mr. Tweet, but hopefully I can update this post in a few days with his info.

Now that I have found Mr. Tweet, I will certainly be running people that I want to follow through it to see how active, conversational and useful they are on twitter.  People who don’t converse much are not worht following in my book, unless they are providing a informational service of some sort.  People who only post 1 tweet a week, or so, are also not worth following since the odds are I will never really see, or interact with them.   People who are not likely to follow me back are also not worth following since how can I interact with someone who is not taking the time to get to know who I am? Now, with Mr. Tweet, I have something to check that type of information and make an informed choice on who to follow before I invest a week into a person on twitter.

How do you use twitter? Let us know in the comments, and go ahead and follow us, we’re interesting ;) .

  • Share/Bookmark

Read Users' Comments (0)

Hello, World. I’m jtv4k

Greetings everyone!

I was recently invited to join For The Love Of Geeks. I’m big on ranting, so you can look forward to an ear full (or, in this case, an eye full). Or you can just skim ;-) .

Anyhow, I’m currently a web developer contracting in the southern California area. I have a degree in computer engineering. Basically, that means hardware design and digital systems. So next time you need to know why your memory isn’t working or why fiber internet has a bandwidth limit, I’m your man!

I’ve got a blog of my own over at http://blog.jtlabs.net/. It will probably mirror content I post here, but if you feel like visiting, please do!

Happy reading!

  • Share/Bookmark

Read Users' Comments (0)

Will Geeks go the way of the DoDo bird?

It used to be a way of slamming someone to call them a geek.  Then the underground geek community found a welcoming home on the internets, and over time we developed pretty well in the land of computers and chat rooms.  Of course, in real life, we were still teased, misunderstood, and generally marginalized.

Now, since we (yes us geeks) did such a good job building, massaging, fixing, tweaking, and geeking the internet the rest of the world has become addicted to the online culture.  With that addiction has come a bit of understanding and acceptance of geek culture.

That understanding, and acceptance has also led to the idea that being a geek is kinda cool.  This is good in some ways and bad in others.  An essential part of being a geek is that you are “outside the mainstream”, so if the mainstream becomes geek.. what does that mean?  How do you define geekiness when everyone claims geek status.

I hold to the idea that that question will be answered differently depending on what type of geek you ask.  For instance, a sci-fi geek will want to have you be able to answer obscure trivia questions about Hitchhikers Guide to the Galaxy, and a computer geek will want you to translate binary without looking online.  So, I guess on some levels, this transition to “geek being cool” may just lead to there being another type of geek. “The geek Geeks”.  Confused.  Yeah, so am I.  Let me see if I can explain.

Computer geeks are computer geeks because they obsess about computers.  So, a Geek geek, would obsess about geeks.  Trying to be one, talking about them, and generally jumping on the recent geek bandwagon.  That’s cool, I suppose.  As geeks, I have found that we are a fairly tolerant group, except when discussing Star Wars Vs. Star Trek, or which OS is better, so we welcome and embrace this new brand of geeks.  It is doubtful that they will hang around the clubhouse for long though.

Culture is a fickle mistress who grabs on hard and then quickly moves on.  The Geek geeks are really more of a pop culture phenomenon  and over time it will dwindle, leaving us to go back to our SciFi, Computers, Chemistry sets, algorithms and general world problem solving responsibilities.   Hopefully maintaining bit of understanding and acceptance from the mainstream culture.

In the end we geeks will always be here, and we will always be making the world a better place, so, embrace your inner geek!

When somebody calls you a geek, don’t quibble about stereotypes, but take it as a compliment.

  • Share/Bookmark

Read Users' Comments (0)