Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Daniel Rice danielricecodes

🎯
Focusing
View GitHub Profile
@danielricecodes
danielricecodes / find_unused_images.rake
Created Jan 29, 2018 — forked from rafaelp/find_unused_images.rake
Rake task to find unused images on Rails project to deletion.
View find_unused_images.rake
# It requires ACK - http://betterthangrep.com/
task :find_unused_images do
images = Dir.glob('app/assets/images/**/*')
images_to_delete = []
images.each do |image|
unless File.directory?(image)
# print "\nChecking #{image}..."
print "."
result = `ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}`
@danielricecodes
danielricecodes / find_unused_images.rake
Last active Apr 23, 2018 — forked from rafaelp/find_unused_images.rake
Rake task to find unused images on Rails project to deletion.
View find_unused_images.rake
#With Homebrew, run `brew install ack` to ensure this will work.
task :find_unused_images do
raise('ack not found!!! install it with your favorite package manager!') if `which ack`.empty?
images = Dir.glob('app/assets/images/**/*')
images_to_delete = images.inject([]) do |memo, image|
#Ignore Directories
unless File.directory?(image)
# print "\nChecking #{image}..."
@danielricecodes
danielricecodes / Deploy.rake
Created Oct 7, 2014
Boilerplate Deploy Rake File
View Deploy.rake
namespace :deploy do
desc "Deploy, migrate and restart production"
task :production do
Bundler.with_clean_env do
puts `git push origin master`
puts `git push production master`
puts `heroku pgbackups:capture DATABASE_URL --expire --app <app_name>`
puts `heroku run rake db:migrate --app <app_name>`
puts `heroku restart --app <app_name>`
@danielricecodes
danielricecodes / gist:633c464151f0f1a53e3d
Last active Aug 29, 2015
Code Test: This is real code. What does this code do?
View gist:633c464151f0f1a53e3d
function program1(depth0,data) {
var buffer = "", stack1;
buffer += "\n <img alt='";
foundHelper = helpers.product;
stack1 = foundHelper || depth0.product;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.name);
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "product.name", { hash: {} }); }
buffer += escapeExpression(stack1) + "' src='";
@danielricecodes
danielricecodes / gist:1551525
Created Jan 2, 2012
manually executing jquery ajax call instead of using remote => true in the link_to tag
View gist:1551525
li.links
= link_to ccn.name, '#', :class => 'symptom_link grey', :id => "symptom-#{ccn.id}"
javascript:
jQuery(function() {
jQuery(".symptom_link").click(function() {
jQuery.ajax("/symptom/update_possible_causes/#{ccn.name.gsub(/\s/, '-').downcase}");
});
});
You can’t perform that action at this time.