Skip to content

Instantly share code, notes, and snippets.

@filipechagas
filipechagas / bad.rb
Created February 19, 2016 14:01
Cyclomatic Complexity - Guard clause overused
def compute_thing(thing)
if thing[:foo]
update_with_bar(thing)
if thing[:foo][:bar]
partial_compute(thing)
else
re_compute(thing)
end
end
end
@filipechagas
filipechagas / fix-nvim-ch.sh
Created December 22, 2015 15:21
Fix issue with NeoVIM and C-H mapping for split movement
# https://github.com/neovim/neovim/issues/2048#issuecomment-78045837
infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
tic $TERM.ti
@filipechagas
filipechagas / gist:01f09e89927dc8806510
Created August 26, 2015 20:05
Elastic Search Utils
# List all entries in an index
> http://localhost:9200/project_environment_users/_search?pretty=true&q=*:*
# Delete an index
> curl -XDELETE http://localhost:9200/project_environment_users
@filipechagas
filipechagas / gist:71e79493d28bba5b79b9
Created July 24, 2015 21:42
Fix Capybara::Poltergeist::JavascriptError - Poltergeist - React
# https://github.com/es-shims/es5-shim/blob/master/es5-shim.js
//= require es5-shim
@filipechagas
filipechagas / gist:49f9f8528158217341f8
Created March 19, 2015 19:08
How to discover the caller method name in ruby
caller[0][/`([^']*)'/, 1]
@filipechagas
filipechagas / gist:c936f4b0dee2cbb2d723
Last active February 10, 2020 21:28
Therubyracer installation problem - OSX Mountain Lion
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
gem uninstall libv8
gem install therubyracer -v=0.10.2
# ------- UPDATE ---- source: https://github.com/shakacode/react-webpack-rails-tutorial/issues/266#issue-145593157
@filipechagas
filipechagas / gist:308336d1aead01ccaeb8
Created February 10, 2015 15:03
Rails 4.2, Vagrant box and port forwarding
#From http://stackoverflow.com/a/27799431
Rails 4.2 now binds to 127.0.0.1 by default and not 0.0.0.0.
Start the server using bin/rails server -b 0.0.0.0 and that should sort it.
@filipechagas
filipechagas / gist:3fb59274155457c3579f
Last active December 8, 2015 16:04
pg_dump and pg_restore
# pg_dump -U username -W databasename -f filename.sql
pg_dump -U username -W -Fc databasename > filename.dump
pg_restore -c -U user_name -d [database_name] [dumpfile_name].dump
# pg_restore -U username -Fc -C filename.bak

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@filipechagas
filipechagas / gist:7d1f53ac8d691a9874b5
Created November 12, 2014 21:50
Freenas and Crashplan
Followed this tutorial:
http://techflow.io/blog/crashplan-plugin-for-freenas
Changed the Jail configuration -> Unchecked VIMAGE and rebooted
Followed this post:
https://forums.freenas.org/index.php?threads/crashplan-3-6-3.18416/#post-101205