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-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-multiple-layouts.rb
Created August 17, 2011 06:39
ThinReports Example: Multiple Layouts
# coding: utf-8
require 'rubygems'
require 'thinreports'
report = ThinReports::Report.create do
use_layout 'multiple_default', :default => true
use_layout 'multiple_cover', :id => :cover
# Add :cover layout (using multiple_cover.tlf).
@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-advanced-list.rb
Created August 17, 2011 06:51
ThinReports Example: Advanced List
# coding: utf-8
require 'rubygems'
require 'thinreports'
report = ThinReports::Report.new :layout => 'advanced_list'
report.layout.config.list(:advanced_list) do
# Define the variables used in list.
use_stores :row_count => 0,
@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-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-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-barcode.rb
Last active April 23, 2019 09:04
ThinReports Example: Barcode
# coding: utf-8
require 'rubygems'
require 'thinreports'
# Load libraries of barby.
require 'barby'
require 'barby/barcode/ean_13'
require 'barby/barcode/ean_8'
require 'barby/barcode/qr_code'