Skip to content

Instantly share code, notes, and snippets.

@mgroebner
mgroebner / application_helper.rb
Last active August 29, 2015 13:57
Tickaroo Button Integration (Ruby)
module ApplicationHelper
def tickaroo_button(opts)
opts[:button_type] ||= :default
sig = TikButtonSignature.new.signature(opts)
s = ""
s += "width='#{opts[:width]}' " if opts[:width].present?
s += "height='#{opts[:height]}' " if opts[:height].present?
s += "lang='#{opts[:lang]}' " if opts[:lang].present?
s += "data-title='#{opts[title]}' " if opts[:title].present?
gem 'celluloid', '0.15.1'
require 'celluloid/autostart'
class Manager
include Celluloid
trap_exit :processor_died
def initialize
puts "manager initialized"
@mgroebner
mgroebner / gist:6578505
Last active December 23, 2015 04:09
celluloid trap exit
require 'celluloid/autostart'
class Manager
include Celluloid
trap_exit :processor_died
def initialize
@ready = 2.times.map { Processor.new_link }
end
@mgroebner
mgroebner / gist:1995665
Created March 7, 2012 20:04
ertl bullshit
def recalculate_score
reload
user_ids = users.collect{|u| u.id }
self.score_cache = 0
Category.all(:conditions => {:calculated => true}).each do |c|
self.score_cache += category.category_scores.all(:conditions => ["user_id IN (?)", user_ids], :order => "score_cache DESC", :limit => 3).sum(&:score_cache)
end
save(false)
end