Put your message here! Contact me for more information
 
 







 

Archive for the ‘Random Walk’ Category


 

I was implementing cache_fu for my upcoming application based on YouTube (will be premiered very soon here on my blog). I wanted to cache certain calls to the YouTube API to reduce the latency and the time mongrels got stuck waiting for the response. The first candidate to get cached was the “Top Rated Video” from YouTube. Since this section is a part of the homepage, I used fragment caching for it. Everything went fine, Memcached just ran so beautifully and the speed gain was exceptional. I added the :ttl option to the cache command to expire the contents, then suddenly nothing worked. Rails kept on whining for the cache helper call:

wrong number of arguments (2 for 1)

I checked and double-checked cache_fu source, and the fragment_cache.rb file in particular. I saw cache_fu extending the fragment cache helper with an extra hash argument to support the :ttl option. Why the hell I could not use it in my view?

It turned out that the fragment_cache overwrite in cache_fu was not called automatically. I had to manually added the call in environment.rb file to invoke the setup.  Strange! It took me a while to figure out since I traced all source files in cache_fu to find the bug. I have to admit, cache_fu (previously known as acts_as_cached) has some kick-ass Ruby code written. I still need to learn a lot more about Ruby to get to that level of code craftsmanship.

To fix this issue, include this one line in your environment.rb file

ActsAsCached::FragmentCache.setup!

That will ensure the cache helper to have the :ttl option.

view comments
 

It’s time to say NO to monopoly and for Net Neutrality to be passed as a law.

It’s not Comcastic as you all claim. It’s ComCraptic. My experiences
with Comcast has got from worse to worser, and now I am a very unhappy
customer. Comcast is in fact using dirty and shady tactics, often
disguised as to help “preserve the speed for its users”, to severely
throttle services that are not in its interest to run on the network.
YouTube doesn’t even want to stream sometime, meanwhile Hulu.com (a new
TV-show site) is streaming Hi-Def videos just fine and it is extremely
fast (because Hulu is not that big yet and so it’s not on the black
slow-list). Netflix Watchnow is now extremely slow and almost
unbearable. I watched a 24-min animation episode and it took 20 minutes
to download the video! I always have DUMeter installed so I constantly
monitored my download/upload rate. Before, for Netflix, I was streaming
at 500KBps - it was almost instant to begin watching the instant
videos. This is how the new “internet experience” should be. I was a
very happy Comcast customer.

I started to read on Slashdot about
Comcast trying to slow down BitTorrent and other traffic. NO! All
traffic on the Web should be considered EQUAL. Why are we trying so
hard to erase racial discrimination while Comcast is trying its best to
discriminate and destroy the foundation of “free internet” ? And NOBODY
right now can do a thing to change this evil Comcrap piece of @#$? What
would happen if Comcast begins to extort money from Netflix, YouTube,
Hulu, or even Amazon, to allow users to use these excellent services?
That would be the end of the free internet.

After a “service outage” in my area, the speed of Comcast degraded
worst than anything. YouTube streaming speed is out right ridiculous,
if not pathetic. Netflix streaming speed degraded from 500KBps to
300KBps, and now, as I’m typing this, it’s only downloading at much
less than 100KBps. It took 20 minutes to half an hour for anything to
work. This is pathetic. And Comcast did NOT disclose anything about
their practices, not until people started to discover concrete proofs.

(http://netflixcommunity.ning.com)

I found this diagram while searching on Comcast and its shady and
disrespects of the customer practice. I don’t think any explanation is
needed.

What kills the internet? Not spam, not phishing, not videos
streaming, not the data tsunami. It is the unfair practices from ISP
that slow down the evolution of the internet. Comcast is playing its
monopoly hand to dominate places where users don’t have an alternative.
And yet, they have all the power to fudge, deny, or change the TOS for
their own legal and financial benefits. I would pay double for my
internet connection if I have any choice other than Comcrap. That’s
right, I would pay $118 a month for any ISP that works and treats their
customers honestly.

In the US, everything is built on Trust, and Credit. Hence we have
credit history, credit cards, personal loans, and mortgages. If
corporations like Comcast are abusing and destroying this circle of
trust and credibility, society as a whole, will be mubh better off
without them.

Comcast, I sincerely wish you would go to hell for your practices.
Meanwhile, you will go to sleep better if you treat your customers with
dignity.

view comments
 

I’m in the process of installing Ruby on Rails on a VPS running CentOS 5.1 and run into an issue with gem complaining for the missing zlib library. What happened was that I first used “sudo yum install ruby” to install the ruby runtime. However, the pre-packaged ruby in the Yum repository was older, 1.8.5. I only found out about this when I tried to run the mongrel_cluster to set up the mongrel instances. Mongrel was complaining about the older version of Ruby and the need for the fcgi fix. I decided to uninstall the yum ruby package and compile the newer version of Ruby from the source.

I compiled and installed Ruby 1.8.6 from the tar ball source first (./configure, make, make install), then I removed the pre-installed package using “sudo yum remove ruby” and removed all the dependencies with it. Next I installed gem 1.1.1 from the source (ruby setup.rb). I proceeded to install rails 2.0.2 again (”sudo gem install rails -y”). Bam, gem started to complain:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require': no such file to load -- zlib (LoadError)

Not good!

I did some research and it turned out that my CentOS 5.1 VPS is a barebone box, it did have the extra development libraries installed. Hence when I compiled Ruby from source, make did not compile the zlib extension because I did not have the zlib-devel package installed.

After installing zlib-devel package through yum (”sudo yum install zlib-devel”), I cd’ed into my Ruby source folder and into the ext/zlib folder (in my case, ruby-1.8.6-p114/ext/zlib/). Then I proceeded to install the zlib library (”ruby extconf.rb”, “make”, “make install”). Afterwards, gem was working fine again! Yay!

view comments
 

This year, Startup School 2008 again had some excellent speakers. I enjoyed it as much as I did for last year. I came in late for about an hour but I hope I did not miss much. I also bumped to a few old faces from last year as well.

Paul Graham is charismatic and funny with his advices as always. He gave a revised speech (a bit different from the one from last year) about the usual topic: “how to start a start up”. A good analogy for his advices is the relationship between the founders and the investors (VC) is similar to a relationship between girls and boys. If you show that you can live without money (or love) and generally be okay on your own financially (or emotionally) then more people would be interested in you (either fund you the money, or trying to get a date with you). A strong start-up with an action plan and a profitable potential will more likely to spark more interests from the VC than one needs the cash infusion to struggle along.

Paul paused, then brought up the next slide:

“A startup needs to be like a roach”

This clicked me. Personally I’m not afraid of any insects or reptiles, but I disgust roaches. Can’t stand them and just imagine how they would crawl up my legs makes me want to find a shotgun and smoke their tiny brown ass. Nonetheless, a startup should have a roach as a hero to look up to for its survivability, adaptation, and persistence. For millions of years, the cockroaches still survive just fine while the almighty dinosaurs went belly up, fossilized, and became the crude oil we got addicted to more than cracks. A startup needs to change when the weather changes, needs to survive from the fierce competitions or the VC’s liquidation, and be persevered to keep going when the odds are all against you.

In his book, “How to get Rich“, Felix Dennis (SOLE owner of Maxim and tons of other magazine) wrote about the idea of acting small and think big (not the other way around). A startup must keep coming even when facing failures is not even an option but a reality and knows how to act small and determined to come back to take a piece of that pie and steal more of the market-share. Personally, after watching a roach running for its life so many times, fleeing away from my smoking shotgun, I should know better how a roach would zig when I’m about to zag it. It would predict my next blow, running as fast as it could on all its got (6 tiny legs and a pair of paper-wings). No matter how much I tried to kill them, they still get away, and come back with more roach-warriors the next day. Acting like a cockroach will definitely help in dire situations when one is starting a startup. We usually learn the best lesson and experience from Mother Nature. Well-done, Paul, and it is hilarious too.

Another old speaker from last year, Greg McAdoo from Sequoia talked about the VC industry and how Sequoia love to work with Startups. Since I am not much interested in getting funded from VC (more of this later), I only listened to him with half the attention. Nonetheless, he is a really good speaker with lots of advices. His observation: the successful entrepreneur needs to have the skills to identify the trend and ride it to where it is heading to. Don’t fight the trend but leverage it to supercharge ahead. Isn’t that what people call “chances” and “luck”? Greg ended his speech with an impressive video, showing this one guy rode the biggest wave I have ever seen:

As much as Greg McAdoo pushes how the VCs are interested in working with little startups, my most favorite speaker of the entire program, (drum rolls…) David Heinemeier Hansson (DHH) dissed the whole general startup mentality, i.e. build something, raise VC’s money , go big, and hope for an exit (or just die in flames). DHH is truely a business man in how he approaches the subject of startup. He knows his goal (making ENOUGH money to enjoy life) and hits the bullseye with his skills (RoR is just amazing - I’m so thankful for his release of RoR to the open-source community and how he has helped me get to my dream).

DHH:

  • Focus on the customers
  • Build something good that you can have the customers hand over their card numbers
  • Going through VC is NOT the only way to make a profit for startups
  • Everybody is a winner in the market if they can grab the customers. The internet is HUGE
  • Instead of technology makes the business profitable, it is the well executed business with the correct technology which will be the cash-cow.
  • Work less hours: 12 hours of work is not necessarily as productive as a good solid 3 or 4 hours of focused, zoned-in development.
  • Shift the mentality of building a tech startup to building a self-sustainable and profitable business
  • Customers can either consumers (harder to get money from) to the Fortune:5,000,000 (easier to get money from, provided that the application is solving a business problem)

As I just wrote, the idea of raising money for my startup never stuck in my mind for long. I’m in this game to build businesses that MAKE money. What DHH said did truly touch me. I want my business card to say “Alex Le - Owner”, not just “Alex Le - so and so of this business”. I want to trade my sweat equity for ownership. With RoR and a little imagination, the road to success has never been as accessible. The real question is that do I really have the guts and perseverance walk down that path. in the future, I may change my mind about raising money from the VC, but it’s only when I know that I can use this money to rocket the business, and only when I am financially independent through my own businesses. More specifically, when I don’t need VC’s money then that is when I want to raise more from them. Why? I can run the business my way if I have the choice to say NO anytime I want to.

I can’t help but post this photo:

Yup, DHH and me. I got a chance to talk to him when the lunch break started. A group of other people gathered around DHH and asked him questions about running an online business. DHH really shines as a extremely smart guy (he is!) and business-savvy. I took a video with my camera for almost of the DHH-group interview but the file is rather big (1.04GB!) so I’ll post it on YouTube later. You’ll probably get a lot of kicks and nuggets of wisdoms from the side-walk talk with DHH. The end result: no more pizza when I came out and I was starving for the rest of the day. But between pizza and the opportunity to talk to DHH? You tell me.

DHH is simply awesome and to see him shot down what Greg McAdoo had just said is equally interesting. DHH has the most credibility and right to say what he said because he has singlehandedly changed the startup/IT industry and happens to get rich along the way. The most important thing is: he is totally right.

However, I am a bit disappointed with Paul Buchheit’s speech this year. He delivered an un-energetic, monotonous talk with a somewhat sparse slide. The big theme for his presentation was to listen to people’s needs, build what they want, but don’t “obey” (the hello-kitty slide was rather cute) all their requests. The talk was stretched into 15 minutes and occasionally got some laughs from the audience. Probably the people already know Paul so they laughed to show him some support. Maybe I set my bar too high after hearing DHH’s speech, but seriously, Paul’s last year speech was a lot more inspirational and energetic than this.

Don’t get me wrong, I enjoyed the contents and message of his talk, but have criticism over the way he delivered it. Don’t shoot the messenger, that’s what people say. However, in this case I think the messenger a bit sloppy in the preparation. Probably Paul had been up late working on FriendFeed the night before.

After the lunch break was Jeff Bezos, CEO of Amazon. From his talk and the way he responded to the questions from the audience, I believe that he is genuinely a nice and humble person. From his vision and actions, he is a man of conviction and strong beliefs in what he does. Amazon Web Service reflects that and I did write a post praising him back in 2006, even before Amazon ’s stock rallied up when people realized the true potentials of the company.

Jeff was promoting and evangelizing AWS, EC2 in particular. He did so rightly because he is more than happy to see more startups using AWS as the underlining infrastructure. As I mentioned in my 2006 post,

Amazon is building the new web economy and they are collecting tax already.

I totally agree with Jeff’s response to a question regarding the competition about Google Engine: the market is huge and everybody wins, i.e. it is not a zero-sum game but everybody benefits as the adoption grows and more and more values are being created everyday.

For the technical questions, Jeff handed to an engineer from Amazon (just wished the engineer was given a microphone so the poor guy did not have to scream his heart out in a 600+ person hall). Nonetheless, I’m so glad to see Mr. Bezos took the time to give a speech at Startup School this year. And I can’t help but to post this …

Hey … he’s the man, I don’t think I can allow myself to miss the chance to take a picture with him. Are you kidding me?

Next was Marc Andreessen. It was a QA session with the host lady and was informative. Marc is a passionate person and I could really see his passion for the web when he talked. I will definitely check out his blog more often.

Last but not least, Peter Norvig, the Director of Research from Google, a guy with intimidating white hair that makes me feel so young, little, and reckless, gave his speech on some data mining techniques. He showed some interesting clustering results from algorithms that Google is employing to enhance the Image Search quality. The example he used was a search for Mona Lisa (with safe search on, he stressed). To come back with good and relevant results, Google look at the contexts of the images (surrounding words, image tags, DOM structures, etc.), then from this result set, they establish the common features of the pictures (main structures, shapes, etc.) and establish clusters of “connected” images by comparing each photos with one another. The end results are clusters of images, with the center images being the most relevant to the search query and the outer ones are still related but with a much lesser degree. Another interesting example was a search for Abraham Lincoln: the algorithms generated 3 clusters for the results: 2 for the indoor statue, and one for the outside building. Seeing the Director of Research from Google giving a presentation on his work is pretty inspiring, considering that Google is spending only(!) $2.1bn in 2007.

A guy , self-proclaimed as the “evangelist” for semantic web (now that was arrogant), asked about Google’s interest in pushing for semantic web. Norvig responded (indirectly) that with the vast amount of text data from the web (50% more spam than ham?), it is already possible to run data mining techniques and algorithms to achieve good results. I think this is true. Analyzing the DOM trees, structures, and other aspects of the vast number of websites out there, one can establish a good working knowledge for relationship between the words and can potentially solve interesting problems already. Semantic web will be helpful, but it won’t be a make-or-break feature of the web, as Norvig answered wittily “Semantic Web is the future of the web, and always will be.”

This is my mini-coverage for the 2008 Startup School. I think I’ll wrap up some other stuff before heading to bed (Note to self: It’s been a long but awesome day already and I’m flying back to Chicago tomorrow afternoon so getting some rest now would be useful :).

A quick photo of me taken with Justin (from Justin TV), Trip (CEO of Scribd), and Wu (I bumped into her at last year Startup School while finding my way to the Kresge Hall)

Other web-coverages:

view comments
 

I was implementing an Ajax feature for a project and felt the need to display messages (progressing, savings prompt, etc.) to the users visibly and unobtrusively. Usually, to indicate a background activity, I tend to hide the link/button/checkbox and show a spinning indicator when the Ajax request was created, then return the link when the request has completed. In this case, there is no user-controllable submit button. It is a photo album page which allows users to rearrange their photos by simply dragging-and-dropping the photos into the correct positions. The positions are saved automatically on the fly. If I am to implement a typical spinning indicator, I have to make sure that it is visible enough for the user to know that the positions are being saved. However, if the user is at mid-page, any indicator at the top section of the page won’t be visible. If I place the indicator at the bottom of the page, I still run into the same situation. My solution is to implement a smart “Prompt” bar that stays affixed to the screen. With Prototype and Scriptaculous, implementation is a breeze.

Show, don’t just tell
Here is a demo which you can try out.

Details
This is made possible by using the “position:fixed” feature of CSS. According to W3Schools,

position: fixed
An element with position: fixed is positioned at the specified coordinates relative to the browser window. The element’s position is specified with the “left”, “top”, “right”, and “bottom” properties. The element remains at that position regardless of scrolling. Works in IE7 (strict mode)

The markup
Here is the HTML for the prompt bar. You can place this HTML anywhere in the page. Ideally it should be outside any container.

Some Prompt Here
Cross

CSS

#prompt
{ position: fixed; width: 400px; height: 20px; border: 1px solid #7F7F7F;z-index: 9999; background-color: #F3FF8F; }

#prompt_message
{ float: left; text-align: center; width: 380px; font-weight: bold;}
#prompt_close
{ float: right; width:16px;}

We have to set the prompt bar’s position to be fixed so that it will stay in place when we scroll the browser window.

The script
The javascript code is fairly simple, since Prototype and Scriptaculous already do the all the heavy lifting (e.g. positioning, animation). The only catch with position:fixed div is that we cannot center the prompt div using CSS. We have to explicitly set the left coordinate before we display the bar (line 16, _center() method). This is to also useful when the user resizes the browser window, we recalculate the position and center the div accordingly.

    var Prompt = {
      autoHideTime: 5000

      ,display: function( msg, options ) {
        $('prompt_message').innerHTML = msg;
        Prompt.show();
        if( options && options.autoHide )
          setTimeout('Prompt.hide()', options.autoHideTime || Prompt.autoHideTime );
      }

      ,working: function(msg, options) {
        msg = '  ’ + msg;
        Prompt.display( msg, options );
      }

      , _center: function(){
        $(’prompt’).style.left = ( ( document.viewport.getWidth() - parseInt( $(’prompt’).offsetWidth ) ) / 2 ) + ‘px’ ;
      }

      ,show: function(){
        Prompt._center();
        new Effect.Move ($(’prompt’),{ x: parseInt( $(’prompt’).style.left ), y: 0, mode: ‘absolute’, duration: 0.2 });
      }
      ,hide: function( msg) {
        new Effect.Move ($(’prompt’),{ x: parseInt( $(’prompt’).style.left ), y: -30, mode: ‘absolute’, duration: 0.1 });
      }
    }

Since the code is simple enough, I’d like to leave the details to you to work out.

Enjoy!

Download

I packaged the demo as a zip file so you can grab it and have some fun. Cheers!

view comments