Skip to content

Instantly share code, notes, and snippets.

View daicham's full-sized avatar

Daisuke Takeuchi daicham

View GitHub Profile
@daicham
daicham / gist:1593705
Created January 11, 2012 08:25
Get Outlook calendar by ruby
require 'win32ole'
def each_meeting
ol = WIN32OLE.connect("Outlook.Application")
myNameSpace = ol.getNameSpace("MAPI")
folder = myNameSpace.GetDefaultFolder(9) # 9 は予定表
#folder.Display
folder.Items.each do |meeting|
GC.start
yield meeting
@daicham
daicham / gist:1593715
Created January 11, 2012 08:30
Import csv to Outlook calendar by ruby
require 'win32ole'
require 'kconv'
require 'csv'
require 'date'
class Ticket
attr_reader :id
attr_reader :subject
attr_reader :from
attr_reader :to
@daicham
daicham / gist:1593722
Created January 11, 2012 08:33
Export csv from a Oracle table by sqlplus
sqlplus -s << EOF > ${sdata_file}
${ora_user_name}/${ora_user_pass}@${ora_sid}
set echo off
set linesize 1000
set pagesize 0
set trimspool on
set trimout on
set feedback off
set colsep ','
@daicham
daicham / gist:1593740
Created January 11, 2012 08:38
iCalendar by ruby
require 'rubygems'
require 'icalendar'
require 'date'
cal = Icalendar::Calendar.new
cal.event do
dtstart DateTime.new(2010, 05, 19, 22, 00), {'TZID' => 'Asis/Tokyo'}
dtend DateTime.new(2010, 05, 19, 22, 30), {'TZID' => 'Asis/Tokyo'}
summary "うちあわせ"
end
@daicham
daicham / gist:1593777
Created January 11, 2012 08:48
ruby code on windows bat file
@echo off
ruby -S -x %0 %*
goto end
#! ruby
# some ruby code
__END__
:end
pause
@daicham
daicham / gist:1955543
Created March 2, 2012 04:04
Print the methods of Jenkins inner object on script console
//all job name
jenkins.model.Jenkins.instance.items.each {
println "Job: ${it.name}"
}
//method list of Jenkins instance
jenkins.model.Jenkins.instance.class.methods.each {
println "Jenkins method: ${it.name}"
}
@daicham
daicham / gist:1964899
Created March 3, 2012 07:33
Show simple alert dialog on iOS
//refs http://d.hatena.ne.jp/thata/20100213/1265987041
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"hoge"
message:textfield.text
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
@daicham
daicham / random.bat
Last active October 1, 2015 17:58
Generate random strings and copy to clipboard by ruby on batch file
@echo off
ruby -S -x %0 %*
goto end
#! ruby
require 'win32/clipboard' # before install "win32-clipboard" gem
pattern = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
puts "Random String => " + Array.new(8){pattern[rand(pattern.size)]}.join
Win32::Clipboard.set_data(value, Win32::Clipboard::UNICODETEXT)
puts "Stored to clipboard"
@daicham
daicham / gist:2145516
Created March 21, 2012 07:45
Print the directory structure and its actual size
def print_tree(base_dir)
base_dir = base_dir + '/' unless base_dir.end_with? '/'
size = 0
Dir.glob("#{base_dir}*/") do |dir|
#puts "entering #{dir}"
size += print_tree dir
end
Dir.glob("#{base_dir}*") do |file|
real_size = File.size file
size += compute_actual_size real_size
@daicham
daicham / gist:2934926
Last active October 6, 2015 04:18
Redmine Backup Script by Groovy
//Dump from mysql
/* dump ファイルが文字化けしたので コマンドラインから sqldump したほうがよさそう
def mysqldump_process = "/path/to/mysqldump -u redmine -psecret redmine".execute()
new File("redmine.dump").withWriter { writer ->
writer << mysqldump_process.text
}
*/
//Archive dump and attachedfiles
new AntBuilder().zip(destfile: "path/to/backup/redmine-backup." + new Date().format("yyyyMMddHHmmss") + ".zip",