Skip to content

Instantly share code, notes, and snippets.

View mkdynamic's full-sized avatar

Mark Dodwell mkdynamic

View GitHub Profile
@mkdynamic
mkdynamic / gist:109588
Created May 10, 2009 10:59
Shows the sizes of all mysql databases
`which mysql` -u root -p INFORMATION_SCHEMA -e 'SELECT s.schema_name,
CONCAT(IFNULL(ROUND((SUM(t.data_length)
+SUM(t.index_length))/1024/1024,2),0.00),"Mb") total_size,
CONCAT(IFNULL(ROUND(((SUM(t.data_length)+SUM(t.index_length))
-SUM(t.data_free))/1024/1024,2),0.00),"Mb") data_used,
CONCAT(IFNULL(ROUND(SUM(data_free)/1024/1024,2),0.00),"Mb") data_free,
IFNULL(ROUND((((SUM(t.data_length)+SUM(t.index_length))
-SUM(t.data_free))/((SUM(t.data_length)
+SUM(t.index_length)))*100),2),0) pct_used,
COUNT(table_name) total_tables
@mkdynamic
mkdynamic / gist:109589
Created May 10, 2009 11:01
Fix Safari 4 dubious UI decisions
shitari(){
defaults write com.apple.Safari DebugSafari4TabBarIsOnTop -bool NO
defaults write com.apple.Safari DebugSafari4IncludeToolbarRedesign -bool NO
defaults write com.apple.Safari DebugSafari4LoadProgressStyle -bool NO
echo 'Fixed.'
}
@mkdynamic
mkdynamic / gist:109591
Created May 10, 2009 11:02
Shortcut for TextMate – open project file if exists, or just open the directory if not
mm(){
[ -f *.tmproj ] && open -a 'textmate' `ls -lG *.tmproj | awk '{print $9}'` || mate .
}
@mkdynamic
mkdynamic / gist:109592
Created May 10, 2009 11:04
Remove .svn recursively from current directory
alias desvn='find . -name ".svn" -exec rm -rf {} \;'
@mkdynamic
mkdynamic / gist:109615
Created May 10, 2009 13:30
Abandon Cucumber for projects where *I am* the client!
require 'test_helper'
class SignupTest < ActionController::IntegrationTest
test "signing up" do
# Given there are X users
2.times { Factory(:user) }
users_count = User.count
# When I go to the signup page
@mkdynamic
mkdynamic / gist:191916
Created September 23, 2009 10:54
Spit out gems.yml and .gems in root of Rails app
namespace :gems do
desc "Spit out gems.yml and .gems in root of app (for Heroku + EY etc.)"
task :specify => :environment do
gems = Rails.configuration.gems
# output gems.yml
yaml = File.join(RAILS_ROOT, "gems.yml")
File.open(yaml, "w") do |f|
output = []
gems.each do |gem|
@mkdynamic
mkdynamic / gist:198559
Created September 30, 2009 23:23
Paperclip, S3 & Delayed Job
#
# Add a :processing flag to our model
#
class AddProcessingToImages < ActiveRecord::Migration
def self.up
add_column :images, :processing, :boolean
end
def self.down
/* the joy of browser standards... seriously, IE8 - why? */
.foo {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; /* IE 8 */
filter: alpha(opacity=50); /* IE 6 + 7 */
-khtml-opacity: 0.50; /* Safari < 1.2 (KHTML) */
-moz-opacity: 0.50; /* FF < 1.5, Mozilla <= 1.6 */
opacity: 0.50; /* FF 1.5+, Safari 1.2+, Opera 9+ (CSS3) */
}
context "#domain" do
should "return correct domain from given host" do
examples = {
"foo.bar.mydomain.com" => "mydomain.com",
"foo.bar.www.mydomain.com" => "www.mydomain.com",
"foo.bar.www.mydomain.co.uk" => "www.mydomain.co.uk",
"www.mydomain.com" => "www.mydomain.com",
"foo.mydomain.co.uk" => "mydomain.co.uk",
"foo.bar.www.my-domain.com" => "www.my-domain.com",
"foo.m.net" => "m.net",
@mkdynamic
mkdynamic / bundles.sh
Created June 18, 2010 02:31
Install all of http://github.com/phuibonhoa's TM bundles (OS X only)
#!/usr/bin/env bash
#
# install all of http://github.com/phuibonhoa's TM bundles (OS X only)
#
echo "Installing bundles..."
# backup dir
if [ -d ~/desktop/_tm_bundle_backups ]; then rm -rf ~/desktop/_tm_bundle_backups; fi