– we create awesome web applications

The Rails 4 Way on Leanpub.com

We are proud to announce that our own Vitaly Kushner co-authored the new edition of 'The Rails 4 Way' together with Rails legend Obie Fernandes of Hashrocket fame.

'The Rails 4 Way' is the latest edition of the most comprehensive, authoritative guide to delivering production-quality code with Rails 4.

Pow is great. The single thing that bothered me was problems with using debugger while pow'ing away.

Did you ever put a debugger into your controller, connected with rdebug, hit refresh but it didn't stop?

The problem is most probably with POW_WORKERS setting. You see, by default, pow will start 2 ruby processes per application.

Since direct console access is not available when using pow, you have to use rdebug instead. Usually it means something like this added to config/environments/development.rb:

# to use ruby debug with Pow do the following:
# echo export RUBY_DEBUG_PORT=20000 >> ./.powenv
#
# to connect:
# rdebug -c -p PORT_NUMBER
if ENV['RUBY_DEBUG_PORT']
  Debugger.start_remote nil, ENV['RUBY_DEBUG_PORT'].to_i
end

Then you can restart your pow application and run the following command line:

rdebug -c -p 20000

Once you get "Connected." back you know that your rdebug has connected to some ruby process and is awaiting breakpoint hit.

The problem is that pow by default starts 2 ruby processes per application, and so only one of them will be able to bind to the port 20000. Which in turn means that only requests being processed by this process will get a chance to be stopped in debugger. So on average only about 50% of your requests will hit the debugger.

The solution is fairly simple. Just add the following line to your ~/.powconfig file:

export POW_WORKERS=1

Then restart pow.

Note: I mean the whole pow server, not just your current application. I'm using the excellent powify gem for this:

gem install powify
powify server restart

From now on you will get only one pow process per application and never miss a breakpoint again.

About half a year ago Vitaly posted a post about how simple it is today to use ruby patches bundled with rvm installation to dramatically reduce big rails app loading times and make your dev environment a much happier place.

Since then Ruby advanced with new patchlevels and there are new patches to use, so let's go over this once again.

First, we start with upgrading the rvm to latest and hopefully greatest

rvm get head

Since Vitaly wrote his post it seems that the railsexpress patch superseded the falcon one. At least that what i got from browsing over the patches repository.

So, next step is to compile our Ruby version with railsexpress patchset applied

rvm install 1.9.3-p392-railsexpress --patch railsexpress

Ok, now for some trivial benchmarking to ensure we made things better and not the other way around. Now, note that the say in the interwebs goes that the bigger your application and amount of gems it has to load the more happy you will be. Also, the usual disclaimer about those performance things, YMMV.

I took a random application from my dev folder. It loads 147 gems. Let's check out some numbers

✗ rvm use 1.9.3
Using /usr/local/rvm/gems/ruby-1.9.3-p392
✗ time rails runner "puts :OK"
OK
rails runner "puts :OK"  16.28s user 1.70s system 98% cpu 18.185 total

✗ rvm use 1.9.3-p392-railsexpress
Using /usr/local/rvm/gems/ruby-1.9.3-p392-railsexpress
✗ time rails runner "puts :OK"
OK
rails runner "puts :OK"  8.56s user 1.22s system 99% cpu 9.820 total

Just to make a comparison to the previous blog post, here are the numbers for the same application with ruby 1.9.3-p327 with falcon patches set:

✗ rvm use 1.9.3-p327-falcon
Using /usr/local/rvm/gems/ruby-1.9.3-p327-falcon
✗ time rails runner "puts :OK"
rails runner "puts :OK"  9.89s user 1.34s system 98% cpu 11.374 total

So, comparing to falcon patches it's not that big of an improvement, but still, another 1.5 seconds win.

And yes, i know that both before and after times are slow. But still, i see a nice around 50% time save on any environment loading. And what i really like is that this improvement demanded the whole 7 minutes of my time.

Back in February we sponsored a great technical event - Reversim Summit 2013

Now the organizers uploaded videos from all talks to youtube, so go check out a lots of quality technical content

My personal favorite - How To Fuckup, by Yosi Taguri

I was frustrated by ⌘Q and ⌘W proximity for a long time. Long, long time. Seriously, long time.

It hits me the most with browsers since I usually open and close quite a lot of tabs during the day. And I tend to do it from keyboard, so sometimes I just hit ⌘Q when I only intended ⌘W.

It just happened again.

But this time I suddenly realized that I can easily remap it. I was using this OSX feature for other things, like remapping useless since the typewriter days Caps Lock key, but somehow missed that I can fix this annoying problem too.

If not universally then at least in Chrome (or any other application if needed).

This is really easy:

  1. go to System PreferencesKeyboardKeyboard Shortcuts and choose Application Shortcuts in the left panel.

    Keyboard Shortcuts

  2. click on the + icon to add another shortcut.

  3. Choose Google Chrome as the application and type in exactly, including case Quit Google Chrome as Menu Title. Generally, it should be the exact menu command name in the application that you want to map.

  4. Now, click inside the Keyboard Shortcut field and then press on you keyboard whatever the new shortcut you want. I chose ⌥⇧Q so that it will stay at the same place but wont be as accidentally press-able.

Quit Google Chrome shortcut

⌘Q will not longer work, and the new shortcut will be correctly displayed in the Chrome's menu:

Chrome Menu

Rails Conference 2012, first time in Israel, was a great deal of fun. Lot's of presenters both local and from all over the world, well, more like from all over the world of Rails. There were talks from Github, Heroku, Engine Yard, Gogobot, Get Taxi and lots and lots of others. Solid organization from Raphael Fogel People and Computers guys. Hordes of interesting people to talk to, nice and abundant food and coffee, lots of great content from the speakers and to sign off the day Github guys invited everyone to an open bar drinkup event.

We gave 2 talks, Vitaly's "Performance - When, What and How" and Boris' "Rails Missing Features". Check out slides and videos of those talks.

nanoScroller.js - jQuery plugin to implement OSX Lion-styled scrollbars for your website.

strong_parameters gem allows you to "test drive" the new way that Rails 4 is going to treat parameters security. attr_accessible and friends are being deprecated.

celluloid.io interesting approach to multithreaded programming for Ruby.

Letters - new take on debugging logging library for Ruby.

showcase of 40 pricing tables and signup pages can help with with some inspiration for your pricing page.

lenticular.js - Tilt controlled images.

Repo.js - light-weight jQuery Plugin that lets you easily embed a Github repo onto your site.

FullCalendar is a jQuery plugin that provides a full-sized, drag & drop calendar with events etc.

tl;dr Legal - easy summaries of open source licenses.

CCMenu - OS X menu bar application to pull build status of your projects. Support many different CI backends.

[Update - 30 Apr 2013] The new, updated and faster version of this blog post covering Ruby 1.9.3 patchelevel 392 and railsexpress patch set.

I knew that there are various Ruby patches available but I've never tried them as I didn't want to waste time for something that I thought I don't really need.

Then I found out that rvm comes bundled with patches ready to be applied, so I'm just a simple command line away from having a patched Ruby. Don't know how I missed that before.

Finally, there is a Rails Conference here in Israel. Long overdue. We're sponsoring it and giving one keynote and one lecture.

I recently switched to ruby 1.9.3 as my deafult ruby verison, and suddenly some of my scripts started to fail in some funny ways.

One of the latest ones was the script that was supposed to change 'updated' timestamp in a YAML formatted file. Instead of the current date it started to spit out binary strings.

The problem is quite complext but the fix is simple...

I did an overview presentation about the current state of real time web and server-push technologies at the Israely DevCon 2012 conference.

Below is the transcript of the talk (actually more like a talk plan ;)

There is also a [pdf version for download][pdf].

It is in English as this is the way I usually write down my presentations, although the actual talk was delivered in Hebrew.

Check out the video of the talk on YouTube or embedded here. And if you more of a reader then viewer you can check out the slides with sort of transcript below.

Given that module Foo is defined elsewhere what is the difference between this snippet:

class Foo::Bar
  ...
end

and this:

module Foo
  class Bar
    ...
  end
end

Answer inside ;)

LaunchBar is one of the tools I can't live without.

Basically, it's an application launcher, but besides actually launching an application it has lots and lots of features that help me complete tasks on my laptop while staying in the flow.

Ever since I installed it on my MacBook my workflow changed quite dramatically to the better.

My Vim-fu improved a lot in the last couple of years.

Part of the reason is that working on [dotvim][dotvim] forced me to dive deeper into it, but thats not the whole story.

I think a much bigger reason is that I decided to systematically work on improving it.

One of the tricks I use is to have a list of Vim tricks and shortcuts that I'm learning right now on my OSX dashboard.

It's alive. Again ;)

This blog was dead for a while. It was running on an old Mephisto system and it's admin interface just broke one day, throwing some cryptic exception.

It was probably not that hard to fix, but every time I thought to write a blog post it was like "oh, I have to dig into this antient codebase to figure out how to fix it before I actually get to write anything. I'll pass..."

So days become weeks, and weeks become months, pretty fast its a year that passed by with no blog posts whatsoever.

Meanwhile I was scribing my thoughts on future blogposts in markdown files on my harddrive.

Not long ago we finally decided to do something about it.

I had a lot of things to do last Thursday, Feb-17. I met a friend from abroad 3am at Ben Gurion Airport and spent several hours talking before we went to sleep, signed a contract for developing killer web app at 1:30am, and finally gave a presentation at The Junction at 4:30pm.

Vitaly gave an interesting presentation about MongoDB at Database 2011 Conference.

MongoDB. NoSQL for SQL addicts.

Slides are here.

We presented on IGTCloud Ruby On Rails Day today.

Agenda was a bit different this time, not only technical presentations but also a few words about modern approach of building web applications.

Find the slides below.

I was working on tests for blender when I came upon a need to mock or stub a back-tick operator e.g.:

`shell command`

Apparently this is just a shortcut for calling Kernel method :`.

The OPEN 2010 conference was very well organized and had many interesting talks.

We are giving 4 out of 20 sessions at Open 2010, an Israeli open source conference.

I just recently reinstalled my MacBook Pro, this time with Snow Leopard.

So I'm again going through various installation problems I already forgot about from few years back when I installed Leopard.

Anyway, just had to hunt down a problem with mysql gem installation on Snow Leopard.

A few days ago I gave a presentation about Ruby for Sayeret Lambda discussion group.

The title was "Ruby is an acceptable lisp" but the message is better served by "Ruby is Better then Lisp ... sometimes" :)

http://markupslicer.com

Supports ERB and HAML for now, vote on site for more formats.

Beautifully crafted, totally free and it's kinda fun.

About a week ago about 15 people were gathered in People and Computers offices thanks to Raphael Fogel.

There is a new (0.2.7) version of Astrails-Safe.

I've just read "Do You Believe In Magic?" and the following quote resonated particularly well:

"It's not magic. There is no magic involved. It's just, if you never learnt Lisp, then you never learned to program, and Ruby's power is exposing a deficiency in your skills."

The opportunity

120 happy dreamers cooking for 54 hours of pure startup joy, well-fed and ready to work. Of course, I’m talking here about Startup Weekend Israel.

The challenge

Come up with an idea that can be implemented in a couple of days, yet is so cool, so innovative, and so useful that I could attract the best of the best.

Read the rest at blogtheblog.jobthejob.com

P.S Now we have some pictures too there, you should check it out

If you follow us on twitter (@astrails if you wondering) you already know that we are at the Startup Weekend Israel right now.

Which is going amazing by the way, thanks for asking, lots and lots of nice people, very creative and energetic atmosphere, food and beer.

Turns out our idea attracted a great team of developers, designers and business developers.

We just started a project for a client that involves Cassandra.

If you've been living under a rock and don't know what Cassandra is let me tell you :)

Cassandra is a "second-generation distributed database" that was built for web scale.

Its is one of the many distributed nosql databases that appear everywhere lately like mushrooms after a heavy rain :).

What sets Cassandra apart is that it comes from a recognizable entity - Facebook.

But I digress.

This is not meant to be a Cassandra introduction, there are enough of those on the net. I Just created a new nosql section on this blog where I'm going to post various tidbits of information about cassandra (and probably others) as I learn them while working on this new project.

Here is the first one: Cassandra gem is just an installer

Yeah, I know, MVC is the "Only True Way™". But sometimes, just sometimes, you need your link_to or html helpers working in the model.

For example, sometimes the cleanest way to implement something is to have to_html in the model (widgets anyone?).

Doing this will most probably require generating some urls, and you need a controller for that. Usually I solved this by passing controller to the to_html function, but it always felt wrong.

Just released a new 0.2.5 version of astrails-safe.

astrails-safe is our very simple to use backup script for mysql, postgres, filesystem, and subversion. It can store your backups locally, on Amazon s3 or on a remote SFTP server. Optional GnuPG enctyption completes the picture.

Since Github stopped to build gems we are moving to the gemcutter.

Damn, I just found this unpublished article in the blog admin...

How come it evaded my attention for 3 months??!!

Anyway, releasing it now thought this is all quite old news, going to announce 0.2.4 in a moment :)

I just did something pretty stupid. I edited /etc/sudoers file directly from within my non-root user account.

This is going to be the first part of a blog post series about javascript widgets.

First type I'm going to cover is Popup Widget. Sometimes it's called Popin Widget because there is no actually new window that pops up, instead the content is shown IN-side a current page. The idea is quite simple: you provide some html/js snippet to other sites. They put it into relevant place, and you have some functionality of your site running there.

Clicktale is a service that allows you to record and later playback behavior of your users while they are using your site. And Rails is Rails, you know.

And those two are getting along just fine, until the user logs in. After that clicktale service is cut out of the html pages this user gets and can't record the session. But it just started to get interesting...

I just pushed new version 0.1.9 of astrails-safe to github.

The main difference is a fix to an embarrassing bug in the S3 backup rotation code.

Thanks to Thuvarakan Tharmalingam for reporting.

Again, the reason it escaped was the fact that we don't yet have full test coverage.

We are getting there though....

It looks like our astrails-safe gem is quite popular :). People started to contribute new features:

Mephisto commenting system is... how do i put it ... outdated :)

And we wanted something more engaging for our blog. Looking around the web we found that Disqus was used all over the place, so we decided to integrate it into our blog instead of the native comments system.

Wouldn't it be cool if you could just require "http://my-host/my-lib.rb" in ruby?

Now You Can! Using our "http_require" gem! :-)

Everyone needs a backup, right? Unfortunately almost no one does though. Why?!

We needed something for ourselves and our customers. Something simple, free, configure-and-forget. Most of the time there is no need for something fancy, a simple tar + mysqldump can do the job for many small/medium sites.

RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. Use it to write your custom monitoring shell scripts or create whole applications using its Perl, Python, Ruby, TCL or PHP bindings.

Let's run it with Ruby on Leopard.

sudo port install rrdtool

Default ports installation comes without ruby bindings.

Thanks a lot to Amit Hurvitz for providing a file of Virtual Disk Image (VDI) of VirtualBox, containing an up and running JRuby on Rails on Glassfish with Mysql. Image also contains some examples (actually solutions to the code camp exercises), all running on top of an OpenSolaris guest OS (can be run on many host systems).

Grab the image ~1.5GB archive.

Grab the exercises ~9.7MB archive.

We recently moved our DNS to dnsmadeeasy.com from godaddy.com name servers.

After the transfer some internal CNAME records had a problem. So after fixing the problem and checking in the terminal that the changes propagated to the DNS server (host xxx.astrails.com) I tried to type the address in the browser, but it kept giving me the "can't find host" error.

We participated in JRuby on Rails with GlassFish Code Camp hosted by Sun Microsystems Inc. I was speaking about the framework in general trying to infect Java developers with Ruby On Rails. Slides are available.

Amit Hurvitz gave exciting presentation about GlassFish and short introduction into DTrace. Find out more details about the Code Camp.

I was the last person in our company working with ERB to render templates. While all the rest switched to HAML. At the beginning it was quite hard for me to read HAML comparing to ERB. HAML looked for me like some completely alien thing with weird percent marks all over the place and the significant whitespace never did it for me. On the other hand ERB felt like warm home after years we spent together.

Until I did the switch.

2008 was the year when we finally switched to full time consulting. And like all consulters we faced the problem of correct pricing. There are two well-known ways to charge a customer: per-hour rate and fixed bid quote, and several combinations of them.

Recently we looked for video transcoding/hosting solution to use in one of our client's projects.

The best thing we've found is Panda. It runs on Amazon stack of services including ec2, s3, and simpledb.

Using amazon has many advantages. no contracts, pay as you go, easy and fast scaling in case your site explodes :)

Unfortunately the image that is refered in the Getting Started (ami-05d7336c) is not safe for production - it has openssh version with a serious security bug, but don't worry, we will explain how to fix it.

This blog-post is mostly targeted at non-Rails developers. Rails devs should know all this by heart :) Many times we need to explain to our customers what is 'proper deployment' and why their current one sucks :) Now we'll be able to just point them to this post...

Blog moved to Mephisto. So we have comments now.

In the process of installing Mephisto I've got a problem with image_science gem.

It installed OK but when trying to require it the was a problem with RubyInline compilation:

We really like Debian and we usually use the current "stable" distribution for our production servers.

It all works great with one little problem: if you need very current soft it is probably not in the 'stable' yet.

The current Debian stable ("etch") includes rubygems 0.9.0-5 which is way too old.

We needed to upgrade to at least 1.2.

We just incorporated our own Ltd. company.

It was coming for a while now but we finally got to it when we started to hire people :)

Once again I’ve hit a problem of installing gems on a machine with very little memory.

On one of our projects we needed to do some caching for an action with an expensive db query. Fragment caching took care of the rendering but we needed a way to skip the db if we have a cache hit. And checking for an existence of the fragment file in the controller just didn’t seem right.