#Development


Resize to a Specific Element’s Dimensions

Here’s a snip­pet to resize a back­ground image to the dimen­sions of an ele­ment. In this case, #bkgIm­age.

var resizeBkg = function() {
    var h = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    var w = self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    var e = document.getElementById('bkgImage');
    if (w > h) {
        e.width = w;
        e.height = w;
    } else {
        e.height = h;
        e.width = h;
    }
} 

Obama iPhone and iPod Touch App

Woah. As if hav­ing the cre­ative likes of Obey Giant (Shep­ard Fairey), ISO50 (Scott Hansen), and Sarah Sil­ver­man weren’t enough, a cou­ple of iPhoneDe­v­Camp alumni vol­un­teered to cre­ate an iPhone and iPod Touch appli­ca­tion for Barack Obama.

You’ll have instant access to Barack’s posi­tions on impor­tant issues, as well as local and national cam­paign news as it hap­pens. Pho­tos and videos from the cam­paign trail are all here, too.

  • Call Friends: A great vol­un­teer­ing tool that lets you make a dif­fer­ence any time you want by talk­ing to peo­ple you already know. Your con­tacts are pri­or­i­tized by key bat­tle­ground states, and you can make calls and orga­nize results all in one place.
  • Call Stats: See nation­wide Obama ’08 Call Friends totals and find out how your call totals com­pare to lead­ing callers.
  • Get Involved: Do more. Find and con­tact your local Obama for Amer­ica HQ.
  • Receive Updates: Receive the lat­est news and announce­ments via text mes­sages or email.
  • News: Browse com­plete cov­er­age of national and local cam­paign news.
  • Local Events: Find local events, share by email and get maps and directions.
  • Media: Browse videos and pho­tos from the campaign
  • Issues: Get clear facts about Barack Obama and Joe Biden’s plan for essen­tial issues fac­ing Americans.

I won­der how the McCain camp will fol­low up on this. For some rea­son, every time I asso­ciate John McCain and the web, I seem to refer to Mike David­son pun­ish­ing McCain’s web team for hot link­ing images on John McCain’s MySpace page. Clas­sic.

Any­ways, enough of the rem­i­nisc­ing. I com­mend the iPhoneDe­v­Camp alumni amongst the other 4 who vol­un­teered their time to the project. It truly gives some boost and good press to the iPhone devel­op­ment plat­form and its every­day appli­ca­tion; whether it be check­ing your health, to learn­ing why to vote for a pres­i­den­tial candidate.

The app is avail­able at http://my.barackobama.com/page/content/iphone

Adobe Creative Suite 4 — Launch Broadcast

Since writ­ing about the Adobe CS4 live web broad­cast a cou­ple of days ago, I was for­tu­nate enough to finally view it. Enjoy!

You may view the video at a higher res­o­lu­tion via http://tv.adobe.com/#vi+f1556v1715. You may also find other related videos on that page with regards to CS4. The ones I am inter­ested in see­ing would prob­a­bly be the following:

All I can say is that this is going to be one very nice Suite, and should be fun to play/work with.

Find Duplicates in Address Book

Ever had the sit­u­a­tion where you have synced your iPhone (to iTunes OS X) and hap­pen to sync both the con­tacts from your Address Book and Google Con­tacts? Or, just hap­pen to add someone’s new con­tact info as another contact-card? Well, here’s how I cleaned and merged dupli­cate con­tacts so that my Address Book per­forms like a champ.

  1. Launch Script Edi­tor (Applications/AppleScript/Script Editor)
  2. Paste the fol­low­ing code snippet
    tell application "Address Book"
        set biglist to {}
        set theGroup to count every person
        if not (exists (group "Duplicate Entries")) then
            make new group with properties {name:"Duplicate Entries"}
        end if
        set the_names to the name of every person as list
        repeat with i from 1 to number of items in the_names
            set this_Name to item i of the_names
            set theName to name of person this_Name as string
            if this_Name is not in biglist then
                copy this_Name to end of biglist
            else
                add (people whose name is theName) to group "Duplicate Entries"
            end if
        end repeat
        save addressbook
    end tell
  3. Save your newly cre­ated script (would usu­ally default to ~/Documents/AppleScripts/), and just open/run it

Now, the eas­i­est way to fig­ure out if its run­ning or not (at least for me) was to run the Activ­ity Mon­i­tor and sort by CPU. I sim­ply just waited to see if Address Book would climb to the top doing 90+, and back down to nil. When this is done, you should be able to see a group called “Dupli­cate Entries”. From there, you may now sort through the details and delete the ones that you don’t need.

Note: You can also do a quick merge via Address Book itself from dupli­cate con­tacts. How­ever, you won’t be able to see which con­tacts are being merged as its just a set-it-and-forget kind of deal. If you do not care and sim­ply just want to get rid of those dupes, you can do so by doing the following:

  1. Launch Address Book
  2. Select Card from its menu
  3. Then, select Look­ing for Dupli­cates… and just go through the fol­low­ing prompts after search results finishes