Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
if ARGV.size == 0
puts "Usage: findlogs <directory>"
exit
end
require 'find'
class Numeric
class ActiveRecord::Base
def force_update_attribute(attribute, value)
self.connection.update_sql("UPDATE #{self.class.name.tableize} SET #{attribute.to_s} = #{self.connection.quote(value)} WHERE id = #{self.connection.quote(id)}")
self.reload
end
end
if Rails.env.test?
class TCPSocket
alias_method :old_initialize, :initialize
def initialize(*args)
if !['localhost', '127.0.0.1', 'www.example.com'].include?(args.first)
# Uncomment and comment the raise line to log all the violations
# logger = Logger.new(File.join(Rails.root, 'log', 'open_sockets.log'))
# logger.info "#{Time.now}: #{args.inspect}"
raise "#{Time.now}: #{args.inspect}"
end
def show_callbacks(klass)
ActiveRecord::Callbacks::CALLBACKS.each do |type|
puts "#{type}"
klass.send("#{type}_callback_chain").each {|c| puts " #{c.method}"}
puts
end
end
@alvarobp
alvarobp / gist:1122327
Created August 3, 2011 10:14
[Chef] Check node architecture
case node[:languages][:ruby][:host_cpu]
when "x86_64"
when "i686"
end
@alvarobp
alvarobp / remote_pairing_setup.md
Last active November 9, 2024 00:13
Setting up a remote pair station with SSH + TMUX and/or Reverse SSH Tunnel

Disclaimer: The following examples try to give an overview of the process followed in different scenarios. Some commands were actually written from memory. Some tools might exist simplifying all this. Furthermore, I'm no expert so if anyone ever reads this and knows any improvement, please let me know.

Case 1: Direct access to Pairing Station

Given that the Guest User can access the Pairing Station directly, either because the station is publicly available or because NAT port forwarding can be used, there's only one thing we need to do, give ssh access to the Guest User by adding his ssh public key to our Local User (pair) .ssh/authorized_keys file.

The local user would open up a tmux session with

tmux new-session -s pairing
@alvarobp
alvarobp / trainer.sh
Last active August 29, 2015 14:09
Kata Trainer
# mkdir kata-name; cd kata-name
# git init .
# curl -sL https://gist.github.com/alvarobp/be0adbec727dca097f84/raw -o trainer.sh
# git add trainer.sh
# echo 'trainer.sh' > .gitignore
# git add .gitignore
# git commit -m'Kata with trainer.sh'
# sh trainer.sh
PERIOD=${PERIOD:-120}
play :E
sleep 0.5
play :E
sleep 0.5
play :G
sleep 1
play :E
sleep 0.5
play :E
@alvarobp
alvarobp / rtanque-instructions.md
Last active June 6, 2016 13:24
RTanque Instructions
@alvarobp
alvarobp / pull_all.sh
Last active April 16, 2020 12:04
Pull from all git repositories within current directory
#!/usr/bin/env bash
function filter_directories () {
grep -ve '^\(.\|./IgnoreA\|./IgnoreB\)$'
}
failed=""
for directory in $(find . -maxdepth 1 -type d | filter_directories | sort); do
pushd $directory &> /dev/null