Skip to content

Instantly share code, notes, and snippets.

View sent-hil's full-sized avatar

Senthil Arivudainambi sent-hil

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

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 January 5, 2013 07:45
Refactoring of Saran's `Endpoint` class based on Sandi Metz's talk/book.
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 January 5, 2013 06:42
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
sent-hil / saran.rb
Last active December 10, 2015 14:48
Some cowbody coding I did couple weeks ago, totally forgot the design decisions and need to start over. :(
# 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 December 10, 2015 14:28
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
sent-hil / makers_schedule.txt
Last active December 10, 2015 14:28
Notes of Maker's Schedule, Manager's Schedule by [Paul Graham](http://www.paulgraham.com/makersschedule.html)
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 December 10, 2015 11:18
Books, papers, blogs & screencasts I plan to read, watch in 2013 or at least try.

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
module Dsl
class Resource
attr_accessor :name
def initialize(name)
@name = name
end
def get
puts name
@sent-hil
sent-hil / gist:4142823
Created November 25, 2012 08:22
Ruby job questions
http://blog.firsthand.ca/2010/08/questions-asked-in-ruby-on-rails-job.html
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.
@sent-hil
sent-hil / gist:4034166
Created November 7, 2012 20:23
HS - Nov 7
--------------------------
Interfaces vs. Duck typing
Duck typing isn't really about checking whether the things you need are there and then using them.
Duck typing is about just using what you need.
Interfaces are named collections of method signatures.
https://gobyexample.com/interfaces
--------------------------