Skip to content

Instantly share code, notes, and snippets.

View xpepper's full-sized avatar
💭
😏

Pietro Di Bello xpepper

💭
😏
View GitHub Profile
@xpepper
xpepper / devops.md
Last active August 29, 2015 14:18
on devops...

The Devops movement addresses the dysfunction that results from organizations composed of functional silos: Devops proposes instead strategies to create better collaboration between functional silos, or doing away with the functional silos altogether and creating cross-functional teams (or some combination of these approaches).

The fundamental problem is this: Bad behavior arises when you abstract people away from the consequences of their actions. Functional silos abstract people away from the consequences of their actions.

The essence of Devops, I believe, is to design a system in which people are held responsible for the consequences of their actions – and indeed, one in which the right thing to do is also the easiest thing to do.

(There’s No Such Thing as a “Devops Team” http://continuousdelivery.com/2012/10/theres-no-such-thing-as-a-devops-team/)

@xpepper
xpepper / sales taxes problem.md
Last active August 29, 2015 14:22
sales taxes problem

Sales taxes problem

This problem requires some kind of input. You are free to implement any mechanism for feeding input into your solution (for example, using hard coded data within a unit test). You should provide sufficient evidence that your solution is complete by, as a minimum, indicating that it works correctly against the supplied test data.

PROBLEM: SALES TAXES

Basic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical products that are exempt. Import duty is an additional sales tax applicable on all imported goods at a rate of 5%, with no exemptions.

When I purchase items I receive a receipt which lists the name of all the items and their price (including tax), finishing with the total cost of the items, and the total amounts of sales taxes paid. The rounding rules for sales tax are that for a tax rate of n%, a shelf price of p contains (np/100 rounded up to the nearest 0.05) amount of sales tax.

Write an application that prints out the recei

@xpepper
xpepper / teams.md
Last active August 29, 2015 14:22
Esther Derby on teams

Esther Derby on teams

(http://www.allaboutagile.com/unteams-and-real-teams/)

Here’s how I define team:

  • They have a common goal or purpose.
  • They share an approach to their work. That doesn’t mean they have a rigid process that they follow in lock-step, but they do have agreement on key elements of their work.
  • They are jointly accountable for results. If one person finishes his tasks and the rest of the team members don’t the team isn’t successful, and neither is the one who finished his tasks.
  • They are small in size, usually between 7-9 people. Some research indicates a productivity sweet spot in the 4-6 range.
  • They have shared history. Teams aren’t teams on the first day. They have to agree to be a team, and then develop enough trust and cohesion to function as a team. Overtime, they learn each others strengths and weaknesses. They learn how to make the best use of everyone’s talents.
  • Finally, teams build their capacity through their work.
@xpepper
xpepper / play.and.jboss.md
Created June 23, 2015 08:28
Let playframework play well with your JBoss

il jar da cambiare è :

    com.typesafe.play.play_2.10-2.2.6.jar

le classi da rimuovere sono :

    play\api\Logger$.class        
    play\api\Logger.class
@xpepper
xpepper / capistrano_rails_guide.md
Created March 22, 2012 23:10 — forked from jrochkind/gist:2161449
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@xpepper
xpepper / class_detector.rb
Created April 4, 2012 21:47
How do you tell if a Ruby object is a class?
class Object
def is_a_class?
respond_to? :superclass
end
end
class MyClass
end
@xpepper
xpepper / class_method_lookup.rb
Created April 22, 2012 22:45
Class method lookup
class Parent
class << self
def who_am_i
puts "I'm #{self}"
end
def singleton
class << self; self; end
end
end
@xpepper
xpepper / document.rb
Created May 16, 2012 12:23
Adding autoload feature to a Ruby class
class Document
def self.reload
instance_methods(false).each { |m| remove_method(m) }
class << self
Document.methods(false).reject {|m| m == "reload" }.each do |m|
remove_method(m)
end
end
load(__FILE__)
@xpepper
xpepper / issues_with_modules.md
Created December 1, 2012 20:44 — forked from ryanb/issues_with_modules.md
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article &lt; ActiveRecord::Base
def search(search_options)
name_regexp = search_options[:name_regexp] || ""
starting_date = search_options[:starting_date] || Date.today
ending_date = search_options[:ending_date] || Date.today
where(:name => /#{name_regexp}/, "efforts.date" => {'$gte' => Date.parse(starting_date)}, "efforts.date" => {'$lte' => Date.parse(ending_date)})
end