This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def tabalize(headings, justifications = nil, out = STDOUT) | |
raise ArgumentError.new('only works on an array of arrays') if size > 0 && ![0].is_a?(Array) | |
raise ArgumentError.new('headings, justifications and array elements must all have the same number of elements') if size > 0 && (headings.size != [0].size) && (!justifications.nil? && (headings.size != justifications.size)) | |
sizes = Array.new(headings.size, 0) | |
headings.each_with_index do |h,i| | |
sizes[i] = [sizes[i], h.to_s.length].max | |
end | |
each do |row| | |
row.each_with_index do |e, i| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'right_aws' | |
namespace :utils do | |
namespace :attachments do | |
task :initialize_s3 => :environment do | |
s3_config = YAML.load_file(File.join(File.dirname(__FILE__), '/../../config/amazon_s3.yml')) | |
s3_config = s3_config[RAILS_ENV].to_options | |
@s3 = RightAws::S3.new(s3_config[:access_key_id], s3_config[:secret_access_key]) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChangePhotoFromAttachmentFuToPaperclip < ActiveRecord::Migration | |
def self.up | |
#Reorganise the actual photos on AWS to suit the RWS/Paperclip schema | |
#Rename attachement_fu columns to paperclip convention | |
rename_column :photos, :filename, :photo_file_name | |
rename_column :photos, :content_type, :photo_content_type | |
rename_column :photos, :size, :photo_file_size | |
#Remove non-paperclip columns | |
remove_column :photos, :width |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- has_attachment :content_type => :image, | |
- :thumbnails => { | |
- :thumb => [80,80], | |
- :small => '320x320>' | |
- }, | |
- :storage => :s3, | |
- :s3_access => :private | |
+ | |
+ has_attached_file :photo, | |
+ :styles => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prawn::Document.generate "test.pdf" do | |
stroke_horizontal_rule | |
text "Some text\nwith a line break" | |
stroke_horizontal_rule | |
move_down 10 | |
stroke_horizontal_rule | |
text "Some <b>bold</b> text<br />with a line break" | |
stroke_horizontal_rule | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prawn::Document.generate "test.pdf" do | |
stroke_horizontal_rule | |
text "Some text\nwith a line break" | |
stroke_horizontal_rule | |
move_down 10 | |
stroke_horizontal_rule | |
text "Some <b>bold</b> text<br />with a line break" | |
stroke_horizontal_rule | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_y = y | |
bounding_box [0, cursor], :width => margin_box.width / 2 do | |
text "Text for the left column" | |
end | |
left_end_y = y | |
y = start_y | |
bounding_box [margin_box.width / 2, cursor], :width => margin_box.width / 2 do | |
text "Text for the right column\nthat is more than one line\nso that the right column is larger" | |
end | |
right_end_y = y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
columns(2, :width => margin_box.width) do | |
column do | |
text "Text for the left column" | |
end | |
column do | |
text "Text for the right column\nthat is more than one line\nso that the right column is larger" | |
end | |
end | |
text "Some text that will be below both columns" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppServerConfiguration | |
attr_accessor :port, :admin_password | |
end | |
class Configuration | |
attr_accessor :tail_logs, :max_connections, :admin_password | |
def app_server(&block) | |
if block_given? | |
@app_server_config = AppServerConfiguration.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
col1 = [] | |
col2 = [] | |
col3 = [] | |
col4 = [] | |
col5 = [] | |
File.open("C:\\Documents and Settings\\Desktop\\test.txt", "r") do |infile| | |
while(line = infile.gets) | |
numbers = line.split(/\s*,\s*/) | |
col1 << numbers[0].to_i | |
col2 << numbers[1].to_i |
OlderNewer