Skip to content

Instantly share code, notes, and snippets.

View raskhadafi's full-sized avatar

Roman raskhadafi

  • Zürich
  • 10:52 (UTC +02:00)
View GitHub Profile
fny / assets.rb
Created July 8, 2015 01:09
Dry Up Your Initializers with #tap
# Before
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.paths << Emoji.images_path
Rails.application.config.assets.precompile += %w( search.js )
# After
Rails.application.config.assets.tap do |assets|
assets.version = '1.0'
assets.paths << Emoji.images_path
assets.precompile += %w( search.js )
mklnz / capistrano_sudo_helpers.rb
Created April 17, 2012 18:12
Sudo put and template methods for Capistrano
# I got tired of uploading to /tmp then moving to the correct location, so these two convenience methods will save you a lot of time in the long run.
# Helper method to upload to /tmp then use sudo to move to correct location.
def put_sudo(data, to)
filename = File.basename(to)
to_directory = File.dirname(to)
put data, "/tmp/#{filename}"
run "#{sudo} mv /tmp/#{filename} #{to_directory}"
xdite / gist:3106785
Created July 13, 2012 19:15
Speedup Rails Asset Pipeline precompile process
adamcooke / dsl.rb
Created November 7, 2014 15:20
The complete code from my DSL tutorial at
class AddressBook
def contacts
@contacts ||= []
def self.load_from_path(path)
# Create a new AddressBook instance
address_book =
# Create a new AddressBookDSL instance
sj26 / assets.rake
Last active May 13, 2023 04:42
Don't discard cache during asset precompile. Full explanation and caveats:
# Stick this in lib/tasks/assets.rake or similar
# A bug was introduced in rails in 7f1a666d causing the whole application cache
# to be cleared everytime a precompile is run, but it is not neccesary and just
# slows down precompiling.
# Secondary consequences are the clearing of the whole cache, which if using
# the default file cache could cause an application level performance hit.
# This is already fixed in sprockets-rails for rails 4, but we patch here for
lelandbatey /
Last active June 2, 2024 11:23
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!


This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"