Skip to content

Instantly share code, notes, and snippets.

#!/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)
@stevenh512
stevenh512 / stripcolor
Created March 30, 2012 02:22
Strip color codes from Rails logs
#!/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"
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 2, 2024 11:04
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@OnesimusUnbound
OnesimusUnbound / quote.txt
Last active August 16, 2023 16:24
Programming Quotes
[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
@vsavkin
vsavkin / domain.md
Created August 25, 2012 14:23
Building Rich Domain Models in Rails

Building Rich Domain Models in Rails

Abstract

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.

@mattetti
mattetti / tracepoint_middlware.rb
Created March 6, 2013 06:34
test middleware for Ruby 2.0 logging the method dispatches going on when a request is being handled.
class TracePoint
class Middleware
def initialize(app)
@app = app
end
def call(env)
stats = {}
trace = TracePoint.new(:call) do |tp|
@bunnymatic
bunnymatic / custom_array_matchers.rb
Last active July 3, 2020 21:24
RSpec Matchers for increasing/decreasing array tests. Useful when sort may not be the easiest way to do things.
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
@hofmannsven
hofmannsven / README.md
Last active May 3, 2024 15:30
Git CLI Cheatsheet
@XVilka
XVilka / TrueColour.md
Last active May 28, 2024 17:42
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@lfender6445
lfender6445 / gist:9919357
Last active May 12, 2024 19:09
Pry Cheat Sheet

Pry Cheat Sheet

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 session

Debugger