Skip to content

Instantly share code, notes, and snippets.

@dpirotte
dpirotte / gist:760592
Created December 31, 2010 01:18
Copy formatting from one row of an xls to another row
book = Spreadsheet.open('excel-2k4-copy.xls')
[0,1].map { |n| book.worksheet(n) }.each do |sheet|
# Let's copy us some rows!
18.upto(25) do |n|
base = n.even? ? 14 : 15
sheet.row(base).formatted.formats.size.times do |f|
#puts "#{n} #{f}"
sheet[n, f] = ''
sheet.row(n).set_format(f, sheet.row(base).formatted.formats[f])
end
@dpirotte
dpirotte / count_per_line_in_file.sh
Created December 30, 2010 17:34
Find the number of tabs on each line of a huge file.
awk 'BEGIN { FS = "\t" } ; { print NF-1 }' huge_file.csv
#!/usr/bin/env ruby
numbers = %w{
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
@dpirotte
dpirotte / post.rb
Created October 1, 2009 14:57
How to use acts_as_taggable_on with searchlogic!
class Post < ActiveRecord::Base
acts_as_taggable_on :categories
# To deal with a single tag type...
scope_procedure :taggable_with_categories, lambda { |tags|
tagged_with(tags, :on => :categories)
}
# Or, deal with all your tag types...
if respond_to?(:tag_types)
$("#edit_station_1 > #station_active").bind("change", function() { alert("hi"); });