<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>computers should be less friendly &#187; RoR</title>
	<atom:link href="http://blog.danmcweeney.com/category/ror/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.danmcweeney.com</link>
	<description></description>
	<lastBuildDate>Mon, 10 Aug 2009 20:38:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Prom Queen</title>
		<link>http://blog.danmcweeney.com/21</link>
		<comments>http://blog.danmcweeney.com/21#comments</comments>
		<pubDate>Tue, 06 Mar 2007 20:19:40 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[innovation]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/21</guid>
		<description><![CDATA[Eddie Herrmann was reading Scoble&#8216;s twits a few weeks back and he was complaining about how annoying it was to take all of your followers and make them friends. So, last night Eddie and I decided to give him a hand. Prom Queen is basically a popularity contest that also helps you convert followers into [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.ewherrmann.com/">Eddie Herrmann</a> was reading <a href="http://scobleizer.com/">Scoble</a>&#8216;s twits a few weeks back and he was <a href="http://twitter.com/Scobleizer/statuses/5845394">complaining</a> about <a href="http://twitter.com/Scobleizer/statuses/5838992">how annoying</a> it was to take all of your followers and make them friends.  So, last night Eddie and I decided to give him a hand.</p>
<p><a href="http://danmcweeney.com/promqueen/">Prom Queen</a> is basically a popularity contest that also helps you convert followers into friends.  Simply, put in your Twitter UserID and password into Prom Queen and it will go out and scrape all your followers and make them friends.  It will also then enter you into our &#8220;popularity contest,&#8221; which ranks you based on the number of Followers you have.  So feel free to use it and let us know what you think.  </p>
<p>This is a total hack so if <a href="http://www.twitter.com">Twitter</a> changes around much expect this site to be down till we fix it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/21/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Badges? I need a stinking Badge!</title>
		<link>http://blog.danmcweeney.com/16</link>
		<comments>http://blog.danmcweeney.com/16#comments</comments>
		<pubDate>Sat, 10 Feb 2007 19:36:35 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[SAPlink]]></category>
		<category><![CDATA[SDN blogger]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/16</guid>
		<description><![CDATA[Just some background before I get into the how-to, I built my badge over the course of a week and a lot of that time was dedicated to figuring out how to deal with my hosting company&#8217;s environment or waiting for them to respond to tickets entered about installing something. What I have learned about [...]]]></description>
			<content:encoded><![CDATA[<p>Just some background before I get into the how-to, I built my badge over the course of a week and a lot of that time was dedicated to figuring out how to deal with my hosting company&#8217;s environment or waiting for them to respond to tickets entered about installing something.  What I have learned about this process is that the average $5/month hosting company has horrible customer service and probably doesn&#8217;t know the first thing about Ruby on Rails development.  That being said, fear not as I will try and point you to useful sites that walk you through how to deal with these issues.  One other point, by no means am I a Ruby on Rails expert, this is really meant to chronicle my experiences and serve as a reference for (myself) and others.</p>
<p>This process started with the dream of making a little snippet of javascript code that would create a decent looking &#8220;badge&#8221; that linked to the <a href="http://www.saplink.org" target="_blank">SAPlink project</a> and displayed the current number of downloads.  However, SAPlink is hosted on <a href="http://code.google.com/hosting/" target="_blank">Google&#8217;s Code hosting site</a>, which doesn&#8217;t have an API to get the number of downloads.  So here is how you could build something like this yourself.</p>
<h3>Get a hosting Company</h3>
<p style="margin-left: 20px">I personally chose <a href="http://www.hostmonster.com" target="_blank">Hostmonster</a> which was very inexpensive, but as you have already read not the most responsive.  I&#8217;m not bashing them here, I only pay like $5 a month or something and have experienced no down time and haven&#8217;t hit any bandwidth/cpu limits, not that tons of people hit my site, but still.  I would recommend getting a hosting company that says they have rails installed and that you can have ssh access, all the other stuff is up to you.</p>
<h3>Create Rails project</h3>
<p style="margin-left: 20px">Now depending on your hosting company you will have to do this a few different ways, I would reccommend looking for some info from your hosting company, once you can get to the &#8220;Welcome to Ruby on Rails&#8221; page. Come back here.</p>
<p style="margin-left: 20px">For my hosting site all I have to do is create a symbolic link in the public_html directory to where i generate the rails project.  So for SAPlink i just ran the following commands:</p>
<pre style="margin-left: 30px"><code>cd ~
mkdir rails
rails SAPlinkbadge
cd ~/public_html
ln -s ~/rails/SAPlinkbadge/public saplinkbadge</code></pre>
<p style="margin-left: 20px">I like to keep things neat and tidy so I created a rails folder to house all projects that I will host.  Then i simply generate a new rails project called SAPlinkbadge.  The final step is create a sym link to the public directory of my rails application.</p>
<h3>Create a local Gem repository</h3>
<p style="margin-left: 20px">Why?  Well, because at any time your hosting company can tell you that they don&#8217;t want to install a gem that does XYZ, so you have to have your own gem repository.  Assuming your hosting company already has rails all you need to do is follow this: <a href="http://forums.site5.com/showthread.php?t=11954" target="_blank">How-to Install your Own Gems in a shared environment</a>.  This will now allow you to install any gems you want without ever involving your hosting company.  One word of caution, on step 9 make sure you place the GEM_PATH <strong>above</strong> the call to the boot.rb file.</p>
<h3>Install Hpricot Gem</h3>
<p style="margin-left: 20px">Now that you have your own gem repository up and running we can install a really great gem from the legendary <a href="http://whytheluckystiff.net/" target="_blank">why the lucky stiff</a> called &#8220;Hpricot.&#8221;  &#8220;<span class="searchword0">Hpricot</span> is a very flexible HTML parser,&#8221; which will allow us to scrape any HTML page and quickly grab the bits we want.  To do this issue the following commands or you can follow <a href="http://code.whytheluckystiff.net/hpricot/wiki/InstallingHpricot" target="_blank">Why&#8217;s instructions for install Hpricot</a>:</p>
<pre style="margin-left: 30px"><code>
gem install Hpricot
</code></pre>
<p style="margin-left: 20px">In this case we will be scraping the google code site page that shows the downloads for SAPlink.  So to test the Hpricot gem we can either use irb or we can use the console that rails has created for us.  Given that we will eventually use this is a rails application we might as well test it from our rails console.  If you have never used the rails script/console before you are missing out.  This console brings up a ruby session that has the same setup as your rails application will execute in.  What I mean here is that if your ruby code works in the script/console odds are pretty good it will work in your rails app.  So CD over to where you created the rails application and type the command:</p>
<pre style="margin-left: 30px"><code>
cd ~/rails/SAPlinkbadge
script/console</code>
You should get something that looks like this:
<code>
Loading development environment.
>>
</code></pre>
<p style="margin-left: 20px">Now let&#8217;s see if Hpricot has been installed and is usable in our rails application, first we have to require the gems per <a href="http://code.whytheluckystiff.net/hpricot/wiki/HpricotBasics">Why&#8217;s great examples</a>:</p>
<pre style="margin-left: 30px"><code>
>> require "hpricot"
=> []
>> require "open-uri"
=> ["OpenURI"]
>>
</code></pre>
<p style="margin-left: 20px">(Hint: Only type the stuff in front of &#8216;&gt;&gt;&#8217;)<br />
So, if everything has gone swimmingly we should be able to get Hpricot to give us our web page.  In the case of my SAPlinkbadge, I want <a href="http://code.google.com/p/saplink/downloads/list?q=label:SAPlink">this site</a>.  To do this it&#8217;s one line of code:</p>
<pre style="margin-left: 30px"><code>
doc = Hpricot(open
    ("http://code.google.com/p/saplink/downloads/list?q=label:SAPlink"))
</code></pre>
<p>The output should be the whole HTML document, this is just Hpricot&#8217;s way of saying that it got what you were looking for.  This means Hpricot is working fine.</p>
<h3>Create your controller and model</h3>
<p style="margin-left: 20px">I&#8217;m not going to go into much of this as there are tons of real Ruby on Rails tutorials to tell you how.  Just do a Google search or check out the <a href="http://wiki.rubyonrails.org/rails">RoR Wiki</a>.  Basically my rails project has one controller and one model.  My model does a few things, first it reads a local database to see when the last time I scraped the Google code site was, if it wasn&#8217;t in the last 10 minutes I go grab the site and then update a local database.  I do this to reduce any load on Google and to keep everything running quickly.  The important bit here is the work Hpricot is doing for me&#8230;.</p>
<h3>Get Hpricot to do your dirty work</h3>
<p style="margin-left: 20px">The site I am pulling is really complex, lots of divs, tables all sorts of non-sense, to parse this myself would be crazy lucky for us why ( and Firebug ) came to the rescue.  Here is my code to scrape the google code site</p>
<pre style="margin-left: 30px"><code>
doc = Hpricot(open("http://code.google.com/p/saplink/downloads/list?q=label:SAPlink"))
total = 0
doc.search("td.col_4").at("a") {|link|
   total += link.innerHTML.to_i
}
</code></pre>
<p>It&#8217;s so easy it should be illegal!  Basically, before I wrote any code, I used Firebug to figure out if the cells I wanted had anything in common luckily, they were all TDs with the style &#8220;col_4.&#8221;  As you can see this from this line <code>doc.search("td.col_4")</code> This instructs Hpricot to give me a collection of objects that match that particular CSS style, neat huh?  Not only that but inside each one of those is a anchor tag whose inner text is one line of the total.  The only easy way to do this is to use Firebug, seriously it&#8217;s a totally amazing tool, it will make you a better web programmer and let you really understand websites.</p>
<h3>Output</h3>
<p style="margin-left: 20px">To accomplish my final task which was to make it so someone could include a simple script tag with the badge and the total downloads, I just created a view that spit out a document.write statement to create a div tag with the floating total retrieved from my model on it.</p>
<p>After I built all this <a href="http://craig.cmehil.com">Craig</a> &#8220;challenged&#8221; me to produce one that was just a image, no script insert required as some of the SDN areas don&#8217;t allow script tags.  So after some more spinning of my wheels I was able to produce the image you see below which uses the same model, the same Hpricot code, it just spits out an image using a gem called <a href="http://rmagick.rubyforge.org/" target="_blank">RMagick</a>.</p>
<p><img src="http://www.danmcweeney.com/saplinkbadge/png/show/blogpost.png" height="57" width="93" /></p>
<p>Hope this helps and hopefully you can follow it to make your own badges.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/16/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ABAP Magic Models</title>
		<link>http://blog.danmcweeney.com/8</link>
		<comments>http://blog.danmcweeney.com/8#comments</comments>
		<pubDate>Sun, 26 Nov 2006 22:23:21 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[ABAP]]></category>
		<category><![CDATA[ABAP Magic Models]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[SDN blogger]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/?p=8</guid>
		<description><![CDATA[After reading a lot about Rails and it&#8217;s former inclusion (thanks to Tom and Ryan) of a bunch of REST functionality into the next release and a blog by Dr. Nic about his Magic Models project I&#8217;ve decided to embark on a new project. Simply put I want Dr. Nic&#8217;s magic models for ABAP. The [...]]]></description>
			<content:encoded><![CDATA[<p>After reading a lot about Rails and it&#8217;s <a href="http://dev.rubyonrails.org/changeset/5554" target="_blank">former inclusion</a> (thanks to <a href="http://atomgiant.com/articles/2006/11/19/active-resource-removed-from-rails-1-2" target="_blank">Tom</a><a href="http://feeds.feedburner.com/atomgiant" target="_blank"><img src="http://www.danmcweeney.com/images/feed-icon16x16.png" /></a> and <a href="http://www.ryandaigle.com/articles/2006/11/20/whats-new-in-edge-rails-activeresource-pulled-world-weeps" target="_blank">Ryan</a><a href="http://feeds.feedburner.com/RyansScraps" target="_blank"><img src="http://www.danmcweeney.com/images/feed-icon16x16.png" /></a>) of a bunch of REST functionality into the next release and a <a href="http://drnicwilliams.com/2006/08/10/bts-magic-models-class-creation/" target="_blank">blog by Dr. Nic</a> <a href="http://feeds.feedburner.com/DrNic" target="_blank"><img src="http://www.danmcweeney.com/images/feed-icon16x16.png" alt="feed" title="feed" /></a> about his <a href="http://magicmodels.rubyforge.org/" target="_blank">Magic Models project</a> I&#8217;ve decided to embark on a new project.</p>
<p>Simply put I want Dr. Nic&#8217;s magic models for ABAP.  The basic idea behind the project is that RoR developers should be able to easily consume ABAP objects.  Current solutions only create the ability to call RFCs, which if you are not an ABAP person are totally procedural elements so, this removes any of the beauty of OOP from systems you can build that interact with ABAP.  With this project I hope to put it back.  In the end what you should be able to do on the RoR side is create a config file to point to your SAP instance and then make calls like this:</p>
<blockquote style="font-family: monospace"><p>@abapObject = Zcl_foobar.new</p>
<p>@abapObject.callMethod( with, some, params )</p></blockquote>
<p>Where Zcl_foobar is the name of class that resides only on the ABAP system.  What this will allow a RoR developer to do is simply and quickly access classes from ABAP without having to have an ABAP person wrap every method call in a function module.  In the background Ruby is using the const_missing method to generate a generic class for Zcl_foobar.  When a method is called the call is converted into a specially formatted REST call to an ICF Node ( basically a servlet ) on the ABAP side and ABAP responds to the message with another XML document that the newly generated class understand and unpacks into more Ruby data objects.</p>
<p>For now I am only building a &#8220;connector&#8221; to the Ruby programming language but, there is nothing to prevent the addition of other scripting languages from using this method and the base ICF node to accomplish similar feats.  Over the next month or two I will be focusing almost all my time in taking this from it&#8217;s current stage, simply a proof of concept to a fully working system.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SAP Analyst Summit</title>
		<link>http://blog.danmcweeney.com/4</link>
		<comments>http://blog.danmcweeney.com/4#comments</comments>
		<pubDate>Tue, 07 Nov 2006 03:02:09 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[RoR]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[Visual Composer]]></category>

		<guid isPermaLink="false">http://blog.danmcweeney.com/?p=4</guid>
		<description><![CDATA[Just got confirmation that I will be able to speak at SAP&#8217;s Analyst Summit. As it stands right now I will be talking about two topic areas, Netweaver Visual Composer and Ruby on Rails. Certainly two fairly divergent topics, yes, but they highlight two interesting areas of foray for SAP. If you don&#8217;t know Visual [...]]]></description>
			<content:encoded><![CDATA[<p>Just got confirmation that I will be able to speak at SAP&#8217;s Analyst Summit.  As it stands right now I will be talking about two topic areas, Netweaver Visual Composer and Ruby on Rails.  Certainly two fairly divergent topics, yes, but they highlight two interesting areas of foray for SAP.  If you don&#8217;t know Visual Composer is a way of creating Flex based applications using a very well designed SVG development environment.  The dev env allows you to very easily whip together Flash based &#8220;composite&#8221; ( SAP speak for applications that both present and update date ) applications using RFC calls to an ABAP system or even web services.  This notion of web services and openness is at the heart of how SAP is starting to position their Netweaver platform and in keeping with this SAP has begun to &#8220;support&#8221; connections to scripting languages.</p>
<p>At the forefront of this scripting language support are two guys, Piers Harding<a target="_blank" href="http://www.piersharding.com/blog/index.rss"><img title="feed" alt="feed" src="http://www.danmcweeney.com/images/feed-icon16x16.png" /></a> from the community side and Craig Cmehil<a target="_blank" href="http://feeds.feedburner.com/CraigsRantings"><img title="feed" alt="feed" src="http://www.danmcweeney.com/images/feed-icon16x16.png" /></a> from the evangelist side.  Piers can be credited with creating most of the scripting connectors (ruby, python, perl) and Craig can probably take a lot of the credit for getting this stuff on someone important&#8217;s radar.  I got involved pretty late in the game only ever writing a little bit of python for some file management stuff, I latched onto RoR because of it&#8217;s ability to create rich, attractive web front ends with almost no effort, which is what I will be showing in my second presentation at the Analyst Summit.</p>
<p>So, if you are going to be at the Summit drop by and check out my presentations or drop me a line so we can meet up.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danmcweeney.com/4/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

