Skip to content

Instantly share code, notes, and snippets.

View hidakatsuya's full-sized avatar
🏡
Working from home

Katsuya HIDAKA hidakatsuya

🏡
Working from home
View GitHub Profile
@hidakatsuya
hidakatsuya / thinreports-example-eudc.rb
Created November 8, 2011 06:24
ThinReports Example: EUDC
# coding: utf-8
require 'rubygems'
require 'thinreports'
ThinReports.configure do
generator.pdf.eudc_fonts = 'eudc.ttf'
end
ThinReports::Report.generate_file('eudc.pdf', :layout => 'eudc.tlf') do
@hidakatsuya
hidakatsuya / thinreports-example-security.rb
Created November 8, 2011 07:12
ThinReports Example: Security
# coding: utf-8
require 'rubygems'
require 'thinreports'
report = ThinReports::Report.new :layout => 'security.tlf'
report.start_new_page
# See more details:
# [Prawn Documentation]
@hidakatsuya
hidakatsuya / sample-create-barcode-using-ghostscript.rb
Created March 9, 2012 16:56
Create a bar code using Ghostscript
# coding: utf-8
require 'rghost'
require 'rghost_barcode'
require 'thinreports'
RGhost::Config::GS[:path] = '/usr/local/bin/gs'
bar = RGhost::Document.new :paper => ['10 cm', '1 cm']
bar.barcode_japanpost '26300233-30-8-403',
@hidakatsuya
hidakatsuya / string-replacement-on-vim
Created May 21, 2012 06:37
String Replacement on Vim
最短マッチ
<.\{-}> #=> <a><b> = "<a>"
改行を含む任意の一文字
\_.* #=> foo\nbar\nhoge = "foo\nbar\nhoge"
CAUTION:
注意すべきは、"\"は「円(¥)」ではなく「バックスラッシュ」であること
MEMO:
@hidakatsuya
hidakatsuya / gist:2892866
Created June 8, 2012 01:29
Example Exec multi-action
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script>
function hoge() {
$.ajax({
type: 'get',
@hidakatsuya
hidakatsuya / gist:3245721
Created August 3, 2012 08:14
Hellow World using ThinReports
# coding: utf-8
require 'thinreports'
report = ThinReports::Report.new :layout => 'hello_world.tlf'
report.start_new_page do
item(:hello_world).value('World')
end
report.generate_file('hello_world.pdf')
# coding: utf-8
require 'thinreports'
report = ThinReports::Report.new :layout => 'dynamic_image.tlf'
report.start_new_page do
item(:image).src('rails.png')
end
@hidakatsuya
hidakatsuya / hoge.rb
Created August 16, 2012 03:59
How to show PDF in browser
class TasksController < ApplicationController
def index
@tasks = Tasks.all
respond_to do |format|
format.html
# GET /tasks.pdf
# response as pdf
format.pdf do
report = ThinReports::Report.new :layout => 'tasks.tlf'
# app/controllers/tasks_controller.rb
class TasksController < ApplicationController
def index
@tasks = Task.all
end
end
# app/views/tasks/index.pdf.thinreports
report.set_layout
@tasks.each do |task|
report.list.add_row :name => task.name
end