Skip to content

Instantly share code, notes, and snippets.

View aruprakshit's full-sized avatar
🏠
Working from home

Arup Rakshit aruprakshit

🏠
Working from home
View GitHub Profile
@aruprakshit
aruprakshit / rules.md
Last active August 29, 2015 14:10 — forked from henrik/rules.md
  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.

@aruprakshit
aruprakshit / .vimrc
Last active August 29, 2015 14:09 — forked from zxiest/.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", ...]

class Object
def send_through(object, *args)
object.dispatcher_for(self).call(self, *args)
end
end
module Dispatcher
class DispatcherNotFound < StandardError; end
def self.extended(klass)
"ab"
"a
b"
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
Scrawl.new(label: "insert", table: TABLE, id: row["id"])

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.

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