Skip to content

Instantly share code, notes, and snippets.

View dinorosic's full-sized avatar

Dino Rošić dinorosic

View GitHub Profile
@denmarkin
denmarkin / resque.rake
Created September 20, 2011 11:02
My rake task for clearing Resque queues and stats
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@be9
be9 / paginate.rb
Created September 5, 2013 04:18
kaminari + JSON API pagination helper
def paginate(scope, default_per_page = 20)
collection = scope.page(params[:page]).per((params[:per_page] || default_per_page).to_i)
current, total, per_page = collection.current_page, collection.num_pages, collection.limit_value
return [{
pagination: {
current: current,
previous: (current > 1 ? (current - 1) : nil),
next: (current == total ? nil : (current + 1)),
class ParseEntries
def process(message)
entry = JSON.parse(message.value)
[entry]
end
end
class CombineEntries
def initialize
@open_transactions = {}
@jwo
jwo / example-action.js
Created August 22, 2016 21:27
Getting React and Redux React and Rails and Fetch and Safari to play nice.
export function saveOfficeStaff(section, staff) {
return (dispatch, getState) => {
const issue = getState().newsletterId;
const theData = {
staff: staff,
section_id: section.id
}
fetch(`/api/newsletters/${issue}/office_staff`, {
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers