This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/paperclip_processors/transparency.rb | |
module Paperclip | |
class Transparency < Thumbnail | |
# Find the background and replace with transparency. | |
# -fuzz 20% simulates antialiasing | |
CONVERT_OPTIONS = [ | |
'-alpha', 'set', | |
'-fill', 'white', | |
'-draw', "'color 0,0 replace'", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin base() | |
.selector { | |
@include base( | |
positioning: { | |
position: absolute; | |
}, | |
box-model: { | |
width: 100%; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$property-groups: positioning, box-model, color, text; | |
@each $property-group in $property-groups { | |
@mixin $property-group { | |
@content; | |
} | |
} | |
.selector { | |
@include positioning { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Setup: | |
# Add this file to your $PATH | |
# Usage: | |
# git assign | |
changed_files=$(git diff --name-only HEAD master) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git-assign() { | |
changed_files=$(git diff --name-only HEAD master) | |
authors=$(echo "$changed_files" | xargs -L1 git log --follow | grep Author:) | |
printf "Authors in order of commits made to these files:\n\n" | |
printf "$changed_files\n\n" | |
printf "$authors" | sort | uniq -c | sort -r | sed 's/Author:/Commits:/g' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveResource::Base | |
include ActiveModel::Dirty | |
def update_attribute(name, value) | |
self.send :"#{name}_will_change!" | |
self.send("#{name}=".to_sym, value) | |
self.save | |
end | |
def update_attributes(attributes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveResource | |
class LogSubscriber < ActiveSupport::LogSubscriber | |
def request(event) | |
result = event.payload[:result] | |
info "#{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}" | |
if event.payload.has_key?(:exception) | |
error "#{event.payload[:exception].join(' ')}\n" | |
else | |
info "STATUS %d %s %d (%.1fms)" % [result.code, result.message, result.body.to_s.length, event.duration] | |
info "BODY #{result.body}\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveResource::Base | |
attr_accessor :dirty_attributes | |
def update_attribute(name, value) | |
dirty_attributes ||= [] | |
dirty_attributes << name.to_sym | |
super(*args) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'action_dispatch/middleware/show_exceptions' | |
module ActionDispatch | |
class ShowExceptions | |
private | |
def render_exception_with_template(env, exception) | |
body = ErrorsController.action(ActionDispatch::ExceptionWrapper.rescue_responses[exception.class.name]).call(env) | |
body[1]['Content-Type'] = "application/json; charset=utf-8" | |
body | |
rescue => e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('body').prepend('<div id="grid-overlay" style="display:none;width:100%;height:100%;position:fixed;z-index:99999999;margin-left:-20px;"></div>'); | |
$(new Array(30)).each(function() { | |
$('#grid-overlay').append('<div style="float:left;width:60px;height:100%;margin-left:20px;background:rgba(255,153,153,0.2);"></div>'); | |
}); | |
keydown_show_grid = function(event) { | |
if(event.which == 71) { | |
$('#grid-overlay').toggle(); | |
} | |
}; |
NewerOlder