NYCPHP Meetup

NYPHP.org

[nycphp-talk] Questions to ask at a job interview?

David Krings ramons at gmx.net
Sat Jul 7 23:23:41 EDT 2007


Ben Sgro (ProjectSkyLine) wrote:
> Hey again,
> 
> "I think 150 lines is huge, I want to do it in two. =D"
> heh.
> 
> "Although,  when would anyone want to switch variable values? Just use 
> the one that
> already has the right value. Saves three lines of code!"
> 
> Good point. I just liked the question because it makes them think.

Made me think, too, because I guessed that the helper variable deal is 
way to obvious to be the desired answer. Besides that, we all do many 
things that have no real purpose.

> 
> "My record is currently at 761 lines for a script including comments and
> empty lines. I think 150 isn't huge.".
> 
> So what did you do in those 761L?

Grab an image file, check if it is jpg, check if it has exif information 
in it, if yes, grab the exif data, then check against all known keys of 
the exif array and echo those with explanatory text in a table.
There are quite a few keys that can be in the resulting array and I want 
to show only those values that are really there and provide for 
explanatory text. Most exif reader scripts just barf up the content of 
the array and don't bother to format it nice and add the field 
definitions to it. So there are tons of isset checks and several switch()es.
Is there a shorter way? Sure there is. I could parse through the array 
keys and load the definitions from an ini file and add a check for the 
case that the value is yet another array. Why check for 50 keys when the 
array has only three. To my defense, the isset and switch way makes it 
less intellectually challenging covering all the weird array values. 
Some are binary strings (Flash), some are just some wild numbers who 
each mean something different (LightSource), then there is the thumbnail 
image, and so on. That exif array is a total mess and dealing with each 
key separately is just easier. It also allows me to show things like 
picture orientation in a more obvious way. Rather than showing 
"Orientation: 6" I show an image of the letter "F" rotated in the way 
the image is oriented based on exif information. That isn't obvious from 
the image itself, because by the time I show exif information I already 
rotated the image on the fly based on rotation settings that I get from 
the database. Sure, I could use the exif values, but not all cameras 
record orientation. The one that I have doesn't and it is the main 
source of the images, but some other user may have a nicer camera.


> Only 125L of code. You can view it here:
> http://www.projectskyline.com/phplist/mine.txt
> 
> Its a datamining script.

It threw me off at the beginning as I think "browser" when thinking PHP. 
That script strikes me to get executed typically from the command line. 
It grabs results from Google searching for files of a particular type 
and stores them in a local folder.
Right?


Thanks for sharing.

David



More information about the talk mailing list