Skip to content

Instantly share code, notes, and snippets.

View buddhamagnet's full-sized avatar

Dave Goodchild buddhamagnet

  • Matrix (South) Ltd
  • Reigate Surrey UK
View GitHub Profile
@buddhamagnet
buddhamagnet / strip .svn files
Created February 7, 2011 16:00
SVN: STRIPPER
find . -name .svn -print0 | xargs -0 rm -rf
@buddhamagnet
buddhamagnet / tagkiller.git
Created May 18, 2012 08:36
GIT: TAGS: KILLER
git tag | grep staging | xargs -n 1 -I % git push origin :refs/tags/%
@buddhamagnet
buddhamagnet / safari.debug
Created May 21, 2012 09:52
OSX: SAFARI: DEBUGGER
defaults write com.apple.Safari IncludeDebugMenu 1
@buddhamagnet
buddhamagnet / scopes.rb
Created May 23, 2012 10:05
UNBOUND: SCOPES
scope :is_a, lambda { |role| joins(:roles).where("roles.name = ?", role) }
scope :subscribed_to, lambda { |book_id| joins(:subscriptions).where("subscriptions.book_id = ?", book_id) }
scope :authors, User.is_a("author")
scope :testers, User.is_a("tester")
scope :accountants, User.is_a("accountant")
scope :admins, User.is_a("admin")
@buddhamagnet
buddhamagnet / cleaner.rb
Created May 23, 2012 10:05
UNBOUND: CLEANER
def notify_subscriber_if_status_changed
if status_changed? && %w[success printed fail].include?(status)
status_message = status_notification
send_notifications(status_message)
end
end
def send_notifications(status_message)
target_market = (Rails.env.development?) ? User.testers.subscribed_to(self.id) : subscribers
target_market.each do |target|
@buddhamagnet
buddhamagnet / cruftacean.rb
Created June 8, 2012 18:36
GIT: HOOKS: PRECOMMIT
#!/usr/bin/env ruby
if `egrep -rls "^<<<<<<< |^>>>>>>> |^=======$" * | xargs file | egrep 'script|text'` != ""
puts "Merge cruft alert!"
puts `egrep -rls "^<<<<<<< |^>>>>>>> |^=======$" * | xargs file | egrep 'script|text' | awk -F: '{print $1}'`
exit(1)
end
@buddhamagnet
buddhamagnet / pry.rb
Created August 12, 2012 08:34
RAILS: CONSOLE: PRY
silence_warnings do
require 'pry'
IRB = Pry
end
@buddhamagnet
buddhamagnet / playercard.html
Created October 26, 2012 10:20
TWITTER: CARD: PLAYER
<meta property="og:description" content="Italian seismologists face time in prison, Microsoft&#039;s new platform goes mobile and a new robot poisons weeds among the lettuce" />
<meta property="og:title" content="Babbage: Lettuce pickers beware" />
<meta property="og:type" content="video.other" />
<meta property="og:url" content="http://swat2.demo.economist.com/multimedia?bclid=1294626183001&amp;bctid=1920852778001" />
<meta name="twitter:card" content="player" />
<meta name="twitter:site" content="@TheEconomist" />
<meta name="twitter:image" content="https://www.google.co.uk/images/srpr/logo3w.png" />
<meta name="twitter:player" content="https://secure.brightcove.com/services/viewer/federated_f9/?isVid=1&amp;isUI=1&amp;playerID=1761156120001&amp;videoId=1920852778001&amp;autostart=true&amp;secureConnections=true" />
<meta name="twitter:player:height" content="270" />
<meta name="twitter:player:width" content="395" />
@buddhamagnet
buddhamagnet / twittersummary.html
Last active October 12, 2015 02:37
TWITTER: CARD: SUMMARY
<meta name="twitter:card" content="summary" />
<meta name="twitter:image" content="https://media.economist.com/sites/default/files/images/print-edition/20120908_BKP001_0.jpg" />
<meta name="twitter:site" content="@TheEconomist" />
<meta property="og:description" content="The End of Men: And the Rise of Women. By Hanna Rosin. Riverhead; 310 pages; $27.95. To be published in Britain in October; £12.99. Buy from Amazon.com,..." />
<meta property="og:site_name" content="The Economist" />
<meta property="og:title" content="Female muscle" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://swat2.demo.economist.com/node/21562174" />
@buddhamagnet
buddhamagnet / mysqlboom.txt
Created January 31, 2013 08:51
MYSQL: SETTINGS
key_buffer_size=1300M
innodb_flush_log_at_trx_commit=0
innodb_buffer_pool_size=768M
innodb_log_file_size=2047M
innodb_log_buffer_size=512M
innodb_thread_concurrency=3
innodb_read_io_threads=4
innodb_write_io_threads=4
innodb_flush_method=O_DIRECT
innodb_file_per_table