Skip to content

Instantly share code, notes, and snippets.

# require email receipt
headers['Return-Receipt-To'] = 'confirm@example.com'
# importance flag on the email
headers['Importance'] = 'high'
headers['X-Priority'] = '1'
headers['X-MSMail-Priority'] = 'High'
@house9
house9 / routes.rb
Created November 28, 2012 00:13
all routes and actions
all_routes = Rails.application.routes.routes
all_routes.each do |route|
if route.requirements.has_key?(:controller) and route.requirements[:controller] != "rails/info" then
puts "#{route.requirements[:controller]} #{route.requirements[:action]}"
end
end
@house9
house9 / build-and-execute-multiple-git-commands.sh
Created October 31, 2012 20:23
build and execute multiple git commands
### matches all git tags that start with numeric value, update regex as needed
# commands to remove local tags
git tag -l | grep "^\d" | sed 's/^/tag -d /' > _remove_tags
# commands to remove remote tags
git tag -l | grep "^\d" | sed 's/^/push origin :refs\/tags\//' > _remove_tags_remote
# review contents of file
cat _remove_tags | while read line; do echo $line; done
# execute each line in file
@house9
house9 / _javascript_object_invoke.html.erb
Created September 29, 2012 15:57
rails asset pipeline - auto invoke javascript based on controller / action
<!--
1) include in layout files after all other javascript includes
2) if you have coffeescript classes that match your controller name - they will be invoked automatically
WARNING: as a general rule don't write js like this with ruby mixed in,
this is one of those rare cases where it 'works' well
-->
<script>
$(document).ready(function () {
-- changes joe.smith@gmail.com -> joe.smith@qa.com
update users set email = replace(replace(regexp_matches(email, '.*@')::varchar, '{', ''), '}', '') || 'qa.com';
-- there must be a better way to get rid of the {} chars returned by regexp_matches
select md5(random()::text)
psql your_db -c "update users set is_active = 'f';"
@house9
house9 / postgres_rebuild.sql.sh
Created April 29, 2012 18:33
Postgres Rebuild database
psql postgres -c "select pg_terminate_backend(procpid) from pg_stat_activity where datname='your_db';"
dropdb your_db
createdb --template=template0 --encoding=unicode your_db
@house9
house9 / postgres_disconnect.sql.sh
Created April 29, 2012 18:30
Postgres Disconnect
# replace your_db with the name of your database
psql postgres -c "select pg_terminate_backend(procpid) from pg_stat_activity where datname='your_db';"