Visual Diagram of SQL Joins

SQL_Joins

A diagram on SQL Joins. Showing the difference between inner and outer joins.

PHP Developer Interview Questions

Name the Four Fundamental Principles of OOP?
What is the difference between PUBLIC, PRIVATE AND PROTECTED
  • PUBLIC scope to make that variable/function available from anywhere, other classes and instances of the object.
  • PRIVATE scope when you want your variable/function to be visible in its own class only.
  • PROTECTED scope when you want to make your variable/function visible in all classes that extend current class including the parent class.
  • Manual

Describe the difference from an array and an associative array?
Arrays in PHP are really “maps” not the strict arrays you find in other languages. The main difference is that you define the indexes in the associative array. While when you do not define the indexes are defined by the system starting at 0 and incremented by 1. Manual
Describe the difference between double equals (==) and triple equals (===)
Directly from the manual:
$a == $b Equal TRUE if $a is equal to $b after type juggling.
$a === $b Identical TRUE if $a is equal to $b, and they are of the same type.

Examples:

Give an example of using GROUP BY in MySQL

Explain the difference between WHERE and HAVING in MySQL?
They function similarly, but their uses differ. The WHERE statement is used to filter field values that are in the table. The HAVING statement is used to filter calculated values, like sum().

Multiple Galleria Image Galleries on One Page

So I had a client that wanted multiple galleries on one page. The page is created from a database, so there could be any number of galleries. The issue I had was making more then one gallery work in their own modal. Using galleria.io and their basic instructions, only the first one I would click on would work, the rest gave me an error.

So I wrote this little javascript to run the gallery when the link to open the modal was clicked and it works like a charm:

Sipgate is closing down, switching to Anveo

So I’ve used Sipgate as my home voip provider for a while now. But they are closing their doors so I had to find a new provider. My search lead me to Anveo.com as the replacement to Sipgate.

Honestly the free service and number from Sipgate was great for me, especially since it came with free incoming calls. Also Sipgate just seems more polished and simpler then Anveo does, but that really is where Sipgate’s advantages stop for me. Anveo doesn’t offer a free number, it’s a dollar a month, but their E911 service is cheaper. Sipgate I paid $1.90 a month for E911, while Anveo is $0.80, add the one dollar for the number a month and you get $1.80. So really it’s a ten cent savings with Anveo.

We don’t make or receive a lot of calls, but it was nice that Sipgate had the free incoming. While that is not something Anveo has, it does offer 40 free minutes a day. This works out well enough and I don’t have to worry about getting charged for making quick calls out. I mentioned before that Sipgate is simpler then Anveo, but Anveo is more powerful, there is much more you can do or add to your service with Anveo.

If you want to try Anveo out here is my referral code: 3182282

Finished a couple Xbox games

I rarely get to play any games, but in the past few weeks I’ve finished both Halo 4 and Batman: Arkham City. If you look at my gamer profile you’ll see like months (seven in the case of Batman) in the gap of play time.

Also I’m giving going through HTML5 Game Programming with enchant.js a try. I found enchant.js really easy to use making a game for my kids.

CakePHP set CreatedAt field on save

So after a quick search I found that CakePHP automatically updates ‘created’ and ‘modified’ for you. Well the database I already had setup uses the fields ‘CreatedAt’ and ‘UpdatedAt’ instead. I didn’t want to go through and modify almost every table in the database just so I don’t have to set the CreatedAt date manually with every new record.

So to make sure I get CreatedAt set on new records I added this to my AppModel.php

Before the data is actually saved and if there is no id, since new records wouldn’t have one yet, it sets ‘CreatedAt’ to the current time. If there is a way to change ‘created’ to ‘CreatedAt’ I would prefer to do that, but this is working for me at the moment.

Because ‘UpdatedAt’ is set to update to the current timestamp on update through the database, I don’t have to worry about CakePHP doing it for me.

LibreOffice Get URL From Hyperlink

So I like using spreadsheets to mash data with, using the formulas there allow me to generate repetitive tasks easily.  This time I needed to map some Ids together, but they were in the URL of hyperlinks.  So I created the following macro to retrieve the URL from the hyperlink object in libreoffice.

Fixed Twitter Feed and Added Listening Links

So since Twitter updated their API, the way that this them pulls feeds wasn’t working anymore, it was really archaic anyway.  Well instead of using one of their embed widget things I created a service on another server of mine that allows for pulling of your last tweets.  You simply give it api.example.com/jordonr/5 and it will return XML with your five last tweets, it works from one to twenty.  I currently have the API caching the calls so it doesn’t have completely live data.  I built the service using perl dancer and starman as the server and memcached for caching.  More of an exercise then anything else.

Also added a link category of Listening/Listened to post the current audio books I’m listening to.  I’m a big fan of podiobooks.com and the authors that put their stuff up there, so I thought I would share what I’ve listened to.  A good place to start is with authors Nathan Lowell and Scott Sigler.  Their stuff is also available on Amazon.com (Nathan Lowell, Scott Sigler).

Finished Guarding the Globe Volume 2, Next is Dune

So I finished the Guarding the Globe Volume 2 trade.  It was maybe six issues so not to long.  Still waiting on getting another tablet to keep reading my electronic comics, thinking about getting the Nook HD+.  I mean for the same price as the Nook HD with 16 GB of storage you get the Nook HD+ which has 16 GB of storage and a bigger screen.  Till that I’ll start focusing on Dune while I’m reading at home.

PHP, Perl, Apache, Dancer, Starman and Beanstalkd – When our powers combine!

That is a mouthful, it almost sounds like a super hero team roster.  In fact I think Apache and Starman are super heroes, or at least are in comics.

So what am I doing with all of these things?  I am planning on using them together for a new side project I am working on.  At first glance it doesn’t seem to make sense, I mean who would choose to use two different languages (PHP, Perl) and two different web servers (Apache, Starman)?  Why would I not just use PHP and Apache or use Perl/Dancer and Starman.  The reason is speed of coding mainly, PHP is my primary language, then after that is Perl and third is Java but that’s not related to this.  So the mashing of services to is to provide a quick yet robust solution while also challenging me enough to learn some new things to keep my interest.

The Break Down:

  • PHP & Apache will handle the main site and crud
  • Apache will proxy out api.example.com to Starman (this will allow for easier separation when needed)
  • Perl using Dancer and Starman will handle the incoming API calls; validating, parsing and pushing the result to beanstalkd
  • Beanstalkd workers will most likely written in PHP to leverage the framework I’m using, but can be written in Perl

Breaking that out is not really convincing that running the API with Perl, Dancer and Starman is the right thing when it’s all on the same server.  An advantage of doing this is mitigating my mistakenly exposing anything since it doesn’t talk to the main PHP site directly.  Makes a little more sense when we separate the API out, I wouldn’t want to have to replicate the PHP server for simple things the API is doing.

Project links: PHP, PerlApache, Dancer, Starman, Beanstalkd