Skip to content

Instantly share code, notes, and snippets.

Daisuke Takeuchi daicham

  • Tokyo, Japan
Block or report user

Report or block daicham

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@daicham
daicham / gist:1593705
Created Jan 11, 2012
Get Outlook calendar by ruby
View gist:1593705
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 Jan 11, 2012
Import csv to Outlook calendar by ruby
View gist:1593715
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 Jan 11, 2012
Export csv from a Oracle table by sqlplus
View gist:1593722
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 Jan 11, 2012
iCalendar by ruby
View gist:1593740
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 Jan 11, 2012
ruby code on windows bat file
View gist:1593777
@echo off
ruby -S -x %0 %*
goto end
#! ruby
# some ruby code
__END__
:end
pause
@daicham
daicham / gist:1955543
Created Mar 2, 2012
Print the methods of Jenkins inner object on script console
View gist:1955543
//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 Mar 3, 2012
Show simple alert dialog on iOS
View gist:1964899
//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 Oct 1, 2015
Generate random strings and copy to clipboard by ruby on batch file
View random.bat
@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 Mar 21, 2012
Print the directory structure and its actual size
View gist:2145516
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 Oct 6, 2015
Redmine Backup Script by Groovy
View gist:2934926
//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",
You can’t perform that action at this time.