Skip to content

Instantly share code, notes, and snippets.

@hyoshiok
hyoshiok / gist:4243472
Created December 9, 2012 05:36
print random numbers
(1..100000).each {|i| puts rand(100000)}
@hyoshiok
hyoshiok / gist:2773087
Created May 23, 2012 03:21
find email like address in csv
$ sed -e "s/.*,\([a-z.]\+@[a-z.]\+\).*/\1/g" file
@hyoshiok
hyoshiok / count_utf8.rb
Created April 16, 2012 09:39
This script guesses the encoding of a csv file, if it is not ASCII, count number of utf8 of a body and compute utf8 / size.
# encodings: utf-8
=begin :rdoc
= count_utf8.rb
This script guesses the encoding of a csv file and print ratio of utf8 / size of the message
The format of the csv file is the following
id, replied_to_id, thread_id, timestamp, group, recipients, private, user_id, user, email_address, body, url, attachment_ids
@hyoshiok
hyoshiok / weeklyrep.sh
Created February 14, 2012 06:55
generate a yammer weekly report
#!/bin/bash
#
# generate a yammer weekly report
#
# usage
# $ ./weeklyrep.sh <export_message.csv>
#
# 8/05/2011 hirotaka.yoshioka@mail.rakuten.com
#
@hyoshiok
hyoshiok / code_detect.rb
Created February 14, 2012 06:53
This script guesses the encoding of a csv file.
# encodings: utf-8
=begin :rdoc
= code_detect.rb
This script guesses the encoding of a csv file.
The format of the csv file is the following
0:id, 1:replied_to_id, 2:thread_id, 3:timestamp, 4:group, 5:recipients, 6:private, 7:user_id, 8:user, 9:email_address, 10:body, 11:url, 12:attachment_ids
@hyoshiok
hyoshiok / unzip_csv.sh
Created February 14, 2012 06:34
unzip yammer message file to csv
#!/bin/bash
#
# unzip csv file
#
# usage
# $ ./unzip_csv.sh <export_message.zip>
#
# input format message_export_yyyymmdd-yyyymmdd.zip
# output format data/messages_yyyymmdd-yyyymmdd.csv
#
@hyoshiok
hyoshiok / fb.rb
Created October 31, 2011 02:58
fizzbuzz in Ruby
#
# fizzbuzz
# author: hirotaka.yoshioka@mail.rakuten.com
# 10/31/2011
#
fz = ["fizzbuzz", 1, 2, "fizz", 4, "buzz", "fizz", 7, 8, "fizz",
"buzz", 11, "fizz", 13, 14]
(1..30).each {|i| p fz[i%15].class == String ? fz[i%15] : i}
@hyoshiok
hyoshiok / cut_f.rb
Created October 13, 2011 05:05
cut a field of csv file.
# encodings: utf-8
=begin :rdoc
= cut_f.rb
This script prints a field of CSV file.
The format of the csv file is the following
id, replied_to_id, thread_id, timestamp, group, recipients, private, user_id, user, email_address, body, url, attachment_ids