Skip to content

Instantly share code, notes, and snippets.

# https://github.com/wallace/resque-lonely_job/blob/master/lib/resque-lonely_job.rb#L34-L42
def before_perform(*args)
unless can_lock_queue?(*args)
# can't get the lock, so re-enqueue the task
reenqueue(*args)
# and don't perform
raise Resque::Job::DontPerform
end
end
require 'rho/rhoapplication'
require 'rho/rhoutils'
class AppApplication < Rho::RhoApplication
def initialize
# Tab items are loaded left->right, @tabs[0] is leftmost tab in the tab-bar
# Super must be called *after* settings @tabs!
@tabs = nil
#To remove default toolbar uncomment next line:
#@@toolbar = nil
# Otherwise you can specify a style for each column.
ws.add_row ['Q1-2011', '26740000000', '=B5/SUM(B4:B7)'], :style => [pascal, money_pascal, percent_pascal]
ws.add_row ['Q1-2012', '46330000000', '=B6/SUM(B4:B7)'], :style => [default, money, percent]
ws.add_row ['Q1-2013(est)', '72230000000', '=B7/SUM(B4:B7)'], :style => [default, money, percent]
# You can merge cells!
ws.merge_cells 'A1:C1'
end
end
wb.add_worksheet(:name => 'Data Bar Conditional Formatting') do |ws|
ws.add_row ['A$$le Q1 Revenue Historical Analysis (USD)'], :style => title
ws.add_row
ws.add_row ['Quarter', 'Profit', '% of Total'], :style => header
# Passing one style applies the style to all columns
ws.add_row ['Q1-2010', '15680000000', '=B4/SUM(B4:B7)'], :style => pascal
p.workbook do |wb|
# define your regular styles
styles = wb.styles
title = styles.add_style :sz => 15, :b => true, :u => true
default = styles.add_style :border => Axlsx::STYLE_THIN_BORDER
pascal_colors = { :bg_color => '567DCC', :fg_color => 'FFFF00' }
pascal = styles.add_style pascal_colors.merge({ :border => Axlsx::STYLE_THIN_BORDER, :b => true })
header = styles.add_style :bg_color => '00', :fg_color => 'FF', :b => true
money = styles.add_style :format_code => '#,###,##0', :border => Axlsx::STYLE_THIN_BORDER
money_pascal = styles.add_style pascal_colors.merge({ :format_code => '#,###,##0', :border => Axlsx::STYLE_THIN_BORDER })
require 'axlsx'
p = Axlsx::Package.new
# Required for use with numbers
p.use_shared_strings = true
# adapted from http://axlsx.blogspot.com/, https://gist.github.com/2484520
require 'axlsx'
p = Axlsx::Package.new
# Required for use with numbers
p.use_shared_strings = true
p.workbook do |wb|
# define your regular styles
styles = wb.styles
@wallace
wallace / getting_barred.rb
Created April 27, 2012 17:01 — forked from randym/getting_barred.rb
Axlxs: Writing Excel With Ruby - Conditional Formatting
require 'axlsx'
p = Axlsx::Package.new
p.workbook do |wb|
# define your regular styles
styles = wb.styles
title = styles.add_style :sz => 15, :b => true, :u => true
default = styles.add_style :border => Axlsx::STYLE_THIN_BORDER
header = styles.add_style :bg_color => '00', :fg_color => 'FF', :b => true
money = styles.add_style :format_code => '#,###,##0', :border => Axlsx::STYLE_THIN_BORDER
percent = styles.add_style :num_fmt => Axlsx::NUM_FMT_PERCENT, :border => Axlsx::STYLE_THIN_BORDER
@wallace
wallace / gist:2492504
Created April 25, 2012 19:23 — forked from thommahoney/gist:2491946
RailsConf 2012 Lightning Talks
5 min:
~Objective-C + Rails:
Communicating w/rails from iOS/mac OS
Dan Hassin
1 min:
~Painless Javascript
koting hatduklgg
with wind tunnel
@wallace
wallace / gist:2492221
Created April 25, 2012 18:53 — forked from thommahoney/gist:2491946
RailsConf 2012 Lightning Talks
1 min:
~Painless Javascript
koting hatduklgg
with wind tunnel
~tenderlove.dup jremsikjr
~iwanttolearnruby.com
(collecting resources for learning ruby)