This file contains hidden or 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 'irb' | |
| require 'time' | |
| require 'net/https' | |
| require 'rubygems' | |
| require 'twitter' | |
| require 'rss' | |
| require 'hpricot' | |
| UNAME = "udzura" |
This file contains hidden or 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 'rubygems' | |
| require 'tmail' | |
| re = /^(.*[^\/\*])((?:\/)?(?:\*)?)$/ | |
| dir = ARGV[0] ? ARGV[0].gsub(re, "\\1/*{.txt,.eml}") : "./*{.txt,.eml}" | |
| outfile = ARGV[1] ? ARGV[1] : | |
| "./result_#{Time.now.strftime('%y%m%d.%H%M%S')}.csv" | |
| puts "search for: #{dir}", "output into: #{outfile}" |
This file contains hidden or 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 | |
| exit 1 if ARGV.empty? | |
| require 'rubygems' | |
| require 'net/ssh' | |
| require 'yaml' | |
| Login = YAML.load_file("./login.yml") | |
| def start_forwarding |
This file contains hidden or 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
| cat /etc/issue | |
| #=> CentOS release 4.7 (Final) | |
| #=>Kernel \r on an \m | |
| wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz | |
| wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz | |
| tar xzf libxml2-2.7.3.tar.gz | |
| cd libxml2-2.7.3 | |
| ./configure --prefix=/usr/local/libxml | |
| make |
This file contains hidden or 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 'rubygems' | |
| require 'nokogiri' | |
| require 'open-uri' | |
| begin | |
| doc = Nokogiri::HTML(open("http://www.ruby-lang.org/ja/")) | |
| nil # irbでの大量返り血対策 | |
| end | |
| puts (doc/"div#logo"/:img).first.attributes["alt"] |
This file contains hidden or 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 'enumerator' | |
| def hyphenize_numbers *args | |
| src = args.map{|v| v.to_i} | |
| src.sort!.uniq! | |
| dst = [[ src[0] ]] | |
| src.each_cons(2) do |cons| | |
| if cons[1] - cons[0] > 1 | |
| dst << [] |
This file contains hidden or 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 hyphenize_numbers2 *args | |
| puts args.map{|v| v.to_i}.sort.uniq.unshift(nil).enum_for(:each_cons, 2).inject([]){|dst, src| dst.push((!src[0] || src[1] - src[0] > 1) ? [src[1]] : dst.pop.push(src[1]))}.map{|nums| nums.length == 1 ? nums[0].to_s : "#{nums.first}-#{nums.last}"}.join(", ") + "." | |
| end |
This file contains hidden or 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 hyphenize_numbers2_ *args | |
| puts args. #=> [1, 2, 3, 5, 6, 7, 8, 9, 12, 14] | |
| map{|v| v.to_i}. # Integerにキャスト | |
| sort. # 整列 | |
| uniq. # 重複いらないので削除 | |
| unshift(nil).#=> [nil, 1, 2, 3, 5, 6, 7, 8, 9, 12, 14] | |
| enum_for(:each_cons, 2). | |
| # [[nil, 1],[1, 2],[2, 3],..., [9, 12],[12, 14]] で each | |
| # enum_cons(2). でもいいよね | |
| inject([]){|dst, src| |
This file contains hidden or 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
| <script type="text/javascript"> | |
| Hatena.Star.SiteConfig = { | |
| entryNodes: { | |
| 'div.post': { | |
| uri: '.post-title a', | |
| title: '.post-title', | |
| container: '.post-title' | |
| } | |
| } | |
| }; |
This file contains hidden or 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
| <?php if (!get_post_meta($post->ID, 'hide_title', true)): ?><h2 class="post-title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2><?php endif; ?> |
OlderNewer