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

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 OpenAuth2::Config.new so it's only optional. Source.

@sent-hil
sent-hil / issue_with_modules.md
Last active Dec 10, 2015
Notes of 'My issues with Modules' by Ryan Bates. Source: https://gist.github.com/4172391
View issue_with_modules.md

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 = Braintree::Transaction.sale(amount: total, credit_card: card)
@sent-hil
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
sent-hil / sandi.md
Created Jan 5, 2013
Notes of 'Go ahead make a mess' by Sandi Metz
View sandi.md

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
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
sent-hil / ego_depletion.md
Last active Dec 10, 2015
Notes of 'Understanding Ego Depletion' by Dan Ariely
View ego_depletion.md

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
sent-hil / makers_schedule.txt
Last active Dec 10, 2015
Notes of Maker's Schedule, Manager's Schedule by [Paul Graham](http://www.paulgraham.com/makersschedule.html)
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
sent-hil / 2013_books_papers_blogs_screencasts.md
Last active Dec 10, 2015
Books, papers, blogs & screencasts I plan to read, watch in 2013 or at least try.
View 2013_books_papers_blogs_screencasts.md

BOOKS IN PROGRESS:

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

BOOKS:

  • Growing object oriented software guided by tests
  • Refactoring by martin fowler
  • Rails As She Is Spoke
  • The Passionate Programmer
View 2013.md

Work:

  • Get a kickass job as a programmer: A job that excites me to jump off the bed every morning. A place where I'm allowed, even required to learn new things every day. Ideally I wouldn't have to worry about things like money, politics, location, work hours, job security etc. I just want to walk in every day and solve problems with smart people.

  • Own open source projects: They work, well tested and are used in production, but I'm not completely comfortable with them. This includes open_auth2, saran and mock_api. Write more open source projects and tell people about them.

  • Dive deeper into Ruby: This means writing bigger and more complicated libraries.

  • Get better at Go: I had a whole lot of fun building a chat server at Hacker School in Go. It was my first real experience in a low level language, aside from trying to learn C.

View nested_resource.rb
module Dsl
class Resource
attr_accessor :name
def initialize(name)
@name = name
end
def get
puts name
You can’t perform that action at this time.