<?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>Viktors Rotanovs &#187; Web Development</title>
	<atom:link href="http://rotanovs.com/category/web-developer/feed/" rel="self" type="application/rss+xml" />
	<link>http://rotanovs.com</link>
	<description></description>
	<lastBuildDate>Thu, 13 May 2010 21:52:59 +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>Hitgeist.com migrated from ERB to HAML and Compass+Blueprint</title>
		<link>http://rotanovs.com/web-developer/hitgeistcom-migrated-from-erb-to-haml-and-compassblueprint/</link>
		<comments>http://rotanovs.com/web-developer/hitgeistcom-migrated-from-erb-to-haml-and-compassblueprint/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 23:11:28 +0000</pubDate>
		<dc:creator>viktors</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://rotanovs.com/?p=329</guid>
		<description><![CDATA[Hitgeist, a ranking service for finding recently popular sites in each country, received a minor upgrade &#8211; now it uses several new libraries to make development of new features easier, and code cleaner and nicer.
I built Hitgeist using Merb, a Ruby framework which brings fun back into web development. In fact, the fun is taken [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hitgeist.com/" title="Fastest Growing Websites">Hitgeist</a>, a ranking service for finding recently popular sites in each country, received a minor upgrade &#8211; now it uses several new libraries to make development of new features easier, and code cleaner and nicer.</p>
<p>I built Hitgeist using Merb, a Ruby framework which brings fun back into web development. In fact, the fun is taken by Symfony, which just <a href="http://www.symfonylab.com/symfony-2-again/">doesn&#8217;t feel elegant anymore</a>. Merb also has less magic than Ruby on Rails, and is a lot better architected. In fact RoR developers liked Merb so much <a href="http://yehudakatz.com/2009/06/11/rails-edge-architecture/">they started to unify both frameworks</a>.</p>
<p>So, what are the updates?</p>
<p><strong>First</strong>, I rewrote all templates from ERB to <a href="http://haml.hamptoncatlin.com/release-notes">HAML</a>. I should have done this before. Code becomes so much cleaner—tags are closed automatically, and visual clutter is reduced:</p>
<p><strong>ERB (before, 9 lines)</strong></p>
<pre style="margin:0"><code style="font-size:11px;">
&lt;div id="container">
  &lt;div id="sitemap">
    &lt;span class="letters">
      &lt;% ('A' .. 'Z').each do |letter| %>
        &lt;a href="/trends/&lt;%=letter%>">&lt;%=letter%>&lt;/a>
      &lt;% end %>
    &lt;/span>
  &lt;/div>
&lt;/div>
</code></pre>
<p style="margin-top:10px;">
<p><strong>HAML (after, 5 lines)</strong></p>
<pre style="margin:0"><code style="font-size:11px;">
#container
  #sitemap
    %span.letters
      - ('A' .. 'Z').each do |letter|
        %a{ :href => '/trends/' + letter }>= letter
</code></pre>
</p>
<p></p>
<p><strong>Second</strong>, I changed site structure to use grid system, a method to construct visually appealing page layouts using columns and rows which was used in newspapers for decades, but started getting its way to web only <a href="http://www.markboulton.co.uk/journal/comments/five_simple_steps_to_designing_grid_systems_part_1/">around 2005</a>. Usually grids are implemented using one of CSS frameworks, which mostly solve cross-browser and printing issues and add niceties such as vertical rhythm and beautiful typography.</p>
<p>There are several CSS frameworks available to implement grids, most famous ones being <a href="http://www.blueprintcss.org/">Blueprint</a> (which is used by sites like <a href="http://www.quantcast.com/">QuantCast</a>), <a href="http://960.gs/">960.gs</a>, and <a href="https://developer.yahoo.com/yui/grids/">Yahoo UI Grids</a>. There are also others, like this <a href="http://kilianvalkhof.com/2009/sencss/pixel-perfect-forms-sencss-06-released/" title="SenCSs">high-quality small CSS framework</a>.</p>
<p>I chose Blueprint because it&#8217;s complete and integrates nicely with <a href="http://wiki.github.com/chriseppstein/compass">Compass</a>, a CSS meta-framework for making CSS shorter, much like HAML does for ERB. It also allows to do computations, for example:</p>
<pre><code style="font-size:11px;">
.bright
  :font-color !main_color + #663300
</code></pre>
<p></p>
<p>Did these changes improve the website? Visit <a href="http://www.hitgeist.com/" title="Trendy websites around the world">new version</a>, and send your feedback.</p>
<p>PS: Do you know anything like HAML but for PHP?</p>
]]></content:encoded>
			<wfw:commentRss>http://rotanovs.com/web-developer/hitgeistcom-migrated-from-erb-to-haml-and-compassblueprint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby 1.9 is released</title>
		<link>http://rotanovs.com/web-developer/ruby-19-is-released/</link>
		<comments>http://rotanovs.com/web-developer/ruby-19-is-released/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 13:02:56 +0000</pubDate>
		<dc:creator>viktors</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://rotanovs.com/web-developer/ruby-19-is-released/</guid>
		<description><![CDATA[Ruby 1.9 release brings around 2x performance improvements, as well as enhanced syntax. Still experimental!]]></description>
			<content:encoded><![CDATA[<p>Great Christmas gift from matz and other contributors: <a href="http://www.ruby-forum.com/topic/136553">Ruby 1.9</a></p>
<p>Some highlights:</p>
<ul>
<li>Around 2x performance increase in many cases, thanks to YARV-based code</li>
<li>Nice syntax enhancements, like <code>(1..10).reduce(:+) # =&gt; 55</code></li>
<li>JavaScript-style literal hashes: {var: &#8220;value&#8221;}</li>
<li>Lots of <a href="http://eigenclass.org/hiki/Changes+in+Ruby+1.9">other enhancements</a></li>
</ul>
<p>Ruby 1.9 is a development release, and contains a lot of experimental features. For production, it&#8217;s recommended to continue using 1.8 branch.</p>
]]></content:encoded>
			<wfw:commentRss>http://rotanovs.com/web-developer/ruby-19-is-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery-style Chainability in PHP, Using SPL</title>
		<link>http://rotanovs.com/web-developer/jquery-chains-php-spl/</link>
		<comments>http://rotanovs.com/web-developer/jquery-chains-php-spl/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 01:18:54 +0000</pubDate>
		<dc:creator>viktors</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ArrayAccess]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[spl]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://localhost/web-developer/2007/10/29/jquery-style-chainability-in-php-using-spl/</guid>
		<description><![CDATA[Hacking jQuery-style chainable array operators into PHP, without modifying Zend core.]]></description>
			<content:encoded><![CDATA[<p>What could be better than chainable operators in jQuery, .addClass(&#8221;beautiful&#8221;).show(&#8221;slow&#8221;)-style? Almost nothing, but adding those to PHP would make code cleaner and life easier.</p>
<p>At first sight, implementing these looks almost impossible, but after a quick look at extensions we notice that <a href="http://www.php.net/~helly/php/ext/spl/">SPL</a> could offer something similar, if combined with <a href="http://es.php.net/manual/en/language.oop5.magic.php">magic methods</a>. Let&#8217;s implement ArrayAccess interface and see how it works:</p>
<pre line="1" lang="php">
$fruits = new Chain(array(
           new String('apple'),
           new String('mango'),
           new String('kiwi')
)); 

echo "First fruit: ";
echo $fruits[0];
echo "\n"; 

echo "All fruits: ";
echo $fruits->toUpperCase()->join();
echo "\n";</pre>
<p>Outputs:</p>
<pre>
First fruit: apple
All fruits: APPLE, MANGO, KIWI</pre>
<p>Beautiful, eh?</p>
<p>Here is a complete listing:</p>
<pre line="1" lang="php">

class Chain implements ArrayAccess {
    private $items = array(); 

    public function __construct($items = array()) {
      if (!is_array($items)) return;
      $this->items = $items;
    } 

    public function add($element) {
      $this->items[] = $element;
    } 

    public function __call($method, $args) {
      if (count($this->items)
            &#038;&#038; !method_exists($this->items[0], $method)) {
        throw new BadMethodCallException();
      } 

      $returnChain = new Chain();
      foreach($this->items as $item) {
        $returnChain->add(call_user_func_array(array($item, $method), $args));
      }
      return $returnChain;
    } 

    public function rewind() {
      reset($this->items);
    } 

    public function current() {
      return current($this->items);
    }
   public function key() {
      return key($this->items);
    } 

    public function next() {
      return next($this->items);
    } 

    public function valid() {
      return $this->current() !== false;
    } 

    public function offsetExists($offset) {
      return isset($this->items[$offset]);
    } 

    public function offsetGet($offset) {
      return $this->items[$offset];
    } 

    public function offsetSet($offset, $value) {
      return $this->items[$offset] = $value;
    } 

    public function offsetUnset($offset) {
      unset($this->items[$offset]);
    } 

    // convenience method
    public function join($separator = ', ') {
      return implode($this->items, $separator);
    }
} 

class String{
    private $s; 

    public function __construct($s) {
      $this->s = $s;
    } 

    public function toUpperCase() {
      $this->s = strtoupper($this->s);
      return $this;
    } 

    public function __toString() {
      return $this->s;
    } 

} 

$fruits = new Chain(array(
              new String('apple'),
              new String('mango'),
              new String('kiwi')
)); 

echo "First fruit: ";
echo $fruits[0];
echo "\n"; 

echo "All fruits: ";
echo $fruits->toUpperCase()->join();
echo "\n";</pre>
]]></content:encoded>
			<wfw:commentRss>http://rotanovs.com/web-developer/jquery-chains-php-spl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web 2.0</title>
		<link>http://rotanovs.com/web-developer/web-20/</link>
		<comments>http://rotanovs.com/web-developer/web-20/#comments</comments>
		<pubDate>Mon, 21 Mar 2005 00:20:24 +0000</pubDate>
		<dc:creator>viktors</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://idealab/uncategorized/2005/03/21/the-web-20/</guid>
		<description><![CDATA[Web 2.0 has finally went mainstream. Old technology vs new technology: links to 4 frameworks, passing cookies vs full-fledged Ajax requests.]]></description>
			<content:encoded><![CDATA[<p>Bored by making websites? Not anymore. Almost overnight <a href="http://www.google.com/webhp?complete=1&amp;hl=en">big</a> <a href="http://flickr.com/">boys</a> made 99% of the web obsolete. Less than 10 seconds page load time? 1 second? Forget about it. Everyone now wants INSTANT results.</p>
<p>Here are a few links for those who want to make their own Google Suggest, Gmail or Flickr:</p>
<ul>
<li><a href="http://www.modernmethod.com/sajax/">Sajax</a> &#8211; allows to call PHP functions from JavaScript</li>
<li><a href="http://jsolait.net/">JavaScript O Lait</a> &#8211; make XML-RPC and JSON-RPC (its own proprietary protocol) calls to server; some SVG examples too</li>
<li><a href="http://eireneh.thorubio.org/dwr/index.html">DWR</a> &#8211; Direct Web Remoting, for Java</li>
<li><a href="http://www.ashleyit.com/rs/jsrs/test.htm">JSRS</a> &#8211; JavaScript Remoting, with PHP and Perl samples</li>
</ul>
<p>Do you know other frameworks with similar functionality?</p>
]]></content:encoded>
			<wfw:commentRss>http://rotanovs.com/web-developer/web-20/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>HttpOnly in PHP (Anti-XSS)</title>
		<link>http://rotanovs.com/web-developer/httponly-php/</link>
		<comments>http://rotanovs.com/web-developer/httponly-php/#comments</comments>
		<pubDate>Sun, 05 Sep 2004 02:55:01 +0000</pubDate>
		<dc:creator>viktors</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://idealab/uncategorized/2004/09/05/httponly-in-php/</guid>
		<description><![CDATA[Patching PHP to prevent stealing of cookies by malicious JavaScripts.]]></description>
			<content:encoded><![CDATA[<p>Wondering how to prevent JavaScript from stealing session cookie? Major browsers got the answer: just add HttpOnly to cookie to protect it from malicious JavaScript code. Full details:</p>
<blockquote><p><a href="http://msdn.microsoft.com/workshop/author/dhtml/httponly_cookies.asp">http://msdn.microsoft.com/workshop/author/dhtml/httponly_cookies.asp</a></p></blockquote>
<p>Since this option is well-supported (AFAIK MSIE, Mozilla/Firefox/Gecko and Konqueror support it) it&#8217;s unclear why PHP doesn&#8217;t support it yet. Here&#8217;s a patch to add HttpOnly support to PHP:</p>
<blockquote><p><a href="http://rotanovs.com/php-session-httponly.patch">http://rotanovs.com/php-session-httponly.patch</a></p></blockquote>
<p>After applying the patch, add this string to your php.ini:</p>
<blockquote><p><code>session.cookie_httponly = 1</code></p></blockquote>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://rotanovs.com/web-developer/httponly-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
