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 / number_with_delimiter.js
Created April 20, 2011 03:08
Create number with delimitation on JavaScript
function numberWithDelimiter(n) {
n = String(n);
while(n != (n = n.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
return n;
}
@hidakatsuya
hidakatsuya / thinreports-example-book-detail.rb
Created August 17, 2011 06:56
ThinReports Example: Book Detail Sample
# coding: utf-8
require 'rubygems'
require 'thinreports'
report = ThinReports::Report.new :layout => 'book_detail.tlf'
report.start_new_page do |page|
page.item(:title).value('はじめての「ThinReports」')
page.item(:author).value('帳票 太郎')
@hidakatsuya
hidakatsuya / thinreports-example-tblock.rb
Created August 17, 2011 06:04
ThinReports Example: Text Block Tool
# coding: utf-8
require 'rubygems'
require 'thinreports'
ThinReports::Report.generate_file('tblock.pdf', :layout => 'tblock.tlf') do
start_new_page
page.values :single_line_left => 'Left(Default)',
:single_line_center => 'Center',
@hidakatsuya
hidakatsuya / thinreports-example-events.rb
Created August 17, 2011 06:47
ThinReports Example: Using Events
# coding: utf-8
require 'rubygems'
require 'thinreports'
ThinReports::Report.generate_file('events.pdf') do
use_layout 'events'
events.on :page_create do |e|
e.page.item(:event_page_create).value('Dispatched at before page creating.')
@hidakatsuya
hidakatsuya / thinreports-example-basic-list.rb
Last active September 26, 2015 19:58
ThinReports Example: Basic List
# coding: utf-8
require 'rubygems'
require 'thinreports'
report = ThinReports::Report.new :layout => 'basic_list.tlf'
30.times do |t|
# Internaly #start_new_page() method is called,
# the page break automatically.
@hidakatsuya
hidakatsuya / thinreports-example-estimate.rb
Created August 17, 2011 06:59
ThinReports Example: Estimate Sample
# coding: utf-8
require 'rubygems'
require 'thinreports'
# Prepare sample data.
data = []
# Sample Data 1
d1 = {:no => 1234,
@hidakatsuya
hidakatsuya / thinreports-example-google-chart-api.rb
Created November 7, 2011 08:41
ThinReports Example: Google Chart API
# coding: utf-8
require 'rubygems'
require 'thinreports'
require 'open-uri'
def open_chart(*params)
open('http://chart.googleapis.com/chart?' + URI.encode(params.join('&')))
end
@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 / 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: