This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Story time: Classy Switch Classes | |
# Say you have a bunch of messages coming in Slack and you'd like to add an automatic emoji | |
# of course your team is multicultural and you may want to cater to the diverse crowd you have. | |
# For the purpose of this exercise we will treat `message#emojis` and `message#replies` as arrays we can push to. | |
# You could write your code like this: | |
if message.text.include?("Good morning!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# After installing ruby-debug19, run this file. | |
# | |
# References: | |
# http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug | |
# http://stackoverflow.com/questions/8087610/ruby-debug-with-ruby-1-9-3 | |
echo "Installing ruby-debug with $MY_RUBY_HOME ..." | |
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem | |
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
# SETUP: | |
# (assumes ~/bin/ is in your path) | |
# cp colorize.rb ~/bin/colorize | |
# chmod +x ~/bin/colorize | |
# USAGE: | |
# tail -f log/development.log | colorize | |
class String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A friend of mine, approaching 50, works as a programmer in a medium sized consultancy. In a recent conversation he told me how he felt like he was feeling older now that they had hired many 20-somethings in his company. The younger developers, he said, would do things faster than he would and it started to look like he was just a slower developer than the more youthful new hires. He was wondering if his days were numbered. | |
He was resigning himself to the idea that he was experiencing some kind of decline of his faculties if he compared himself to the more youthful years of his career. However this wasn’t the only conversation I had about the work at his company. The conversation before that one had him put the finger on something crucial. | |
So I had a conversation with him about it and we connected the dots. | |
Me: What was the password story they tackled? | |
Him: A password reset. | |
Me: And what was wrong with how they implemented it. | |
Him: Well the user typed their email in and then if they click the “forgot passw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# initiate the change with an interactive rebase from the point you want | |
git rebase -i SHA^ | |
git reset HEAD^ | |
# do this as many times as you need. | |
git add -p | |
git commit -v | |
# once all your changes are committed | |
git rebase --continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instead of rebooting system | |
# If audio has half going through speakers and half going through headphones. | |
ps aux | grep 'coreaudio[d]' | awk '{print $2}' | xargs sudo kill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "awesome_print" | |
Pry.print = proc { |output, value| output.puts value.ai } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loop { Thread.new { sleep } rescue puts "Borked at #{Thread.list.count} threads." } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run psql command to get to this | |
# Replace APP_NAME with application name | |
grant all privileges on database APP_NAME_dev to postgres; | |
grant all privileges on database APP_NAME_test to postgres; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
config.before(:suite) do | |
connection = ActiveRecord::Base.connection | |
query = connection.tables.map { |t| "ALTER TABLE #{t} SET UNLOGGED;" }.join("\n") | |
# one line for each foreign_key at the end of your schema.rb | |
ActiveRecord::Migration.remove_foreign_key "reports", "users" | |
connection.execute(query) | |
end |