1 2 3 4 | Rails::Initializer.run do |config| #....... config.middleware.use 'ResqueWeb' end |
Sunday, August 01, 2010
Running Resque Web
Monday, July 19, 2010
If they can copy a fighter jet, they can copy your damn website
They copy computers, cellphones, cameras, video players, watches, bags, and everything man-made—but did you know that the Chinese also copy entire combat airplanes? It's simple: They buy one and measure every part and system to clone it.
Lately, I've taken note of both ASmartBear's It's not a Competitive Advantage and Sachin's assertion (can't find the quote right now) that when investors ask him about defensibility, he replies that they don't understand the internet.
If they can copy a fighter jet, they can copy your damn website.
What's missing from a copy? I'd say intent is one of them. Especially if your product iterates and always tries to do something hard. It'll take them longer to copy, and they'll always be on the defensive. For actual competitive advantages, check out another list by the bear.
Friday, July 09, 2010
More dead than alive
At some point soon we’ll start having an awful lot of dead people around. I’m very sure Google and other search engines will start to filter for deceased people search. It won’t be long at at until we have way more dead people online than live people online.
That's a thought I never thought about. But it may be true.
But what would even be more memorialistic(?) is if we could have online versions of ourselves running around the online world commenting and participating, as if we were alive.
I remember thinking this when I saw "I, Robot", where Will Smith talks to a holographic 2D projection of a dead investigator for clues, but the investigator can only reply to what he knew up to the point of his death.
Though I'm not sure we can recreate something like what's in the movie, it's not infeasible to be able to feed all the text archived in all your chat logs, emails, wall posts, and status messages into some machine learning algorithm so given some text directed at you, it would be able to generate what you would mostly likely say in reply. It may be just an elaborate hidden markov model or something else, but either way, just a elaborate quote machine--that quotes you.
It could be a service that you'd go to, in order to talk to someone dead--like at an oracle, shrine, or memorial. Or it would be a service that let your personality loose online and your facsimile would participate in the diggs, reddits, and facebooks of the day.
I don't even want to think about what this would mean for future religious figures born today. Imagine if you could talk to Jesus or Budda's quote machine.
It's a bit creepy, to be able to talk to a facsimile of a dead person. But it could be it's just because we're not use to the idea. I suppose it's the same as when photographs came out and you could see dead people.
However, just as the dead can't reach out from photographs to the present, quote machines of the dead wouldn't be able to reach out from the past into the present. At least, I don't know that they should.
Thursday, July 08, 2010
Picking the right problem
Nowadays, software can be updated continuously and iteratively. This lets us build what we often call minimum viable product, or MVP, and improve it from there. However, most of us don't end up building MVP despite best intentions.
The reasons are varied, from fear of negative feedback, not knowing what MVP really looks like, or thinking that your early customers want more than they actually do. The first problem founders-to-be come across when doing MVP is actually picking the scope for the problem.
When you're first building a product, you spend time thinking about what features should be included and what the benefits would be to the end-user. Then you start thinking of all the things that a user might need before they start using it. The vision for your product is big and could go in any number of directions. The opportunity and potential may be huge!
I think this is the wrong way to go about it. Before you start thinking about all that, you need pick one problem to focus on. This problem is what you're going learn whether people even want this problem solved.
But even when you find a problem that people want solved, the next most common pitfall is picking the wrong size of problem to work on. We often try to solve a version of the problem that's too big. Don't try save the world on first shot. If you can subdivide the problem into smaller problems, if it's a problem to different types of people, or solves related problems in different contexts, your problem is too large.
The advantages of picking the right, focused problem are many. It makes the product easy enough to do, it's tractable, and you can see an end in sight--which is extremely motivating. In addition, it's easy to explain to others. Don't underestimate the power that stems from the ease of conveying your idea and the problem it's trying to solve.
Don't worry about the problem being too shallow. All problems are interesting when you look deep enough.
Paypal on the surface seems easy enough in the beginning. It's like a web-bank that only does transfers, and you don't even need to connect to financial institutions for paypal to paypal transactions. But what people don't realize in trying to copy paypal is that fraud will increase the more popular your service gets, and that will eventually kill you unless you get it under control.
Twitter seemed easy enough as well in the beginning. Search the web and you'll read a lot of naysayers back in 2006-2008 where they can't understand why posting a message to the web generates so many fail whales. By nature of the interconnectedness of the data in producing the feeds for a given user with a specific set of followers, it's actually a non-trivial problem.
Groupon has been interesting because it changed how people thought of the intersection between local businesses and online ecommerce. With groupon, you go into group buying agreements with other strangers on the web to get deals. However, it's actually a small part of a larger set of problems that you could solve with a similar set of mechanics, such as group campaigning and petitioning. Instead of trying to solve all these problems, the founder decided to just focus on one: group buying.
Tuesday, June 22, 2010
Integrating Facebook into Rails
Recently, I integrated facebook’s new Graph API into Noteleaf. Though it’s far far easier than the old API, which almost didn’t warrant a blog post. However, authorization took a little bit of figuring out, so I thought I’d share.
If you’re using the languages blessed by Facebook, such as PHP, Javascript, Python, Objective-C and Java Android, then there’s already an SDK for you.
However, as a rubyist, we were on our own. Since we’re using Authlogic, we should be able to find a plugin for authenticating facebook.
On the Authlogic docs, it has authlogic_facebook_connect listed. It also depends on the most popular ruby gem for facebook integration, facebooker. However, facebooker’s documentation is shabby and the tutorials are out of date. I didn’t want to be digging around in something that wasn’t our core value proposition. So I didn’t end up going that route.
I was digging for alternatives, but in all the wrong places. It wasn’t until I was reading the facebook api docs more carefully, that I realized I should be looking for an OAuth2 module for Authlogic. After that, it was a breeze.
The instructions for authlogic_oauth2 are pretty clear, but here’s some tips. Beyond the instructions in authlogic_oauth2, make sure you set the oauth2_scope to request offline_access. If you don’t, when the user’s facebook session expires, your oauth_token that you stored in the user’s database will be expired. That means that after a while, the user won’t be able to log back in without requesting another token.
class UserSession < Authlogic::Session::Base oauth2_scope "offline_access,email" end
And if you do store the user’s facebook id locally, make sure it’s a big int.
class AddFacebookIdToUser < ActiveRecord::Migration def self.up add_column :users, :facebook_id, :bigint, :limit => 8 end def self.down remove_column :users, :facebook_id end end
which you can subsequently set in a before_create filter in User model.
class User < ActiveRecord::Base before_create :populate_oauth2_user private def populate_oauth2_user return if oauth2_token.blank? response = oauth2_access.get('/me') user_data = JSON.parse(response) if !user_data['id'].blank? self.facebook_id = user_data['id'] end end end
You may also want to consider using the provided javascript SDK. That way, you’d be able to load your page first, and have the client’s browser request the rest of the facebook data, so it appears you page loads faster.
Monday, June 21, 2010
APK Downloads for Android Projects - GitHub
For all you Android developers out there, we now will automatically detect when you upload an Android package (.apk) file and will give you a QR code page link on your download page list, like this:
Friday, June 18, 2010
Boosting my social memory
I've changed what I'm working on, as I decided to table Graphbug as a side project. Everyone said public data would be a good thing for lay-people to browse through easily, but no one could specifically think of what datasets they'd want. Like going to the dentist, it's something that's good for other people, but not themselves. In hindsight, I should have picked data to visualize for apartment hunting and moving as the niche problem to solve. Otherwise, I was trying to boil an ocean.
But that's ok, as I've moved on to found a startup to do something I've really wanted for a long long time. We're working on Noteleaf, something to boost your social memory by making it easy to take notes and follow up on the people you know and meet.
I have terrible social memory. It's not just not merely remembering people's names. That can be done with a little bit of effort and mental hacks. I can't remember what other people are doing in their lives, whether they're graduating, moving, or looking for a job. I can't remember what the name of their kids are, their girlfriend, or fiancé.
One fine day in May, I called my friend Amy up and said, "Congratulations!". She replied enthusiastically, but puzzled: "Thanks! But for what?" I told her, "For graduating dental school." She laughed, "Ahh, thanks, but I graduated last year, and you called me then to congratulate me too."
It's not that I don't care. I just can't remember. I have disparate groups of friends, so I don't get gossip about other friends to remind me of what they're doing. My friend ranges from college-aged to recent parents with kids. With everyone in different stages of life, I can't keep track. I have enough things to keep track in my own life that it's hard to have bandwidth to think of others.
Thoughtfulness has to be both relevant and timely. Relevant, because it makes no sense to congratulate someone on their new job when they are still at their old one. Timely, because wishing someone happy birthday on a day that's not their birthday doesn't have the same effect.
We wrote Noteleaf to help us do both. By taking simple notes about others, you can recall what you talked to them about last time and start right where you two left off. And by scheduling automatic followups you can be thoughtful on your own time, and they get it when it's timely for them.
Facebook has been nice in getting news about friends old and new. However, not everything you'd want to remember about them comes on the news feed. There's a transient nature to the news feed, that chances are, you won't remember whether a friend left for vacation this week or next, and you meant to give them some travel tips.
With business contacts, you may not even be facebook friends. While important, you may meet them even less, so the details of their lives are even more fleeting. It's a leg up to getting things done, when you can remember who they are and what's important to them.
Noteleaf is still in closed beta for the time being, but just put yourself on our email list, and we'll let you know when we open the gates. In the meanwhile, we also started a noteleaf blog.
For all of our busy lives, I think it's important that we are involved in the lives of those we care about, and keep making connections to new and interesting people. Because beyond the glory of work and career, the trappings of fame and accolades, and enticement of money and prestige, deep connections to people we care about is one aspect of life that fulfills us and makes us whole.
Sunday, June 13, 2010
How to generate forms in rails helpers
This is more of a note to myself than anything, since I find myself having to generate forms from helpers in Rails every once in a while. This is for Rails 2.3.5. I don’t know if Rails 3 has this problem.
I wrote my own in-place editor for model fields, and it generates a form through a helper.
1 # used internally to generate the form for the en_place editor 2 def en_place_form(record_or_array, field_name, 3 options = {}, html_options = {}) 4 # process the options, and other misc details 5 form_block = proc do 6 form_for(record_or_array, :html => html_options) do |f| 7 concat(f.text_field field_name, :class => "en_place") 8 concat(f.submit "Update") 9 end 10 end 11 is_haml? ? capture_haml(&form_block) : capture(&form_block) 12 end
All you have to do is capture a block that calls form_for or form_tag. And then inside of the form, you can to call concat on the fields that you want inside of the form.
Then lastly, you have to capture the block. If you’re using haml, you have to call capture_haml() instead.
Saturday, June 05, 2010
A left merge versus a right merge
Recently, I found out that you can set the default winner in a merge for a hash. I wasn’t going to write about it since I figured it was pretty basic. But then again, I hadn’t written in a while. Been busy. So something easy to get me back on the wagon.
I’ll call it a left merge and a right merge. Let’s say we have some options, like default options and new options in a method, and we want merge them together, where options override default options, but you store it into options.
1 # some options 2 default_opts = { :a => 1, :b => 2 } 3 opts = { :b => 3, :c => 4 }
Well, the normal way of merging things won’t work:
1 # the normal default merge 2 opts.merge!(default_opt) # => { :a => 1, :b => 2, :c => 4 }
Well, that’s not right. We want the default options to be overridden by the new options and store it in the opts variable. We could do it like this:
1 # one way of doing things 2 opts = default_opts.merge(opts) # => { :a => 1, :b => 3, :c => 4 }
But then here’s another
1 # the other merge 2 opts.merge!(default_opts) { |k,o| o } # => { :a => 1, :b => 3, :c => 4 }
Yay!
Tuesday, June 01, 2010
BrowserCouch is CouchDb for browsers
BrowserCouch Documentation
BrowserCouch is an attempt at an in-browser MapReduce implementation. It's written entirely in JavaScript and intended to work on all browsers, gracefully upgrading when support for better efficiency or feature set is detected.
Not coincidentally, this library is intended to mimic the functionality of CouchDB on the client-side, and may even support integration with CouchDB in the future.
Why?
This prototype is intended as a response to Vladimir Vukićević's blog post entitled HTML5 Web Storage and SQL. A CouchDB-like API seems like a nice solution to persistent storage on the Web because so many of its semantics are delegated out to the JavaScript language, which makes it potentially easy to standardize. Furthermore, the MapReduce paradigm also naturally takes advantage of multiple processor cores—something that is increasingly common in today's computing devices.
Things to do
To learn how to use BrowserCouch, check out the work-in-progress tutorial.
Aside from that, you can run the test suite and the semi-large data set test, though they're not particularly exciting. In the future, we'd like to make CouchDB's Futon client work entirely using BrowserCouch as its backend instead of a CouchDB server, but that's a ways away.
If you'd like to see more code samples of what the BrowserCouch API currently looks like, check out the annotated source code for the test suite. You can also read the primary source code documentation for more on BrowserCouch's implementation.
This is really awesome. I thought about doing this, but figured it was a massive undertaking. I'm glad someone's doing it. CouchDb's replication features (while not implemented yet in BrowserCouch), is something to really look forward to, especially if it's available for mobile browsers.
Friday, May 21, 2010
I am one of the creators of the first "synthetic" bacterial cell. AMA : IAmA
More specifically, I am one of the authors of this paper. I was primarily involved in the assembly of the synthetic genome. I will answer your questions to the best of my ability, and to the extent of which I am allowed to discuss these things.
Monday, May 10, 2010
Whenever I hear "I'm not good at math", it's like people telling "I can't read, and it's ok"
Granted, thinking statistically is tricky. We like to construct simple cause-and-effect stories to explain the world as we experience it. “You need to train in this way of thinking. It’s not easy,” says John Allen Paulos, a Temple University mathematician.
That’s precisely the point. We often say, rightly, that literacy is crucial to public life: If you can’t write, you can’t think. The same is now true in math. Statistics is the new grammar.
Whenever I hear "I'm not good at math", it's like people telling me "I can't read, and it's ok."
Thursday, May 06, 2010
Friday, April 30, 2010
Henry Ford's "Thoughts on Horses"
The idea of gas engines was by no means new, but this was the first time that a really serious effort had been made to put them on the market. They were received with interest rather than enthusiasm and I do not recall any one who thought that the internal combustion engine could ever have more than a limited use. All the wise people demonstrated conclusively that the engine could not compete with steam. They never thought that it might carve out a career for itself. That is the way with wise people--they are so wise and practical that they always know to a dot just why something cannot be done; they always know the limitation...
Recently, a friend was telling me that DSLR cameras will never be supplanted by cameraphones. As of 2010, it seems a silly proposition. But that's seeing camera technology as they are now, not what they will be.
I don't think DSLRs will ever go away, like the radio never went away. But I don't think it's infeasible that cameraphones will get better and better so that for many DSLR users now, it would get 'good enough'.
I sent him the post I wrote on this subject. But I don't think he read it.
Thursday, April 29, 2010
Back to HATEOS and APIs
REST-like discoverability could also be a boon for some services. What if Twitter provided something like this along with a tweet’s JSON?
{ "actions": { "Retweet" : { "method":"POST", url:"/1/statuses/retweet/12345.json" }, "Delete" : { "method":"DELETE", url:"/1/statuses/destroy/12345.json" }, "Report Spam" : { "method":"POST", url:"/1/statuses/retweet/12345.json", params:{"id":12345} } } }
YES. I had talked about this in the HATEOS post that I wrote a while back. Right now, only html is self-discovering. XML and JSON docs should also have self-documented descriptions of next actions a client can take. That way, you'd cut down on the amount of documentation requires to understand or use an API.
One good point brought up in the comments in that last point was that if I had internal links, a client is likely to know what to do with what it gets back. But if I linked outside of my service, say geonames.org, how would I understand the schema? There's no standardized set of tags for geolocation data, like there is hypertext data.
Until we get standard media types for specific kinds of web applications, I'm afraid we're stuck.
Tuesday, April 27, 2010
How to kill an unresponsive ssh session
approach has been to switch to another terminal window or shell and then killing the process in question. Today I happened to be skimming through the ssh client’s man page and I found a section about escape characters. Suddenly I gazed upon the glory of the disconnect key sequence: a newline followed by ~.. It works like a charm. As always, I thought I shouldThat's something I've been looking for a while now. I don't know if this is just bad user interface, or if it's awesome that it has a surprise feature.
Friday, April 23, 2010
Monday, April 12, 2010
Facebook | A Dismal Guide to Concurrency
Two people can paint a house faster than one can. Honeybees work independently but pass messages to each other about conditions in the field. Many forms of concurrency [0], so obvious and natural in the real world, are actually pretty alien to the way we write programs today. It's much easier to write a program assuming that there is one processor, one memory space, sequential execution and a God's-eye view of the internal state. Language is a tool of thought as much as a means of expression, and the mindset embedded in the languages we use can get in the way. [1]
There's a really interesting idea in this post. It's that in the CAPs theorem, consistency usually get the boot, and we find that it's not the end of the world. Updated state needs to propagate through the system, and hence, you get a speed-of-light effect like in the real world: light(information) has a finite speed, and you need light-cone diagrams to show you what you're talking about.
Speed up Rails tests when using Compass
So here's a little tidbit. When you're using Compass with Rails, check to see if it slowed down your tests. I used test_benchmark, and saw that it increased my test times 3 fold. I narrowed it down to the initializer/compass.rb files that gets loaded. Tests should need to use Compass at all to make it work, and just wrap its contents, like so:
if RAILS_ENV != "test"
require 'compass'
# If you have any compass plugins, require them here.
Compass.configuration.parse(File.join(RAILS_ROOT, "config", "compass.config"))
Compass.configuration.environment = RAILS_ENV.to_sym
Compass.configure_sass_plugin!
end
And that'll do it.
I got too lazy to put this in a gist. It'd be really nice if posterous let you edit gists in-place in their editor.
Friday, April 02, 2010
More Ubuntu-ing, less ranting about the iPad
The technorati over at HN are talking about Cory Doctrow's rant on the iPad.
Much of the sentiment that I hear opposing it seem to be in the vein of:
The point is, Cory Doctorow is in a small, small minority. The minority isn't small because people don't know what he's saying -- it's small because they don't care. He's protesting the very philosophy that gives Apple products the quality that people who buy Apple products desire. And honestly, making the openness of Apple products your raison d'etre is a bit like getting furious about the mechanical details of your favorite brand of dishwasher. The answer is always the same: don't like it? Don't buy it.
- Comment on HN
I think what Cory Doctrow is saying matters, but I don't think it's sufficient.
It might not matter much to most people in the world, at least not directly, if you assume most people are just consumers, not makers. But it should matter to us as makers, and matter to those of us that want to cultivate and provide a place for future creatives. Without a sandbox to tinker, you have less tinkerers.
And in addition, we've seen that when you lower the bar, and invite "most people" to tinker, they will. They'll be rough around the edges, but they will, and some of the stuff they produce are some good shit. How many writers and video producers would you never heard of if not for blogging and youtube?
What's dangerous is not the iPad itself, but the perpetuating notion that people are just consumers. The world can only suffer from less makers and tinkerers.
I do agree that iPad is a fine machine. And that Apple has presented their wares, and we have brought into their conditions. To me, that means instead of railing against closed platforms like the iPad, open platforms really need to step up their game. Open platforms need to take user experience and design into account, like what Ubuntu has done for linux.
Open source/hardware are very good at building well known and well understood platforms, not new and innovative platforms.
The best that open tablets can do is be very good and fast followers. It's not sufficient just to rant.
