<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace Site Server v5.9.2 (http://www.squarespace.com/) on Sun, 14 Mar 2010 07:39:40 GMT--><feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><title>Shaheeb Roshan -My most profound thoughts on pants</title><subtitle>Shaheeb Roshan -My most profound thoughts on pants</subtitle><id>http://www.shaheeb.com/blog/</id><link rel="alternate" type="application/xhtml+xml" href="http://www.shaheeb.com/blog/"/><link rel="self" type="application/atom+xml" href="http://www.shaheeb.com/blog/atom.xml"/><updated>2010-01-21T04:12:16Z</updated><generator uri="http://www.squarespace.com/" version="Squarespace Site Server v5.9.2 (http://www.squarespace.com/)">Squarespace</generator><entry><title>Trusting Trust...</title><id>http://www.shaheeb.com/blog/2010/1/20/trusting-trust.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2010/1/20/trusting-trust.html"/><author><name>Shaheeb</name></author><published>2010-01-21T04:09:09Z</published><updated>2010-01-21T04:09:09Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p><a href="http://cm.bell-labs.com/who/ken/trust.html">This brief talk</a> by <a href="http://en.wikipedia.org/wiki/Ken_Thompson">Ken Thompson</a> is an elegant treatise on computing trust.&nbsp; I've read it 3 times now, and feel like it is only just starting to sink in.</p>]]></content></entry><entry><title>Panasonic BL-C111A rocks. Cereal.</title><id>http://www.shaheeb.com/blog/2009/9/28/panasonic-bl-c111a-rocks-cereal.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2009/9/28/panasonic-bl-c111a-rocks-cereal.html"/><author><name>Shaheeb</name></author><published>2009-09-29T00:18:58Z</published><updated>2009-09-29T00:18:58Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>A few weeks ago, I purchased a Linksys WVC54GCA Wireless IP-Camera and found myself <a href="http://www.shaheeb.com/blog/2009/8/22/linksys-wvc54gca-woes.html">somewhat frustrated</a>.&nbsp; The has been dutifully monitoring the breakfast nook in the kitchen, and sure enough, the pups spend minutes out of the day in there.&nbsp; That's right, minutes!</p>
<p>Since Romy and Mothi have decided that the living room is more their style these days, I thought it was a good opportunity to revist the IP-Camera project, and (hopefully) correct some of my first-time missteps.</p>
<p>&nbsp;<br /><strong>What's over there?</strong></p>
<p>PTZ.&nbsp; Pan. Tilt. Zoom.&nbsp; One of the issues I had with my Linksys fixed camera was that it monitored only a fairly narrow portion of the room.&nbsp; Now in the living room, I knew I need my camera to be able to cover a larger area, and the ablity to move the camera around was a necessity.&nbsp; The Pannie sports a 180 degree pan, and a 150 degree tilt.&nbsp; Its digital zoom isn't going to win any awards, but the range of movement easily compensates.</p>
<p><strong>But it'll cost ya!</strong></p>
<p>PTZ adds an easy $100 to the standard fixed versions.&nbsp; If I wanted to also keep wireless, I'm looking at $250.&nbsp; Yipes.&nbsp; Enter Powerline Adaptors.&nbsp; I'd like to write a more detailed post on these suckers alone, but in a nutshell, Powerline Adaptors convert the electrical wiring in your home into network cabling.&nbsp; So anywhere you have an outlet, you have network at abour 85mbps.&nbsp; A fantastic compromise which put my camera investment back down to $160.</p>
<p><strong>Network Printing should be this easy...</strong></p>
<p>The <a href="http://www.amazon.com/Panasonic-BL-C111A-Network-Camera-Wired/dp/B000NVSPQW/ref=sr_1_1?ie=UTF8&amp;s=electronics&amp;qid=1254189227&amp;sr=1-1">BL-C111A</a>.&nbsp; Box to streaming video in less than 6 minutes. I timed it.&nbsp; Fine, I cheated a little.&nbsp; I only run Macs at home, so using the included setup CD wasn't going to fly.&nbsp; I found this fantastic tip that pointed me to the camera's default address (192.168.0.254).&nbsp;</p>
<blockquote>
<p><em>By &nbsp;&nbsp;&nbsp; Jefferson Harkins (FL, VI, NS) - See all my reviews<br />(REAL NAME)&nbsp;&nbsp; <br />Panasonic doesn't support it, but this camera, and all Panasonic Netcams, work fine with a Mac. Later versions of Safari, Netscape and Firefox allow you to view full motion video. No add-ons or active-x or other such nonsense is needed with. The video just works. <br /><br />As for setup, you will have to set this (and other Panasonic Netcams) up with a broswer, not with the automatic setup CD that works with windows. It's not difficult. Configure your Mac to use the built in Ethernet connection only, configured manually to IP address 192.168.0.5, subnet 255.255.255.0. Connect an ethernet cable between your Mac and the Camera (with a modern Mac any cable will do, with older ones you'll need a crossover cable.) Then access the camera at the address specified deep in the documentation (for this camera it's 192.168.0.253). The first time in you'll be asked to select a username and password. Do that and then you'll have full access to the setup utilities where you can change IP addrerss, DCHP, and other parameters. You can also setup the excellent free viewnetcam.com service and give your camera a real internet name. This is my third Panasonic Netcam, and I've been very pleased with them all.</em></p>
</blockquote>
<p>The web setup is comprehensive and intuitive.&nbsp; While the camera can stream RTSP, I've found enabling my router's UPnP setting and allowing the camera to auto-configure its port forwarding is a much better bet.</p>
<p>The web portal works like a charm on my iPhone, and supports display from upto 16 cameras.&nbsp; So I'm officially on the lookout for as many as these little Pannies as I can!&nbsp; If you're on the fence about picking up an easy, solid camera to keep an eye on your pets or kids or whatever, you cannot go wrong with the BL-C111A.&nbsp; Git one!</p>]]></content></entry><entry><title>Linksys WVC54GCA Woes...</title><id>http://www.shaheeb.com/blog/2009/8/22/linksys-wvc54gca-woes.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2009/8/22/linksys-wvc54gca-woes.html"/><author><name>Shaheeb</name></author><published>2009-08-22T19:57:27Z</published><updated>2009-08-22T19:57:27Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>So now that Mona has resumed her hectic full time school schedule, our 5 month old little puggies are going to spend more time home-alone.&nbsp; They're housebroken and generally pretty lazy, but I've been thinking that I'd feel better if I could check in on them from work.&nbsp; Enter the wonderful world of <a href="http://en.wikipedia.org/wiki/IP_camera">network enabled webcams</a>.</p>
<p>&nbsp;<br />IP Cameras have to-date been used for security and surveillance for small businesses, and recently have made appearances in consumer product lines from labels such as <a href="http://www.dlink.com/category/productcategories/?cid=37">D-Link</a> and Linksys.&nbsp; Fundamentally a simple concept, IP cameras are essentially web-cams with an embedded server that can stream the video over HTTP or RTP RTSP.&nbsp; Add in 802.11 b/g/n on the packaging and you'll shell out an extra $50-$75 for a wireless network cam.</p>
<p>Beyond the wired/wireless, the other main differentiating feature in network cameras is whether the device is fixed or capable of Pan, Tilt and Zoom (commonly referred to as PTZ).&nbsp; The ability to move the lens around a room will roughly double the cost of the camera (new of course, but I've found that the more mature models are so new that the second hand market doesn't provide any better than a 15% discount).</p>
<p>After some typically obsessive research, I had my choices narrowed down to the <a href="http://www2.panasonic.com/consumer-electronics/shop/Computers-Networking/Network-Cameras/Residential-IP-Network-Cameras/model.BL-C111A_11002_7000000000000005702">Panasonic BL-C111A</a> and two Linksys models <a href="http://www.linksysbycisco.com/US/en/products/WVC54GCA">WVC54GCA</a>.&nbsp; I decided that Pan, Tilt Zoom wasn't critical, but wireless would definitely be a requirement.&nbsp; I settled on the WVC54GCA and ordered one up from Amazon.</p>
<p>After unboxing this neat little camera, and promptly tossing aside the manual and included CD (who needs directions), I plugged the device into my switch and powered it on.&nbsp; The single blue LED in the front blinked a few times (which I later learned indicates the camera is booting up), and helpfully stayed on solid.</p>
<p>&nbsp;</p>
<p>... Now What?</p>
<p>It turns out that configuring this thing is probably quite straightforward on a vanilla home network (managed by a dandy Linksys router no doubt) with few changes from the manufacturer's settings.&nbsp; Of course, no such luck on my network.&nbsp; Its not that I'm some uber hacker with obtuse or complex configurations at work, but I do have DD-WRT running on my router and have changed my internal network addressing from the default 192.168.1.255 subnet to 30.30.30.255.&nbsp;</p>
<p>Next problem: I don't have a PC.&nbsp; So even if I did swallow my pride and tried to use the "Discover cameras on my network" option on the installation CD, I would be out of luck.</p>
<p>After nearly a half hour of poking around (banging my head against my desk), I found this <a href="http://www.macworld.com/article/53277/2006/10/pingfind.html">helpful tidbit</a> on identifying new devices on your network; especially if you run macs at home.</p>
<p>Once you land on the Linksys web-based admin page, I have to admit it was pretty smooth sailing.&nbsp; I'll point out a few points I wish I had stumbled upon sooner that maybe helpful to others, but first, my complaints:</p>
<ol>
<li><strong>I wanted to check in on my pups from work</strong>:&nbsp; I didn't realize how much I had to compromise on performance if I wanted to rely on the wireless part of my wireless network camera.&nbsp; I have a 15/3 cable&nbsp; connection at home, and viewing my camera feed over the internet was dog-slow (ha ha!).</li>
<li><strong>I thought it'd be cool if I could view my feed on my iPhone</strong>:&nbsp; Documentation on RTSP support on the iPhone is rather sketchy.&nbsp; I just found a fantastic app called <a href="http://www.iphonelife.com/category/app-name/streamer">Streamer</a> that supports RTSP streams and does a terrific job with the WVC54GCA's feed.&nbsp; That said, its still reliant on the quality of the network connection:&nbsp; both on the iPhone, as well as your network that's attempting to up-stream the feed wirelesly from the camera.&nbsp; In my case, with the camera just 30 feet from my wireless-N router, I couldn't do better than 10 fps.&nbsp; Disappointing.</li>
<li><strong>I wanted something plug/play/forget</strong>:&nbsp; What can I say.&nbsp; BonJour and zero-conf networking on the Macs have spoiled me.&nbsp; Took me 2 hours to get the camera setup, streaming wirelessly, and accessible via the outside net.&nbsp; And having it operational for just over 5 hours now, the camera has already dropped off the network twice.&nbsp; Granted it came back pretty much on its own, its a bit frustrating when you're out to lunch and want to check in on something that ate up a chunk of your morning only to find the picture choppy, then stuck and then gone.</li>
</ol>
<p>Lessons learned:</p>
<ol>
<li>The default ip the camera grabs is 192.168.1.115 (admin/admin) .&nbsp;&nbsp; This is useless on any customized network.&nbsp; You'll need to figure out what the device's IP is using either a broadcast ping or something similar to <a href="http://www.macworld.com/article/53277/2006/10/pingfind.html">these directions</a></li>
<li>The access key if you want to secure in mobile mode must be numeric only!&nbsp; (You'll know what this means if your web-wizrd tells you that your text-overlay is invalid)</li>
<li>The fixed lens on the camera has a pretty narrow field of vision.&nbsp; If you want to look at a room of any decent size ( I wanted to cover a room about 20x15), you'll need to either mount this thing on the ceiling in a corner, or accept a failry substantial blind-spot.</li>
<li>You need some seriously comprehensive wireless coverage wherever you intend to install the camera.</li>
<li>RTSP streaming is quite impressively supported on the <a href="http://www.iphonelife.com/category/app-name/streamer">Streamer iPhone app</a>.&nbsp; Get it!</li>
</ol>
<p>&nbsp;</p>
<p>Bottom Line:</p>
<ol>
<li>I'm going to upgrade my network with a couple of wireless repeaters and give this camera another shot.&nbsp; But I have to say, the performance better rock, otherwise, this thing is going back to the store.</li>
<li>I haven't given up on network cameras, but to get my approval, the wireless performance has to be much better, and I ill not compromise on the PTZ feature next time around.</li>
</ol>
<p>YMMV, so I'm looking forward to feedback.</p>]]></content></entry><entry><title>A brief history of Behavioral Economics...</title><id>http://www.shaheeb.com/blog/2009/6/22/a-brief-history-of-behavioral-economics.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2009/6/22/a-brief-history-of-behavioral-economics.html"/><author><name>Shaheeb</name></author><published>2009-06-23T02:57:14Z</published><updated>2009-06-23T02:57:14Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p><a href="http://www.predictablyirrational.com/?page_id=5">Dan Ariely</a>'s <a href="http://www.amazon.com/Predictably-Irrational-Hidden-Forces-Decisions/dp/006135323X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1245727133&amp;sr=8-1">Predictably Irrational</a> has topped my reading list for past two weeks, and I have found myself raving about his experiments and facinating conclusions to anyone who will indulge me.&nbsp; The foundation of Alriely's research is based on Behavioral Economics, which (somewhat radically) suggests that human beings are not so much the highly efficient benefit maximizers that traditional economic theory assumes, but rather a fickle and often irrational lot.</p>
<p>NPR recently published a <a href="http://www.npr.org/templates/story/story.php?storyId=104803094&amp;ft=1&amp;f=1007">terrific article</a> describing the origins of Behavorlal Economics, its challenge to traditional economic theory, and its current application by proponents within the Obama Administration.&nbsp; This article along with works by authors like Ariely offer an exciting possibility to understand the choices that people often make that at the face of them appear irrational or inexplicable.</p>]]></content></entry><entry><title>Atul Gawande's Commencement Address to 2009 Chicago Medical School Grads...</title><id>http://www.shaheeb.com/blog/2009/6/15/atul-gawandes-commencement-address-to-2009-chicago-medical-s.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2009/6/15/atul-gawandes-commencement-address-to-2009-chicago-medical-s.html"/><author><name>Shaheeb</name></author><published>2009-06-16T03:06:24Z</published><updated>2009-06-16T03:06:24Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>The New Yorker posted the commencement address that one of their staff writers delivered at the Chicago Medical School's graduation ceremony this past weekend.&nbsp; You can enjoy the full transcript <a href="http://www.newyorker.com/online/blogs/newsdesk/2009/06/atul-gawande-university-of-chicago-medical-school-commencement-address.html">here</a>.</p>
<p>A lot has been said about the cost of healthcare, its impact on the overall economy, and the various options to "fix it".&nbsp; Gawande, himself an <a href="http://www.gawande.com/bio.htm">accomplished surgeon</a>, draws on his equally substantial experience as a commentator and policy maker to provide some of the most engaging observations on the responsibilites care-providers bear in this issue.</p>
<p>I implore anyone interested in the great debate on healthcare reform (and perhaps more earnestly to those who are not) to read Gawande's startling reports on the disturbing variation in the cost of healthcare between nearby cities, and even within neighborhoods.&nbsp; For example,</p>
<blockquote>
<p>"A recent study of New York and Los Angeles hospitals found that even within cities, Medicare&rsquo;s costs for patients of identical life expectancy differ by as much as double, depending on which hospital and physicians they go to."</p>
</blockquote>
<p>&nbsp;And the fact that despite the enormous expense of medical care, patients are not any better off!</p>
<blockquote>
<p>"Yet studies find that in high-cost places&mdash;where doctors order more frequent tests and procedures, more specialist visits, more hospital admissions than the average&mdash;the patients do no better, whether measured in terms of survival, ability to function, or satisfaction with care. If anything, they seemed to do worse."</p>
</blockquote>
<p>&nbsp;</p>
<p>But beyond the familiar rhetoric on what's wrong with the system, Gawande has an inspired message to the flock of new care-givers ready to take on the mantle of their noble profession:&nbsp; Don't wait for a fix to be handed down from on high.&nbsp; Do what you are trained to do best: find solutions that show promise among your peers and mentors, then nurture them within your own practice.</p>
<p>Gawande calls this method finding "positive deviants".&nbsp; He offers a remarkable story about a collegue and friend in charge of "a Save the Children program to reduce malnutrition in poor Vietnamese villages".&nbsp; Finding himself out of funds, his friend opted to look within the villages to find instances of healthy children and attempt to understand what set them apart from the others.&nbsp; By teaching other villagers the techniques that had nutured these healthy "positive deviants",</p>
<blockquote>
<p>"In two years, malnutrition dropped sixty-five to eighty-five per cent in every village the Sternins had been to.</p>
</blockquote>
<p>Gawande challenges the new doctors to learn about and understand techniques that produce "low-cost, high-quality institutions like the Mayo Clinic; the Geisinger Health System in rural Pennsylvania; Intermountain Health Care in Salt Lake City".&nbsp; He boldly encourages the new physicians to find "ways to resist the tendency built into every financial incentive in our system to see patients as a revenue stream".</p>
<blockquote>
<p>"Look for those in your community who are making health care better, safer, and less costly. Pay attention to them. Learn how they do it. And join with them."</p>
</blockquote>
<p>&nbsp;</p>
<p>Gawande's advice is genuine and earnest.&nbsp; If the physicians walking across the stage that day have paid heed to his words, all of us along with our ailing healthcare system may yet have hope.</p>
<p>&nbsp;</p>]]></content></entry><entry><title>Dan Ariely's Predictably Irrational...</title><id>http://www.shaheeb.com/blog/2009/6/11/dan-arielys-predictably-irrational.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2009/6/11/dan-arielys-predictably-irrational.html"/><author><name>Shaheeb</name></author><published>2009-06-11T03:33:48Z</published><updated>2009-06-11T03:33:48Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>I have been voraciously reading Dan Ariely's book <a href="http://www.amazon.com/Predictably-Irrational-Revised-Expanded-Decisions/dp/0061854549/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1244690860&amp;sr=8-2">Predictably Irrational</a>, and have experienced more than a handful of "aha!", and "hmmm!" moments.&nbsp; One that just occurred to me is related to his chapter on the effects of an implied social contract or implied market norm on the dynamic within a relationship.</p>
<p>Dan suggests that people behave differently and react differently to stimuli within a relationship based on whether the framework that defines that relationship is of a social nature or more market like.&nbsp; While this seems intuitive, the practical implications are interesting if you consider the possibilities of moving a relationship from one context into another.&nbsp; That is, consider the impact of moving a relationship that may be based on social norms now such as asking a neighbor to watch the dogs for a few hours as a favor, or buying a gift for a new girlfriend, into a more market-based norm.&nbsp; You may now offer to pay your neighbor a few bucks to watch the dogs for the evening, or perhaps gently suggest to your new girlfriend that your gift set you back a few notes.</p>
<p>The risks of moving from a social norm to one more market based seem easy to spot:&nbsp; your neighbor may not think a few bucks is worth the trouble of picking up after your dogs, or watching them destroy their couch.&nbsp; And your new girlfriend may not be thrilled to have you point out that "sentimental token" did have a price tag attached.&nbsp; I found Dan's thoughts on efforts to move in the other direction - from market norms to ones defined more by social contracts- , much more exciting.&nbsp; Dan's shares a particular example of a Border Patrol officer that didn't feel a need to risk his life for his "government salary".&nbsp; Dan asks us to consider if the war on drugs at the borders may be more engaging and intense if the officers felt a more personal connection to the cause, or a social committment to the effort rather than an assignment for work.</p>
<p>At a personal level, this chapter made me recall a deal my Dad made with my 7 year old nephew.&nbsp; My Dad promised my nephew that for every "10 out of 10" my nephew would score on a test at school, my Dad would take him to Toys 'R Us for a new toy.&nbsp; Of course my Dad is proud of my nephew, and he simply wants to motivate the boy to succeed.&nbsp; But I think my Dad has inadvertantly determined a fairly consistent market value for that "A" grade.&nbsp; The scores have turned into currency.&nbsp; And sure enough, my nephew has racked up a nice cache of Star Wars space-junk.&nbsp;</p>
<p>But what if he misses the mark on the next test.&nbsp; Well no big deal right?&nbsp; He already has plenty of toys!</p>
<p>Now what if my nephew had a more personal or "social norm" based relationship with those grades.&nbsp; I have no idea what that means per say (I don't know how my Dad would allocate additional units of love or affection or pride in my nephew), but I can see that it could motivate my nephew more effectively.&nbsp; And this may allow him to personalize the value of good performance at school in a way that will persist far longer than his fascination with Legos and action figures.</p>
<p><br />Anyway.&nbsp; Its late and I've rambled enough.&nbsp; I'll wrap this post up with the thought that remains brightly highlighted in my mind:&nbsp; <strong>Dan Ariely: you rock.</strong></p>]]></content></entry><entry><title>Web Automation fun with Selenium RC</title><id>http://www.shaheeb.com/blog/2008/11/23/web-automation-fun-with-selenium-rc-1.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2008/11/23/web-automation-fun-with-selenium-rc-1.html"/><author><name>Shaheeb</name></author><published>2008-11-23T01:50:42Z</published><updated>2008-11-23T01:50:42Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>So, many of you are probably familiar with Selenium for deploying automated web-application testing. I've recently begun a small side project that involves automated calls to web-sites that are AJAX and Javascript heavy in order to scrape content from the pages. Typically, I would turn to my trusty friend cURL for most screen-scraping, but in cases where the content on a page is dynamically generated by AJAX, its a lot easier to emulate a browser as closely as possible. Enter Selenium-RC, and in my case, the PHP Selenium driver. More on this topic later, but for now, if you are facing a strange intermittent problem with the Selenium server complaining about SocketException: Broken Pipe , here is your solution: The command handler in the Testing/Selenium.php uses (apparently) an incomplete socket connection routine. I have found that the same handler provided by the PHPUnit's Selenium Driver is much more robust.</p>
<div class="codeSnip">
<p>&nbsp; protected function doCommand($verb, $args = array())<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $url = sprintf('http://%s:%s/selenium-server/driver/?cmd=%s', $this-&gt;host, $this-&gt;port, urlencode($verb));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ($i = 0; $i &lt; argnum =" strval($i" s="%s',"&gt;sessionId)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $url .= sprintf('&amp;amp;%s=%s', 'sessionId', $this-&gt;sessionId);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!$handle = fopen($url, 'r')) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Testing_Selenium_Exception('Cannot connected to Selenium RC Server');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream_set_blocking($handle, false);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream_set_timeout($handle, 0, 60000);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $response = stream_get_contents($handle);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fclose($handle);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br />&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream_set_blocking($handle, 1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream_set_timeout($handle, 0, 60000);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $info&nbsp;&nbsp;&nbsp;&nbsp; = stream_get_meta_data($handle);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $response = '';<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (!$info['eof'] &amp;amp;&amp;amp; !$info['timed_out']) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $response .= fgets($handle, 4096);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $info = stream_get_meta_data($handle);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fclose($handle);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $response;<br />&nbsp; }</p>
<p>&nbsp;</p>
</div>
<p>&nbsp;</p>
<p>Replace the doCommand function with the above code, and you should find better results.  More on this to come...</p>]]></content></entry><entry><title>Vite,Vite! Squid Reverse Proxy ...</title><id>http://www.shaheeb.com/blog/2008/11/23/vitevite-squid-reverse-proxy.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2008/11/23/vitevite-squid-reverse-proxy.html"/><author><name>Shaheeb</name></author><published>2008-11-23T01:45:27Z</published><updated>2008-11-23T01:45:27Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>So <a href="http://en.wikipedia.org/wiki/Web_accelerator" target="new">http acceleration</a> is something I've been looking to take for a spin for some time now.  I've had a lot very good experience with application acceleration using <a href="http://www.danga.com/memcached/" target="new">memcached</a>, and I was eager to explore this concept further.  A popular option to implement web-acceleration has been <a href="http://www.squid-cache.org/">Squid</a>, so I thought this would be a nice option to try out first.</p>
<p>Wow.</p>
<p>It was hard!  But I got through it.  And that's the important thing I suppose.  I do have a couple of thoughts I'd like to share on the experience, with the most important being:  <br /><br /><strong> Know what you intend to accomplish. </strong> You'll find that (at least for a novice user like me) Squid is a difficult service to configure correctly, and can easily make things a lot worse on your server if you aren't careful.  So think carefully about what you intend to accomplish by implementing the Squid Web Cache (or really, any other caching strategy).  If you run a site that serves a hugh proportion of static content (such as html pages, images, or other media), then a reverse proxy like Squid can dramatically reduce the load on your web-server.  This is particularly handy if you either currently handle a high volume of traffic, or especially if you expect to receive a large influx of visitors over a short period of time.  If you serve mostly dynamic content, on the other hand, then be aware that you wouldn't reap a proportional benefit by simply running Squid out of the box.  You would need to complement your caching strategy with some mechanism to turn your dynamic pages into static, cacheable elements.</p>
<p>Once you have decided (with excellent reason of course) that you must implement a web-accelerator, another key point to consider is :  <strong>Benchmarking performance before and after the implementation</strong>.  I can tell you from experience that few things are more frustrating than spending hours tuning and troubleshooting a solution, only to realize once you are done that you have no idea whether you are better off for your efforts.  There are simple techniques to hedge against this, such as <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" target="new">benchmarking your web-server</a> with a realistic load before you begin.</p>
<p><a href="http://www.linuxjournal.com/article/6691" target="new">Stress test</a> your site or application to reveal problem areas or low-hanging fruit that you can target specifically.  But bottom line:  make sure that you can quantify the benefit of your efforts.  So of course, I did none of this, and proceeded to undertake the acceleration of a tiny personal site with no real traffic to speak of.  All in the name of science!  A couple of quick tips:</p>
<ul>
<li><strong>Webmin is useless for Squid</strong>:  Don't get me wrong, I love Webmin, but the Squid module is easily one of the most obtuse configuration tools I have ever used.  You'll be better off editing the squid.conf directly.</li>
<li><strong>Squid.conf is a scary beast</strong>:  Over 4000 lines long in its default mode, the conf file contains pretty much every imaginable switch and optional mode under the sun.  None of which I found useful in setting up my fairly simple cacheing protocol.</li>
<li><strong>Beware the version used in online tutorials</strong>:  There are vast differences in fairly fundamental aspects of configuration between 2.5, 2.6 (stable) and 3.0 (devel).  <strong>My notes are for 2.6</strong></li>
</ul>
<p>Here is what I intended to accomplish:</p>
<ul>
<li>Accelerate multiple domain name-based virtual hosts on a single physical machine:  This is important, because configuration of Squid for multiple physical web-servers (even in a load balanced setup) <strong>appears to be simpler</strong> than setting up the proxy on the same machine as your web-server</li>
<li>Understand the Squid configuration well enough to setup a transparent proxy at a later time.</li>
</ul>
<p>Well, so let's get started.  Installing Squid is very painless.  My server is running FC6, so a quick yum install squid did the trick.  As I mentioned earlier, while I have grown to adore Webmin for administering the different services on my machine, the Squid configuration tool requires a thorough and masterful understanding of some seemingly complex issues.  The <a href="http://wiki.squid-cache.org/ConfigExamples" target="new">Squid Wiki</a> hosts a set of useful config examples, so I was able to cobble together the bits I needed for my desired setup.</p>
<div class="codeSnip">http_port XXX.XXX.XXX.XXX:80 accel defaultsite=www.yoursitehere.com vhost<br />cache_peer 127.0.0.1 parent 81 0 no-query originserver name=myAccel weight=1<br />forwarded_for on<br />acl serverBeach dstdomain .www.shaheebroshan.com shaheebroshan.com<br />cache_peer_access myAccel allow serverBeach</div>
<p>&nbsp;</p>
<p>The first line essentially defines this particular Squid configuration as a web-accelerator.  The last keyword <em>vhost</em> further instructs Squid to be aware that the webserver is setup with domain based virtual hosts.  Note that the setting tells Squid to listen for requests on port 80.  Obviously, we will then need to tell the real webserver to listen and serve on a different port.  The <em>cache_peer</em> setting points Squid to the real webserver and also provides the reference name for later use (<em>myAccel</em> in this case).</p>
<p>Once the Squid behavior is configured, you must specify the specific domains you wish to accelerate using a set of ACLs.  The <em>acl</em> line names the rule, and then specifies the domains to include in the group.  I am still trying to better understand the syntax, but it appears that the dot is used to indicate a wildcard match.  This configuration format allows users to reach this site using "<a href="http://www.shaheeb.com/">shaheeb.com</a> or anything I set up at xyz.shaheeb.com etc.  Finally the <em>cache_peer_access</em> line specifically allows all requests for the acl group to be allowed.  Well that fairly well does it for the Squid configuration.</p>
<p>Now, before you go restarting servers, remember that we have to change the behavior of the "real" web-server before the proxy can take effect.   Telling <a href="http://www.apache.org/">Apache</a> to bind to a different port is as simple as:</p>
<div class="codeSnip">Listen 127.0.0.1:81</div>
<div class="codeSnip"><br /></div>
<p>Now restart the Squid service and the webserver and point your browser to your new speed-demon website.  <a href="http://wiki.squid-cache.org/SquidFaq/SquidLogs" target="new">Logs</a> like the <strong>cache.log</strong> and <strong>access.log</strong> will provide ample information about the server's behavior, as well as the efficiency of your cache configuration.</p>
<p>Whew!  Allright, well go on and give it a try!  I'd love to hear more about successfull Squid deployments, particularly in accelerator mode.</p>
<p>In the meanwhile, I'm going to start researching the setup of a Squid cache on a router.  <a href="http://www.dd-wrt.com/">DD-WRT</a> has been very good to me, and I'm sure there's a good tutorial out there to set something like this up.  Good luck!</p>]]></content></entry><entry><title>Yay Math! Joys and hardships of basic trig</title><id>http://www.shaheeb.com/blog/2008/11/23/yay-math-joys-and-hardships-of-basic-trig.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2008/11/23/yay-math-joys-and-hardships-of-basic-trig.html"/><author><name>Shaheeb</name></author><published>2008-11-23T01:38:48Z</published><updated>2008-11-23T01:38:48Z</updated><content type="html" xml:lang="en-US"><![CDATA[Moments after I completed my last <a href="http://www.blogger.com/www.processing.org">Processing</a> sketch,  I wanted to explore other variations on the theme.  The simplest one being drawing a shape on the canvas rather than a simple line. 

This couldn't be simpler!
<div class="codeSnip">
rect (0,0, 50, 50);
</div>

Yup, that's that.  Well, how about a bit more in the way of the motion of the shape.  We covered simple rotation about an axis, so let's try a different model.  The Processing <a href="http://www.processing.org/reference/index_alpha_ext.html">documentation</a> details a number of possibilities, and one that caught my eye is <a href="http://processing.org/learning/examples/movingoncurves.html">sinusoidal</a> motion.

Motion on curves is a classic technique to achieve smooth animations such as <a href="http://robertpenner.com/easing/easing_demo.html">easing</a>.  So let's take a look:
<div class="codeSnip">
float singraph(float sa) {<br>
 &nbsp;&nbsp;sa = (sa - 0.5) * 1.0; //scale from -1 to 1<br>
 &nbsp;&nbsp;sa = sin(sa*PI)/2 + 0.5;<br>
 &nbsp;&nbsp;return sa;<br>
}
</div>

Now, you can easily read lots of technical descriptions of this <a href="http://en.wikipedia.org/wiki/Trigonometric_function#Sine">concept</a>, some with <a href="http://mathworld.wolfram.com/Sine.html">exquisite</a> detail.

My favorite has been reading about <a href="http://en.wikipedia.org/wiki/Simple_harmonic_motion">Simple Harmonic Motion</a>.  This concept takes a fairly esoteric notion and applies it to describe interesting behaviors like <a href="http://en.wikipedia.org/wiki/Uniform_circular_motion">uniform circular motion</a> or the motion of a mass on a spring.

In practical application, the sine function allows you to achieve a fairly smooth and organic motion without a lot of overhead (fewer lines of code, fewer minutes of thinking).  I pass our increment value through this function to give me the rotation value.

<div class="codeSnip">
void draw() {<br>
 &nbsp;&nbsp;background(247,247,247);<br>
 &nbsp;&nbsp;smooth();<br>
 &nbsp;&nbsp;pushMatrix();<br>
 &nbsp;&nbsp;translate (width/2,height/2);<br>
 &nbsp;&nbsp;<b>radVal+=.1;<br>
 &nbsp;&nbsp;float sinVal = (singraph(radVal));<br>
 &nbsp;&nbsp;rotate (sinVal);</b><br>
 &nbsp;&nbsp;stroke(90,90,90);<br>
 &nbsp;&nbsp;fill(sinVal*100,100,0);<br>
 &nbsp;&nbsp;rect (0,0, 50, 50);<br>
 &nbsp;&nbsp;rectMode(CENTER);<br>
 &nbsp;&nbsp;popMatrix(); <br>
}
</div>

The result is a hypnotic, springy motion.  I added a bit of spice by having the fill color pass through the same sine-based alteration.
<div class="processingSketch" style="width: 200px; height: 200px; top: 35px;"><applet code="helloWorld_sineShape" archive="http://www.shaheeb.com/assets/sketches/hw/helloWorld_sineShape.jar" height="200" width="200"></applet></div>
Give it a shot, and show me any other trig based transforms you've seen in the wild.]]></content></entry><entry><title>Processing Exploration: Rotating a sprite...</title><id>http://www.shaheeb.com/blog/2008/11/23/processing-exploration-rotating-a-sprite.html</id><link rel="alternate" type="text/html" href="http://www.shaheeb.com/blog/2008/11/23/processing-exploration-rotating-a-sprite.html"/><author><name>Shaheeb</name></author><published>2008-11-23T01:10:50Z</published><updated>2008-11-23T01:10:50Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>I have been following the development of <a href="http://www.processing.org/">Processing</a> for a couple of years now, and I am generally astounded at its remarkable capabilities.  Even the <a href="http://www.processing.org/learning/topics/animatedsprite.html">learning exercises</a> are presented in such a elegantly <a href="http://www.processing.org/learning/3d/letterk.html">simple</a> fashion, that the language is nothing short of sexy.  Add in some of its more robust capabilities of interacting with <a href="http://hardware.processing.org/">hardware</a>, its image and <a href="http://processing.org/learning/libraries/livepocky.html">video processing</a> features, and it is clear that Processing is a must-have tool for anyone interested in prototyping and code sketching.  Well, in the spirit of getting off the sidelines and into the fray, I picked one of the ideas I have been sketching on paper, and have begun to use it as a model to learn Processing.  A couple of mechanical details to start off:</p>
<ul>
<li>Processing is a <a href="http://processing.org/faq.html#whyjava">Java based</a> variant.</li>
<li>It features a nice core set of functionality, but relies heavily on <a href="http://processing.org/reference/libraries/index.html">external libraries</a> for its true power.</li>
<li>It includes a fancy pants, light-weight IDE that works pleasantly on my Macs.</li>
</ul>
<p>I learn by doing, so I immediately started writing my copies of the projects featured on the Processing web-documentation.  Pretty painless stuff working through the fundamental drawing/rendering concepts, but I found that I need a better understanding of some fairly sophisticated mathematical concepts.  Now, I'll admit, I probably made this more complex for myself than I needed to, but I did had fun figuring this sucker out.  The problem:  draw a line on the canvas, and then rotate it around its centerpoint like a propeller.  Seems simple right!  Well let's see how it goes</p>
<div class="codeSnip">
<p>--------code---------<br />void setup () {<br />&nbsp;size (200,200);<br />&nbsp;stroke(255);<br />&nbsp;frameRate(30);<br />}<br />------------------------</p>
</div>
<p>Pretty simple stuff, just a quick setup of the canvas.</p>
<div class="codeSnip">
<p>--------code---------<br />&nbsp;float radVal = 0;<br />&nbsp;float degVal = 1;<br /><br />void draw() {<br />&nbsp;background(0);<br />&nbsp;pushMatrix();<br />&nbsp;translate (width/2,height/2);<br />&nbsp;radVal += ((degVal*PI)/180);<br />&nbsp;rotate (radVal);<br />&nbsp;line (-1*width,-1*height,width,height);<br />&nbsp;popMatrix();<br />}<br />------------------------</p>
</div>
<p>Yeah.  I told ya!  Well, allright, its actually a lot easier than it looks.  Let's break it down.  The variables declared first give you a preview of what's to come.  I find it easier to think about rotation in terms of degrees, like hands on a clock.  Processing, however, deals with rotation in <a href="http://en.wikipedia.org/wiki/Radian">radians</a>, so you know we'll have to deal with a conversion down the line.  The <span style="font-style: italic;"><a href="http://processing.org/reference/pushMatrix_.html">pushMatrix()</a> </span>function works essentially as a frame-buffer.  This allows you to perform any number of transformations before drawing the result on screen.  Now, speaking of transformations:  The translate() function is used here to redefine the origin of the canvas to dead center.  The reason for this is that the problem statement was to rotate the line like a propeller around the centerpoint, and not one of the ends.  With the origin redefined to the center of the canvas, we perform the rotation.  As I mentioned before, Processing takes in parameters to the rotate() function in radians, so we need to do a little math first.  degVal is basically an incrementing variable.  So we convert easy to understand increments of whole numbers into radians by multiplying the increment into (PI/180).  Now we finally draw the line!  Remember that the origin is now in the center of the canvas.  I wanted the line to bisect the window, so my coordinates should make sense.  And finally, popMatrix() is the corresponding bookend that outputs the contents of our buffer to screen.  I really enjoyed this exercise because I feel like I got to learn a couple of interesting mechanics of Processing by solving a very specific problem.  Granted, its not the most complicated or difficult problem, but nonetheless, I was forced to visualize what I wanted to accomplish and explore some different vectors to actually materialize it!.</p>
<div class="processingSketch" style="width: 200px; height: 200px;"><applet code="helloWorld_propeller" archive="http://www.shaheeb.com/assets/sketches/hw/helloWorld_propeller.jar" height="200" width="200"></applet></div>
<div class="flockcredit" style="text-align: right; color: #cccccc; font-size: x-small;">Blogged with the <a style="color: #999999; font-weight: bold;" title="Flock Browser" href="http://www.flock.com/blogged-with-flock" target="_new">Flock Browser</a></div>]]></content></entry></feed>