Skip to content

Instantly share code, notes, and snippets.

Subrat Rout subratrout

Block or report user

Report or block subratrout

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
subratrout /
Created Sep 22, 2017 — forked from somu45/
Ruby, Rails and Sql Specific Questions


  1. Fix the following snippet. Given a collection of 1000 draft Articles, update all of them to be published

    Post.where(status: :draft).each { |p| p.update_attributes(status: :published}
    #Ans. Post.where(status: :draft).update_all(status: :published)
subratrout /
Created Sep 22, 2017 — forked from Vasyl-Varkholyak/
Questions to Ask During a Ruby Interview


Senior programmers won't have a problem with these, while junior programmers will usually give only half-answers.

What is a class?

A text-book answer: classes are a blue-print for constructing computer models for real or virtual objects... boring.

In reality: classes hold data, have methods that interact with that data, and are used to instantiate objects.

View gist:0d0e56fd2038b1a93a85026a512b86f6

1. What is a class, what is an object and why we need modules

This may be simple, but it allows to start a conversation between two strangers involved into the same craft.


Classes are a blue-print, they may hold data, likely they hold methods; classes are directly connected with an idea of objects, because object is an instance of a class. As objects are first-class citizens in Ruby, there is a main, root class Object, and all classes are inherited from this root entity. Modules, generally, are a tool for mix-ins and they provide something we call a namespace. Modules cannot be initialised the way we can do this with classes, but they provide a multiple inheritance.

2. Who’s _why and what’s up with his Shoes?


#A team

##What is Rails?

Rails is an open source web application framework written in Ruby. It is a full-stack framework that has been optimised for programmer happiness and sustainable productivity. It emphasises the use of well-known software engineering patterns and paradigms, including convention over configuration (CoC), don't repeat yourself (DRY), the active record pattern, and model–view–controller (MVC).

Extra: David Heinemeier Hansson (DHH) is the creator of Rails, having extracted it from his work on Basecamp. He first released Rails as open source in July 2004.

Useful Links:

subratrout / btc-eth-dca-buy.php
Created Aug 24, 2017 — forked from levelsio/btc-eth-dca-buy.php
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
View btc-eth-dca-buy.php
// by @levelsio
// 2017-08-23
// 1) buy $40/day BTC
// 2) buy $10/day ETH
View gist:58848394af50c7db7ccd75a910174a32
Try implementing a method called occurrences that accepts a string argument and uses inject to build a Hash. The keys of this hash should be unique words from that string. The value of those keys should be the number of times this word appears in that string.
def occurrences(str)
word_hash =
str.scan(/\w+/).inject(word_hash) do | number, word|
number[word.downcase] += 1
View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')
subratrout /
Created Jun 22, 2017 — forked from erikreagan/
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

subratrout / gist:e621e75f6e4c3eb0c46c85bf7bdd3ee9
Created May 11, 2017 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview
View gist:e621e75f6e4c3eb0c46c85bf7bdd3ee9

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.

You can’t perform that action at this time.