Throttler Ramaze helper

After reading Rails Plugin: Throttler I created a Throttler Ramaze Helper .

  • What is it for? ”...The throttling plugin monitors the load of your server and allows you to disable certain features of your app when the load is too high...”
  • How to use it?
    • Copy throttler.rb to {ramaze_gem_dir}/lib/ramaze/helper/throttler.rb
    • In your controllers code:
class MainController < Ramaze::Controller
  helper :throttler

  def index
    # (optional): override the threshold when calling throttled?()
    # unless throttled?(10.00) ...
    unless throttled?
      "Hello World" 
    else
      "Overloaded: #{current_load}" 
    end
  end

protected
  # (optional) set another threshold value
  def threshold
    5.00
  end
end

Thanks a lot to Kashia from #ramaze for the help.

Later I start thinking “Hm, maybe that one is better to be Rack middleware ...”. Maybe next try…

Locale problems with Ubuntu-7.10 minimal install

  • Problem (after any package install i've got):
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
  • Solution:
$ sudo apt-get install language-pack-en

Second GIT origin

I made a mistake to clone from my GitHub Public Clone URL(git://github.com/zh/raplanet.git) . When trying to push the changes, there was a message:

fatal: The remote end hung up unexpectedly
error: failed to push to 'git://github.com/zh/raplanet.git'

So I added the second origin, the Push URL(git@github.com:zh/raplanet.git) and successfully pushed to it

$ git remote add origin2 git@github.com:zh/raplanet.git
$ git push origin2 master

Well done, no changes lost :)

Notes on MacWorld 2008

Last night I stayed from 2:00 to 4:00 o'clock, following the online coverage of MacWorld 2008 Conference and & Expo. Some thoughts:

  • In fact all sites following the presentation was not fully functional - connection errors, slow refresh. Live video streaming - couldn't find any. Maybe for the next conference some Comet based server, pushing updated to the connected clients can do the job. Hm, or can be used some form of P2P video streaming.
  • Time Capsule - so we need to replace the freedom to connect the other makers HDDs to the USB port of the AirMac with capsulated, produced be Apple HDDs. No, thanks.
  • iPhone SDK is coming in February. iPod Touch have already Mail, Maps, Notes, Stocks and Weather included. Maybe only that was interesting for me. Will probably buy an iPod Touch. Cause iPhone will never come to Japan. Google and Apple working together - bad boys(C) for life. Most of the mobiles in Japan have an Yahoo! Mail button. Will they add also a Gmail one ;)
  • Rental Movies. Worldwide Gyao Next. Tryed already with their devices. Not bad, depends on the contents. For me the interesting was not Apple TV, but the fact Apple convinced all big film makers to work with them. Scary :(
  • MacBook Air - the biggest disappointment. Just cannot figure where can I use it: 1. in home - then better use the usual MacBook; 2. in the train - Steve never traveled with Japanese train. You have just ONE FREE HAND. That's why everybody is using mobiles, not notebooks; 3. in Starbucks - are you kidding me! $3000 bucks notebook, near to my cup of coffee? No way. Think will wait for the $75 notebook.

Finnaly good tip for noise IRC channels (irssi):

/ignore -channels #noisy_spammers * JOINS PARTS QUITS NICKS

Merb on Joyent Accelerator (part 1)

The Accelerator including almost everything by default - Ruby, gems etc. Adding the Merb framework was without any problems. Some tips:

  • Pre-requirements:
$  sudo gem install mongrel json json_pure erubis mime-types rspec hpricot mocha \
                    rubigen haml markaby mailfactory Ruby2Ruby --no-rdoc --no-ri
  • Switching to merb trunk:
$ svn co http://svn.devjavu.com/merb/trunk merb
$ cd merb/
$ rake gem
$ sudo gem install pkg/merb-0.4.2.gem --no-rdoc --no-ri
  • Swithing to merb_helpers trunk (for better form helpers):
$ svn co http://svn.devjavu.com/merb/plugins/merb_helpers
$ cd merb_helpers/
$ rake gem
$ gem list
$ sudo gem install pkg/merb_helpers-0.4.1.gem --no-rdoc --no-ri

There was problems with the datamapper installation. The do_sqlite3 gem compilation was successful. For do_mysql gem one however I needed:

cd /opt/local/lib/ruby/gems/1.8/gems/do_mysql-0.2.2/ext/
make clean
ruby extconf.rb --with-mysql-include=/opt/local/include/mysql \
                --with-mysql-lib=/opt/local/lib/mysql
make
cd ../
rake gem
gem install pkg/do_mysql-0.2.2.gem \
    --no-rdoc --no-ri -- \
    --with-mysql-include=/opt/local/include/mysql \
    --with-mysql-lib=/opt/local/lib/mysql

My coworker Jeffrey Gelens was pretty excited about merb+datamapper combo. He even submitted some composite indexes patch to their repository.

Joyent Facebook Developer Accelerator


Got my own Joyent Facebook Developer Accelerator . Will try to put some Merb application on it. To read: