<?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>dev on rails - hyperco.de blog</title>
	<atom:link href="http://blog.hyperco.de/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hyperco.de</link>
	<description>the official blog of hyperco.de web services and its cio</description>
	<lastBuildDate>Wed, 10 Aug 2011 10:37:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ruby performance marshalling JSON YAML</title>
		<link>http://blog.hyperco.de/index.php/2011/08/ruby-performance-marshalling-json-yaml/</link>
		<comments>http://blog.hyperco.de/index.php/2011/08/ruby-performance-marshalling-json-yaml/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 10:26:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[rails tricks]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[ruby json yaml memcache memcached dalli]]></category>

		<guid isPermaLink="false">http://blog.hyperco.de/?p=152</guid>
		<description><![CDATA[While we are using memcached to keep a lot of things available for our app, and now we switched to Rails 3 and for memcached we are using the faster Dalli Client, I was kind of interested about the marshalling performance of different methods.

For this performance test I have made a copy of a quite [...]]]></description>
			<content:encoded><![CDATA[<p>While we are using memcached to keep a lot of things available for our app, and now we switched to Rails 3 and for memcached we are using the faster Dalli Client, I was kind of interested about the marshalling performance of different methods.</p>

<p>For this performance test I have made a copy of a quite big object from one of our production apps. If this object is converted plain to <span class="caps">YAML </span>it takes about of 3.7 <span class="caps">MB, </span>and in byte stream ruby marshalling about 1.8 <span class="caps">MB.</span> It consists mainly of big hashes, whereas the hashes hold strings as keys and integers as values. Summed all values together in that object that might be around 200k objects (basically short strings and <span class="caps">DWORD </span>integers)</p>

<p>Using <strong>ruby 1.8.7</strong> converting that object to <span class="caps">YAML </span>is quite a pain. Not using only over 200 MB of <span class="caps">RAM </span>after calling the .to_yaml method but also taking 25.6 seconds to fullfill that request on a small Debian 6 system.</p>

<p>The .to_json performs an edge faster with 3.8 seconds and using only about ~ 30 MB of <span class="caps">RAM </span>usage for the ruby process.</p>

<p>Much better performance showed the built-in marshalling method. The ruby built-in Marshal.dump resp. Marshal.load methods did not show a significant difference. Dumping and loading take each approximately 90 ms.</p>

<p>Finally retrieving that object from memcached, whose sub objects are kept in 5 chunks to not excess the 1 MB limit takes about 40 ms. And in this time not only the bytestream is being converted to an object, but also the whole data is transmitted via <span class="caps">TCP </span>sockets.</p>

<table class="right" cellspacing="0"><tr><td></td><td>time</td><td>stream<br />
length</td><td>performance</td></tr><tr><td><span class="caps">YAML</span>*</td><td>25.6 s</td><td>3.7 MB</td><td>0.351 %</td></tr><tr><td><span class="caps">JSON</span></td><td>3.8 s</td><td>2.8 MB</td><td>2.36 %</td></tr><tr><td>marshal</td><td>0.09 s</td><td>1.8 MB</td><td>100%</td></tr><tr><td>memcached<br />
Dalli.get</td><td>0.04 s</td><td>n.a.</td><td>225 %</td></tr></table>

<p>*excessive <span class="caps">RAM </span>usage when streaming to <span class="caps">YAML.</span></p>


<p>Finally I hope there is going to be some major improvements to the built-in <span class="caps">JSON </span>and <span class="caps">YAML </span>performance to come with future ruby and rails versions. Enough yaml libraries out there ...</p>]]></content:encoded>
			<wfw:commentRss>http://blog.hyperco.de/index.php/2011/08/ruby-performance-marshalling-json-yaml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer 9 beta released</title>
		<link>http://blog.hyperco.de/index.php/2010/10/internet-explorer-9-beta-released/</link>
		<comments>http://blog.hyperco.de/index.php/2010/10/internet-explorer-9-beta-released/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 12:15:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[random stuff]]></category>

		<guid isPermaLink="false">http://blog.hyperco.de/?p=134</guid>
		<description><![CDATA[Styling web sites for different browsers has always been a hassle. Naturally web standards are some more or less common to one or another browser. Internet Explorer has always been one of the major browsers worldwide, but had its very own interpretation of "web standards". So when a new realease of the IE hits the [...]]]></description>
			<content:encoded><![CDATA[<p>Styling web sites for different browsers has always been a hassle. Naturally web standards are some more or less common to one or another browser. Internet Explorer has always been one of the major browsers worldwide, but had its very own interpretation of "web standards". So when a new realease of the IE hits the beta state I always was very curious about how much less work I will have to do when styling future websites while adapting them to the extraordinary behaviour of microsofts browser.</p>

<p>Internet Explorer 7 had after several years of waiting <span class="caps">PNG'</span>s with alpha channel supported. Internet Explorer 9, which is now out for beta comes with rounded corners (CSS3 border-radius), currently passes 95% of the <span class="caps">ACID3</span>-Test and utilizes Direct2D which gives very smooth browsing experience on websites were you zoom and drag a lot like bing maps or google maps.</p>

<p>Interestingly due to the new Direct2D implementation, google maps is even faster in IE 9 as in Google's Chrome 5 itself, which is still my favourite browser - but at least microsoft did a big step towards the future. Let's hope that the little style bugs disappear before the final release.</p>

<h3>Links</h3>


<ul>
<li><a href="http://windows.microsoft.com/de-de/internet-explorer/download/ie-9/worldwide">Internet Explorer 9 beta Download</a></li>
<li><a href="http://acid3.acidtests.org/"><span class="caps">ACID</span> 3 Test</a></li>
<li><a href="http://en.wikipedia.org/wiki/Direct2D">Direct2D Wiki Page</a></li>
<li><a href="http://maps.bing.com">Bing Maps</a></li>
<li><a href="http://maps.google.com">Google Maps</a></li>
<li><a href="http://news.softpedia.com/news/54-Amazing-IE9-Websites-You-Have-to-Try-157008.shtml">54 amazing websites to try in IE 9</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.hyperco.de/index.php/2010/10/internet-explorer-9-beta-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>hyperco.de NoSQL cms online now!</title>
		<link>http://blog.hyperco.de/index.php/2010/09/hyperco-de-nosql-cms-online-now/</link>
		<comments>http://blog.hyperco.de/index.php/2010/09/hyperco-de-nosql-cms-online-now/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 07:39:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[random stuff]]></category>

		<guid isPermaLink="false">http://blog.hyperco.de/?p=128</guid>
		<description><![CDATA[We are proud to announce that our new CMS is online now. It is a self linking, smart navigating, and easy to administer content management system, based fully on open source software, Rails 2.3.81, Memcached2 and CouchDB3. It makes heavy use of json, and jQuery4, relies on ajax technologies and runs on all major browsers.

Till [...]]]></description>
			<content:encoded><![CDATA[<p>We are proud to announce that our new <span class="caps">CMS </span>is online now. It is a self linking, smart navigating, and easy to administer content management system, based fully on open source software, Rails 2.3.8<sup>1</sup>, Memcached<sup>2</sup> and CouchDB<sup>3</sup>. It makes heavy use of json, and jQuery<sup>4</sup>, relies on ajax technologies and runs on all major browsers.</p>
<p>
Till 2011 our new <span class="caps">CMS </span>will be exclusively available for <a href="http://www.asiacomfort.com">asiacomfort.com</a> and is being developed steadily.</p>

<ol class='legend'>
<li><a href='http://rubyonrails.org/'>Ruby on Rails</a> - the agile and fast web framework</li>
<li><a href='http://memcached.org/'>memcached</a> - unix native, distributed, high performance, memory object caching system</li>
<li><a href='http://couchdb.apache.org/'>CouchDB</a> - document oriented, distributed and scalable database system beyond <span class="caps">SQL</span></li>
<li><a href='http://jquery.com/'>jQuery</a> - the all in one javascript and ajax framework
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.hyperco.de/index.php/2010/09/hyperco-de-nosql-cms-online-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rails: fast mysql table export to csv</title>
		<link>http://blog.hyperco.de/index.php/2009/12/sql_to_csv/</link>
		<comments>http://blog.hyperco.de/index.php/2009/12/sql_to_csv/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 12:02:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[random stuff]]></category>

		<guid isPermaLink="false">http://blog.hyperco.de/?p=61</guid>
		<description><![CDATA[
Sometimes it is necessary to have a function for easily downloading a SQL table exported to a plain csv file for further external processing or manual data lookup. Normally people in forums on the net recommend to use phpmyadmin for tasks like this, but on a real production server phpmyadmin is of course no option [...]]]></description>
			<content:encoded><![CDATA[<p>
Sometimes it is necessary to have a function for easily downloading a <span class="caps">SQL </span>table exported to a plain csv file for further external processing or manual data lookup. Normally people in forums on the net recommend to use phpmyadmin for tasks like this, but on a real production server phpmyadmin is of course no option security wise.<br />
</p>
<p>
Another approach often recommended is to use FasterCSV to build the csv-file. FasterCSV is a nice tool when you want to freely create custom csv files, but performance wise this approach takes some time if you are really exporting large tables (&gt;10000 rows).<br />
</p>
<p>
Much faster is to just use MySQL's built-in method for exporting a table directly into csv format.<br />
</p>
<p>
Just put this into the model you want to export as csv.<br />
</p>
<p><blockquote><code># model
# function returns table as csv string 
def self.to_csv
  db_name = self.configurations[Rails.env]['database']
  # pay attention to the backticks ``
  return `echo &quot;use #{db_name};
    select * from #{self.table_name};&quot; 
    | mysql -u monitor_user --password=&quot;1234&quot;`
end</code></blockquote>
</p>
<p>
Ensure that you have a seperate <strong>mysql user with only select priviliges</strong> on your database to get this working safely - in this example the user name is 'monitor_user' with password '1234'.<br />
Of course if you are planning to implement this functionality in several models, you could put this into a module into ./lib and just include the module in each desired model class.<br />
</p>
<p>
To provide the generated csv string from the model for download, you could use some code like this in your controller.<br />
<blockquote><code># controller
def download_csv
  send_data(MyModel.to_csv, {
    :type      =&gt; 'text/csv',
    :filename  =&gt; &quot;my_model_#{Date.today.to_s}.csv&quot; } )
end
</code></blockquote>
<p>
Beneficial over the phpmyadmin solution,<br />
you define the security rules directly in your application,<br />
no need to rely on mysql priviliges and<br />
most important, you don't expose a common interface to the database server which is permanently under fire from automated attack bots<sup>1</sup>.<br />
</p>
<ol class='legend'>
<li>for those of you don't know about phpmyadmin ... even we don't have it running on our server - we have more than 1000 requests per month on a farely unpublic domain, trying to gain access to several possible phpmyadmin paths and underlying scripts - so its probably better to turn the doorbell of on permanent knock-a-door-runs</li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.hyperco.de/index.php/2009/12/sql_to_csv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>display upgrade S-PVA, E-IPS vs TN</title>
		<link>http://blog.hyperco.de/index.php/2009/11/display-upgrade/</link>
		<comments>http://blog.hyperco.de/index.php/2009/11/display-upgrade/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 19:35:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[random stuff]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[e-ips]]></category>
		<category><![CDATA[ips]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[pivot]]></category>
		<category><![CDATA[pva]]></category>
		<category><![CDATA[s-pva]]></category>
		<category><![CDATA[tft]]></category>
		<category><![CDATA[tn]]></category>

		<guid isPermaLink="false">http://blog.hyperco.de/?p=39</guid>
		<description><![CDATA[
For 2-odd years now I'm very lucky with my Eizo S2411W. Most of the time I'm surfing the web, writing code or do photoshopping. Usually at the end of the year you try to spend some money, and as I feel that displays have become real keen now (as opposed to RAM, which where half [...]]]></description>
			<content:encoded><![CDATA[<p>
For 2-odd years now I'm very lucky with my Eizo <span class="caps">S2411W.</span> Most of the time I'm surfing the web, writing code or do photoshopping. Usually at the end of the year you try to spend some money, and as I feel that displays have become real keen now (as opposed to <span class="caps">RAM, </span>which where half the price a year ago) I decided to get me a smaller additional pivot display, especially nice for reading or writing large text and code.<br />
</p>
<p>
<div id="attachment_43" class="wp-caption aligncenter" style="width: 490px"><a href="http://blog.hyperco.de/wp-content/uploads/2009/11/display-upgrade_m.jpg"><img src="http://blog.hyperco.de/wp-content/uploads/2009/11/display-upgrade_s.jpg" alt="Samsung, Eizo, Dell" title="The three buds" width="480" height="233" class="size-full wp-image-43" /></a><p class="wp-caption-text">Samsung, Eizo, Dell</p></div><br />
</p>
<p>
I ordered a Samsung SyncMaster 2243BW, as this display was one of the lowest priced models for around <span class="caps">EUR</span> 180 with 22 inch and pivot stand. Shortly after the arrival and setup of the display I noticed that these so popular TN-Panels had much worse viewing angle properties than I was expecting. Of course I knew about the properties of TN panels, that's why I was buying the Eizo 2 years ago having a S-PVA panel, offering the best color reproduction, highest font detail, constant color and contrast over the full viewing angle compared to any other <span class="caps">LCD </span>technology. My disappointment over the extraordinary nasty color shifts occurring on little viewing angle changes leaded me to the decision to get another display for comparison. I have heard <span class="caps">IPS </span>technology made some advantages in the past, and as you can get displays with this type of panel for little extra money compared to TN panels I decided to give them a try. The second display I ordered was a Dell 2209WA having an E-IPS panel as this was nearly the lowest price 22 inch model with pivot stand and E-IPS panel for around <span class="caps">EUR</span> 250.<br />
</p>
<h2>Comparison</h2>
<table><tr><td style='vertical-align:top;'>
<b>Dell</b><br />
<ul>
<li>+ higher max brightness</li>
<li>+ more natural colors</li>
<li>- loss of contrast in dark parts (dark parts get bright, especially in diagonal direction)</li>
<li>+ smooth stand</li>
<li>+ white stays white - no matter what direction</li>
</ul>
</td><td style='vertical-align:top;'>
<b>Samsung</b><br />
<ul>
<li>+ sensor buttons</li>
<li>+ low price</li>
<li>- distinct shift of colors from angles about 10 degrees and more</li>
<li>- crop of black levels at little angels (dark parts get black on small angles, especially on angles to the bottom)</li>
<li>- extreme shift of tones from angles to the bottom of the display - problematic in 90 degrees pivot operation</li>
<li>- dark levels get bright on little angles to the top</li>
<li>- white shifts to grey, green, blue or a little red depending on the direction</li>
</ul>
</td></tr></table>

<p>On the following figure you can see the difference in color and contrast reproduction on a tilted viewing angle. On the left, the Samsung, its fairly recognizable that light tones are shifted dramatically to green, red, grey, and even white is shifted to blue, wheres blue is shifted to green. And the more darker mid-tones become very vibrant, loosing a lot of tonal detail. Depending on the viewing angle this changes all the time. So if you are looking for wicked spectral effects this display might be interesting for you, although I prefer the reproduction quality can be seen on the second photograph - the <span class="caps">IPS </span>panel of the Dell display reveals nearly no color shifts even on highly tilted viewing angles. One downside even for Dells <span class="caps">IPS' </span>- the black parts get clearly brighter on larger angles, but this effect is at least in daylight situation negligible.
</p>
<a href='http://blog.hyperco.de/wp-content/uploads/2009/11/TNvsIPS_angels.jpg' target='_blank'><img src='http://blog.hyperco.de/wp-content/uploads/2009/11/TNvsIPS_angels_s.jpg' width=240 /></a>
<p>
Both shots are taken and processed with totally equal settings.<br />
</p>]]></content:encoded>
			<wfw:commentRss>http://blog.hyperco.de/index.php/2009/11/display-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Wordpress login with yourblog.de/login</title>
		<link>http://blog.hyperco.de/index.php/2009/11/apache-wordpress-rewrit/</link>
		<comments>http://blog.hyperco.de/index.php/2009/11/apache-wordpress-rewrit/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 23:47:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[random stuff]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[rewrite_cond]]></category>
		<category><![CDATA[rewrite_rule]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.hyperco.de/?p=27</guid>
		<description><![CDATA[
I thought it would be cool to not have the meta-widget on my wordpress blog enabled as there is probably little need for visitors to have a login-link visible on the start page.


If you are used to simple naming conventions from rails you expect to have the login in my case on http://blog.hyperco.de/login - but [...]]]></description>
			<content:encoded><![CDATA[<p>
I thought it would be cool to not have the meta-widget on my wordpress blog enabled as there is probably little need for visitors to have a login-link visible on the start page.<br />
</p>
<p>
If you are used to simple naming conventions from rails you expect to have the login in my case on http://blog.hyperco.de/login - but the wordpress login page sits in wp-login.php - that seems to be a general design rule. All of the pages in the wordpress root start with 'wp-' and end with '.php' - not my prefered taste.<br />
</p>
<p>
So I thought, wouldn't it be nice to have apache redirect all requests to files not found on the disk to the wordpress style named files?<br />
</p>
<p>
I assume you are using apache web server and you have the RewriteEngine aka <a href='http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html'>mod_rewrite</a> enabled, then this will do the trick:<br />
</p>
<blockquote><code>RewriteEngine on
RewriteCond %{LA-U:REQUEST_FILENAME} !-f
RewriteCond %{LA-U:REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(.*)\.php$
RewriteRule ^/(.*)$ /wp-$1.php [R=307]
</code></ol></blockquote>
<p>
This peace of code you can easily be pasted into your vhost config or .htaccess file or whatever else config file you are using.<br />
</p>
<ol class='legend'>
<h4>Explanation</h4>
<li>in line one we enable the RewriteEngine</li>
<li>apply rule only if no file on disk with this name exists</li>
<li>apply rule only if no directory on disk with this name exists</li>
<li>apply rule only if <span class="caps">REQUEST</span>_URI does <span class="caps">NOT </span>end on <em>.php</em></li>
<li>rewrite (redirect) <em>/login</em> to <em>/wp-login.php</em></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://blog.hyperco.de/index.php/2009/11/apache-wordpress-rewrit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple inline code in your rails templates</title>
		<link>http://blog.hyperco.de/index.php/2009/10/simple-inline-code-in-your-rails-templates/</link>
		<comments>http://blog.hyperco.de/index.php/2009/10/simple-inline-code-in-your-rails-templates/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 20:26:41 +0000</pubDate>
		<dc:creator>d5e</dc:creator>
				<category><![CDATA[frontend]]></category>
		<category><![CDATA[%]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[trim-mode]]></category>

		<guid isPermaLink="false">http://blog.hyperco.de/?p=6</guid>
		<description><![CDATA[when I write views and templates sometimes it occurs that I want to use some code like
&#60;% if c = @customer[:image] %&#62;;
  &#60;img src='...' /&#62;;
&#60;% end %&#62;

but obviously this code would look much more nice with short tags enabled, so I could use code like

% if c = @customer[:image]
  &#60;img src='...' /&#62;
% end
but [...]]]></description>
			<content:encoded><![CDATA[<p>when I write views and templates sometimes it occurs that I want to use some code like</p>
<blockquote><code>&lt;% if c = @customer[:image] %&gt;;
  &lt;img src='...' /&gt;;
&lt;% end %&gt;</code></blockquote>
<p>
but obviously this code would look much more nice with short tags enabled, so I could use code like<br />
</p>
<blockquote><code>% if c = @customer[:image]
  &lt;img src='...' /&gt;
% end</code></blockquote>
<p>but poorely, in a standard rails env this trim mode for ERb is not enabled by default.</p>
<p>
For Rails 2.1.2, I've made it working by<br />
</p>
<blockquote><code># environment.rb:

# ALLOW open ruby code lines inside templates
ActionView::Base.erb_trim_mode = '-%'</code></blockquote>
<p>
At least for Rails 2.3.4 this does not works as a class is frozen error is raised. I'll post an update here, when I found out a simple solution to get this working in rails 2.3.x without the need to install the <a title="rails-erb-trim-mode - Project Hosting on Google Code:" href="http://code.google.com/p/rails-erb-trim-mode/" target="_blank">trim mode plugin</a>.<br />
</p>]]></content:encoded>
			<wfw:commentRss>http://blog.hyperco.de/index.php/2009/10/simple-inline-code-in-your-rails-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

