Skip to content

Instantly share code, notes, and snippets.

View HansHauge's full-sized avatar

Hans Hauge HansHauge

  • Eastern Washington
View GitHub Profile
Verifying that "hanshauge.id" is my Blockstack ID. https://onename.com/hanshauge
Verifying that "hanshauge.id" is my Blockstack ID. https://onename.com/hanshauge
@HansHauge
HansHauge / gist:222550c32d2fba3e24ef
Created March 19, 2015 15:13
Rails Fragment Caching - Dalli and Memcachier
# Use a different cache store in production.
# /config/environments/production.rb
config.cache_store = :dalli_store,
(ENV["MEMCACHIER_SERVERS"] || "").split(","),
{:username => ENV["MEMCACHIER_USERNAME"],
:password => ENV["MEMCACHIER_PASSWORD"],
:failover => true,
:socket_timeout => 1.5,
:socket_failure_delay => 0.2
}
@HansHauge
HansHauge / gist:56eae8de34becb9ea8ff
Created March 19, 2015 15:06
Rails Fragment Caching - environment development
# /config/environments/development.rb
config.action_controller.perform_caching = true
@HansHauge
HansHauge / gist:30aa21a22aa0c0f5db32
Created March 19, 2015 15:02
Rails Fragment Caching @ Controller
# in your controller
time_range = (DateTime.now - 1.day)..DateTime.now
@listings = Rails.cache.fetch('front-page', expires_in: 1.hour) do
Listing.where(created_at: time_range)
end
@HansHauge
HansHauge / gist:42af3fabd8970d60756e
Created March 18, 2015 18:45
config/unicorn.rb
# If you have a very small app you may be able to
# increase this, but in general 3 workers seems to
# work best
worker_processes 3
# Load your app into the master before forking
# workers for super-fast worker spawn times
preload_app true
# Immediately restart any workers that
@HansHauge
HansHauge / gist:f4f8965a60359745ae1e
Created March 17, 2015 00:39
Rake task to call rss feed updater job
namespace :update_rss_feeds do
desc "Updates all the feeds"
task update_all: :environment do
UpdateRssFeedsJob.perform_now
end
end
class UpdateRssFeedsJob < ActiveJob::Base
attr_accessor :r_jokes_feed
queue_as :default
def perform
update_r_jokes
end
def update_r_jokes