Archive

Archive for the ‘Tutorials’ Category

A Secret Agent Trick

April 14th, 2010

I recently discovered a neat little “trick” on my iPad (and iPhone): I’ve stumbled upon a way to listen to music streaming from Internet radio stations while I do “other things,” like check my email, take photos, or write text messages.

While iPhone OS 4.0 — due out this summer — will finally deliver the long-requested ability to allow users to listen to their Pandora or Last.fm radio streams in the “background” by virtue of its new “multi-tasking” capabilities, the solution I’ve stumbled upon works (in slight variations) today with any device running iPhone OS 3.x.

Although this little trick won’t work with Pandora, since you must be using a Pandora client to stream their music, you can use it with any radio station which exposes its MP3 or AAC music stream via a multimedia playlist file URL (which will typically end in .pls); basically any radio station you’ll find on Live 365, Soma FM, and more.

I’m a fan of Soma FM’s Secret Agent radio station, so we’ll use that for our example; feel free to try this out for any station you like.

The process is super easy, but slightly different between the handheld iPhone OS devices (eg, iPhone and iPod Touch) and iPads (for which it’s actually a bit spiffier), so I’ll take you through the steps for doing it on each one.

iPhone / iPod Touch

Launch Mobile Safari, and head to the following URL:

http://somafm.com/secretagent48.pls

You’ll see the following:

Safari fetches the PLS file URL

Once the playlist file is loaded, Safari will find the URL of the music stream, and start playing the music, and you’ll see this:

Safari has started playing the audio stream

Now — click the Home button and, say, check in on your email. Note that the music continues to play.

Isn’t that fantastic?

Just one caveat, though: you won’t be able to browse other websites in Safari until you click the “Done” button (top left), which — as you might expect — causes the music to stop playing.

One workaround is to use an alternative browser, like iCab, Opera Mini, or any of a number of other web browsers (some paid, some free) available in the App Store.

iPad

Things get a little cooler on the iPad. The steps to get you listening to the music stream are the same, but we can do a few more things once the music starts playing on the iPad.

Once the music starts to play, you’ll see this:

Screenshot of Safari playing the audio stream

Safari playing the audio stream

Note one key difference to note, however: unlike the iPhone’s Mobile Safari app, the iPad’s Mobile Safari continues to show you the browser chrome up top.

For starters, this means that you may continue browsing other websites in Safari on the iPad by simply tapping the tabs icon at the top:

A screenshot of Safari's tabs manager

Change tabs or create new ones.

What’s more you can actually create a bookmark for the radio station, so you can quickly listen any time:

Screenshot of Bookmarking

Create bookmarks for your favorite stations

But — and this is where I started to get a little verklempt — it gets just slightly more fantastic: you can bookmark it to your Home Screen.

A screenshot of creating a Home Screen bookmark

Now I can fire up Secret Agent FM from my Home Screen, just like Pandora or Last.fm.

Looks like the folks at Soma FM went the extra mile to specify a Home Screen icon for their website. Your mileage will vary with the availability of your favorite station’s dedicated icon for your Home Screen, however, depending on the site publisher.

Meanwhile, go forth and enjoy streaming some music while you’re sending those texts or reading the Times.

Check it out, Tutorials , , , , ,

Bizarro HowTo: Write CSS Like a Total Douche Bag

August 3rd, 2009

We’re half way through 2009. All the major browser vendors are shipping products with really great rendering engines now. Usage of the much-maligned Internet Explorer 6 has plummeted to the 15% neighborhood (stats vary, but they all show < 20%).

The days that Web developers dreamed about — seemingly, at the time, against all odds — for about half a decade are nigh upon us with this progression.

Although much work remains to be done before all browsers can be universally relied upon to render HTML in a consistent and relatively uniform manner, the Web development community can at least now begin breathing a sigh of relief about having finally gotten some of the worst of it behind us.

But has anyone ever stopped to think about the folks that actually get off on making other people’s jobs difficult? Clean style sheets? Progressive Enhancement? Semantic Web?

How do you suppose they feel right now? Whether it’s sadism or nostalgia, they’ve got feelings, too.

To them, I say with reassurance: fret not!

For them, I offer here three fabulous pointers for writing CSS like a total douche bag:

  1. Use the same IDs for more than one element in an HTML document. The HTML spec is very explicit about not doing this, so you can absolutely bet that — some time down the line — some other developer tasked to add some jQuery or Prototype enhancements to your page will totally get screwed.

  2. Sprinkle your IE 6 “hacks” directly into and all throughout your primary CSS files. Do not separate these IE 6 optimizations out from your main.css file into main_ie6.css. Coding your site to standards first will only make it easier to phase out this pollution when IE 6 finally drops off the planet. To ensure you really nail this one, you should be previewing the site in IE 6 from the very beginning of your development efforts. In fact, I could even recommend you develop the site’s HTML and CSS in IE 6 exclusively first, then go back and apply hacks to make it work in the rest of the more standards-compliant browsers… in fact Firefox 3.x and Safari 4.x both include really great developer tools to help you figure out which “standards compliancy hacks” you’ll need to use to keep the site from looking completely fucked in those browsers.

  3. Use CSS style and ID names like next_alignright_blue or registration_form_gray. The more you mix styling cues directly into these names, the more you’ll be able to laugh and laugh and laugh and laugh when those “next” links need to be green when the site’s holiday theme feature gets finished after Thanksgiving. Honestly: what’s funnier than knowing that next_alignright_blue will render green links? And, if you’re truly lucky, maybe a usability audit of the site might conclude that the “next” links should not get jammed to the right, but should appear adjacent to their associated “previous” link.

  4. Avoid descendant selectors like the plague. The only thing that these will ever afford you is the opportunity to minimize the number of IDs and class names. Where will your opportunity for laughs come when elements can be targeted by JavaScript enhancements using a syntax like this:

        [#!javascript]
        $('#sidebar .panel .description a.more').click( ... );
    

    instead of:

        [#!javascript]
        $('#sidebar_videos_panel a.more').click( ... );
        $('#sidebar_widgets_panel a.more').click( ... );
        $('#sidebar_uploads_panel a.more').click( ... );
        $('#sidebar_archives_panel a.more').click( ... );
    

    The first example allows some other developer to continue to leverage the selector code to enhance the “more” link, should another .panel element with a qualifying like in its .body element, rather than having to explicitly add another line.

And so I hope I’ve demonstrated that there’s simply no reason to mindlessly progress into the hegemony of maintainability, efficiency, and sanity for your colleagues. Not when you can utilize simple little techniques like these.

With your efforts, we can squander much of this hard-earned potential for progress! If you have other douchey ideas you’d like to share, please leave them in comments.

Tutorials , , ,

A Single Pear

July 24th, 2009

I’ve just invested several hours trying to get my system to use the Pear libraries from MacPorts rather than the Pear libraries I had installed years ago using the command line installer, as described here. This is largely because I’m happy to let the MacPorts package manager take care of upgrading my software, and making sure all inter-dependencies are looked after.

The command line installer adds files to the traditional /usr/local directory, while the MacPorts package manager adds the files to /opt/local.

And from there, troubles arose. Read more…

Tabula Quasi-Rasa, Tutorials , , ,

The Habits of Effectively Exploiting Twitter

June 4th, 2009

I’ve lately been involved in a number of conversations about the value proposition of Twitter as a publishing platform to anyone interested in developing a public persona for a company, an organization, or even one’s own career identity. What follows are ideas that have repeatedly surfaced during these conversations, as well as a handful of links I’ve been amassing from my reading, as well as links friends and colleagues have shared with me.

Some Terms

Throughout this post, for the purpose of simplicity, I will use the term brand to apply to all types of public personae, whether organization or personality.

I will also be speaking about a brand’s domain of interest, by which I intend to refer to the plurality of whatever industries and/or disciplinary fields that are relevant to the brand. I’ll use it in this singular form as a blanket concept, covering all topics of interest to the brand.

Finally, I’ll be using the term market to refer to any and all entities to whom a brand seeks (largely competitively) to offer a value proposition, and who interest — in whole or in part — in the brand’s domain of interest. In the case of a company, their market is naturally their customers, clients, etc. In the context of an organization, its market may be composed of the members it seeks to attract, or the community that it seeks to serve. Finally, a market for an individual’s own brand can consist of one’s prospective employers, clients, students, an educational institution, or grant or fellowship for which he or she may wish to apply.

Why Even Bother With Twitter?

Before I get into the any of the how, let’s invest a moment to get on the same page with respect to the why, since the means must be evaluated against whether or not they advance your efforts towards the desired ends.

This is material that’s been covered the world over around the Web, so I’ll keep this concise:

The goals are currency and reputability.

Currency here refers to the state of maintaining continuing familiarity with the ideas and topics relevant to the conversations presently taking place in the brand’s domain of interest. Currency helps a brand focus its efforts to remain relevant to its market, and is maintained by consuming incoming information.

Reputability refers to the brand’s reputation within the context of its market. Its measure exists only in the eyes of the brand’s prospective market, so it can only be built and developed with public action. On Twitter, this means publishing, or tweeting.

And so the value-proposition that participation in the Twittersphere offers a brand is that it can help the brand stay at the top of its game, and give the market a sense of the brand’s voice, relevance, and even competitive acumen.

But how can a brand engage with Twitter to realize these goals?

Read more…

Business Sense, Tutorials , ,

Using the HP Mini Netbook: Pimping the Mini’s MIE: Adding Flock

May 21st, 2009

I broke down and hacked my MIE. But just a teeny bit, though: I simply installed the Flock browser and added it to the application launcher.

I needed to know it could be done.

Having satisfied my need to see the proof-of-concept, I intend to return to using the non-hacked configuration (by disabling what I’ve done) for a little while longer, while I complete a review period during which I use the computer with only the applications found on the default system.

That said, I will mention that am rather pleased with the initial results of my efforts in hacking this thing.

Once I’m done assessing its performance and capability as configured in its “out-of-the-box” mode, I intend to hack the hell out of MIE. Maybe I’ll even manage to fix the damned issue I’m encountering with the Mail widget on the home screen that HP’s customer support facilities have utterly failed at helping me resolve… but I’ll get into the saga of HP’s epic failures at customer support in a future post.

Read more…

General Thoughts, Tutorials , , , , , ,

sfPropelLazyHydrationIteratorPlugin — Lazy Hydration, Made Concise

May 13th, 2009

I’ve recently been working on Symfony / Propel projects that deal with particularly large data sets. In such cases, Propel’s documentation recommends a “lazy hydration” approach.

This “lazy hydration” of Propel’s looks like this:

  [#!php]
  // query all the author entities as a Creole ResultSet
  $rs = AuthorPeer::doSelectRS( new Criteria() );

  while( $rs->next() )
  {
    $author = new Author();
    $author->hydrate( $rs );
    echo "{$author->getLastName()}, {$author->getFirstName()}";
  }

The code above does the following:

  1. it queries the database for all records in the author table, and loads it into a Creole ResultSet object.
  2. enters a loop, iterating over each result (ie, table row) in the ResultSet, and with each of its records, it:
    1. creates a new, empty Author object
    2. hydrates the empty object with the data in the ResultSet‘s current row
    3. writes the author’s last and first name to the output buffer

In this way, only one Author instance is in use at any given time. Each iteration discards the previous instance and creates a new one.

But I hate it — it’s ugly and unwieldy.

This overt use of the ResultSet object is an awkward practice when using an ORM. The primary design goal of ORMs is to allow the developer to work at a higher level of abstraction than SQL queries and database result sets.

So what should it look like? Read more…

Tutorials , , , , ,

Stop Installing Windows

April 11th, 2009

My brother and I had been suffering from a chronic affliction for roughly the last decade. You see, every year or so, we’d have to reinstall Windows on the PCs in our father’s office. The reasons for the re-installation ranged from viruses, to a hosed registry, and even hard drive failures; the poor man’s PCs have seen it all.

It was a cycle that looked something like this:

  1. the computer starts behaving strangely (random crashes of applications or the system, mysterious prolonged lock-ups, etc)
  2. my brother or I get called in to diagnose
  3. we discover the problem
  4. we attempt to fix
  5. sometimes the problem is resolved, but other times it’s necessary to reinstall
  6. we attempt to backup the most recent data (if it’s not somehow corrupted), or use the latest weekly backup
  7. boot the Windows installation disk
  8. clear the hard drive
  9. install Windows
  10. activate our copy of Windows
  11. install anti-virus software
  12. install the latest Windows Service Packs, as well as any other security updates
  13. install the necessary software
  14. restore the backed up data files
  15. wait for the cycle to start again

Some folks reading this far might argue that we should have moved him off Windows a long time ago, and saved ourselves the trouble. Why not just give him a Mac or install Linux and put the worries aside?

Unfortunately, it’s not that simple.

He needs to run Windows because he runs his business on an accounting software package called PeachTree. The fact that alternatives exist is immaterial; all the business data is already stored in there, Dad and his book keepers know how to use it, and nobody involved feels like learning some other convoluted accounting software.

Windows simply cannot be removed from the equation.

Unfortunately, we were trapped in what seemed like an interminable cycle. It had practically reached the point where my brother and I developed the capability to do the job drawing purely on muscle memory to lead us through.

But muscle-memory or not, installation demands time.

Even after the Windows installer itself would do its job, we would then have to download and apply the most recent Service Packs, install his software, and reconfigure his desktop so that everything is “in the right place.”

In our case, the reinstallation process would typically consume about a full 8-hour workday, and occasionally more if there are network connectivity issues or other mishaps. Naturally, since both my brother and I have day to day responsibilities of our own, the effort would always wind up consuming one of our weekend or holiday days.

It happened again in February of 2009… specifically, on my brother’s birthday weekend. My father took the family out for a birthday brunch, after which my brother and I accompanied him to his office to do the dirty work.

But this time, a new strategy occurred to me: surrender.

I decided to accept the eventuality that Windows will, in time, shit the bed on us. This has all happened before, and it will all happen again. It may be some sort of malware, or just a badly-written (but perfectly legitimate) installer that hoses your registry.

Once I’d accepted this, and the denial had melted away, my goals changed from protecting Windows from malware to working out how to make the restore suck less.

Since we’d managed to get them in the weekly practice of making weekly backups of their business data, the worst part about restoring their computers was simply investing the time it takes wait out all the damned progress bars of the process. Installer after installer would run, many needing an attentive human present to click “OK” or to accept license agreements.

The faster we could get from empty hard drive to functional Windows system, and the less attentive effort it required of anyone, the better everyone’s life would become ever more.

The goal was to reduce the restore process to a simple file copy.

And with this thought, I suddenly knew what had to be done: all we needed was a bunch of free software (and a RAM upgrade for one of the computers), and we could install and configure Windows—and all of his software—for the last time, ever.

We erased the hard drives of his PCs and installed Ubuntu Linux on all of them. We then installed Sun’s free and open source virtualization software, called VirtualBox, and carried out our routine installation and configuration of Windows — and all the necessary software — into a virtual machine.

We added free DropBox account service to the picture, just to bulletproof the backup strategy for his business data.

Once everything was installed and properly configured, we stopped the VirtualBox virtual machine and created a master backup copy of the new virtual machine’s hard drive image file. This master copy of the hard drive image now contained a fully-configured, pristine version of Windows.

Moving forward, a full Windows restoration process for the accounting PC can be conducted over a lunch, instead of the course of a full workday.

And because Windows is running in a virtual machine, we’ve even managed to reduce the amount of time that would be required to replace the entire machine: simply wipe its hard drive, install Linux on it, copy over the Windows virtual machine’s hard drive image, and we’re up and running with all of our user settings and latest business data in place. And because Windows only ever “sees” the virtualized “hardware” presented by VirtualBox, it won’t require a reactivation.

I should finally note that the accounting machine is used as a fulltime Windows machine. That is, from the moment of startup, VirtualBox is launched, and the Windows desktop is used in full-screen mode, with nary a though given to the Linux environment, until they’re ready to shut the machine down.

So from now on, when Windows does eventually punk out in one of its many—and, at times, even innovative—ways, we’ll be ready.

Tutorials