Skip to content

Instantly share code, notes, and snippets.

View rishiip's full-sized avatar
🎯
Focusing

Rishi Pithadiya rishiip

🎯
Focusing
View GitHub Profile

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.

@rishiip
rishiip / hashes.md
Last active August 29, 2015 14:17 — forked from ryansobol/hashes.md

What's a Hash and why is it important?

A Hash is a collection of key-value pairs. To add, fetch, modify, and delete a value from a Hash, you refer to it with a unique key.

While an Array is indexed by Integers only, a Hash is keyed by any object -- Strings, Integers, etc.

In other programming languages, a Hash might be known as an 'associative array', 'dictionary', or 'HashMap'.

What does a Hash look like?

class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@rishiip
rishiip / arch.md
Last active August 29, 2015 14:23 — forked from mislav/arch.md

Create the partition:

sgdisk --zap-all /dev/sda
cgdisk /dev/sda
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt

Edit the mirror list to bring the preferred mirror to the top:

@rishiip
rishiip / server.rb
Last active August 29, 2015 14:25 — forked from emad-elsaid/server.rb
require 'webrick'
Port = 3000
Directory = Dir::pwd
WEBrick::HTTPServer.new(
Port: Port,
DocumentRoot: Directory
).start
@rishiip
rishiip / nil_empty_blank_present_ffdierence_in_ruby
Last active December 8, 2015 10:56 — forked from pythonicrubyist/nil_empty_blank_present_ffdierence_in_ruby
Difference between nil?, empty?, blank? and present? in Ruby and Ruby on Rails.
# nil? can be used on any Ruby object. It returns true only if the object is nil.
nil.nil? # => true
[].nil? # => false
{}.nil? # => false
"".nil? # => false
" ".nil? # => false
true.nil? # => false
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero.
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass
@rishiip
rishiip / gist:bd36c65f85031e66ee56
Created December 8, 2015 11:08 — forked from mistrikushal/Rspec private methods.txt
RSpec - Testing private methods of a model
# RSpec allows us to test private methods of a model.
for example,
class User
def is_active?
true
end
private :is_active?
end
@rishiip
rishiip / bson.rb
Created March 10, 2016 06:11 — forked from rishi-amura/bson.rb
Return mongo `_id` bson object as regular `id` within Rails application
Save below code to `bson.rb` file within `config/initializers` directory and restart the server
module BSON
class ObjectId
def as_json(*args)
to_s
end
end
end
@rishiip
rishiip / IndianCities.json
Created March 10, 2016 06:11 — forked from rishi-amura/IndianCities.json
Indian States and their Cities
{
"AP":[
"Adilabad",
"Anantapur",
"Chittoor",
"Kakinada",
"Guntur",
"Hyderabad",
"Karimnagar",
"Khammam",
@rishiip
rishiip / install.sh
Created July 31, 2019 06:13 — forked from maanavshah/install.sh
Install and Configure Ruby on Rails, MongoDB, PostgreSQL, Git, Sublime Text, Oh-my-zsh and Deepin on Ubuntu
#!/bin/bash
sudo apt-get update
# To make sure we have everything necessary for Webpacker support in Rails, we're first going to start by adding the Node.js and Yarn repositories to our system before installing them.
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update