Posts Tagged ‘ruby’

I use RubyMine and Vagrant for my Rails development and run RSpec specs from RubyMine for convenience. The problem is that every time I start rspec, it takes a few seconds to connect to the box, before actually doing anything. This is especially annoying when running single spec which should be fast. vagrant ssh is […]

veebr. 13th, 2015 | Filed under Programming

In a recent project I found myself writing recirect_to :back alot, and then found myself worrying that what if for some reason there is no :back. Drawing inspiration from this blog, I wrote two helpers in my application_controller.rb. The store_location stores current URI (or referer URI in case of non-GET request) into session[:return_to] for later […]

dets. 27th, 2012 | Filed under Programming
Tags: ,

I run into a case where I had method and I wanted the GroupMember model be searchable by the user’s attributes. The most DRY way to accomplish this in Rails 3 is to merge scopes. In the User model:

NB! It’s important to have the User’s field names fully qualified so that they […]

dets. 17th, 2012 | Filed under Programming
Tags: ,

Ruby 1.9’s Object#tap method has always seemed useful to me, but until now I hadn’t met the chance to use it. Every other time it seemed like abusing it in some way. Now I came to an old code. Consider this:

I needed to turn that maxlength into a conditional attribute (omiting it if […]

juuni 14th, 2012 | Filed under Programming

Setting up solid Ruby on Rails developer box based on Windows can be tedious task. More so than on other platforms, because vanilla Windows is meant for end user and lacks proper development tools that exist on other platforms. But fear not, there are many good people out there that have jumped through multitude of […]

apr. 2nd, 2012 | Filed under Programming

Facing the question which Ruby Rack server perform best behind Nginx front-end and failing to google out any exact comparison, I decided to do a quick test myself. The servers: Passenger 3.0.8 Unicorn 4.1.0 Thin 1.2.11 Later I tried to test UWSGI server too as it now boasts built-in RACK module, but dropped it for […]

aug. 25th, 2011 | Filed under Programming

Merge SVG files with CSV file using Inkscape

aug. 10th, 2011 | Filed under Programming
Tags: , ,

I stumbled upon a problem with one of my scripts: how do you split a yielded block between two different callers while conforming to the DRY principe? The answer is lambda method.

apr. 27th, 2010 | Filed under Programming

Building and releasing iPhone apps and at the same time versioning them easily can be a bit tedious. Several posts (like this or this) show how to use agvtool for automated versioning. But for me this is still not automated enough.

veebr. 1st, 2010 | Filed under iPhone, Programming

This script can be used in e.g. KMuddy to automatically practice all known skills to attack mobs. Once upon a time, when I played Aardwolf a bit. To make my life easier, I wrote a simple script to practice all known kill methods on mobs. This script chooses a random skill (some skills can be […]

aug. 19th, 2007 | Filed under Programming
Tags: ,