Put your message here! Contact me for more information
 
 







 

Archive for March, 2007


 

After a much delayed (4 terminal changes, 5 hours waiting from 5pm to 10pm, and 150 page through the Pragmatic Ruby on Rails book… more on the Ruby on Rails stuff later) flight from Chicago due to foggy condition, I arrived in San Jose around 12:40am.

It’s now 8:15am Saturday and I’m about to leave for Stanford University for the StartUp School. Rich White from SlimTimer.com will probably join me after SS ends (I just sent him an email after I got to San Jose). If things go smoothly, which it should, we will then head to the Supper Happy Dev House (http://superhappydevhouse.org/SuperHappyDevHouse16) for some additional fun.

It is quite a trip and I only have 1 day to do it all. It’s gonna be FUN, eye-opening fun. And I do feel like I almost need a laptop now (good old remote desktop + logmein are all I need so far and that conbination has been able to pay my bills quite well, so why bother with a laptop)

Here is the schedule of Startup School from their website. I seriously look forward to the speech of Max Levchin, the founder of PayPal. Don’t know what to expect from Paul Graham’s talk because I’ve read most of his essays already. Still, the oppurtunity to meet with these Web 2.0 “celebrities”, for me at this moment, is invaluable.

SS
9:00 Mark Macenka
Partner, Goodwin Procter

9:30 Paul Buchheit
Creator of GMail

10:00 Chris Anderson
Editor in Chief, Wired Magazine

10:30 Paul Graham Partner, Y Combinator; Founder, Viaweb

11:00 Break

11:15 Michael Mandel
Chief Economist, BusinessWeek

11:45 Max Levchin
Founder, Slide; Founder, PayPal

12:15 Ali Partovi
Founder, iLike; CEO, GarageBand.com; Founder, LinkExchange
Hadi Partovi
President, iLike; GM, MSN.com; Founder, Tellme

12:45 Lunch

2:00 Rahoul Seth
CFO, Adteractive

2:30 Mitch Kapor
President, Open Source Applications Foundation; Founder, Lotus

3:30 Break

3:45 Greg McAdoo
Partner, Sequoia Capital

4:15 Mark Zuckerberg
Founder, Facebook

4:45 Joel Lehrer
Associate, Goodwin Procter

5:15 Recent Founders Panel

view comments
 

Stock QuoteI’m back from a period of hibernation. Lots of exciting stuff and new things, just barely have enough time to sleep and catch up with all the pending projects that I’ve been crazily taking on. Anyway, today I’d like to share something that maybe useful for someone out there: how to retrieve live stock quote data using Yahoo quote service with ColdFusion.

I was working on a project which originally utilizes the WebServiceX.net’s [[http://www.webservicex.net/stockquote.asmx/GetQuote|StockQuote web service]]. Things were working fine until WebServicex.net is down, as of today, March 22nd, 2007, with a big fat “Service Unavailable”

“Crap!” was what I said to myself. Luckily my work buddy forwarded a [[http://aspalliance.com/articleViewer.aspx?aId=112&pId=#Page2|link]] to an article on how to access the Yahoo Stock Quote service using ASP.NET (C#). Bingo! This was exactly what I needed. Based on the article, I was able to hack out the code using ColdFusion to retrieve stock info in just a few lines of code (or markup since I don’t really consider ColdFusion a real “language”)

===== Yahoo Stock quote CSV service =====
First of all, I didn’t even know if this service ever exists. I don’t really know where the official Yahoo documentations for the Stock Quote CSV service is (anybody knows the link please let me know). More ironically, I used Google to search for tutorials on how to use the Yahoo Stock Quote API. Anyway, this is the URL to request a CSV (comma-separated values) file containing stock information for a particular symbol, in this case, YHOO (I think I do have to give Yahoo some credits for the free service)http://quote.yahoo.com/d/quotes.csv?s=YHOO&f=l1c1v
with
* **s=SYMBOL**: with SYMBOL is the actual stock symbol
* **f=REQUESTED_FORMAT_STRING** where the REQUESTED_FORMAT_STRING is a string of letters representing what fields to be requested. The oder of the letters will be used as the order of the fields in the returned CSV.\\ I messed around and found out about the meaning of the letters used in the **f** parameter. If you want the full information about the symbol, you can use **f=sl1d1t1c1ohgvj1pp2wern** instead.http://quote.yahoo.com/d/quotes.csv?s=YHOO&f=sl1d1t1c1ohgvj1pp2wern Don’t sweat, here comes the explanation for each letter (or letter-digit pair)
* s: the symbol name
* l: last value (or current price). If you use l alone, you will get back a string similar to Mar 22 - 31.26
* l1: (letter l and the number 1) to just get the last value of the symbol
* d: d alone will give you 0, while d1 will return the current date (e.g. 3/22/2007)
* t: t by itself will request the yahoo-generated chart. However, you will get back the chart image with a whole bunch of other HTML garbage, e.g. src=http://chart.yahoo.com/c//y/yhoo.gif” alt=”Chart”>


* t1: the time of last update, for example 4:00pm.
* c: the change amount. Can either be used as c or c1.
* o: opening value
* h: high value
* g: low value
* v: volume
* j: 52-week low.
* j1: the market cap. This is string like “42.405B” for $42 billion. Man… that can buy **a lot** of hamburger or bowls of phở
* p: after hour price (?)
* p1: (?)
* p2: change percentage e.g. “-0.10%”
* w: 52-week range
* e: EPS (Earning per share)
* r: P/E (Prince/Earning) ratio
* n: Company name

(This list is hand-compiled by me based on my own interpretation. If you find any explanation being inaccurate, please let me know)

===== The Code =====
ColdFusionThe code is pretty simple: we will read from the result the Yahoo CSV service using the tag into a variable. This variable will then contain the comma-separated values list of what we put in for the f parameter. Back to our example, the URL we are requesting is http://quote.yahoo.com/d/quotes.csv?s=YHOO&f=l1c1v, which will return to us a string 31.26,-0.03,13249801. Since the response is in CSV format, we can utilize the ColdFusion List functions like ListLen(), ListGetAt() to access the values.

Here is the CFML code snippet





#stockInfo# 

* First, we construct the Yahoo Stock Quote service URL. We are requesting for last price, change amount, and the stock volume.
* Next we use the cfhttp tag to request the url, then grab the content into the cfhttp.FileContent variable and assign to the stockInfo variable. stockInfo will contain something similar to 31.26,-0.03,13249801
* To get the different values in the list, we use ListGetAt() with the appropriate index. And remember, indices of Array and List in ColdFusion start at 1, not 0.

That’s it!

Final Remarks
I hope you will find this useful. Thanks to Yahoo for providing a free stock quote service. I know I can **abuse** this CSV service as much as possible before getting banned because it’s Yahoo. Any services other than those of Yahoo, Google, Microsoft, I will probably have some guilty thoughts before doing anthing. But it’s Yahoo so I really don’t have no guilt abusing it. Just kidding though. I do appreciate the free (as in free beer) stock quote service.

===== References =====
* Bromberg, Peter, PhD. [[http://www.eggheadcafe.com/articles/20010404.asp|Build a C# Stock Quote WebService and Client using the WebService Behavior HTC (Part I)]]
* Perry, Jason. [[http://aspalliance.com/articleViewer.aspx?aId=112&pId=#Page2|Building a Yahoo stock quote ticker]]

view comments
 

Joomla LogoIf you ever run into the issue of Joomla’s tinyMCE Edit HTML Source popup window being blank, showing only “{$lang_theme_code_title}” on the Title bar, here is the explanation and solution:
The popup window is a HTML file located in

http://your-joomla-site.com/mambots/editors/tinymce/jscripts/tiny_mce/themes/advanced/source_editor.html.

When you click “Edit HTML Source“, tinyMCE will open up this source_editor.html file using the URL defined in $mosConfig_live_site (in configuration.php), and this file in turn will execute some javascript to allow you to edit the HTML code. Due to some cross-site scripting security restriction, if you happen to visit your site with a slightly different URL than the URL in the $mosConfig_live_site, e.g. with or without the www, then the javascript in source_editor.html will not be executed properly.
For example, if your set your $mosConfig_live_site to be “http://your-joomla-site.com” and you access the Joomla admin page via “http://www.your-joomla-site.com/administrator” (notice the additional www), then the “Edit HTML Source” popup will not work due to the cross-site scripting security restriction. Because your-joomla-site.com and www.your-joomla-site.com are not considered the same, the javascript from the main tinyMCE editor cannot interact with javascript in the source_editor.html file, which is being opened through a different domain (in this case without the www).
To solve this issue, you just have to access your Joomla site via the URL that is being used in the $mosConfig_live_site variable. Another more convenient way to solve this issue is that your can write a simple redirection to redirect traffic from http://your-joomla-site.com to http://www.your-joomla-site.com (in this case your $mosConfig_live_site is set to the www domain)
Cheers!

view comments
 


sus3.gif
I just received the accepting letter from Startupschool, inviting me to the talk at Standford University on this 24. Looking at the speakers list, which includes Paul Graham, Max Levchin, and other hugely success figurers, I just can’t believe it.

This is my dream comes true. But the issue is: I am broke right now. It will cost my at least $600 for the tickets and other expenses. I am broke!

But this is a once in a life time chance. I simply cannot afford to miss it.

So Stanford here I comes. See you there on March 24, 2007!

view comments