Skip to content

Instantly share code, notes, and snippets.

View alexdesi's full-sized avatar

Alessandro De Simone alexdesi

View GitHub Profile
@dhh
dhh / test_induced_design_damage.rb
Last active June 22, 2023 06:18
This is an extraction from Jim Weirich's "Decoupling from Rails" talk, which explained how to apply the hexagonal design pattern to make every layer of your application easily unit testable (without touching the database etc). It only seeks to extract a single method, the EmployeesController#create method, to illustrate the design damage that's …
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end
@andrey-skat
andrey-skat / deploy.rb
Last active August 5, 2018 12:03
Local assets precompilation on Rails 4 using Capistrano 3
# also you need to uncomment next line in Capfile
# require 'capistrano/rails/assets'
namespace :deploy do
namespace :assets do
Rake::Task['deploy:assets:precompile'].clear_actions
desc 'Precompile assets locally and upload to servers'
task :precompile do
@altamic
altamic / golden_rule_for_software_development.md
Last active December 24, 2015 09:49
Golden Rule for Software Development

Never deliver code liable to exploit the well-being of colleagues

What you can do

If you agree with the above principle, you are encouraged to adopt measures so that a such conduct can be effectively applied in your environment.

If you are a developer, be ready to point out (perhaps in writing) that you are willing to take full responsibility of your code and for this reason you are expected in some situation (i.e. insufficient technical experience, insufficient aptitude, etc.) to proclaim the impossibility to deliver code for ethical reasons conflicting with the principle. Reciprocally, you should have the right to know the position of each member of your team about the principle.

@manuelmorales
manuelmorales / push_branch_and_set_tracking.sh
Created September 28, 2011 09:15
Make git pull and push always do it from the same branch
# From http://mislav.uniqpath.com/2010/07/git-tips/
# git push will by default push all branches that have the same name on the remote.
# To limit this behavior to just the current branch, set this configuration option:
git config --global push.default tracking
git config push.default tracking
# pushes the "master" branch to "origin" remote and sets up tracking
@manuelmorales
manuelmorales / custom_gemfiles.sh
Created August 24, 2011 16:00
Custom Gemfiles
# define your BUNDLE_GEMFILE environment variable
# NOTE: Ubuntu users must use .bashrc instead of .bash_profile
echo "export BUNDLE_GEMFILE=Gemfile.dev" >> ~/.bash_profile
# reload your terminal
source ~/.bash_profile
# install the bundler gem
gem install bundler
" search across files in vim
:lgrep -r pattern dir_1 dir_2
:lopen
" go to next file
:lnf
" go to next or previous match
:lnext
:lprev