Skip to content

Instantly share code, notes, and snippets.

@guiltry
guiltry / gist:0630b46560894f84f984705f1f28deb9
Created April 4, 2016 15:57
Remove all pip dependencies
for dep in $(pip show somepackage | grep Requires | sed 's/Requires: //g; s/,//g') ; do pip uninstall -y $dep ; done
development:
sessions:
default:
database: sribulancer_development
hosts:
- <%= "#{ENV['SRIBULANCER_DB_1_PORT_27017_TCP_ADDR']}:#{ENV['SRIBULANCER_DB_1_PORT_27017_TCP_PORT']}" %>
options:
pool_size: 201
options:
raise_not_found_error: false
web:
build: .
command: bundle exec rails s
volumes:
- .:/myapp
ports:
- "3000:3000"
links:
- db
- redis
FROM ruby:2.1.2
RUN apt-get update -qq
RUN apt-get install -y debian-keyring debian-archive-keyring
RUN apt-key update
RUN apt-get install -y build-essential qt5-default libqt5webkit5-dev xvfb
RUN mkdir /myapp
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
grep -v development |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
class Factory::User
def self.make_user(user_type)
if user_type == "Knight"
@user = Knight.new
# Do some Knight specific operation
elsif user_type == "Archer"
@user = Archer.new
# Do some Archer specific operation
end
class Factory::User
def self.make_user(_user_params)
if user_params[:type] == "Knight"
@user = Knight.new(_user_params)
@user.increase_strength(10)
@user.decrease_agility(4)
# You can add specific logic that come from "unexpected feature" here.
# Without editing all logic-contained files.
class User < ActiveRecord::Base
end
class Knight < User
end
class Archer < User
end
class UserController < ApplicationController
class Order < ActiveRecord::Base
after_initialize :change_strategy
def set_paid_strategy(paid_strategy)
@paid_strategy = paid_strategy
end
def set_unpaid_strategy(unpaid_strategy)
@unpaid_strategy = unpaid_strategy
end
class Order < ActiveRecord::Base
after_initialize :change_state
def set_state(order_state)
@state = order_state
end
def change_state
# we keep this logic block, to choose what state logic the object use at initialization
if self.status == Order::PAID