The rants and ravings of a Mac developer
I Love programming, Macs, the iPhone, iPad, Apps & iOS! In my spare time I like Programming in ExtJS, PHP, MySQL / SQLite3 and Apache - in other words a Real Geek's geek. I've tinkered around with programing for iOS in the not so distant past . During the day I work for Motorola Solutions in IT as BSA for our Export Compliance system JPMorgan's TradeSphere. At night I freelance program on the Mac & Web. I'm also a techie who likes Sci-Fi and Horror. Some of my favorite authors include Stephen King, William Gibson and Frank Herbert as well as his son Brian Herbert and Kevin Anderson.
But my real passion is for Comic Book Collecting. My current freelance project is writing a web based application using ExtJS for collecting comics books. After I get the web application completed, I will be integrating some portion of the web application into a desktop client for the Mac through the use of web services for all data exchange & transaction. Eventually, the web site & Mac client would also include a social networking component as well as an iOS component.
I started collecting comic books as a kid when my grandfather passed away and we found my father's comic book collection when we were cleaning out my grandfather's basement. There were a number of early issues in that stash, such as Fantastic Four number one, The Amazing Spider-Man number one, number 22 of the Uncanny X-Men... and others. So needless to say, I was hooked.
After high school I stopped collecting - college, drinking and woman took priority (not necessarily in that order) over visiting the local comic book shop. Now that I have 2 kids of my own, I've gotten back into collecting.
Article that talks about how to add some basic security to authenticating when SSL encryption is not available.
I really hate Virus Barrier’s alerts… the first couple of times I got them I thought they were some kind of phishing attack.
5 months agoSo, Steve Jobs has left his role as Apple’s CEO. Like, for good this time. It’s a shame, but it was inevitable, and it sounds like everything’s running pretty well down in Cupertino anyway.
For the purposes of this anecdote, it’s worth noting that I grew up entirely surrounded by Macs. My mom is…
For a generic solution to reading both XML PList files and Binary PList files check out Rodney Rehm’s CFPropertyList a PHP Implementation of Apple’s PList (binary and xml).
It has a nice object oriented API to read in, traverse, access, modify and save PList files.
Here’s a quick example that I used to read in the iPhoto binary PList file and get the directory where the iPhoto Library is stored.
require_once('CFPropertyList/CFPropertyList.php');
$plist = new CFPropertyList(
'/Users/xxxxxxx/Library/Preferences/com.apple.iPhoto.plist',
CFPropertyList::FORMAT_BINARY );
$pa = $plist->toArray();
print $pa['RootDirectory'] . "\n";
Wow I’m not the only one that has suffered though the pain of UTF-8… though I wonder why he suggests using —default-character-set=utf8 but fails to mention the use of SET NAMES ‘utf8’; after connecting to MySQL to set all of the related character set / collation for the connection, the client, etc. Doing so when using languages such as PHP is very helpful. See my previous post on MySQL and character set here. I also wonder why he chooses to use the collation of utf8_unicode_ci instead of the faster utf8_general_ci?
There seems to be a dearth of information about the iPhoto SQLite3 database, so I am going to continue to post what I find out in hopes that it will help others. This is a follow up to my other posts about iPhotoMain.db SQLite3 database, which can be found here:
Additionally, I found the information I needed from the following blog posts on Punctuated Noise.
The key info I needed that came from the last post above was:
update SqGlobals set modificationDate = (julianday(\"now\") - julianday(\"2001-01-01 00:00:00\")) * 60 * 60 * 24;
From this I was able to determine how to ‘decode’ Apple’s floating point date representation. Not only does Apple use a floating point number to represent a date (it actually form a julian day), but they apparently have 2 different forms of it. UGH!
For those of you who just want the info, check this query out which selects records from the iPhotoAux.db table, SqPhotoInfoOther.
select primaryKey,
archiveDate as rawArchiveDate,
datetime((archiveDate / (60 * 60 * 24)) + julianday('2001-01-01 00:00:00'))
as archiveDate,
originalPhotoDate as rawOriginalPhotoDate,
datetime(originalPhotoDate + julianday('2000-01-01 00:00:00'))
as originalPhotoDate,
originalFilename
from SqPhotoInfoOther;
If you execute the following SQL with values from the SqPhotoInfoOther.archiveDate and SqPhotoInfoOther.orgiginalPhotoDate - you’ll get some nonsensical values back.
select datetime(335385037.045712) as archiveDate, datetime(4239.64527777778) as originalDate;
archiveDate: 913540-11228636-08 13:05:49
originalDate: -4701-07-04 03:29:12
From my Date Format used in iPhotoMain.db database post above, you can see I figured out the 2nd date (original photo date) a while ago… you just need to add the julian day for Jan 1st 2000 @ midnight to the floating point value, then use the datetime() function on the new value.
I tried this for the first date (archiveDate) and no luck: 920252-11228637-15 01:05:49. No improvement. When I came across the update statement above from the Punctuated Noise blog. I knew I had it!
For some strange reason you had to divide the floating point value by the number of seconds in a day (60 * 60 * 24 or 86,400) before adding the julian day for Jan 1st 2000 @ midnight. BINGO!
Now if some one could tell me why Apple, in there infinite wisdom, did it this way. I suspect its something to do with how the Core Data API handles time stamps fields versus date time fields as I have noticed that I have to adjust the archive date by -5 hrs (current offset from GMT for the Central Time Zone), that is the number is GMT, and I don’t have to do that for the original photo date…
Or may be it has something to do with iPhoto knows to store the archive date in GMT and then converts it to the local time zone when displaying it. But for the original photo date, the EXIF data from camera doesn’t have the time zone, so it stores it as it comes in.
Pity, it would be nice if both dates were stored in GMT for consistency.
5 months agoI’m currently working on a program that reads iPhoto’s (version 8.1.2 [424] aka iPhoto ‘09]) main SQLite3 database, iPhotoMain.db. As part of the development I needed to determine the relationships between the various tables. The following SQL query shows the relationships between the following tables:
To retrieve all information about the photos belonging to a specific event (name) in your iPhoto library execute the follow SQL SELECT statment:
select * from SqEvent as e join SqPhotoInfo as pi on pi.event = e.primaryKey join SqFileImage as fim on fim.photoKey = pi.primaryKey join SqFileInfo as fi on fim.sqFileInfo = fi.primaryKey where e.name = 'At the Beach Hargar Park Coloma, MI 2011';
The above query will return multiple records (usually 3, but it can be more than 3 records if the photo was modified) for each photo.
One record for the Original (unmodified) photo, another record for the Thumbnail and a third record that only references the file name (not sure of the function of this record yet).
5 months agoTo show the default character set of a MySQL database use this query:
SHOW CREATE DATABASE `DB_NAME`