Vim - Change Colorscheme Based on Iterm profile

I like to change my (neo)vim colorscheme quite frequently, and when I do I want it to match my iterm colors. Many colorscheme authors also provide an iterm color palette, so you can import the .itermcolors file, create a new iterm profile with that palette, start a new session and you have the same vim colorscheme in your iterm. But then, when you launch vim, you still have to type :colorscheme somecolor....

December 19, 2016 · 2 min · metalelf0

Vim - sort ruby methods by name

Yesterday I had to refactor a very large ruby class. It had a lot of methods and, to make it cleaner, I decided to sort methods alphabetically. Is there a way to do this in vim? Of course there is, and it’s quite tricky - so let’s see how we can do it. The basic idea is taken from this post on wincent.com, I just adapted it for ruby. All credits to this guy for his work :)...

July 29, 2016 · 2 min · metalelf0

Mocked - a minitest pattern

Minitest is good for mocking, right? Well… Minitest is gaining a lot of popularity and can actually be a 100% replacement for RSpec. It’s a pure ruby testing framework, it’s fast, light weight, and it supports both a test-unit like syntax and a spec engine with Rspec like syntax. Still, when it comes to mocking, it can be a little painful. You have to initialize mocks and verify them manually after running the code under test....

May 11, 2016 · 3 min · metalelf0

Command pattern in ruby and rails

The problem If you have a growing Rails application and you feel your models are getting too fat you might have a problem. We’ve all been educated with the “fat models, thin controllers” dogma - but sometimes putting all the domain logic inside the models has its downsides. As an example, the typical flow of an ActiveRecord object through a Rails request involves: fetching the object from the DB based on the params you receive (controller); doing something with the object inside the model (model); when something goes wrong, you set errors onto the model attributes (model); you finally return the object to the view, and present it accordingly (view)....

May 2, 2016 · 4 min · metalelf0

Git: preview conflicts

Hi everyone! What we’re trying to tackle today is a very common problem, that I’m sure all of you encountered. Suppose you’re on your git feature branch, you want to merge it into another branch (being it master, staging, production, whatever) and you’re asking yourself: will there be conflicts?. If you’re using Github, you can simply open the Pull Request page for your feature branch and look for the following box:...

July 12, 2014 · 2 min · metalelf0