05 2 / 2013

Yesterday I came to one production project and saw several Resque Failures. And it seems one of them blocked others, so the queue hungs for more than 20 jobs.


15 10 / 2012

Пост не технического содержания, посему пишу на русском.

С товарищем произошла забавная история. У него дома интернет дом.ру, подключенный напрямую к ПК (кто не знает, дом.ру привязывается к мак адресу). Вчера он взял себе ноут, попытался подключиться через кабель - у него ничего не вышло.


17 9 / 2012

Hi guys!

Again it was long lull in my blog and now I ready to write small post.

In my current project I had a need to use autocomplete tool but with very specific query to db. Certanly, all you know about excellent gem https://github.com/crowdint/rails3-jquery-autocomplete But there is two ways in which you won’t be comfortable using it.


21 6 / 2012

Hi all!

I hav not written anything for a long time. And now I want to show you solution to implement hit counter in your rails app. Certanly you can just increase field of your model inside your controller, but if you have high attendance of your site, it will cause perfomance problem. 

So my decision is using redis with cron. 


26 3 / 2012

In one task I needed to calculate sha1 for first 1mb of my file.

Here is simple solution:

opened = File.open(path)
Digest::SHA1.hexdigest opened.read(1048576)     # 1mb.

That’s all =)

23 3 / 2012

When I tried to install ruby 1.9.3 on my mac lion with openssl 1.0.0e I take segfault error.

And here you can take a look, how to avoid this.

 rvm remove ruby-1.9.3
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.rvm/bin
rvm pkg install iconv
rvm pkg install openssl
rvm install ruby-1.9.3 --with-openssl-dir=$rvm_path/usr --with-iconv-dir=$rvm_path/usr

Based on Chris Irish post http://www.christopherirish.com/2011/09/02/ruby-1-9-2-segmentation-fault-and-openssl/

22 3 / 2012

17 3 / 2012

STATUSES = %w(pending available sold)

STATUSES.each do |status|
class_eval "scope :#{status}, where(status: :#{status})"

16 3 / 2012

09 2 / 2012

I made this task for quite some time, so I can not reproduce the process in order, so I will describe just how it should looks in the end.