Archive for the ‘Code’ Category
I am a News Filtering Visionary
My First Facebook App: Waterloo Records Redux
I was looking for a new app idea to try out on the Facebook Platform, but then I remembered that Virtual Waterloo Records app I made last year. I figured it would be easier to start with an existing app so I ported it to Facebook (minus the ratings).
Add Waterloo Records Stickers to your Facebook profile.
Screenshot:

The nifty drag and drop scriptaculous stuff is gone in the Facebook version. Javascript is apparently verboten if you’re using a FBML Canvas page.
JSoR?
Back in December 2005, I asked “why on God’s green earth didn’t these Rails people just use Javascript on the server?” because it seems like Javascript has a lot of the same language features that make Ruby work well for Rails, but it’s much more popular.
Behold: Steve Yegge’s Google Rails Clone. He’s reportedly re-written Rails in Javascript (because he wanted to use Rails but Google didn’t want to support Ruby in its infrastructure). I hope that’s not a joke.
Back in February he described what he thought was going to be the Next Big Language. Most of the commenters guessed it was Javascript. I guess now we have his answer.
The NBL was to have optional static typing, which isn’t coming until ECMAScript 4/Javascript 2. You don’t need that at all for Rails of course, so it doesn’t matter that Rhino doesn’t support static typing. I wonder how static typing would benefit rails, though. Performance? After working in Ruby for the past six months, I’m starting to lose my fondness for the compiler. Automated testing should be your compiler.
Side note: This wouldn’t be the first javascript-based server. IIS has allowed you to run ASP pages in Javascript for a long, long time. I don’t think that’s a popular choice though. Also, a couple of years ago I was looking into server-side javascript for one project and ran across the Helma framework. I didn’t end up using it but I thought the idea had merit. Scratchdisk had some notes regarding Helma vs. Rails.
Update
Man, I feel like an ass. If I had done a little searching around I would have discovered that Yegge’s rails port to Javascript is not the first. TrimPath Junction has had a working version of rails running in Javascript/Rhino for a while now. Check out this comparison of code snippets for an idea of how it works.
Processing Sketch: Circle Packing
This evening I implemented a circle packing algorithm in processing.
I have some more ambitious ideas in mind for this, but what I really need is a hierarchical circle packing implementation like the one described here. I started down that road but I kept getting stumped by the math. That’s frustrating because it’s basic geometry and trig. The alternative algorithm I chose for this applet is much simpler and performs reasonably well for interactive use.
Social Engineering
I bet my site gets hijacked for this. My karma is going down the shitter lately, so I hope you find this entertaining.
I was minding my own business just now when I was contacted by a stranger via IM. He wanted help with the “friendster password hack” – which isn’t real. It’s a joke. People still don’t get it after all these years. Yet it’s still my #1 google referral. :(
In a fit of juvenile pranksterism I decided to turn the tables and get him to give up his password. Sure enough, a mere seven minutes into it he hands his username and password over to me, a complete stranger.
Bonus: he reveals the userid of the girl whose account he wants to hack.
I did nothing with this information besides log in to make sure it worked.
2:36:23 PM [name omitted]: hi i saw ur addy @ your webblog 2:36:37 PM [name omitted]: and read about friendster hack... 2:37:03 PM banksean: and you want to hack some friendster password? 2:37:17 PM [name omitted]: my ex...gf 2:37:40 PM banksean: have you tried my 133t scripts yet? 2:37:58 PM [name omitted]: i didn't know such script 2:38:23 PM [name omitted]: can you help me pls... 2:38:28 PM banksean: sure 2:38:35 PM banksean: whats ur passwrd? 2:38:42 PM [name omitted]: before i know her password 2:38:45 PM [name omitted]: in what? 2:38:50 PM [name omitted]: my password? 2:38:55 PM banksean: yes for friendster 2:39:01 PM banksean: so my bot can search your firends list 2:39:28 PM banksean: it tries different combos of words 2:39:30 PM [name omitted]: i don't have a friendslist 2:39:35 PM banksean: from your friends profiles and comments 2:39:46 PM banksean: but it needs to log in as you 2:39:57 PM [name omitted]: oh that's hard coz i don't have friends yet there 2:40:35 PM banksean: add her friends to your list 2:40:47 PM [name omitted]: she doesnt accept 2:40:57 PM banksean: no - not her, her friends 2:40:58 PM [name omitted]: i tried many times 2:41:04 PM banksean: do you have friends in common? 2:41:16 PM [name omitted]: no not at all 2:41:26 PM [name omitted]: but i know there username 2:41:39 PM [name omitted]: their usernames 2:42:14 PM banksean: okay so lets start with your username and password tho 2:42:30 PM [name omitted]: okay just wait 2:43:22 PM [name omitted]: mailto:[omitted] 2:43:30 PM [name omitted]: pw : [omitted] 2:44:05 PM banksean: okay did you get an email from friendster? 2:44:36 PM [name omitted]: now? 2:44:44 PM [name omitted]: what email? 2:45:57 PM [name omitted]: her name is [omitted] the one who view my profile
Photo Booth In Flash, Without All the Flash Crap
I got this idea for a web-based photo booth application (yeah yeah real original, I know) but the only practical way to access a camera from a browser-based app is through Flash.
Now, I know databases, networks, application servers, frameworks of all kinds. If it’s code I’ve probably at least tinkered with it if not built an app and got paid for it. I take pride in my breadth of knowledge of all things programmery.
Except Flash.
I wrote this long rant on how Flash programming sucks if you’re used to doing “Real” development because the tools are all jumbled up with this Movie metaphor and the tools are bulky and sclerotic.
But then I deleted it because if I were you I’d skip past the ranting and look for the meat.
So here it is (you need to have a web cam in order for it to work):
This is just the first baby step, so it doesn’t do anything besides show you the live image and if you hit the space bar it grabs the current frame and shows it to the right of the live video. I’ll add more to it later but I figured if anybody else is looking for a basic starting point for a mostly actionscript-based flash app, this is pretty damn dependency-free and cruftless.
To build it you do need to have MTASC and SWFMill installed. I wrote a brain dead build.sh script for my little project. Oh sure I could do something complicated for the build using ant or rake but I’m lazy and this build.sh gratification was instant.
MTASC is an open-source flash compiler and SWFMill is used to bundle resources into a .swf file, which is what the web browser wants to load and run.
Here are some links I found helpful, since I haven’t found any good “ActionScript/Flash for People Who Have Been Spoiled by Decades of Using Real Development Tools” articles anywhere. “Flash for Programmers” would be a good short name too.
HOWTO: Develop Flash on Mac OSX with Rake, MTASC, SWFMill and TextMate
This post that’s in French but who cares since the code make sense.
This article on capturing bitmap data from the web cam. Hint: BitmapData is why there’s a “-version 8″ flag in my build script.
Snapshotter is a very similar application with source code (.fla tho so I couldn’t make much sense of it) and a bunch of server side stuff that’s all in Cold Fusion.
The comments here are helpful too.
Things I have learned so far:
Somebody at Macromedia has a hard-on for MovieClips. Fucking everything has to be goddamn movie clip to these people. Seriously- need a button? Make a movie clip of a button. Need a background image? Make a one-frame movie clip and loop it or whatever. [shakes head]
Saying ActionScript is just like JavaScript is misleading. DHTML apps have the Document Object Model, which is pretty well documented and widely implemented. ActionScript apps have a “stage” and they feel lost and lonely without a big crusty IDE hanging around them with timelines for all their movie clips.
MTASC and SWFMill are really cool. I didn’t have to pay a gazillion bucks to Adobe or use their bizarro tools.
eBay Architecture
From The eBay Architecture (emphasis mine):

As I am fond of pointing out, most people who say they use J2EE actually only use the servlet engine. In case you’re looking through the J2EE spec, the servlet engine is the two (or five, if you use JSP) packages around the middle of the list of 79 packages that make up the J2EE API. Think about that. Most J2EE development uses only two out of 79 packages, or 2.5% of the J2EE spec (roughly, I know the packages vary in size and complexity). That’s even less than the Ninety-Ninety rule would suggest.
Saying that the J2EE API is bloated isn’t really a controversial statement these days. It’s just funny that Enterprise is supposed to mean Big and J2EE is supposed to be a standard cookie cutter answer for building Big Applications, but all the Big Applications suffer scalability issues in their own private, peculiar ways. Like Tolstoy says, “All happy families are alike; each unhappy family is unhappy in its own way.” The same could be said of software applications. I don’t think I came up with that analogy but I can’t remember where I might have seen it. Point being the forces and constraints applied to a service like eBay lead to some very non-standard ways of doing things, if you think of J2EE as ‘standard’.
Frank Sommers brings up a good point over at Artima, regarding the evolution of the eBay architecture over time rather than the specifics of any one incarnation of it:
The most amazing aspect of this evolution to me is not necessarily the technical brilliance of the solutions at each architecture stage, but the fact that eBay was able to meet the challenges of its growth with subsequent refinements to its system, all the while keeping the site operational.
The reason that’s interesting is because it suggests that you can start with almost any architecture—even with Perl or Rails or JSP pages—as long as you know how to migrate to the next step, and have the capability to do so, if and when you need to scale your app. That, in turn, suggests that the key test of scalability is not so much how each architecture stage scales, but how readily a company or an organization can move an application from one architecture step to the next. That indicates that scaling is as much an individual or organizational question as a technical one.
It’s the development organization that scales, not the software architecture. I think that’s a helpful way of looking at the problem. Rather than asking, “What are the characteristics of a scalable software architecture?” we should be asking, “What are the characteristics of a scalable software development team?”
Biblical Citations via Google
I wonder which Bible verses are cited most often on the web. What are the most popular pieces of Holy Wisdom, according to Google?
I seek to answer this question with some code I’ve written.
Here’s a chart of Google results for every verse in Genesis:

I’m writing an interactive browser for this dataset in Proce55ing (that chart is a screenshot actually), so stay tuned if you want to see the finished product.
There are some interesting problems with displaying a chart like this on a normal computer screen. For one thing, you’d need a screen 31,000 pixels wide in order to display it at a one-pixel per verse resolution. That’s one hell of a sparkline.
I’ll probably borrow a few ideas from some of the Human Genome Project data browsers and visualizations out there on the net.
What I’m aiming for at this point is a way to seek out the most often cited verses, and see them in context of who quotes them and why.
It’s obvious that some verses are more popular than others, but why? From a textual analysis of the most popular verses, I’d also like to build a Markov process to generate new verses that might also be appealing.
God damnit. Somebody already did it. I’m starting to get sick of this postmodern creative dilemma shit.
[Edit: Fucking shit. I hate my life. Just one original idea. That's all I fucking want.]
EC2, Day 2
Picking up from where I left off with Ruby on Rails on EC2 (hehehe).
I’m not sure why, but all of a sudden my S3 tools started working [shrug]. As I’m fond of pointing out, problems that go away by themselves tend to come back by themselves. So I’m joyfully looking forward to more intermittance.
Plugging along, I followed this recipe for creating an AMI from a running instance after I installed my RoR/MySQL stack and saved it to S3 directly from my ec2 box. In step 13 of that recipe he suggests you download the image to your local computer for backup purposes, and then upload it to S3, but I’d rather skip that step since data transfer between ec2 and s3 is free.
I now have a bootable rails/mysql/mongrel enabled fedora core 4 image in my “ec2railsimage” s3 bucket. I fired up an instance of it earlier this afternoon to try it out and it works. I’m pretty jazzed about this whole thing.
Apokalyptick has some interesting notes on running MySQL replication in EC2. Actually, that setup is a great example of how constraints (EC2 is full of ‘em) force people to get creative. The trick of running two MySQL servers on each machine is non-intuitive but I get it. Don’t know if I’ll *use* it but I do think it’s pretty clever.
Aside from EC2 he’s 100% right about partitioning horizontally rather than vertically, and abandoning the idea of a monolithic database altogether. Those apply to any large database application, not just within the constraints of EC2.
