Archive for the ‘Uncategorized’ Category

Post a status update to the native Facebook app from a web link

Thursday, February 2nd, 2012

The skinny

Copy this code:

<a href="fb://publish/profile/me?text=foo">Post to Facebook</a>

Explanation

As you may know, Facebook has a URL scheme fb:// which seems to be mainly used by native developers. What most folks don’t realize is that it’s just a URL scheme, like http://, and that we can use it within our mobile browsers! The only problem is that there’s no official documentation for it, so folks have had to hunt down the particulars.

After poking around a bit, you might find this topic on Stackoverflow, which contains a ton of protocols for getting to specific sections of the Facebook app, as well as this interesting snippet:

fb://publish/profile/#ID#?text=#BODY#

Trying that as a link does work, but it takes you to this blank screen:

Facebook app - blank screen

That blank screen isn’t too exciting, but it is peaceful, like a Zen rock garden. Bookmark that page so you can come back later, when you’re overwhelmed by friends flooding your updates screen with baby pictures.

Google to the rescue!

Ok, now back to work!

After poking around and trying to find my Facebook id, I inserted it and got the link to work. But that’s not ideal, since everyone has different user ids. And I’m not about to load in all the bloatware that comes with the Facebook API just to find a user id!

After poking around a bit, I found this link which showed this generic pattern:

fb://publish/profile/me

Whoo! And that works! But I still want to prepopulate the status field. We can do that by passing in a URL parameter:

fb://publish/profile/me?text=foo

Clicking on it will get you to a screen which looks like this:

Facebook status update with share button disabled

This, interestingly enough, appears to be the old implementation of the status screen. Here’s what it looks like if you launch it through the button on the native app:

Facebook status - what it looks like normally

Also note that the Share button is disabled until the user types in text themselves. This might be a little confusing for some users, but it’s probably the best way to prevent spam.

Detecting if the Facebook app is installed

There’s another issue with folks who don’t have the native Facebook app installed. There doesn’t seem to be a perfect way to detect if the link failed and went nowhere. What we have to work with are hacky workarounds involving setTimeout.

It looks like native iOS apps have an ideal URL scheme checking ability with a canOpenURL method. Unfortunately it doesn’t look like the web has this function (yet). Let’s bug Apple to implement it! :)

Related

Just a heads up – I’m definitely not the first one to figure this out, as I found a jsfiddle with the same information, plus an example for posting to Twitter. That was surprisingly the only result! I couldn’t find anyone who blogged about it yet, so here you are!

More URI schemes for other launching other native apps

Web development / Silicon Valley rant

Saturday, October 22nd, 2011

(if you didn’t read the title – warning: rant…)

As far as web development goes, I guess I could rant on and on about the generalities. Of all things ephemeral. The lust after money, gadgets, and other worthless material crap that we use to stuff inside our oversized houses.

The startling creativity and in equal amounts the lack of creativity. The amount of amazing invention and the equal amount of copying and ripping off.

I could complain of amazing shortsightedness, of fads, and of constant new waves of developers that have to relearn and be convinced of old tried-and-true best practices (while still being able to identify the outdated best practices).

I could possibly ponder some of the stupid things we concern ourselves with, which are criticisms more aimed at the Silicon Valley mentality in general. The sheer amount of idiotic startups. The desire to have a startup only for the payout, for the acquisition. The one worthwhile and meaningful startup surrounded in a sea of hangers-ons, social network clones, photo sharing service clones, Facebook game clones, and on and on ad nauseum.

I could complain about the few passionate ones, surrounded by a pool of passionless jumpers-on-the-bandwagon, people looking for a free ride, and people looking to coast through their secure jobs, content with nothing more than receiving their paycheck.

I could complain about the lack of real heroes. People who made a difference to our small isolated communities, spoke at conferences, authored books, wrote popular blog articles, but were perhaps never themselves. People who we could not look up to as model human beings, but as model toolmakers and nothing more. I suppose it’s folly to look for too much else there anyhow.

I could complain about the praise of life imbalance. Of prideful people showing off, working longer hours than their peers, feeling like they have to in order to keep up, and bragging about losing sleep and becoming unbalanced and unhinged individuals. Competition is good and pushes everyone to be more detailed and more polished, but there seems to be no admission of a limit, of reaching a life imbalance. The more time spent coding, the better. If you don’t code in your free time, you must not be a true coder. If you don’t enjoy learning new languages, you must be a crappy coder. The amount of pride and self-delusion here is scary.

I could talk about corporations seeking young programmers without commitments in order to suck dry every last ounce of their passion, essence, and thirst, distracting their focus away from all things important. Of those same corporations sticking those young impressionables onto outdated projects, maintaining and fixing bugs. All for what?

I could speak of self-delusion that programming language X will save the world, and on self-delusion in general, which I believe is rampant here and elsewhere, and is possibly our greatest weakness as human beings.

I suppose now you’ll tell me I’ve lost my head and gone crazy, but I would disagree. These things have never been so clear and the arguments have never been so cogent as they are now. There is no utopia, no perfect occupation, but I believe there are some that are better than others. Everything has its faults, and web development isn’t for everyone. Perhaps it’s simply not for me?

I got into web development as a means to an end – as a way of publishing what I enjoyed doing. As a tool I picked up and put down when I was finished, and then got on with my life. Perhaps it’s time to move it back to that corner of my life, and even better, to use it as a tool to help me build new, meaningful, less ephemeral things. Something I could be proud of in more than a few years. Something more than being an “HTML5 expert” or “Mobile expert” or “JavaScript expert”.

No. I want to use these things as tools that are put back in their shed after I’m done. Tools to build something greater than the sum of its parts. Tools to make a meaningful contribution that may not amount to a hill a beans in this crazy world, but could at least be something I’m proud of.

Programming as a profession is only moderately interesting. It can be a good job, but you could make about the same money and be happier running a fast food joint. You’re much better off using code as your secret weapon in another profession.

People who can code in the world of technology companies are a dime a dozen and get no respect. People who can code in biology, medicine, government, sociology, physics, history, and mathematics are respected and can do amazing things to advance those disciplines.

(Advice From an Old Programmer)

Somewhat related: Where Do All of the Old Programmers Go?, The ACL is Dead, Silicon Valley’s Dark Secret: It’s All About Age [and the disturbing reddit thread to accompany that])

Addendum

It’s notable to add that I’ve been comparing “Kyoto culture” to “Silicon Valley culture”. They are so dissimilar that it’s doubtful we’re even using “culture” in the same sense in both cases. Kyoto culture, a long proud, rich, colorful history of a people, and Silicon Valley culture: an atmosphere of tech, founded by money and driven by money. In one, it’s almost a crime to stay inside and not to explore and enjoy the city. In the other, our wealth lets us build up a castle, buy devices and home entertainment to keep us busy in our little fiefdom. Silicon Valley is more like a boomtown which exists only for one sick purpose, and consequentially lacks a soul even more severely. Would you rather be underpaid in a city with a soul or overpaid in a soulless city?

On professional self-worth

Tuesday, June 21st, 2011

Huge huge rant incoming, but all is not said and done, and much is open for debate of course. Counterpoints and criticisms are more than welcome in the comments. This is just my opinion based on my experience at this point in time.

Self-worth: the rich man and the poor man

For a long while there have been places in the world that view self-worth as largely tied to wealth.  No doubt there is more than just money, as even within the rich community there’s a distinction between the established rich and the “nouveau riche”, or the newly rich.  One is ranked higher than the other, but nonetheless the rich are themselves seen as being more important than the average person.

You might not believe me.  That means it’s time for a thought experiment!

One way to hammer home this point is to posit a classic thought experiment.  There are two people – one rich and one poor – and this is all the information we have about them (this is important).  Assuming that one of them will die in some horrific way and we can only choose to save one, most people would probably save the rich person (assuming they don’t have a bias or some psychological complex against rich folks).  Remember, we have no other information about them other than one is rich and one is poor.  The aim of the thought experiment, rather than trying to give a realistic scenario, is to simply try to show us that we give the rich person preference.  At least ij the case where we have no other information.

And it’s not even that we think we might receive a reward from the rich person!  Even if we figure that in, we still give preference to the rich person, probably in part because we think that they must be somewhat more important than the poor person.  They must have acquired that money some way, after all.  Possobly even through hard work.  The poor person, we assume, must be poor for a reason, and that might be through sheer laziness.  So we have a hard worker versus a lazy worker… which one is more worthy to live?  And it’s only those hasty assumptions that we have to deal with.

Professional worth: employees of famous and nonfamous companies

Laying aside issues of money for a moment, let’s perform a similar thought experiment, except with different people.  One person works at company X, which no one has really heard of, and the other person works at company Y, which at the time is a wildly famous and reputable company.  Because this industry is so fickle and subject to change, at the time of this writing this famous company might be Facebook, Google, or Twitter.  Or any other company which has the tech zeitgeist or mojo at the time.

Assuming we know nothing else but the people’s employers (and laying aside biases and hatred for certain companies), if we put these people on the line, the one employee of a no-name company and the other employee of a famous company, we would probably choose to save the latter.  For much of the same reasons as above.  For instance, this person got a job at Facebook, so they must be smart and a hard worker.  On the other hand, the person at the no-name company (i.e. the vast majority of people out there) is probably not as smart or not as hard-working.  After all, if they were, then they would’ve been at (famous company) by now!  Therefore they are undoubtedly less worthy professionally, and by hasty extension, less worthy as a human being (remember, we have no other information to base our conclusion off of).

So it is!  Death to the employee of the nonfamous company!

Work history, first impressions, and professional self-worth

We chose to save the rich person and the Facebook engineer. The good thing is that luckily almost no one thinks in these horrible black-and-white terms, and we always take into account other available factors.  For instance, as an example of a poor person we might have Mother Teresa and as a rich person we might have mean old Donald Trump.  No one in their right mind would send Mother Teresa off to the gallows while letting Trump off (regardless of what you think of Trump really).

The problem here is that although we do take into account different factors, professionally we (and recruiters) weigh our work history much too heavily in the grand scheme of things.  We take other factors into consideration, sure, but work history is a huge deciding factor as far as people are paid attention to, give off good first impressions, or are even given a single glance by recruiters.

This isn’t totally unwarranted, I should say.  Chances are, if someone worked at a few famous companies, there’s a good chance they are a better than average engineer, even though there’s no guarantee of this (there are always exceptions).  But that’s not the problem here.  The problem is because this is given a disproportionate amount of weight, people start to view this as THE deciding factor in whether to work for a company.  Name-brand recognition becomes a goal-in-itself.  Money always matters, sure, but professionally there is little that can beat having a reputable name brand on a resume.

So what happens in practice?  An engineer becomes employed at a famous big company, is put to work maintaining some existing platforms, and at the end of a year perhaps learns some things that make them a better engineer.  But the same person instead working for some no-name startup might in the same period of time learn many more technologies, solve many more problems, and have a bit more freedom and opportunity to create (though they won’t necessarily learn best practices or scaling issues that typically come with famous large companies, but there’s more to being a good engineer than that!).  Each gets an opportunity to get their hands dirty with different varieties of dirt.  At the end of the day, I would say the latter very well becomes a more well-rounded engineer, instead of a generic single-functioned cog in some big company machine.

Ok, now my bias is showing through brilliantly!

Let’s at least say, for the purposes of argument, that both engineers are equally skilled (though this is hard to quantify, though, obviously).  So who do the recruiters contact, the employee at the famous company or the employee at the nonfamous company?  Who gets more attention from people in general when they’re asked where they work?  In short, whose professional life is a priori more highly valued?  You already know the answer.

Final thoughts

We MUST become more confident of our skills (I need to work on this myself), and we must be tough enough and realistic enough to know our own professional worth.  Appearances count for much in this world, and too much at that.  But what better to maintain if we are authentic human beings: an appearance or something deeper?

Famous companies do look good on resumes in the same way Ivy Leagues colleges look good on the very same piece of paper.  But don’t make this a deciding factor when choosing an employer.  It’s true that it will help you find more jobs and get more respect in the long run, but then you are wasting your time doing something you don’t want to do for the duration, for a company that exists for its own ends, not the ends of its employees (this is true of most companies out there, to be fair).  If you are ok wasting your time for a cause such as this, then go for it. It seems some people are ok with that.  At the very least be aware of it.

So what happens to the passionate engineers who actually do want to work for a famous company for reasons other than brand recognition?  They might not always get the job.  But it’s definitely not the end of the world.  No one should be disheartened because Google turned them away for not being able to answer today’s technological equivalent of “how many angels can dance on the head of a pin” (or other mental masturbation puzzles).  In the end it’s you that makes you a worthy professional and a good engineer.  If your job doesn’t actually give you a chance to be one, you can still become one on your own.  I would say most people are capable of this if they invest the effort.

But working for a famous company, and for its own sake?  It doesn’t necessarily make you a good engineer, any more than wearing glasses and dressing in a suit gives more validity to your opinions (even though many people sadly tend to think otherwise).

(Note to self: I wrote this on the banks of the Kamogawa River in Kyoto on my iPad. I was enjoying the moment and obviously in a contemplative mood!)

The incredibly painful way of getting an RSS feed of a Twitter list

Sunday, June 5th, 2011

(why does Twitter make it so hard? What did RSS ever do to it?)

The skinny

The Twitter API appears to support two methods for getting RSS feeds of lists. Both of these methods are pretty buried and their API docs don’t help too much, but nonetheless both of these feeds work:

http://api.twitter.com/1/nathansmith/lists/javascript/statuses.atom

If you have the list ID (requires using some dev tools – see below), you can also use this format:

http://api.twitter.com/1/lists/statuses.atom?list_id=41981352

The explanation

As it turns out, getting an RSS feed of a Twitter list is no easy task, at least from what I’ve found. Twitter has largely replaced RSS for me, in terms of getting the latest and greatest information, and maybe Twitter wants to keep it that way by having me rely on their service instead of an RSS feed. That’s how it seems to me anyway (this is also evidenced by their killing off of making RSS feeds easily discoverable but still making the feed available as long as you can figure out your Twitter user id (which is a task in itself), for instance here’s my RSS feed: https://twitter.com/statuses/user_timeline/16521889.rss). I’d say this is simply a conspiracy against RSS feeds and developers in general, which is the direction Twitter is headed these days.

In any case, I digress! I want to get an RSS feed of a Twitter list. Great! All I should have to do is go to the page of the list and subscribe to the RSS feed. But.. there’s no RSS feed. Hmm.

Google is your friend… most of the time

A search for “twitter list rss” comes up with links to implementing an RSS feed via Yahoo Pipes as well as pages referring to an appspot service that now 404s (twiterlist2rss). In any case, they are both not what I’m looking for. Which means I have to get creative. Which means… my options at this point are screen scraping (made harder by the fact that Twitter content is now served with JavaScript) or.. gasp.. using their API!

Twitter REST API to the rescue

After digging through the API docs, I found just the page I was looking for, detailing the REST service for Twitter lists.

As it turns out, the basic structure for requesting list data is as follows:

http://api.twitter.com/version/lists/statuses.format

As a newbie Twitter developer, there were a couple of things wrong here. First, what’s the version of the API I’m supposed to use? From other examples on the web (outside of the documentation…) I just assumed I’d be using version 1, and that seemed to work. Ok, whatever, we’ll go with 1:

http://api.twitter.com/1/lists/statuses.format

Second step: this API is actually quite nice, and will return data in three different formats: xml, json, or atom (RSS!). Ok, now we’re making progress!

http://api.twitter.com/1/lists/statuses.atom

Where’s this list_id you speak of?

Now to pass in the info – I need to pass in the list ID in a key called “list_id”. The only problem is… where do I find the list ID? For the purposes of this example I’ll use Nathan Smith’s excellent JavaScript developers list. To normal human beings, this list might be called “nathansmith/javascript”, but a Twitter ID is numerical, so that’s not what we’re looking for.

So.. I assume at this point I can use some of the Twitter developer tools and fiddle around with them until I find an API call that will translate the human-readable list name into a numerical ID. But no.. I don’t want to download anything, I don’t want to investigate more of the API or go down any more rabbit holes.

It’s time to cut this rabbit hole short and do a bit of investigating. So I pulled up the list, opened up Web Inspector in Chrome, and took a look at the Network tab in the hopes of seeing an API call with an ID I was looking for…

…And I found it! Somewhere down the line, Twitter was calling statuses.json with this request:

https://api.twitter.com/1/lists/statuses.json?list_id=41981352&include_entities=1&include_available_features=1&contributor_details=true

There’s our list_id (and incidentally, the same API call [with json instead of atom].. which shows that Web Inspector is more useful than API docs sometimes)! After a short copy-paste, all the pieces of my Frankenstein API call have been put together:

http://api.twitter.com/1/lists/statuses.atom?list_id=41981352

And it works, without having to mess around with OAuth or authentication, registering an app, or whatever. Of course now we can refer back to the API docs and mess around with some parameters to get just the data I’m looking for. Maybe most useful to developers is the handy ability to get easily paginated results:

http://api.twitter.com/1/lists/statuses.atom?list_id=41981352&page=2

There’s also what would be a handy “count” variable, but it’s altogether useless as it appears to be ignored. The API always returned 20 results for me.

In any case, there you have it! The incredibly roundabout way to get an RSS feed of your favorite Twitter list.

UPDATE

Thanks to this site, it looks like there’s a more straightforward way of getting the RSS feed. Using the same list we were trying to get above, it looks like this also works:

http://api.twitter.com/1/nathansmith/lists/javascript/statuses.atom

Android 3.0 Honeycomb is first to implement the Device API

Thursday, February 24th, 2011

I fired up the newly released Android 3.0 SDK to run some tests and found they’ve implemented part of the long-awaited Device API (aka the Media Capture API). From your browser you can now upload pictures and videos from the camera as well as sounds from the microphone. The returned data should be available to manipulate via the File API (although I haven’t yet tested this).

I made a short video demo with some explanation:

Here’s the code so you can play around with it for yourself!

<form enctype="multipart/form-data" method="post">
  <h2>Regular file upload</h2>
  <input type="file"></input>

  <h2>capture=camera</h2>
  <input type="file" accept="image/*;capture=camera"></input>

  <h2>capture=camcorder</h2>
  <input type="file" accept="video/*;capture=camcorder"></input>

  <h2>capture=microphone</h2>
  <input type="file" accept="audio/*;capture=microphone"></input>
</form>