Skip to content

Instantly share code, notes, and snippets.

View danielricecodes's full-sized avatar
👨‍💻
www.railsagency.com

Daniel Rice danielricecodes

👨‍💻
www.railsagency.com
View GitHub Profile
# config/initializers/instrumentation.rb
# Subscribe to grape request and log with Rails.logger
ActiveSupport::Notifications.subscribe('grape.request') do |name, starts, ends, notification_id, payload|
Rails.logger.info '[API] %s %s (%.3f ms) -> %s %s%s' % [
payload[:request_method],
payload[:request_path],
(ends-starts)*1000,
(payload[:response_status] || "error"),
payload[:x_organization] ? "| X-Org: #{payload[:x_organization]}" : "",
@danielricecodes
danielricecodes / arrow-heroku.aptfile
Last active June 30, 2021 22:38 — forked from jeroen/arrow-ubuntu.sh
Install arrow on Ubuntu
:repo:deb [trusted=yes arch=amd64] https://apache.jfrog.io/artifactory/arrow/ubuntu/ focal main
libarrow-dev
libparquet-dev
libarrow-glib-dev
libparquet-glib-dev
libgirepository-1.0-1
libgirepository1.0-dev
@danielricecodes
danielricecodes / find_unused_images.rake
Created January 29, 2018 14:58 — forked from rafaelp/find_unused_images.rake
Rake task to find unused images on Rails project to deletion.
# 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 April 23, 2018 18:59 — forked from rafaelp/find_unused_images.rake
Rake task to find unused images on Rails project to deletion.
#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 October 7, 2014 20:56
Boilerplate Deploy Rake File
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 August 29, 2015 14:00
Code Test: This is real code. What does this code do?
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 January 2, 2012 17:53
manually executing jquery ajax call instead of using remote => true in the link_to tag
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}");
});
});