<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7130671258050667038</id><updated>2025-11-25T09:01:39.207+01:00</updated><category term="javascript"/><category term="ruby"/><category term="netvibes"/><category term="gem"/><category term="music"/><category term="tips"/><category term="uwa"/><category term="appjet"/><category term="rails"/><category term="blogger"/><category term="c"/><category term="codepress"/><category term="gedit"/><category term="greasemonkey"/><category term="heroku"/><category term="igoogle"/><category term="java"/><category term="jruby"/><category term="mac"/><category term="merb"/><category term="python"/><category term="sinatra"/><title type='text'>FaziBear</title><subtitle type='html'>Gloomy Programming Adventures</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default?alt=atom'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default?alt=atom&amp;start-index=26&amp;max-results=25'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-6349981801488070043</id><published>2009-11-23T16:45:00.000+01:00</published><updated>2009-11-23T16:45:38.303+01:00</updated><title type='text'>from rubyforge to github</title><content type='html'>Finally I moved my &lt;a href=&quot;http://rubyforge.org/&quot;&gt;rubyforge&lt;/a&gt; repositories to github and gems to &lt;a href=&quot;http://gemcutter.org/&quot;&gt;gemcutter.org&lt;/a&gt;:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://github.com/fazibear/gruby&quot;&gt;gruby&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://github.com/fazibear/colorize&quot;&gt;colorize&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&amp;nbsp;RDoc documentation is now on &lt;a href=&quot;http://rdoc.info/&quot;&gt;rdoc.info&lt;/a&gt;:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://rdoc.info/projects/fazibear/gruby&quot;&gt;gruby&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://rdoc.info/projects/fazibear/colorize&quot;&gt;colorize&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;It was quite easy. But there is necessary to use jeweler ? The only thing I need is gemspec file. Build and push are made by gem. There is any thiny tool that can manage version and gemspec files ?</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/6349981801488070043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/6349981801488070043?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/6349981801488070043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/6349981801488070043'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2009/11/from-rubyforge-to-github.html' title='from rubyforge to github'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-5299354634300204856</id><published>2009-11-13T11:46:00.002+01:00</published><updated>2009-11-13T11:49:56.292+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="heroku"/><category scheme="http://www.blogger.com/atom/ns#" term="music"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="sinatra"/><title type='text'>My Player 2.0</title><content type='html'>Do you remember &lt;a href=&quot;http://fazibear.blogspot.com/2008/02/my-music-player.html&quot;&gt;My Music Player&lt;/a&gt; ? I still hate myspace sites! Unfortunately AppJet hosting go down, but... &lt;a href=&quot;http://heroku.com/&quot;&gt;Heroku&lt;/a&gt; comes in. My Player 2.0 is new webapp, is completly writen in &lt;a href=&quot;http://www.ruby-lang.org/&quot;&gt;Ruby&lt;/a&gt; and &lt;a href=&quot;http://www.sinatrarb.com/&quot;&gt;Sinatra&lt;/a&gt; framework.&lt;br /&gt;
Once again ...&lt;br /&gt;
&lt;br /&gt;
Want use it ? &lt;br /&gt;
&lt;br /&gt;
Go for it &lt;a href=&quot;http://myplayer.heroku.com&quot;&gt;here&lt;/a&gt; or take a look at source code at &lt;a href=&quot;http://github.com/fazibear/myplayer&quot;&gt;github&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/5299354634300204856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/5299354634300204856?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/5299354634300204856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/5299354634300204856'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2009/11/my-player-20.html' title='My Player 2.0'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-7782766962883181528</id><published>2009-02-23T21:31:00.003+01:00</published><updated>2009-02-23T21:35:57.380+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="merb"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>What&#39;s wrong with merb ?</title><content type='html'>If you get this ...&lt;br /&gt;&lt;code&gt;FATAL: The gem data_objects (= 0.9.11, runtime), [] was not found&lt;/code&gt;&lt;br /&gt;... try this ...&lt;br /&gt;&lt;code&gt;sudo gem install launchy&lt;/code&gt;&lt;br /&gt;... and everything will be fine ...</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/7782766962883181528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/7782766962883181528?isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7782766962883181528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7782766962883181528'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2009/02/whats-wrong-with-merb.html' title='What&#39;s wrong with merb ?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-1845516713465330071</id><published>2008-12-08T16:11:00.018+01:00</published><updated>2008-12-08T17:48:16.081+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c"/><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Processing Mac Sudden Motion Sensor with RubyInline</title><content type='html'>&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;require &#39;rubygems&#39;&lt;br /&gt;require &quot;inline&quot;&lt;br /&gt;class SMS&lt;br /&gt;  class &lt;&lt; self&lt;br /&gt;    inline do |builder|&lt;br /&gt;      builder.add_compile_flags &#39;-x objective-c&#39;, &#39;-framework IOKit&#39;&lt;br /&gt;      builder.include &quot;&amp;lt;IOKit/IOKitLib.h&gt;&quot;    &lt;br /&gt;      builder.c %q{&lt;br /&gt;        VALUE values(){&lt;br /&gt;&lt;br /&gt;          struct data {&lt;br /&gt;            unsigned short x;&lt;br /&gt;            unsigned short y;&lt;br /&gt;            unsigned short z;&lt;br /&gt;            char pad[34];&lt;br /&gt;          };&lt;br /&gt;&lt;br /&gt;          kern_return_t result;&lt;br /&gt;&lt;br /&gt;          mach_port_t masterPort;&lt;br /&gt;          IOMasterPort(MACH_PORT_NULL, &amp;masterPort);&lt;br /&gt;          CFMutableDictionaryRef matchingDictionary = IOServiceMatching(&quot;SMCMotionSensor&quot;);&lt;br /&gt;          &lt;br /&gt;          io_iterator_t iterator;&lt;br /&gt;          result = IOServiceGetMatchingServices(masterPort, matchingDictionary, &amp;iterator);&lt;br /&gt;          &lt;br /&gt;          if(result != KERN_SUCCESS) {&lt;br /&gt;            return rb_str_new2(&quot;Error&quot;);&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          io_object_t device = IOIteratorNext(iterator);&lt;br /&gt;          IOObjectRelease(iterator);&lt;br /&gt;          if(device == 0){&lt;br /&gt;            return rb_str_new2(&quot;Error&quot;);&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          io_connect_t dataPort;&lt;br /&gt;          result = IOServiceOpen(device, mach_task_self(), 0, &amp;dataPort);&lt;br /&gt;          IOObjectRelease(device);&lt;br /&gt;&lt;br /&gt;          if(result != KERN_SUCCESS) {&lt;br /&gt;            return rb_str_new2(&quot;Error&quot;);&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          IOItemCount structureInputSize;&lt;br /&gt;          IOByteCount structureOutputSize;&lt;br /&gt;&lt;br /&gt;          struct data inputStructure;&lt;br /&gt;          struct data outputStructure;&lt;br /&gt;          structureInputSize = sizeof(struct data);&lt;br /&gt;          structureOutputSize = sizeof(struct data);&lt;br /&gt;&lt;br /&gt;          memset(&amp;inputStructure, 1, sizeof(inputStructure));&lt;br /&gt;          memset(&amp;outputStructure, 0, sizeof(outputStructure));&lt;br /&gt;&lt;br /&gt;          result = IOConnectMethodStructureIStructureO(&lt;br /&gt;            dataPort,&lt;br /&gt;            5,&lt;br /&gt;            structureInputSize,&lt;br /&gt;            &amp;structureOutputSize,&lt;br /&gt;            &amp;inputStructure,&lt;br /&gt;            &amp;outputStructure&lt;br /&gt;          );&lt;br /&gt;&lt;br /&gt;          if(result != KERN_SUCCESS) {&lt;br /&gt;            return rb_str_new2(&quot;Error&quot;);&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;          IOServiceClose(dataPort);&lt;br /&gt;&lt;br /&gt;          VALUE coords = rb_ary_new2(3);&lt;br /&gt;          rb_ary_store(coords, 0, INT2FIX(outputStructure.x));&lt;br /&gt;          rb_ary_store(coords, 1, INT2FIX(outputStructure.y));&lt;br /&gt;          rb_ary_store(coords, 2, INT2FIX(outputStructure.z));&lt;br /&gt;&lt;br /&gt;        return coords;&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;loop do&lt;br /&gt;  x,y,z = SMS.values&lt;br /&gt;  puts &quot;#{x} #{y} #{z}&quot;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/1845516713465330071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/1845516713465330071?isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/1845516713465330071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/1845516713465330071'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/12/process-mac-sudden-motion-sensor-with.html' title='Processing Mac Sudden Motion Sensor with RubyInline'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-7892942482557102959</id><published>2008-06-05T13:59:00.008+02:00</published><updated>2008-08-19T12:06:52.315+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rails"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Include helpers in controllers</title><content type='html'>Yes, i know!&lt;blockquote&gt;Helpers are modules that provide methods which are automatically usable in your view.&lt;/blockquote&gt;But somtimes you want to use it in controllers ;)&lt;br /&gt;This is my solution. Helpers are available in module named &#39;Helpers&#39;, so they don&#39;t brake anything. All rails helpers and named routes are included by default.&lt;br /&gt;This is simple usage:&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;class ExampleController &lt; ApplicationController&lt;br /&gt;  include_helper ApplicationHelper, PicturesHelper&lt;br /&gt;&lt;br /&gt;  def show&lt;br /&gt;   ...&lt;br /&gt;   flash[:notice] = Helpers::flash_with_picture(&#39;Hello from helper&#39;)&lt;br /&gt;   ...&lt;br /&gt;  end&lt;br /&gt;end&lt;/pre&gt;And method to add to ApplicationController class.&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;class ApplicationController &lt; ActionController::Base&lt;br /&gt;  def self.include_helper(*args)&lt;br /&gt;    require &#39;action_controller/integration&#39;&lt;br /&gt;    class_eval do&lt;br /&gt;      helpers = const_defined?(&#39;Helpers&#39;) ? const_get(&#39;Helpers&#39;) : Module.new do&lt;br /&gt;        @@controller = ActionController::Integration::Session.new&lt;br /&gt;        def self.method_missing(method, *args, &amp;block)&lt;br /&gt;          if @@controller &amp;&amp; method.to_s =~ /_path$|_url$/&lt;br /&gt;            @@controller.send(method, *args, &amp;block)&lt;br /&gt;          else&lt;br /&gt;            raise NoMethodError, &quot;undefined method `#{method}&#39; for #{self}&quot;&lt;br /&gt;          end&lt;br /&gt;        end&lt;br /&gt;      end&lt;br /&gt;      ActionView::Helpers.constants.each do |constant|&lt;br /&gt;        helpers.extend ActionView::Helpers.const_get(constant) if ActionView::Helpers.const_get(constant).instance_of?(Module)&lt;br /&gt;      end&lt;br /&gt;      if args.instance_of?(Array)&lt;br /&gt;        args.each do |helper|&lt;br /&gt;          helpers.extend helper if helper.instance_of?(Module)&lt;br /&gt;        end&lt;br /&gt;      elsif args.instance_of?(Module)&lt;br /&gt;        helpers.extend args&lt;br /&gt;      end&lt;br /&gt;      const_set( &#39;Helpers&#39;, helpers ) unless const_defined?(&#39;Helpers&#39;)&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/7892942482557102959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/7892942482557102959?isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7892942482557102959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7892942482557102959'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/06/include-helpers-in-controllers.html' title='Include helpers in controllers'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-6680910108466764178</id><published>2008-04-29T15:46:00.008+02:00</published><updated>2009-10-16T12:43:47.951+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gedit"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>GEdit With Multi Terminal</title><content type='html'>&lt;a href=&quot;http://www.gnome.org/projects/gedit/&quot;&gt;GEdit&lt;/a&gt; is nice developer editor for &lt;a href=&quot;http://www.gnome.org/&quot;&gt;GNOME&lt;/a&gt;. &lt;a href=&quot;http://macromates.com/&quot;&gt;Textmate&lt;/a&gt; like snippets, file browser and embedded terminal. Last one is a nice feature, but default plugin gives you only one terminal. But wait, plugins are written in python. This is my third attempt to modify python code... It was not so bad, after few print(), dir(), and id() I can add and remove terminal windows within gedit :) &lt;br /&gt;
&lt;br /&gt;
How to install ? Copy all files to ~/.gnome2/gedit/plugins, disable terminal plugin, restart gedit and enable mterminal plugin. &lt;br /&gt;
&lt;br /&gt;
How to use it ? To add new terminal right-click on terminal window and choose &#39;New Terminal&#39;. If you want to remove it, right-click and choose &#39;Remove Terminal&#39;. &lt;br /&gt;
&lt;br /&gt;
&lt;strike&gt;Plugin/Sources are located &lt;a href=&quot;http://fazibear.googlepages.com/mterminal.tar.gz&quot;&gt;here&lt;/a&gt;.&lt;/strike&gt;&lt;br /&gt;
&lt;br /&gt;
I hope you like it.&lt;br /&gt;
&lt;br /&gt;
This plugin is now on &lt;a href=&quot;http://github.com/fazibear/gedit-mterminal&quot;&gt;github&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/6680910108466764178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/6680910108466764178?isPopup=true' title='26 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/6680910108466764178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/6680910108466764178'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/04/gedit-with-multi-terminal.html' title='GEdit With Multi Terminal'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>26</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-7339934665909417029</id><published>2008-03-14T13:54:00.003+01:00</published><updated>2008-03-14T13:58:21.710+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="netvibes"/><category scheme="http://www.blogger.com/atom/ns#" term="uwa"/><title type='text'>UWA Google Suggest</title><content type='html'>Google Suggest is now UWA style widget. Check &lt;a href=&quot;http://eco.netvibes.com/widgets/110/google-suggest&quot;&gt;this&lt;/a&gt; out.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/7339934665909417029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/7339934665909417029?isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7339934665909417029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7339934665909417029'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/03/uwa-google-suggest.html' title='UWA Google Suggest'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-4729492050190209960</id><published>2008-03-07T14:52:00.005+01:00</published><updated>2008-06-11T16:47:16.035+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Id of nil object</title><content type='html'>&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;nil.id == 4 # =&gt; true&lt;br /&gt;&lt;/pre&gt;Sweet truth ;)</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/4729492050190209960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/4729492050190209960?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/4729492050190209960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/4729492050190209960'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/03/id-of-nil-object.html' title='Id of nil object'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-2065213326422686353</id><published>2008-02-29T12:24:00.009+01:00</published><updated>2008-03-10T12:12:58.589+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="tips"/><title type='text'>Generating Methods in Ruby</title><content type='html'>I was trying to find a way for generating dynamic methods.&lt;br /&gt;My first attempt was very ugly and use a simple eval:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;class DynamicMethods&lt;br /&gt;  %w{ one two three }.each do |z|&lt;br /&gt;    eval &quot;def #{z}(param) puts &#39;Hello from \\&#39;#{z}\\&#39; method with \\&#39;&#39;+param+&#39;\\&#39; param&#39; end&quot;&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Hmm... no... all this escape characters ... there must be a better way. And there is. Using %Q{} ... &lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;class DynamicMethods&lt;br /&gt;  %w{ one two three }.each do |z|&lt;br /&gt;    eval %Q{&lt;br /&gt;      def #{z}(param)&lt;br /&gt;        puts &quot;Hello form &#39;#{z}&#39; method with &#39;\#{param}&#39; param&quot;&lt;br /&gt;      end&lt;br /&gt;    }&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That&#39;s better ... more readable, but i don&#39;t have syntax highligt for this whole string. Lets try define_method ...&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;class DynamicMethods&lt;br /&gt;  %w{ one two three }.each do |z|&lt;br /&gt;    define_method z do |param|&lt;br /&gt;      puts &quot;Hello from &#39;#{z}&#39; method with &#39;#{param}&#39; param&quot;&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There it is. No eval, no big strings, just a method name and code block. Beautful. All examples give you same output.&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;DynamicMethods.new.one(&quot;hello&quot;) # =&gt; Hello from &#39;one&#39; method with &#39;hello&#39; param&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/2065213326422686353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/2065213326422686353?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2065213326422686353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2065213326422686353'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/02/generating-methods-in-ruby.html' title='Generating Methods in Ruby'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-4603274920723398843</id><published>2008-02-27T13:57:00.009+01:00</published><updated>2009-11-13T11:48:57.850+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="appjet"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="music"/><title type='text'>My Music Player</title><content type='html'>Another application written in javasctipt, using &lt;a href=&quot;http://appjet.com/&quot;&gt;AppJet&lt;/a&gt; solution. This one is simple application for browsing myspace music profiles and listen music. Big different is that you don&#39;t need to wait for whole ugly myspace page. Type band name, click search and press play on player :) Easy ? Take a look under player, there are similar artists. This might be helpful.&lt;br /&gt;
&lt;br /&gt;
&lt;strike&gt;Want use it ? Go for it &lt;a href=&quot;http://mymusic.appjet.net/&quot;&gt;here&lt;/a&gt; or take a look at &lt;a href=&quot;http://source.mymusic.appjet.net/&quot;&gt;source code&lt;/a&gt;&lt;/strike&gt;.&lt;br /&gt;
&lt;br /&gt;
AppJet is down, there is a new version &lt;a href=&quot;http://fazibear.blogspot.com/2009/11/my-player-20.html&quot;&gt;here&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/4603274920723398843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/4603274920723398843?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/4603274920723398843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/4603274920723398843'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/02/my-music-player.html' title='My Music Player'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-2319270288795430220</id><published>2008-02-18T21:18:00.003+01:00</published><updated>2008-02-27T14:11:39.926+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="netvibes"/><category scheme="http://www.blogger.com/atom/ns#" term="uwa"/><title type='text'>UWA Quick Translator</title><content type='html'>Quick translator is now available on UWA platform.&lt;br /&gt;Check it now &lt;a href=&quot;http://eco.netvibes.com/widgets/3709/quick-translator&quot;&gt;here&lt;/a&gt;. ;)</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/2319270288795430220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/2319270288795430220?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2319270288795430220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2319270288795430220'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/02/uwa-quick-translator.html' title='UWA Quick Translator'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-3919503350824810549</id><published>2008-02-18T19:31:00.004+01:00</published><updated>2008-02-18T21:17:56.569+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="netvibes"/><category scheme="http://www.blogger.com/atom/ns#" term="uwa"/><title type='text'>UWA Netvibes Customize</title><content type='html'>Netvibes Cutomize widget is now available in UWA api. It works only in Netvibes environment, using it in any other just makes no sense ;)&lt;br /&gt;If you find any bugs write about it on Netvibes Developers Forum in &lt;a href=&quot;http://dev.netvibes.com/forum/viewtopic.php?id=770&quot;&gt;this&lt;/a&gt; thread.&lt;br /&gt;I hope you like it.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/3919503350824810549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/3919503350824810549?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/3919503350824810549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/3919503350824810549'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/02/uwa-netvibes-customize.html' title='UWA Netvibes Customize'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-945904063204738538</id><published>2008-02-10T16:28:00.003+01:00</published><updated>2008-02-27T14:13:25.229+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="appjet"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="music"/><title type='text'>Metal Releases ICalendar v2</title><content type='html'>Here is new version of icalendar feed. This version is written in javascript. Now is hosted by &lt;a href=&quot;http://appjet.com/&quot;&gt;AppJet&lt;/a&gt;.&lt;br /&gt;&lt;blockquote&gt;AppJet is the easiest way to create a web app. Just type some code into a box, and we&#39;ll host your app on our servers.&lt;/blockquote&gt;&lt;br /&gt;Feed is available &lt;a href=&quot;http://metalstorm-releases.appjet.net/calendar.ics&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;You should also check out sample &lt;a href=&quot;http://metalstorm-releases.appjet.net/&quot;&gt;calendar&lt;/a&gt; and &lt;a href=&quot;http://source.metalstorm-releases.appjet.net/&quot;&gt;source code&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/945904063204738538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/945904063204738538?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/945904063204738538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/945904063204738538'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/02/metal-releases-icalendar-2.html' title='Metal Releases ICalendar v2'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-67065455494977005</id><published>2008-01-14T12:16:00.000+01:00</published><updated>2008-02-12T18:58:00.785+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="jruby"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Echo2 with JRuby</title><content type='html'>I want to play with jruby, and I rewrite a numberguess example application from &lt;a href=&quot;http://echo.nextapp.com/site/echo2&quot;&gt;Echo2&lt;/a&gt; framework into Ruby using JRuby.&lt;br /&gt;Let&#39;s see...&lt;br /&gt;First we need to rewrite a NumberGuessServlet to load a NumberGuessApp ruby class instead of java class.&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;&lt;br /&gt;public class NumberGuessServlet extends WebContainerServlet {&lt;br /&gt;&lt;br /&gt;    Ruby runtime = Ruby.getDefaultInstance();&lt;br /&gt;&lt;br /&gt;    public NumberGuessServlet() {&lt;br /&gt;      super();&lt;br /&gt;&lt;br /&gt;      StringBuffer script = new StringBuffer();&lt;br /&gt;      URL url = NumberGuessServlet.class.getResource(&quot;NumberGuessApp.rb&quot;);&lt;br /&gt;      URI uri;&lt;br /&gt;&lt;br /&gt;      try {&lt;br /&gt;        uri = new URI(url.getFile());&lt;br /&gt;        File file = new File(uri.getPath());&lt;br /&gt;&lt;br /&gt;        BufferedReader fin = new BufferedReader(new FileReader(file));&lt;br /&gt;        String line = null;&lt;br /&gt;&lt;br /&gt;        while ((line = fin.readLine()) != null) {&lt;br /&gt;          script.append(line+&quot;\n&quot;);&lt;br /&gt;        }&lt;br /&gt;        fin.close();&lt;br /&gt;&lt;br /&gt;      } catch (URISyntaxException e) {&lt;br /&gt;          e.printStackTrace();&lt;br /&gt;      } catch (ArrayIndexOutOfBoundsException e){&lt;br /&gt;          e.printStackTrace();&lt;br /&gt;      } catch (IOException e){&lt;br /&gt;          e.printStackTrace();&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      try {&lt;br /&gt;        runtime.evalScript(script.toString());&lt;br /&gt;      } catch (Exception e) {&lt;br /&gt;        e.printStackTrace();&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * @see nextapp.echo2.webcontainer.WebContainerServlet#newApplicationInstance()&lt;br /&gt;     */&lt;br /&gt;    public ApplicationInstance newApplicationInstance() {&lt;br /&gt;&lt;br /&gt;      Object numberGuessApp = runtime.evalScript(&quot;NumberGuessApp.new&quot;);&lt;br /&gt;      numberGuessApp = org.jruby.javasupport.JavaEmbedUtils.rubyToJava(runtime,&lt;br /&gt;                (org.jruby.runtime.builtin.IRubyObject) numberGuessApp, ApplicationInstance.class);&lt;br /&gt;&lt;br /&gt;      return (ApplicationInstance) numberGuessApp;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Now we have to write a ruby class.&lt;br /&gt;Create a NumberGuessApp.rb and include a Java magic&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;include Java&lt;br /&gt;&lt;/pre&gt;This make all Java stuff avaiable in ruby.&lt;br /&gt;Next we need to include Echo2 stuff.&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;module Echo2&lt;br /&gt;  include_class &#39;nextapp.echo2.app.ApplicationInstance&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.Button&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.Color&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.ContentPane&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.Extent&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.Insets&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.Label&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.ResourceImageReference&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.Column&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.TextField&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.Window&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.event.ActionEvent&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.event.ActionListener&#39;&lt;br /&gt;  include_class &#39;nextapp.echo2.app.layout.ColumnLayoutData&#39;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;This makes all Echo2 lib namespaced. Don&#39;t forget to prefix Echo2 classes with Echo2::.&lt;br /&gt;Next big thing is casts. We can&#39;t make a cast in ruby. But we can make something like this.&lt;br /&gt;We need a NumberGuessApp instance, lets make a simple method that return it:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;class NumberGuessApp &lt; Echo2::ApplicationInstance&lt;br /&gt;  def self.instance&lt;br /&gt;    @@instance&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def init&lt;br /&gt;    @@instance = self&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;now instead of this:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;&lt;br /&gt;((NumberGuessApp) ApplicationInstance.getActive())&lt;br /&gt;&lt;/pre&gt;we can write:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;NumberGuessApp.instance&lt;br /&gt;&lt;/pre&gt;getActive() method propably do something more, but this is enough for this app.&lt;br /&gt;Nice feature of JRuby is that we can change all method and variables names to fit ruby style, don&#39;t need to use any setters and getters.&lt;br /&gt;For example you can write:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;@window.title = &quot;Echo2 Guess-A-Number&quot;&lt;br /&gt;layout_column.cell_spacing = Echo2::Extent.new(10)&lt;br /&gt;submit_button.add_action_listener(self)&lt;br /&gt;&lt;/pre&gt;But there is one problem. All methods that overrides included interfaces need to have a java names:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;def actionPerformed(event)&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;Take a look at CongratulationsPane. Constructor have an argument, but it&#39;s don&#39;t want to work with jruby. We have to delete it. There will be no information about number of tries on congratulation screen. Sorry :)&lt;br /&gt;All variables are initialized in constructor (initialize method). For example:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;  def initialize&lt;br /&gt;&lt;br /&gt;    #&lt;br /&gt;    # Randomly generated number between 1 and 100 inclusive.&lt;br /&gt;    #&lt;br /&gt;    @random_number = rand 100&lt;br /&gt;  end&lt;br /&gt;&lt;/pre&gt;Static variables like colors should looks like this:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;@guess_entry_field.foreground = Echo2::Color::WHITE&lt;br /&gt;&lt;/pre&gt;All source files are &lt;a href=&quot;http://fazibear.googlepages.com/echo2_numberguess.tar.gz&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;If you want to run it download all required jar files and copy it to lib.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://repo1.maven.org/maven2/org/jruby/jruby-complete/1.0.3/jruby-complete-1.0.3.jar&quot;&gt;JRuby 1.0.3&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://mirrors.ibiblio.org/pub/mirrors/maven2/servletapi/servlet-api/2.4/servlet-api-2.4.jar&quot;&gt;Servlet Api 2.4&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Echo2_App.jar&lt;/li&gt;&lt;li&gt;Echo2_WebContainer.jar&lt;/li&gt;&lt;li&gt;Echo2_WebRender.jar&lt;/li&gt;&lt;/ul&gt;Echo2 files are from &lt;a href=&quot;http://download.nextapp.com/downloads/echo2/2.0.0/NextApp_Echo2.tgz&quot;&gt;echo2&lt;/a&gt; package.&lt;br /&gt;Start ant.&lt;br /&gt;Copy a war file into your application server and launch it.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/67065455494977005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/67065455494977005?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/67065455494977005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/67065455494977005'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/01/echo2-with-jruby.html' title='Echo2 with JRuby'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-2398465927315884411</id><published>2008-01-03T16:40:00.002+01:00</published><updated>2008-03-07T15:02:52.926+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codepress"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="rails"/><title type='text'>CodePress Addons</title><content type='html'>I was playing around with CodePress. There are some modification I made:&lt;br /&gt;This one updates all textareas fields when form is submited, and fix the problem with rails javascript tag hepler.&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;javascript&quot;&gt;&lt;br /&gt;CodePress.run = function() {&lt;br /&gt;  s = document.getElementsByTagName(&#39;script&#39;);&lt;br /&gt;  for(var i=0,n=s.length;i&lt;n;i++) {&lt;br /&gt;    if(s[i].src.match(&#39;codepress.js&#39;)) {&lt;br /&gt;      CodePress.path = s[i].src.replace(/codepress.js.*$/,&#39;&#39;);&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  t = document.getElementsByTagName(&#39;textarea&#39;);&lt;br /&gt;  for(var i=0,n=t.length;i&lt;n;i++) {&lt;br /&gt;    if(t[i].className.match(&#39;codepress&#39;)) {&lt;br /&gt;      id = t[i].id;&lt;br /&gt;      t[i].id = id+&#39;_cp&#39;;&lt;br /&gt;      eval(id+&#39; = new CodePress(t[i])&#39;);&lt;br /&gt;      t[i].parentNode.insertBefore(eval(id), t[i]);&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  f = document.getElementsByTagName(&#39;form&#39;);&lt;br /&gt;  for(var i=0,n=f.length;i&lt;n;i++) {&lt;br /&gt;    cps = f[i].getElementsByClassName(&#39;codepress&#39;);&lt;br /&gt;    if(cps.length &gt; 0){&lt;br /&gt;      f[i].cps = cps;&lt;br /&gt;      f[i].onsubmit = function(){&lt;br /&gt;        for(var i=0;i&lt;this.cps.length;i++){&lt;br /&gt;          this.cps[i].value = eval(this.cps[i].id.replace(&#39;_cp&#39;,&#39;&#39;)+&#39;.getCode()&#39;);&lt;br /&gt;          this.cps[i].disabled = false;&lt;br /&gt;        };&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I also update a little syntax highlight for Ruby language:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;javascript&quot;&gt;&lt;br /&gt;/*&lt;br /&gt;* CodePress regular expressions for Ruby syntax highlighting&lt;br /&gt;*/&lt;br /&gt;// Ruby&lt;br /&gt;Language.syntax = [&lt;br /&gt;  { input : /\&quot;(.*?)(\&quot;|&lt;br&gt;|&lt;\/P&gt;)/g, output : &#39;&lt;s&gt;&quot;$1$2&lt;/s&gt;&#39; }, // strings double quote&lt;br /&gt;  { input : /\&#39;(.*?)(\&#39;|&lt;br&gt;|&lt;\/P&gt;)/g, output : &#39;&lt;s&gt;\&#39;$1$2&lt;/s&gt;&#39; }, // strings single quote&lt;br /&gt;  { input : /([\$\@\%]+)([\w\.]*)/g, output : &#39;&lt;a&gt;$1$2&lt;/a&gt;&#39; }, // vars&lt;br /&gt;  { input : /\|(.*?)(\||&lt;br&gt;|&lt;\/P&gt;)/g, output : &#39;|&lt;a&gt;$1&lt;/a&gt;$2&#39; }, // block vars&lt;br /&gt;  { input : /(def\s+)([\w\.]*)/g, output : &#39;$1&lt;em&gt;$2&lt;/em&gt;&#39; }, // functions&lt;br /&gt;  { input : /\b(alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\b/g, output : &#39;&lt;b&gt;$1&lt;/b&gt;&#39; }, // reserved words&lt;br /&gt;  { input  : /([\(\){}])/g, output : &#39;&lt;u&gt;$1&lt;/u&gt;&#39; }, // special chars&lt;br /&gt;  { input  : /#(.*?)(&lt;br&gt;|&lt;\/P&gt;)/g, output : &#39;&lt;i&gt;#$1&lt;/i&gt;$2&#39; }, // comments&lt;br /&gt;  { input  : /#(.*?)(&lt;br&gt;|&lt;\/P&gt;)/g, output : &#39;&lt;i&gt;#$1&lt;/i&gt;$2&#39; }, // comments&lt;br /&gt;  { input  : /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/g, output : &#39;&lt;big&gt;$1&lt;/big&gt;&#39; } // buildins&lt;br /&gt;];&lt;br /&gt;Language.snippets = []&lt;br /&gt;Language.complete = [&lt;br /&gt;  { input : &#39;\&#39;&#39;,output : &#39;\&#39;$0\&#39;&#39; },&lt;br /&gt;  { input : &#39;&quot;&#39;, output : &#39;&quot;$0&quot;&#39; },&lt;br /&gt;  { input : &#39;(&#39;, output : &#39;\($0\)&#39; },&lt;br /&gt;  { input : &#39;[&#39;, output : &#39;\[$0\]&#39; },&lt;br /&gt;  { input : &#39;{&#39;, output : &#39;{$0}&#39; }    &lt;br /&gt;]&lt;br /&gt;Language.shortcuts = [] &lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/2398465927315884411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/2398465927315884411?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2398465927315884411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2398465927315884411'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2008/01/codepress-addons.html' title='CodePress Addons'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-3420506188976913199</id><published>2007-09-17T15:43:00.000+02:00</published><updated>2007-09-20T14:28:06.468+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Ivo Reader</title><content type='html'>This is a ruby rewrite of ivonka.sh script. This simple script read data from standard input or command line parameters using &lt;a href=&quot;http://say.expressivo.com/&quot;&gt;say.expressivo.com&lt;/a&gt; text to speech reader.&lt;br /&gt;&lt;br /&gt;Features:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;english language (default)&lt;/li&gt;&lt;li&gt;male and female polish voice&lt;/li&gt;&lt;li&gt;romanian language&lt;/li&gt;&lt;li&gt;files are player directly from internet&lt;/li&gt;&lt;li&gt;mplayer as default player&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Script can be downloaded from &lt;a href=&quot;http://fazibear.googlepages.com/ivo.rb&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Simple usage:&lt;br /&gt;&lt;code&gt;# ivo.rb &quot;This is simple text&quot;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;# echo &quot;simple text&quot; | ivo.rb&lt;/code&gt;&lt;br /&gt;&lt;code&gt;# cat somefile.txt | ivo.rb&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Configuration:&lt;br /&gt;DEFAULT_LANGUAGE - default language&lt;br /&gt;PLAYER - filename of mp3 player.&lt;br /&gt;SLEEP - time between http requests in seconds (something about 0.5s)&lt;br /&gt;SLEEP_ON_FAIL - time after failed http request (it should be something about 1s)&lt;br /&gt;MAX_TEXT_LENGTH - lenght that can be converted at one request (for now in 200)&lt;br /&gt;&lt;br /&gt;To change reader language, pass a language symbol as parameter while creating ivo object.&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;ivo = Ivo.new :PL #for polish&lt;br /&gt;ivo = Ivo.new :PLM #for polish male voice&lt;br /&gt;ivo = Ivo.new :PLF #for polish female voice&lt;br /&gt;ivo = Ivo.new :RO #for romanian&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/3420506188976913199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/3420506188976913199?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/3420506188976913199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/3420506188976913199'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/09/ivo-reader.html' title='Ivo Reader'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-2409369301449038744</id><published>2007-09-03T15:42:00.000+02:00</published><updated>2008-01-22T20:01:54.038+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="blogger"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>Blogger Syntax Highlighter</title><content type='html'>My syntax highligter widget for blogger is avaiable. It&#39;s based on &lt;a href=&quot;http://code.google.com/p/syntaxhighlighter/&quot;&gt;SyntaxHighlighter&lt;/a&gt; 1.5.1.&lt;br /&gt;Package include all compressed code and brushes, works in blogger mode. This script also handle older/newer posts links.&lt;br /&gt;To add it check out &lt;a href=&quot;http://fazibear.googlepages.com/blogger.html&quot;&gt;this&lt;/a&gt; page.&lt;br /&gt;For usage information visit &lt;a href=&quot;http://code.google.com/p/syntaxhighlighter/wiki/Usage&quot;&gt;this&lt;/a&gt; wiki page.&lt;br /&gt;&lt;br /&gt;Update:&lt;br /&gt;All _WidgetManager magic was removed. It&#39;s simply don&#39;t work for now. Next and previous post don&#39;t use XHR. If you have any javascript errors with _WidgetManager remove this widget and add once again.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/2409369301449038744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/2409369301449038744?isPopup=true' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2409369301449038744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/2409369301449038744'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/09/blogger-syntax-higlighter.html' title='Blogger Syntax Highlighter'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-9067372029385630066</id><published>2007-08-11T13:45:00.001+02:00</published><updated>2008-04-11T11:10:50.083+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gem"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Ruby Projects Updates</title><content type='html'>&lt;span style=&quot;font-weight: bold;&quot;&gt;GRuby&lt;/span&gt; 0.2.1&lt;br /&gt;&lt;ul&gt;&lt;li&gt;added gruby.rb file&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;colorize&lt;/span&gt; 0.5.6&lt;br /&gt;&lt;ul&gt;&lt;li&gt;added effects methods&lt;/li&gt;&lt;li&gt;new readme files&lt;/li&gt;&lt;li&gt;new rake file&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/9067372029385630066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/9067372029385630066?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/9067372029385630066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/9067372029385630066'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/08/ruby-projects-updates.html' title='Ruby Projects Updates'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-3273716308860665064</id><published>2007-08-05T17:23:00.001+02:00</published><updated>2008-04-11T11:10:14.169+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gem"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>GRuby 0.2.0</title><content type='html'>New version of gruby gem uploaded to &lt;a href=&quot;http://rubyforge.org/projects/gruby/&quot;&gt;rubyforge&lt;/a&gt; repository.&lt;br /&gt;Changes:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;uri-open instead of socket in connection_params method&lt;/li&gt;&lt;li&gt;few callback added&lt;/li&gt;&lt;li&gt;readme files&lt;/li&gt;&lt;li&gt;new rake file&lt;/li&gt;&lt;/ul&gt;Documentation is avaiable &lt;a href=&quot;http://gruby.rubyforge.org/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;As always you can install it with:&lt;br /&gt;&lt;code&gt;# gem install GRuby&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/3273716308860665064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/3273716308860665064?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/3273716308860665064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/3273716308860665064'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/08/gruby-020.html' title='GRuby 0.2.0'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-5713561268220029795</id><published>2007-08-03T21:11:00.000+02:00</published><updated>2007-08-06T15:41:10.660+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="igoogle"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>iGoogle Customize</title><content type='html'>I just made an iGoogle module. Now you can make some customization of your page. Add it &lt;a href=&quot;http://www.google.com/ig/adde?moduleurl=http%3A%2F%2Fhosting.gmodules.com%2Fig%2Fgadgets%2Ffile%2F112690233521707929957%2Figc.xml&quot;&gt;here&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/5713561268220029795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/5713561268220029795?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/5713561268220029795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/5713561268220029795'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/08/igoogle-customize.html' title='iGoogle Customize'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-4916709099842835357</id><published>2007-06-18T17:50:00.001+02:00</published><updated>2007-08-04T14:56:28.113+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="netvibes"/><title type='text'>Netvibes Modules Are Unavaiable</title><content type='html'>Sorry, all my netvibes modules are temporarily unavailable because traffic limits per month:&lt;br /&gt;&lt;blockquote&gt;Total Available Traffic: 4096 MB (4294967296 Bytes)&lt;br /&gt;Total Used Traffic:  4125 MB (4325182876 Bytes)&lt;br /&gt;&lt;/blockquote&gt;They will return next month, or maybe earlier if I find new hosting.&lt;br /&gt;Be patient, Sorry.&lt;br /&gt;&lt;strike&gt;Right now all modules are moved here: http://fazibear.ifastnet.com/netvibes/*.xhtml example: &lt;a href=&quot;http://fazibear.ifastnet.com/netvibes/customize.xhtml&quot;&gt;http://fazibear.ifastnet.com/netvibes/customize.xhtml&lt;/a&gt;&lt;/strike&gt;&lt;br /&gt;All modules are moved here: &lt;a href=&quot;http://netvibes.atspace.com/&quot;&gt;http://netvibes.atspace.com&lt;/a&gt; example: &lt;a href=&quot;http://netvibes.atspace.com/customize.html&quot;&gt;http://netvibes.atspace.com/customize.html&lt;/a&gt;&lt;br /&gt;This hosting should be better, they offer&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Free UNLIMITED Traffic&lt;br /&gt;&lt;/li&gt;&lt;li&gt;99.8% Uptime Guarantee&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Ultra Fast Network&lt;/li&gt;&lt;/ul&gt;we will see ...</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/4916709099842835357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/4916709099842835357?isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/4916709099842835357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/4916709099842835357'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/06/netvibes-modules-are-unavaiable.html' title='Netvibes Modules Are Unavaiable'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-1338828589764758752</id><published>2007-06-13T08:57:00.000+02:00</published><updated>2007-09-03T15:56:55.460+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="netvibes"/><title type='text'>Netvibes Quick Translator Fixed</title><content type='html'>Quick Translator widget fixed. Now just works ;)</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/1338828589764758752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/1338828589764758752?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/1338828589764758752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/1338828589764758752'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/06/netvibes-quick-translator-fixed.html' title='Netvibes Quick Translator Fixed'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-6069210981495859292</id><published>2007-05-31T01:20:00.001+02:00</published><updated>2008-02-29T12:23:04.959+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="tips"/><title type='text'>Clear Terminal Window with Ruby</title><content type='html'>Clean and simple :)&lt;br /&gt;Works only on *nix systems&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;CLEAR = `clear`&lt;br /&gt;print CLEAR&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/6069210981495859292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/6069210981495859292?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/6069210981495859292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/6069210981495859292'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/05/clear-terminal-window-with-ruby.html' title='Clear Terminal Window with Ruby'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-741713553497688406</id><published>2007-05-09T19:18:00.001+02:00</published><updated>2008-02-29T12:22:27.499+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="tips"/><title type='text'>File.modify!</title><content type='html'>Here is a little ruby File class method called modify!. This simple method allows you to invoke a block on file content - array of chomped lines.&lt;br /&gt;This beautiful method looks like this ;)&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;class File&lt;br /&gt;  def self.modify!( filename, &amp;block )&lt;br /&gt;    file = open( filename, &#39;r+&#39; )&lt;br /&gt;    lines = file.readlines.collect! do |line|&lt;br /&gt;      line.chomp&lt;br /&gt;    end&lt;br /&gt;    yield lines&lt;br /&gt;    file.pos = 0&lt;br /&gt;    file.print(lines.join(&quot;\n&quot;))&lt;br /&gt;    file.truncate(file.pos)&lt;br /&gt;    file.close&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and it can be use it like this:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;&lt;br /&gt;File.modify!(&#39;somefile.txt&#39;) do |lines|&lt;br /&gt;  lines.collect! do |line|&lt;br /&gt;    line.upcase+&quot;!&quot;&lt;br /&gt;  end&lt;br /&gt;  lines &lt;&lt; &quot;new line&quot;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;For now it&#39;s too small to make a gem. But maybe I&#39;ll add some similar object methods, who knows ;)</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/741713553497688406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/741713553497688406?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/741713553497688406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/741713553497688406'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/05/filemodify.html' title='File.modify!'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7130671258050667038.post-7172781831818423439</id><published>2007-04-22T12:58:00.001+02:00</published><updated>2008-04-11T11:09:20.114+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gem"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Ruby Colorized Console</title><content type='html'>I wrote a simple ruby string class extension to displays console colors easier using ANSI escape sequences.&lt;br /&gt;Links for &lt;a href=&quot;http://rubyforge.org/projects/colorize/&quot;&gt;project page&lt;/a&gt;, and &lt;a href=&quot;http://colorize.rubyforge.org/&quot;&gt;documentation page&lt;/a&gt;.&lt;br /&gt;Install:&lt;br /&gt;&lt;code&gt;# gem install colorize&lt;/code&gt;&lt;br /&gt;Some examples:&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;ruby&quot;&gt;puts &quot;This is blue&quot;.colorize( :blue )&lt;br /&gt;puts &quot;This is light blue&quot;.colorize( :light_blue )&lt;br /&gt;puts &quot;This is also blue&quot;.colorize( :color =&gt; :blue )&lt;br /&gt;puts &quot;This is blue with red background&quot;.colorize( :color =&gt; :light_blue, :background =&gt; :red )&lt;br /&gt;puts &quot;This is blue with red background&quot;.colorize( :light_blue ).colorize( :background =&gt; :red )&lt;br /&gt;puts &quot;This is blue text on red&quot;.blue.on_red&lt;br /&gt;puts &quot;This is red on blue&quot;.colorize( :red ).on_blue&lt;br /&gt;puts &quot;This is uncolorized&quot;.blue.on_red.uncolorize&lt;br /&gt;&lt;/pre&gt;This thing should work in Windows too, but its untested. So if you check it out, please give me some feedback.</content><link rel='replies' type='application/atom+xml' href='http://fazibear.blogspot.com/feeds/7172781831818423439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7130671258050667038/7172781831818423439?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7172781831818423439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7130671258050667038/posts/default/7172781831818423439'/><link rel='alternate' type='text/html' href='http://fazibear.blogspot.com/2007/04/ruby-colorized-console.html' title='Ruby Colorized Console'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>