Archive for the ‘Programming’ Category

Again, building on my previous scripts it was dead to make a script that creates new window for Atom editor. This is best used with Spotlight or Alfred to quickly create new window in current space (even if another window was open in some other space it will not switch there). Installation Unzip the archive […]

sept. 22nd, 2015 | Filed under Mac, Programming

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

How to use GIT to merge two SVN branches TL;DR: Download the git-merge-svn script here I’ve been using git for years now but had to start using SVN for some projects. I found that GIT is good enough Subversion client too, especially as I retain the ability to commit often and rebase my work on […]

apr. 23rd, 2013 | Filed under Programming, Rest of the World

Previously I have written AppleScripts to open new windows for TextMate, Sublime Text 2 and also Safari. But the latter was somehow corrupt when using with Mac OS X 10.8.3, so I rewrote it based on previous two, adding features in the process: Checks if Safari is already running and creates new window (without switching […]

märts 21st, 2013 | Filed under Mac, 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: ,

Building upon my older post on opening new window in Text Mate 2, I now threw together small script to do the same in Sublime Text 2. While Sublime Text 2 is superb text editor, it is not Mac native, thus it’s even less probable that a new Mac-style Dock icon menu will appear in […]

juuni 25th, 2012 | Filed under Mac, Programming

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

For whatever reason, Ruby DBI and DBD have axed the quote method from their midst, breaking compatibility with previous versions. Sadly I couldn’t find any clues as to why it was removed (actually, bluntly commented out). Fortunately I was able to unearth some hints how to restore this method and with an added fix to […]

mai 29th, 2012 | Filed under Programming

How to quickly mount partitions when the need arises? A small AppleScript to help you out. The need No good comes without little drawbacks. When I swapped ODD with HDD, I noticed that it was quite a bit noisier than SSD and even compared to similar MBP with HDD in original bay (probably because ODD […]

mai 15th, 2012 | Filed under Mac, Programming