<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Conductr - Home</title>
  <id>tag:conductr.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://conductr.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://conductr.com/" rel="alternate" type="text/html"/>
  <updated>2008-03-03T07:30:41Z</updated>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2008-03-03:20</id>
    <published>2008-03-03T06:56:00Z</published>
    <updated>2008-03-03T07:30:41Z</updated>
    <link href="http://conductr.com/2008/3/3/php-string-manipulation-performance-benchmarking" rel="alternate" type="text/html"/>
    <title>PHP String Manipulation Performance Benchmarking</title>
<content type="html">
            &lt;p&gt;Believe it or not, but I&#8217;ve been off the Rails for a couple months now. I went back to &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; because of the speed issues with Rails (and Ruby in general). As &lt;a href=&quot;http://conductr.com/2008/2/21/build-slide-show-movies-from-flickr-with-video-conductr&quot;&gt;I mentioned&lt;/a&gt;, &lt;a href=&quot;http://video.conductr.com/&quot;&gt;video.conductr&lt;/a&gt; was so slow on Rails I had to rewrite the whole thing in &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;. It wasn&#8217;t that bad, it&#8217;s a dead simple application. But, that&#8217;s what got me working with &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; again &#8211; and I love the speed.&lt;/p&gt;


	&lt;p&gt;Now I&#8217;ve started working on a new project that is quite large. I learned a lot about &lt;span class=&quot;caps&quot;&gt;OOP&lt;/span&gt; from using Ruby which has made coming back to &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; tolerable being that it now has better support for objects. (I jumped ship sometime before &lt;span class=&quot;caps&quot;&gt;PHP5&lt;/span&gt;).&lt;/p&gt;


	&lt;p&gt;Anyways, the point of writing this article is because I always refactor my code for performance. My refactoring process often includes looking for double quotes which can be single quotes, rethinking my functions, loops, and a whole bunch of string manipulations. But, as I was refactoring I start to wonder what kind of gains I was receiving or whether they were even worth my time.&lt;/p&gt;


	&lt;p&gt;To further spark my curiosity, I &lt;a href=&quot;http://www.jaisenmathai.com/blog/2008/02/29/10-tips-to-make-your-php-application-scream-part-2-of-n/&quot;&gt;ran accross these tips&lt;/a&gt; today courtesy of DZone. So, I decided to write up a little benchmarking script to see how much difference my refactoring has on overall performance.&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://video.conductr.com/benchmarks.php&quot;&gt;Benchmarking &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; String Manipulations&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;After refreshing the page a few times it&#8217;s easy to see that the performance advantages are so small that they are not even consistent. The typical performance gain is a few tenths of a second per 100,000 executions.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2008-02-21:19</id>
    <published>2008-02-21T20:31:00Z</published>
    <updated>2008-02-21T20:39:24Z</updated>
    <category term="Hosting"/>
    <category term="Rails"/>
    <link href="http://conductr.com/2008/2/21/build-slide-show-movies-from-flickr-with-video-conductr" rel="alternate" type="text/html"/>
    <title>Build Slide Show Movies from Flickr with Video.Conductr</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://video.conductr.com/&quot;&gt;&lt;img src=&quot;http://conductr.com/assets/2008/2/21/video.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;In the past &lt;a href=&quot;http://conductr.com/2007/2/14/flickr-api-app-on-hiatus-mode-cue-social-music-app&quot;&gt;I mentioned&lt;/a&gt; an application that I was building using Rails and the Flickr &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;. After building it, it turned out to be way too resource intensive for me to host with Dreamhost. Since then, I rewrote the application in &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; and it is a bit faster. It&#8217;s still a bit of a &lt;span class=&quot;caps&quot;&gt;CPU&lt;/span&gt; hog , and Dreamhost probably isn&#8217;t too happy about that, but I wanted to put it up anyway.&lt;/p&gt;


	&lt;p&gt;The application is &lt;a href=&quot;http://video.conductr.com/&quot;&gt;video.conductr&lt;/a&gt;. It searches &lt;a href=&quot;http://flickr.com&quot;&gt;Flickr&lt;/a&gt; for images with your search terms in their tags, text descriptions, etc. and pulls the images together into a Flash video. The videos can be viewed on site, embedded on other pages, or even downloaded as &lt;span class=&quot;caps&quot;&gt;MP4&lt;/span&gt;. No account registration is required, however, it will help you keep track of your movies, registered users&#8217; movies have priority in the queue, and you will get a friendly email notice when your movies have been produced. To keep down on resource use, I am currently producing about 3-6 movies per hour maximum. If the site gets heavy usage, I will put it on a better machine and this limitation will be gone.&lt;/p&gt;


	&lt;p&gt;&#8220;Urban&#8221; was a recommended tag today when I visited the Flickr homepage. &lt;a href=&quot;http://video.conductr.com/show.php?id=15&quot;&gt;Here is the video&lt;/a&gt; and embedded below.&lt;/p&gt;


&amp;lt;embed pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; type=&quot;application/x-shockwave-flash&quot; src=&quot;http://video.conductr.com/movies/flvplayer.swf&quot; flashvars=&quot;file=http://video.conductr.com/movies/15.flv&#38;image=http://video.conductr.com/images/previews/15.jpg&#38;callback=http://video.conductr.com/watch/15&#38;lightcolor=0xff0084&#38;backcolor=0xcccccc&#38;frontcolor=0x0063dc&quot; height=&quot;260&quot; width=&quot;320&quot; /&gt;

&lt;span class=&quot;caps&quot;&gt;TODO&lt;/span&gt;:
	&lt;ul&gt;
	&lt;li&gt;Fix movie introduction text&lt;/li&gt;
		&lt;li&gt;Fix view counter&lt;/li&gt;
		&lt;li&gt;Add commenting system&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2008-01-19:18</id>
    <published>2008-01-19T19:43:00Z</published>
    <updated>2008-01-19T20:51:42Z</updated>
    <category term="Business"/>
    <category term="Finance"/>
    <category term="Hosting"/>
    <link href="http://conductr.com/2008/1/19/dreamhosts-fat-finger-billing-cost-users-13-million" rel="alternate" type="text/html"/>
    <title>Dreamhost's "Fat Finger" Billing Cost Users $1.3 Million</title>
<content type="html">
            &lt;h2&gt;Background&lt;/h2&gt;


	&lt;p&gt;Earlier this week Dreamhost, the company hosting this blog, &lt;em&gt;accidentally&lt;/em&gt; &lt;a href=&quot;http://blog.dreamhost.com/2008/01/15/um-whoops/&quot;&gt;over billed their users for $7.5 million&lt;/a&gt;. Over a couple days time, they looked into the issue and have mostly &lt;a href=&quot;http://blog.dreamhost.com/2008/01/16/the-aftermath/&quot;&gt;corrected the problem&lt;/a&gt; and now &lt;a href=&quot;http://blog.dreamhost.com/2008/01/17/the-final-update/&quot;&gt;consider it solved&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Of course, this has resulted in thoroughly pissing off their users and the delivery of the explanation was so poor &lt;a href=&quot;http://www.techcrunch.com/2008/01/15/dreamhost-overbills-customers-75-million-uses-homer-simpson-to-deliver-apology/&quot;&gt;TechCrunch called them out&lt;/a&gt; on it. I wasn&#8217;t too upset, my credit card had expired and I didn&#8217;t have the auto-bill feature activated so I didn&#8217;t get hit by it. If I had, it would have been awful. Dreamhost bills my bank account via check card where I usually operate around a $1000 buffer/emergency balance. However, at this time I was shifting some funds around and arranging my various balances because I am gearing up to move to Dallas. Long story short, I only had $50 in my account at the time and a $120 hosting bill would have caused an overdraft.&lt;/p&gt;


	&lt;p&gt;The cost of my overdraft fees are $35 but, there is more. I also had 4 small transactions pending, all of which would have triggered fees when they attempted to settle. So, I dodged a $175 bullet fired by a trigger happy &#8220;fat finger.&#8221; Luckily, I never trust any service enough to allow them to auto-bill me and my card was expired anyway but, for many users this event had a real cost.&lt;/p&gt;


	&lt;h2&gt;Financial Analysis&lt;/h2&gt;


	&lt;p&gt;This is a very rudimentary and somewhat ridiculous analysis of how much &#8220;fat fingers&#8221; can cost your users. I&#8217;ll explain my logic but you can &lt;a href=&quot;http://conductr.com/assets/2008/1/19/dreamhost.xls&quot;&gt;get the Excel file&lt;/a&gt; and make up your own assumptions.&lt;/p&gt;


First, I identified three ways this event has real costs:
	&lt;ol&gt;
	&lt;li&gt;Finance Charges&lt;/li&gt;
		&lt;li&gt;Overdraft Charges&lt;/li&gt;
		&lt;li&gt;Affect on Credit Rating&lt;/li&gt;
	&lt;/ol&gt;


	&lt;h3&gt;Finance Charges&lt;/h3&gt;


	&lt;p&gt;This cost is associated with having an elevated credit card balance. Most credit cards calculate finance charges based on an average daily balance. This means an elevated balance for more than one day, even if refunded in the future, will cost you money.&lt;/p&gt;


Given:
	&lt;ul&gt;
	&lt;li&gt;$7.5 million dollars worth of balance elevation&lt;/li&gt;
	&lt;/ul&gt;


Assumptions:
	&lt;ul&gt;
	&lt;li&gt;18% &lt;span class=&quot;caps&quot;&gt;APR&lt;/span&gt; / 365 = 0.049% Daily rate; ignored compounding&lt;/li&gt;
		&lt;li&gt;3 days elevated (days until refund)&lt;/li&gt;
		&lt;li&gt;85% of balances were credit cards, otherwise no finance charge&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;strong&gt;Cost to Users: $9,432&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;The only given in this analysis is that $7.5 million was billed to users. I assumed the average &lt;span class=&quot;caps&quot;&gt;APR&lt;/span&gt; is 18% and that it would take 3 days on average to refund the charges. Also, I figured about 85% of transactions were on credit cards, it could be much more/less. Charges to non-credit card accounts are assumed to bear no cost.&lt;/p&gt;


	&lt;h3&gt;Overdraft Charges&lt;/h3&gt;


	&lt;p&gt;This cost is associated with those users who experienced overdraft, over-the-limit, or some type of fee due to the unexpected charge.&lt;/p&gt;


Assumptions:
	&lt;ul&gt;
	&lt;li&gt;$125 average bill&lt;/li&gt;
		&lt;li&gt;60,000 bills&lt;/li&gt;
		&lt;li&gt;10% of bills defaulted&lt;/li&gt;
		&lt;li&gt;$35 fee&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;strong&gt;Cost to Users: $210,000&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;Based on Dreamhost&#8217;s prices and the user&#8217;s comments I estimated $125 as an average billing price. With $7.5 million in total billing, that gives us 60,000 bills that were erroneously collected. The default rate is rather subjective, I wouldn&#8217;t be surprised if it was actually 1% while it may be upwards of 20%. And, $35 is on the high side of fees but they are usually in that general range.&lt;/p&gt;


	&lt;h3&gt;Affect on Credit Rating&lt;/h3&gt;


	&lt;p&gt;This cost is associated with the long-term affects of a blemished credit rating. Specifically, the risk that your interest rates will be increased.&lt;/p&gt;


Assumptions:
	&lt;ul&gt;
	&lt;li&gt;6,000 users affected&lt;/li&gt;
		&lt;li&gt;$9,000 average debt held&lt;/li&gt;
		&lt;li&gt;2% rate increase&lt;/li&gt;
		&lt;li&gt;1 year affected&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;strong&gt;Cost to Users: $1,080,000&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;If affected, this cost can be huge. However, it is difficult to estimate and the formula I used is extremely sensitive to change. I&#8217;ve read reports that puts average U.S. consumer debt at any where from $8,000 to $12,000; so, I went with $9,000. I know the 2% rate increase and 6,000 users affected (all users who received overdraft charges) are probably over-estimates. But, I also only assumed they would be affected for one year. In reality, those affected may be paying up for several years, all the while interest is compounding. For that matter, I also ignored daily compounding throughout the year.&lt;/p&gt;


	&lt;h3&gt;Result&lt;/h3&gt;


	&lt;p&gt;&lt;strong&gt;Total Cost to Users: $1,299,432&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;with&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Total Cost per User: $21.66&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;With the continuous growth of large subscription based sites, I wonder how often this happens? Dollar amount over billed? Real cost to users? And lastly, how long until these issues turn into class action lawsuits?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-11-03:17</id>
    <published>2007-11-03T21:29:00Z</published>
    <updated>2008-01-19T16:43:55Z</updated>
    <category term="Business"/>
    <category term="Finance"/>
    <link href="http://conductr.com/2007/11/3/why-microsoft-can-t-compete-with-google" rel="alternate" type="text/html"/>
    <title>Why Microsoft can't compete with Google</title>
<content type="html">
            &lt;p&gt;Honestly, I&#8217;m a big fan of both companies. Microsoft for Windows and Office. Google for search, Gmail and being a proponent to the Web 2.0 movement. I will admit that I admire Google as a corporation much more than Microsoft and as far as the future goes: I&#8217;m long &lt;span class=&quot;caps&quot;&gt;GOOG&lt;/span&gt; and holding &lt;span class=&quot;caps&quot;&gt;MSFT&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;With that in mind, I came across an article today &lt;a href=&quot;http://www.businessweek.com/magazine/content/07_37/b4049070.htm?chan=search&quot;&gt;from BusinessWeek&lt;/a&gt; that instills my belief that Google will continue to innovate and grow while Microsoft is just a cash cow.&lt;/p&gt;


	&lt;p&gt;The meat of the article is an interview with Steve Ballmer (Microsoft&#8217;s &lt;span class=&quot;caps&quot;&gt;CEO&lt;/span&gt;) and Lisa Brummel (Microsoft&#8217;s newly appointed HR executive). It&#8217;s fairly lengthy, but the last question asked to Ballmer shows just why Microsoft can&#8217;t compete with Google: they are out of touch.&lt;/p&gt;


	&lt;p&gt;The Question: You think Lisa&#8217;s [corporate] blog is a good idea?&lt;/p&gt;


	&lt;p&gt;The Answer: &#8220;I won&#8217;t blog ever &#8230; Writing is not a natural skill for me. It takes me a long time to write &#8230; I could say I speak very well. I could do a &lt;em&gt;verbal blog&lt;/em&gt; every day, but it wouldn&#8217;t be the same.&#8221; (Emphasis mine).&lt;/p&gt;


	&lt;p&gt;So, I can relate with not being a natural writer. I&#8217;m not too fond of writing; as evidenced by the infrequencies in my entries. But, my issue is with the term &#8220;&lt;em&gt;verbal blog&lt;/em&gt;&#8221;. Maybe he meant &lt;em&gt;podcast&lt;/em&gt; or &lt;em&gt;video blog&lt;/em&gt; (vlog). But, &lt;strong&gt;verbal blog&lt;/strong&gt;? Maybe he&#8217;s just out of touch.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-08-14:16</id>
    <published>2007-08-14T03:32:00Z</published>
    <updated>2008-01-19T16:42:59Z</updated>
    <category term="Business"/>
    <category term="Finance"/>
    <link href="http://conductr.com/2007/8/14/benefits-of-the-credit-crunch" rel="alternate" type="text/html"/>
    <title>Benefits of the Credit Crunch</title>
<content type="html">
            &lt;p&gt;The ongoing, getting worse as I type, &lt;a href=&quot;http://www.investopedia.com/terms/c/creditcrunch.asp&quot;&gt;credit crunch&lt;/a&gt; that is occurring in the U.S. may have a bright side.&lt;/p&gt;


	&lt;p&gt;Less of this:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://conductr.com/assets/2007/8/14/refi-ad.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;... or any other rich media that has me select my state from a caterpillar&#8217;s abdomen.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-08-03:15</id>
    <published>2007-08-03T22:53:00Z</published>
    <updated>2007-11-17T02:14:06Z</updated>
    <category term="Prosper"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://conductr.com/2007/8/3/prosper-api-for-ruby" rel="alternate" type="text/html"/>
    <title>Prosper API for Ruby</title>
<content type="html">
            &lt;blockquote&gt;
		&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: This Prosper &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; project has been discontinued, and is not functional in it&#8217;s current state. Prosper makes huge updates to their &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; without warning, or even notifying the developer mailing list of the updates. The most recent change totally discontinued &lt;span class=&quot;caps&quot;&gt;HTTP GET&lt;/span&gt;/POST access to the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; (which this code used) and moved forward with a &lt;span class=&quot;caps&quot;&gt;SOAP&lt;/span&gt; only approach. If Prosper opens communication with the developers in the future, I may revisit this project. At this point, I can not invest the time only to have them radically change the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; without notice once again.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;While working on &lt;a href=&quot;http://www.prosperk.com&quot;&gt;ProsperK&lt;/a&gt;, I wrote an interface to the Prosper &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;. There was no such project on &lt;a href=&quot;http://rubyforge.org/projects/prosper/&quot;&gt;RubyForge&lt;/a&gt; so I decided to put mine up there.&lt;/p&gt;


	&lt;p&gt;It&#8217;s really simple to use, refer to the RDoc for some detailed examples.&lt;/p&gt;


	&lt;h2&gt;Installation&lt;/h2&gt;


	&lt;p&gt;Get the &lt;a href=&quot;http://code.conductr.com/svn/prosper/&quot;&gt;source&lt;/a&gt;. &lt;code&gt;require&lt;/code&gt; the &lt;code&gt;prosper.rb&lt;/code&gt; file.&lt;/p&gt;


	&lt;p&gt;I put &lt;code&gt;prosper.rb&lt;/code&gt; in &lt;code&gt;app/models&lt;/code&gt; and it will be loaded with the application.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;svn co http://code.conductr.com/svn/prosper/&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;- or -&lt;/p&gt;


	&lt;p&gt;Just grab the &lt;code&gt;http://code.conductr.com/svn/prosper/prosper.rb&lt;/code&gt; file and require it.&lt;/p&gt;


	&lt;h2&gt;Usage&lt;/h2&gt;


&lt;pre&gt;
&lt;code&gt;cd ./prosper
rdoc&lt;/code&gt;
&lt;/pre&gt;
Open the doc directory with your browser (or, the index file within). The documentation has usage examples for each method.
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-07-14:14</id>
    <published>2007-07-14T05:59:00Z</published>
    <updated>2007-07-14T06:06:03Z</updated>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://conductr.com/2007/7/14/10-9-a-one-billion-pixel-project-beta" rel="alternate" type="text/html"/>
    <title>10^9: A One Billion Pixel Project - Beta</title>
<content type="html">
            &lt;p&gt;My latest project has just been released in Beta. It&#8217;s at &lt;a href=&quot;http://9figs.com/&quot;&gt;9figs.com&lt;/a&gt; and is a goal oriented project. The goal is to receive 1 Billion pixels, uploaded from users, to display in our widget.&lt;/p&gt;


	&lt;p&gt;This is built with &lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Ruby on Rails&lt;/a&gt; except 2 files. The scripts that serve up the widget content and handle the resulting click-throughs are &lt;a href=&quot;http://php.net/&quot;&gt;&lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;&lt;/a&gt;. As the project grows, these files will likely receive a very high number of requests so RoR speed issues are a concern. Initially, I wrote them as part of the Rails app and then ported them over to &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;. Since, it has been over 2 years since I&#8217;ve touched anything ending with .php, this made the transition easy. &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; still remains extremely easy to pick up. You just have to remember to end all your lines with a semi-colon.&lt;/p&gt;


	&lt;p&gt;The widget serving file was extremely slow in Ruby. Each request generated several RMagick objects and it would not have taken many requests to pull the server to a halt. Or, require a more advanced (read: expensive) hosting solution. I was impressed by how fast the same logic could execute when written in &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;. I do miss that benefit of &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;I was able to build the entire app in 28 hours of development time. Speaking as a freelancer who only codes a few hours a week, productivity is key. So far, I haven&#8217;t found a case where I am not more productive in Rails than I would be in &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; (and I&#8217;m not interested in learning anything else).&lt;/p&gt;


	&lt;p&gt;Go check out &lt;a href=&quot;http://9figs.com/&quot;&gt;the project&lt;/a&gt; and &lt;a href=&quot;http://9figs.com/code&quot;&gt;get the widget&lt;/a&gt; up on your site.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-07-09:13</id>
    <published>2007-07-09T06:15:00Z</published>
    <updated>2007-07-09T06:17:53Z</updated>
    <link href="http://conductr.com/2007/7/9/got-my-click" rel="alternate" type="text/html"/>
    <title>Got my Click</title>
<content type="html">
            &lt;p&gt;&lt;img src=&quot;http://conductr.com/assets/2007/7/9/swivel.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;I just thought this was a cool ad =p&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-06-25:12</id>
    <published>2007-06-25T04:49:00Z</published>
    <updated>2007-06-25T04:50:51Z</updated>
    <link href="http://conductr.com/2007/6/25/bears-need-beer-too" rel="alternate" type="text/html"/>
    <title>Bears need Beer, too</title>
<content type="html">
            &lt;blockquote&gt;
		&lt;p&gt;&lt;a href=&quot;http://www.nytimes.com/2007/06/24/us/24bear.html&quot;&gt;Mr. Everhart was given a ticket for failing to secure his campsite&lt;/a&gt;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Good. Although, I wonder how long it took the authorities to come up with that charge.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-06-03:11</id>
    <published>2007-06-03T20:27:00Z</published>
    <updated>2007-06-03T20:58:03Z</updated>
    <category term="Ruby"/>
    <link href="http://conductr.com/2007/6/3/easy-keys-using-strings-that-succ" rel="alternate" type="text/html"/>
    <title>Easy Keys using Strings that Succ!</title>
<content type="html">
            &lt;p&gt;Ruby has a cool method on the &lt;a href=&quot;http://www.rubycentral.com/book/ref_c_string.html&quot;&gt;String&lt;/a&gt; object that allows you to make quick keys easily. The &lt;a href=&quot;http://www.rubycentral.com/book/ref_c_string.html#String.succ&quot;&gt;succ&lt;/a&gt; method recognizes the pattern you have created and returns the successor (the next in the pattern).&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&gt;&gt; s='a99y';3.times do puts s.succ! end
a99z
b00a
b00b
=&gt; 3&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This comes in handy when trying to make short &#8220;keys&#8221; to reference. For example, &lt;a href=&quot;http://tinyurl.com&quot;&gt;TinyURL&lt;/a&gt; generates a small key to reference an entire &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; which is saved in a database (presumably).&lt;/p&gt;


	&lt;p&gt;This is great, but what happens when we run out of 4 character successors?&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&gt;&gt; s='z99y';3.times do puts s.succ! end
z99z
aa00a
aa00b
=&gt; 3
&gt;&gt; s='99y';3.times do puts s.succ! end
99z
100a
100b
=&gt; 3&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Ruby has it all figured out. It prepends an alpha or numeric depending on which character was found first in the pattern and it never stops.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&gt;&gt; s='@a1';7019.times do |i| puts &quot;#{s.succ!} ===&gt; #{i}&quot; end
.....
@zz8 ===&gt; 7016
@zz9 ===&gt; 7017
@aaa0 ===&gt; 7018
=&gt; 7019&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you are using this with a database, it is important that you make sure the keys are unique.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-05-23:10</id>
    <published>2007-05-23T06:47:00Z</published>
    <updated>2007-05-25T23:12:39Z</updated>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://conductr.com/2007/5/23/the-hand-fed-api" rel="alternate" type="text/html"/>
    <title>The Hand-Fed API</title>
<content type="html">
            &lt;p&gt;While planning any application, there is one constant: I may open things up with an &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; in the future. Maybe I won&#8217;t go production without it, or maybe I put the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; on the back burner for a future release. Either way, I try to keep that in mind while building the &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; controllers/views. Nothing new there, I&#8217;m sure everyone does this these days, but it helped me stumble upon a &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; method that I think would be pretty cool.&lt;/p&gt;


	&lt;p&gt;I, as the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; provider, want to give the easiest use to all developers using my service. Naturally, that means encouraging the use of Ruby on Rails. Not entirely, it will be just as easy for non-RoR users to develop with the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; but we can do so much more for those on Rails. For example, give them a model with the migration, tests, etc.&lt;/p&gt;


	&lt;p&gt;So here&#8217;s the plan, let&#8217;s start by looking at some code examples of how our &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; should be designed to help out a RoR developer.&lt;/p&gt;


	&lt;p&gt;Inside a &lt;code&gt;rails app&lt;/code&gt; do &lt;code&gt;script/generate scaffold_resource bid&lt;/code&gt; end.&lt;/p&gt;


Migration
&lt;pre&gt;&lt;code&gt;create_table :bids do |t|
    t.column :amount, :decimal, :precision =&gt; 9, :scale=&gt;4
    t.column :creation_date, :datetime
    t.column :key, :string
    t.column :last_modified_date, :datetime
    t.column :listing_key, :string
    t.column :member_key, :string
    t.column :minimum_rate, :decimal, :precision =&gt; 6, :scale=&gt;5
    t.column :participation_amount, :decimal, :precision =&gt; 9, :scale=&gt;4
    t.column :status, :integer
    # Your own stuff
end&lt;/code&gt;&lt;/pre&gt;

Once the developer has this in place, then they just follow some simple logic.
&lt;pre&gt;&lt;code&gt;# Make a Bid instance
xml = Net::HTTP.get('api-host.cm', '/bids/1.xml')
hash = Hash.from_xml( xml )
@bid = Bid.new hash['bid']

# Developer saves it
@bid.save

# Developer uses it
puts &quot;Winning&quot; if @bid.status == 2&lt;/code&gt;&lt;/pre&gt;

Easy, right? Let&#8217;s make it a one liner out of respect for all you Rubyist ninjas&#8230; or pirates? I won&#8217;t judge.
&lt;pre&gt;&lt;code&gt;@bid = Bid.new( Hash.from_xml( Net::HTTP.get('api-host.cm', '/bids/1.xml') )['bid'] )&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Fun stuff. Back to my prospective as an &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; provider. Wow. I did virtually nothing and people can tap into my &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; literally within 20 seconds of turning on their computer. That&#8217;s right, I timed myself to get that statistic and it assumes you have rails installed and ready to go.&lt;/p&gt;


	&lt;p&gt;The &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;&#8217;s &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt; file remains easy for any developer to use. It&#8217;s important to note that all of this works because the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; service runs &lt;code&gt;render :xml =&amp;gt; @bid.to_xml&lt;/code&gt; such as with the generated &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; scaffolding controllers. Rendering the exact &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt; format that will be recognized by the developers app. If you are not running Rails on your &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; service, provide an endpoint with the &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt; formated for RoRs developers. I don&#8217;t see this being done anytime soon, but you never know with the growth of RoR thus far.&lt;/p&gt;


	&lt;p&gt;Thought: For all I know this is what Action Web Services is all about. I&#8217;ve never read up on it so I don&#8217;t know anything about it. Not really investigating it either &lt;strong&gt;shrug&lt;/strong&gt;.&lt;/p&gt;


	&lt;p&gt;One Dollar Give Away! To the first person who correctly guess what &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; was used in the above examples. Just leave your guess as a comment and I&#8217;ll send you a buck via Paypal.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-05-18:9</id>
    <published>2007-05-18T05:28:00Z</published>
    <updated>2007-05-18T05:28:46Z</updated>
    <link href="http://conductr.com/2007/5/18/aim-killer-app-of-tech-1-0" rel="alternate" type="text/html"/>
    <title>AIM: killer app of Tech 1.0</title>
<content type="html">
            &lt;p&gt;&lt;img src=&quot;http://blog.conductr.com/assets/2007/5/18/aim.gif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Everyone &lt;a href=&quot;http://techcrunch.com/&quot;&gt;reads&lt;/a&gt; about a great thing known as Web 2.0. It goes hand-in-hand with Bubble 2.0. Collectively, Tech 2.0. When thinking of Tech 1.0, reminiscing if you will, I remembered a point in time where I was unusually attached to &lt;a href=&quot;http://aim.com&quot;&gt;&lt;span class=&quot;caps&quot;&gt;AIM&lt;/span&gt;&lt;/a&gt; (AOL&#8217;s Instant Messenger). In particular, from about 1998/99ish  when I first started using the internet frequently until about 2004, when I just got burned out of being interupted while doing work on the computer. So, one day I just logged off of &lt;span class=&quot;caps&quot;&gt;AIM&lt;/span&gt;. I wasn&#8217;t really trying to quit the service, but I just never went back to it, only on rare occasion where I want to ask a friend something quickly, maybe someone I don&#8217;t talk to frequently and just dropping a casual message not warranting the possible inconvience of a phone call.&lt;/p&gt;


	&lt;p&gt;So, now it&#8217;s over 3 years since I&#8217;ve used the &lt;span class=&quot;caps&quot;&gt;AIM&lt;/span&gt; application. Since then, I&#8217;ve got a &lt;a href=&quot;http://myspace.com&quot;&gt;Myspace&lt;/a&gt; and &lt;a href=&quot;http://facebook.com&quot;&gt;FaceBook&lt;/a&gt; but I&#8217;m not really active on either. It&#8217;s nice being connected, but shit I&#8217;ve got better things to do than poke people and send sparkly image comments saying &#8220;Thanks for the Add&#8221;.&lt;/p&gt;


	&lt;p&gt;I&#8217;ve adopted text messaging as a preferred method of instant contact. Recently, however, I logged into my old &lt;span class=&quot;caps&quot;&gt;AIM&lt;/span&gt; account and was reminded that there is one area where this Tech 1.0 favorite still prevails: separating regular &#8220;ChIcKz&#8221; from hot chicks.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-05-06:8</id>
    <published>2007-05-06T22:01:00Z</published>
    <updated>2007-05-06T22:04:20Z</updated>
    <category term="Rails"/>
    <link href="http://conductr.com/2007/5/6/putting-javascript-inline" rel="alternate" type="text/html"/>
    <title>Putting JavaScript Inline</title>
<content type="html">
            &lt;p&gt;Sometimes, usually in development, I find it useful to have my Javascripts printed inline rather than using the &lt;code&gt;&amp;lt;script src=&quot;/path/to&quot;&amp;gt;&lt;/code&gt; tags that are generated by &lt;a href=&quot;http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#M000591&quot;&gt;&lt;code&gt;javascript_include_tag&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;With &lt;code&gt;javascript_inline_tag&lt;/code&gt; you can simply declare your Javascripts just like you would with &lt;code&gt;javascript_include_tag&lt;/code&gt; and it will spit out the script into your view/layout.&lt;/p&gt;


	&lt;p&gt;Put it where you like, but I chose to keep with my &lt;code&gt;application_helper.rb&lt;/code&gt;.&lt;/p&gt;


&lt;strong&gt;javascript_inline_tag&lt;/strong&gt;
&lt;pre&gt;&lt;code&gt;module ApplicationHelper
  # ..... your app helpers, per usual
end

module ActionView::Helpers::AssetTagHelper
  def javascript_inline_tag(*sources)
    if sources.include?(:defaults) 
      sources = sources[0..(sources.index(:defaults))] + 
      @@javascript_default_sources.dup + 
      sources[(sources.index(:defaults) + 1)..sources.length]
      sources.delete(:defaults) 
      sources &amp;lt;&amp;lt; &quot;application&quot; if defined?(RAILS_ROOT) &#38;&#38; File.exists?(&quot;#{RAILS_ROOT}/public/javascripts/application.js&quot;) 
    end

    sources.collect do |source|
      source = javascript_path(source).sub(/\?\d+/,'')
      contents = ''
      File.open(&quot;#{RAILS_ROOT}/public#{source}&quot;).each do |line|
        contents &amp;lt;&amp;lt; line
      end
      javascript_tag(contents)
    end.join(&quot;\n&quot;)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;strong&gt;Sample Usage&lt;/strong&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;%= javascript_inline_tag :defaults,'niftycube' %&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;strong&gt;Notes&lt;/strong&gt;
	&lt;ol&gt;
	&lt;li&gt;You can not pass an &lt;code&gt;options&lt;/code&gt; hash.&lt;/li&gt;
		&lt;li&gt;For production, I&#8217;ll just say, consider caching (browser&amp;amp;server) and page size.&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://www.html.it/articoli/niftycube/index.html&quot;&gt;Nifty Corners Cube&lt;/a&gt; is an awesome script that I recently discovered.&lt;/li&gt;
		&lt;li&gt;You may find &lt;code&gt;render :file =&amp;gt; ''&lt;/code&gt; to work for you, I just thought it wasn&#8217;t flexible enough for this situation.&lt;/li&gt;
	&lt;/ol&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-03-31:7</id>
    <published>2007-03-31T17:07:00Z</published>
    <updated>2007-03-31T17:09:51Z</updated>
    <link href="http://conductr.com/2007/3/31/acton-mba-call-to-action" rel="alternate" type="text/html"/>
    <title>Acton MBA call to Action</title>
<content type="html">
            &lt;p&gt;&lt;img src=&quot;http://blog.conductr.com/assets/2007/3/31/ad.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Gee, I can&#8217;t wait to get to work on my obituary. I wonder what marketing genius gave the thumbs up on this?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://conductr.com/">
    <author>
      <name>Chad</name>
    </author>
    <id>tag:conductr.com,2007-02-19:6</id>
    <published>2007-02-19T05:42:00Z</published>
    <updated>2007-02-19T07:02:42Z</updated>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://conductr.com/2007/2/19/remove-files-after-a-destroy" rel="alternate" type="text/html"/>
    <title>Remove Files After a Destroy</title>
<content type="html">
            &lt;p&gt;This blog was started with the purpose of writing mostly about code. I have yet to do so until now. Here we go.&lt;/p&gt;


	&lt;p&gt;My current project, similar to &lt;a href=&quot;http://amie.st&quot;&gt;AmieStreet&lt;/a&gt;, requires the uploading of files (eg mp3&#8217;s) that are linked to a record in the database. While the database stores all of the information about the song (eg Title) the mp3 itself is stored on the filesystem. If, for whatever reason, we delete the record from the database we should also remove the associated mp3 from the filesystem.&lt;/p&gt;


	&lt;p&gt;Rails makes this incredibly easy for us. As the convention goes, I will call the delete a destroy from here on out.&lt;/p&gt;


&lt;strong&gt;Version 1&lt;/strong&gt;
&lt;pre&gt;&lt;code&gt;def after_destroy
  if FileTest.exist?(source)
    FileUtils.rm self.source
  end
  if FileTest.exist?(clip)
    FileUtils.rm clip
  end
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This was my original code. I have 2 mp3 files, the source (entire song) and the clip (sample from song), each file should be removed from the filesystem after the record is destroyed. Conveniently, the &lt;a href=&quot;http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html#M000924&quot;&gt;after_destroy&lt;/a&gt; callback lets me run my logic after the destroy.&lt;/p&gt;


	&lt;p&gt;Since I have 2 files, I test to see if each &lt;a href=&quot;http://www.rubycentral.com/book/ref_m_filetest.html#FileTest.exist_qm&quot;&gt;exists&lt;/a&gt; if so I &lt;a href=&quot;http://www.ruby-doc.org/core/classes/FileUtils.html#M004356&quot;&gt;remove&lt;/a&gt; it. Note: the source and clip methods just return full paths to the files, like &lt;code&gt;RAILS_ROOT+&quot;/path/to/file.mp3&quot;&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;It could be so much better, let&#8217;s &lt;a href=&quot;http://en.wikipedia.org/wiki/Don't_repeat_yourself&quot;&gt;&lt;span class=&quot;caps&quot;&gt;DRY&lt;/span&gt;&lt;/a&gt; things up a bit.&lt;/p&gt;


&lt;strong&gt;Version 2&lt;/strong&gt;
&lt;pre&gt;&lt;code&gt;def after_destroy
  removables [source, clip]
end
def removables(paths = [])
  paths.each{|p| FileUtils.rm p if FileTest.exist?p }
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Here I wanted to make a method that I could feed multiple file paths and it would execute the logic. So I made the &lt;code&gt;removables&lt;/code&gt; method, which steps through each path in the &lt;code&gt;paths&lt;/code&gt; array and removes the file if it exists. This is pretty clean, but it gets better.&lt;/p&gt;


&lt;strong&gt;Version 3, Final&lt;/strong&gt;
&lt;pre&gt;&lt;code&gt;def after_destroy
  FileUtils.rm_f [source, clip]
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Upon closer inspection, I noticed that the FileUtils.rm* methods actually accept a list of files to delete. And, with the force option the method does not throw errors if the file is not there. I was so used to always having to check whether a &lt;a href=&quot;http://php.net/manual/en/function.file-exists.php&quot;&gt;file existed&lt;/a&gt;, in order to avoid errors that come up if I tried to delete a nonexistent file, that I did not even think this could be done. Of course, with Ruby, the solution is simple.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;This is a perfect example of how I am trying to think like a Rubyist. From V1 to V3, Final took me about 5 minutes so I feel that I am getting a good deal better &#8230; and oh so addicted.&lt;/p&gt;
          </content>  </entry>
</feed>
