A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
One-line version to paste in your DevTools
Use $$
if your browser aliases it:
~ 108 byte version
# lib/tasks/db.rake | |
namespace :db do | |
desc 'Maintains database by running command as ANALYZE, VACUUM and REINDEX' | |
task maintain: :environment do | |
verbose = ENV['VERBOSE'].present? | |
connection = ActiveRecord::Base.connection | |
puts "Maintaining database #{connection.current_database} ..." | |
connection.execute("VACUUM FULL #{'VERBOSE' if verbose}") |
def view_css | |
path = "views/#{params[:controller]}/#{params[:action]}" | |
stylesheet_link_tag(path) unless Rails.application.assets.find_asset(path).nil? | |
end |
class @GoogleAnalytics | |
@load: -> | |
# Load the analytics code | |
window['GoogleAnalyticsObject'] = 'ga' | |
window['ga'] = window['ga'] || -> | |
(window['ga'].q = window['ga'].q || []).push arguments | |
window['ga'].l = 1 * new Date() | |
# Add the script |
# google_analytics.js.coffee | |
class @GoogleAnalytics | |
@load: -> | |
window['GoogleAnalyticsObject'] = 'ga' | |
window['ga'] = window['ga'] || -> | |
(window['ga'].q = window['ga'].q || []).push arguments | |
window['ga'].l = 1 * new Date() |
# config/initializers/compression.rb | |
Rails.application.configure do | |
# Use environment names or environment variables: | |
# break unless Rails.env.production? | |
break unless ENV['ENABLE_COMPRESSION'] == '1' | |
# Strip all comments from JavaScript files, even copyright notices. | |
# By doing so, you are legally required to acknowledge | |
# the use of the software somewhere in your Web site or app: |
module Cancelerizer | |
def cancel arg | |
Sidekiq::ScheduledSet.new.each do |job| | |
(klass, method, args) = YAML.load job.args.first | |
if self == klass and args.first == arg | |
job.delete | |
end | |
end | |
end | |
end |
def social_meta_tags | |
title = "#{(content_for?(:title) ? (strip_tags(content_for(:title)).html_safe + ' / ') : '')}#{t('project_title')}" | |
description = content_for?(:description) ? content_for(:description) : '' | |
image = if @doc.present? | |
image_url(@doc.cover_photo.cover.url) | |
elsif @main.present? | |
image_url(@main.cover_photo.cover.url) | |
else | |
'' | |
end |
# Parse a CSV file reading certain attributes and outputting to Rails | |
# #create format that can be used as seed data. | |
# | |
# Not particularly good code but will do for now. | |
# | |
# Usage: | |
# $ ruby parse_pc_seed_data.rb | |
# | |
require 'csv' | |
require 'awesome_print' |
# This will move all images and other Dragonfly assets from your local server file system to Amazon S3. | |
namespace :dragonfly do | |
task :migrate_to_s3 => :environment do | |
# Adjust this line to meet your needs: | |
{ Product => [:image_uid, :other_uid], Page => :image_uid }.each do |klass, col| | |
puts "Migrating #{klass.table_name}..." | |
Array(col).each do |col| | |
klass.where("#{col} != ''").find_each do |instance| | |
begin |