This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from pyPdf import PdfFileWriter, PdfFileReader | |
import sys | |
def main(): | |
"""ファイル を 1ページごとに分割する""" | |
div = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'digest/md5' | |
file = ARGV.shift | |
exit unless file | |
exit unless File.exist?(file) | |
ext = '' | |
if file =~ /^(.*)(\.\w+)$/ then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# http://Gyazz.com/増井研/オリエンテーション2012 のようなGyazzページをスライドテキストに変換 | |
# % ruby gyazz2slide 増井研 オリエンテーション2012 user pass > slide.txt | |
# | |
require 'rubygems' | |
require 'gyazz' | |
name = ARGV.shift | |
page = ARGV.shift | |
user = ARGV.shift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#「は」+「゛」のようなUTFを「ば」に変換する | |
# コード表 | |
# http://orange-factory.com/sample/utf8/code3-e3.html | |
def normalize(ss) | |
s = ss.dup | |
while s =~ /^(.*)\xe3([\x81\x82\x83])(.)\xe3\x82\x99(.*)$/ do # 濁点 | |
c1 = $2[0] | |
c2 = $3[0] | |
if c1 == 0x82 && c2 == 0xbf then # 「タ」 | |
c1 = 0x83 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_a(s) | |
s.split(//).map{|i| i == "a" ? 1 : 0}.inject(:+) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_a(s) | |
s.split(//).grep(/a/).length | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_a(s) | |
count = 0 | |
(0...s.length).each { |i| | |
count += 1 if s[i] == 97 | |
} | |
count | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
Net::HTTP.start('masui.sfc.keio.ac.jp', 80) {|http| | |
http.post('/door/open') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1, 2, 3, 4] | |
sum = a.inject(:+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1..100).each { |i| | |
s = '' | |
s += 'Fizz' if i % 3 == 0 | |
s += 'Buzz' if i % 5 == 0 | |
s = i.to_s if s == '' | |
puts s | |
} |