Skip to content

Instantly share code, notes, and snippets.

View petrblaho's full-sized avatar

Petr Blaho petrblaho

  • Brno, Czech Republic
View GitHub Profile
@petrblaho
petrblaho / datasize.rake
Created February 10, 2010 06:57
database size rake task
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
@petrblaho
petrblaho / Gemfile
Created February 26, 2010 20:34 — forked from indirect/Gemfile
# include at least one source and the rails gem
source :gemcutter
gem "rails", "~> 2.3.5", :require => nil
gem "sqlite3-ruby", :require => "sqlite3"
# Devise 1.0.2 is not a valid gem plugin for Rails, so use git until 1.0.3
# gem "devise", :git => "git://github.com/plataformatec/devise.git", :ref => "v1.0"
group :development do
# bundler requires these gems in development
@petrblaho
petrblaho / gist:1016755
Created June 9, 2011 13:45 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
module MyApp
class IncViewsCounterFor < ::Liquid::Tag
Syntax = /(#{::Liquid::Expression}+)?/
def initialize(tag_name, markup, tokens, context)
if markup =~ Syntax
@name = $1
else
raise ::Liquid::SyntaxError.new("Syntax Error in 'inc_views_counter_for' - Valid syntax: inc_views_counter_for <content>")
@petrblaho
petrblaho / rdio-next.sh
Last active August 29, 2015 14:11 — forked from jistr/rdio-next.sh
#!/bin/bash
set -eo pipefail
xdotool key --window $(xdotool search --name 'Rdio \- Mozilla Firefox') bracketright