start new:
tmux
start new with session name:
tmux new -s myname
#!/bin/sh | |
# | |
# Postgresql backup script | |
# http://www.bitweaver.org/wiki/pg_backup+PostgreSQL+backup+script | |
# | |
# Author | |
# | | |
# +-- speedboy (speedboy_420 at hotmail dot com) | |
# +-- spiderr (spiderr at bitweaver dot org) | |
# +-- flexiondotorg (code at flexion dot org) |
#!/bin/sh | |
# Strip color codes from Rails logs | |
# Examples: | |
# stripcolor test.log > test.log.nocolor # Save a copy of the log without color | |
# stripcolor test.log | gist # Gist the log | |
# stripcolor test.log | pbcopy # Copy the log to the clipboard in OSX | |
# stripcolor test.log | xclip -selection clipboard # Copy log to clipboard in Linux | |
cat "$@" | sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" |
[T]he difference between a bad programmer and a | |
good one is whether he considers his code or his | |
data structures more important. Bad programmers | |
worry about the code. Good programmers worry about | |
data structures and their relationships. | |
-- Linus Torvalds | |
~~~ | |
Clarity and brevity sometimes are at odds. | |
When they are, I choose clarity. | |
-- Jacob Kaplan-Moss |
Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.
One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.
Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about here.
class TracePoint | |
class Middleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
stats = {} | |
trace = TracePoint.new(:call) do |tp| |
RSpec::Matchers.define :be_monotonically_increasing do | |
match do |actual| | |
derivative = actual.each_cons(2).map{|x, y| y <=> x} | |
derivative.all?{|v| v >= 0} | |
end | |
failure_message_for_should do |actual| | |
"expected array #{actual.inspect} to be monotonically increasing" | |
end |
Press minus + shift + s
and return
to chop/fold long lines!
THIS GIST WAS MOVED TO TERMSTANDARD/COLORS
REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
Command Line
pry -r ./config/app_init_file.rb
- load your app into a pry session (look at the file loaded by config.ru)pry -r ./config/environment.rb
- load your rails into a pry sessionDebugger