Skip to content

Instantly share code, notes, and snippets.

Senthil Arivudainambi sent-hil

Block or report user

Report or block sent-hil

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
sent-hil /
Last active Dec 11, 2015
A list of lessons learned from refactoring my open_auth2 library to make it a better OOP citizen.

Recently I've been learning a lot about OOP, especially how to structure code to make it easier to change in the future. The following are some of the ways I refactored my open_auth2 library.

Don't optimize prematurely

I did the mistake of assuming what sugars were required, only to realize I never used them. Source.

Inject dependencies

The Token object accesses Config object for information. Before it was hard coded into Token, so they're highly coupled, so now I pass it as an argument to #initialize. Better yet it defaults to so it's only optional. Source.

sent-hil /
Last active Dec 10, 2015
Notes of 'My issues with Modules' by Ryan Bates. Source:

When working through unknown code method, ask:

What does a given method do?
What is the current object context that I am in?
What other methods can I call here?
module Purchasable
  def purchase
    result = total, credit_card: card)
sent-hil / endpoint.rb
Created Jan 5, 2013
Refactoring of Saran's `Endpoint` class based on Sandi Metz's talk/book.
View endpoint.rb
module Saran
# Makes http requests.
class Endpoint
attr_reader :verb, :path, :provider, :endpoint, :access_token
# TODO: remove config dependency,
# can combine path, endpoint, access_token
# depends on if OpenAuth can deal with full_url
# how to deal with provider?
sent-hil /
Created Jan 5, 2013
Notes of 'Go ahead make a mess' by Sandi Metz

Your apps starts great and you love working with it up until beta when it becomes a mess and you hate it.

Your app is made up of things and know things about themselves and about others. The latter is dependencies. When the dependencies change, the object will need to change as well.

OO design makes you write code that your future self will love. Stop worrying and learn to love the mess.

sent-hil / saran.rb
Last active Dec 10, 2015
Some cowbody coding I did couple weeks ago, totally forgot the design decisions and need to start over. :(
View saran.rb
# approach 1
require 'bundler/setup'
require 'open_auth2'
require 'active_support'
require 'active_support/inflector'
require_relative 'saran/config_accessors'
require_relative 'saran/endpoint'
sent-hil /
Last active Dec 10, 2015
Notes of 'Understanding Ego Depletion' by Dan Ariely

On stressful days many of us give in to temptation and choose unhealthy options.

Six steps to avoid breaking unders stress

  1. Acknowledge the tension, don't ignore it - we use self control every time we force ourself to make the good, reasonable decision, and that self control, like other human capacities is limited.

  2. Call it what it is: ego depletion - depletion is the psychological sum of these feelings, of all the decisions you made that led to that moment.

  3. Understand ego-depletion - people under greater cognitive strain were less able to overturn their instintive desires.

sent-hil / makers_schedule.txt
Last active Dec 10, 2015
Notes of Maker's Schedule, Manager's Schedule by [Paul Graham](
View makers_schedule.txt
Jan 3, 2013 4:21 PM
Manager's schedule:
Traditional appointment book.
Each day cut into one hour intervals.
By default you've to change what you're doing each hour.
Maker's schedule:
Prefer longer units of time, at least half a day.
Can't work/switch every hour, barely enough time to get started.
sent-hil /
Last active Dec 10, 2015
Books, papers, blogs & screencasts I plan to read, watch in 2013 or at least try.


  • Practical Object-Oriented Design in Ruby: An Agile Primer
  • Cracking the coding interview
  • Eloquent javascript


  • Growing object oriented software guided by tests
  • Refactoring by martin fowler
  • Rails As She Is Spoke
  • The Passionate Programmer
View nested_resource.rb
module Dsl
class Resource
attr_accessor :name
def initialize(name)
@name = name
def get
puts name
sent-hil / gist:4142823
Created Nov 25, 2012
Ruby job questions
View gist:4142823
Q. What is polymorphism?
* Allows values of different data types to be handled using an uniform interface.
* 3 types:
* Overloading: Methods of same name exists in different class.
Ex: + method operates differently for integers and floats.
* Parametric: Methods of same name, but accept diff. parameters.
* Inclusion: The ability to redefine methods in inherited classes.
You can’t perform that action at this time.