Skip to content

Instantly share code, notes, and snippets.

Working from home

Arup Rakshit aruprakshit

Working from home
View GitHub Profile
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

View .vimrc
set nocompatible
filetype off
" set runtime path to include vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Let Vundle manage Vundle
$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')

If you need the table names:

$ ActiveRecord::Base.connection.tables

=> ["accounts", "assets", ...]

View dispatcher.rb
class Object
def send_through(object, *args)
object.dispatcher_for(self).call(self, *args)
module Dispatcher
class DispatcherNotFound < StandardError; end
def self.extended(klass)
View 1notifier.rb
def store(provider, board, status)
# @connection is a PG::Connection object
# @logger is a Logger object
# The part before `.each` is inconsequential, it's just a prepared statement and we're
# iterating over the results.
@connection.exec_prepared(TYPE, [provider, board].concat(statement status)).each do |row|
# Ignore this
@logger.debug(Harvester::Runner) do "insert", table: TABLE, id: row["id"])
View gist:87991b5de610a4305888

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.

View fibers.rb
require 'socket'
require 'fiber'
#A list of readables and writables for, and which fiber is waiting for which IO
watch = {
readable: {}, #{io => fiber}
writable: {}
View respond_to_missing.rb
class Wrong
def method_missing(m, *)
if m =~ /\Ahello_(.+)\z/
puts "Hello, #{$1.capitalize}"