Katsuya Hidaka hidakatsuya

View Capifile
1 2 3 4 5 6 7 8 9 10
$:.unshift File.expand_path(File.dirname(__FILE__) + '/lib') # << 必ず先頭に追加
 
# Load DSL and Setup Up Stages
require 'capistrano/setup'
 
# Includes default deployment tasks
require 'capistrano/deploy'
# :
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
View README.md

ThinReports でテキストを回転させる

動作確認環境

  • ThinReports 0.7.6
  • Ruby 1.9.3, 2.0
  • Rails 3.2, 4.0

準備

View Capifile
1 2 3 4 5 6 7 8 9
require 'railsless-deploy'
 
Dir.chdir 'output'
 
set :application, 'hoge.com'
set :repository, '.'
 
set :user, 'username'
set :use_sudo, false
View README.md

Barby で作ったバーコードのサイズを調整するサンプルコード

動作確認環境

  • Mac OSX 10.8
  • Ruby 2.0.0-p195
  • ThinReports 0.7.6
  • barby 0.5.1
  • chunky_png 1.2.8
View gist:5882766
View fix-error-print-encrypted-pdf-by-prawn.rb
1 2 3 4 5 6 7 8 9
require 'thinreports'
 
# https://github.com/prawnpdf/prawn/commit/34039d13b7886692debca11e85b9a572a20d57ee
class Prawn::Core::Reference
def <<(data)
(@stream ||= "") << data
@data[:Length] = @stream.length
@stream
end
View visitor_pass
1 2 3 4 5 6 7 8 9 10
# coding: utf-8
 
class VisitorPassController < ApplicationController
def create_pass
visitor = Visitor.find(params[:id])
report = ThinReports::Report.new layout: File.join(Rails.root, 'app', 'reports', 'visitor_pass.tlf')
report.start_new_page do |page|
# jpg_filepath method will return the path of JPEG file.
# e.g. "Rails.root/photos/visitor_001.jpg"
page.item(:photo).src(visitor.jpg_filepath)
View routes.rb
1 2 3 4 5
Tasks::Application.routes.draw do
resources :tasks to
match '/', on: :collection, via: :delete, action: 'destroy_all'
end
end
View gist:3756769
1 2
sudo rm -fr /usr/local/php5*
sudo rm -fr /usr/local/packager
View gist:3622334
1 2 3 4 5 6 7 8 9 10
report = ThinReports::Report.new :layout => 'page_no.tlf'
 
report.events.on :page_create do |e|
e.page.item(:page_no).value(e.page.no)
end
 
report.events.on :generate do |e|
page_count = e.report.page_count
 
e.pages.each do |page|
Something went wrong with that request. Please try again.