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
=begin | |
[Ruby内で重複する値を抽出する方法](http://d.hatena.ne.jp/kiyo560808/20110801/1312196444) | |
``` | |
$ ruby -v | |
> ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
user system total real | |
overlaps : [1, 2, 3, 4, 5, 2000] | |
1.850000 0.010000 1.860000 ( 1.866822) |
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 ruby | |
=begin | |
TODO: | |
* show the plugin name and its description. It could retrieve | |
from [INFO] section(XML) in the js file. | |
* suspicious english | |
=end | |
require 'pathname' |
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
# Combine below files: | |
# https://github.com/github/gitignore/blob/master/Global/VisualStudio.gitignore | |
# https://github.com/github/gitignore/blob/master/CSharp.gitignore | |
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) | |
[Bb]in/ | |
[Oo]bj/ | |
# mstest test results | |
TestResults |
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 'pp' | |
class PP | |
module PPMethods | |
def seplist(list, sep=nil, iter_method=:each) # :yield: element | |
sep ||= lambda { comma_breakable } | |
first = true | |
nest(1) { | |
breakable |
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
# make empty element | |
echo '<hoge></hoge>\n' | sed -E 's/<([^>]+)>\s*\n*<\/\1>/<\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
* PRE : ubuntu 12.04 distributed jwhois.conf | |
* POST: download from gnu prjct page, add the costomization for japanese servers | |
* > downloaded from : http://cvs.savannah.gnu.org/viewvc/*checkout*/jwhois/jwhois/example/jwhois.conf?revision=1.143 | |
* NOTE: Japanese encoding is "ISO-2022-JP" | |
--- jwhois.conf.bk 2010-11-25 00:39:15.000000000 +0900 | |
+++ jwhois.conf 2013-01-23 14:26:57.966240523 +0900 | |
@@ -17,6 +17,11 @@ | |
type = regex; | |
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
# coding: utf-8 | |
require 'pathname' | |
require 'fileutils' | |
class Pathname | |
def basename_without_ext | |
Pathname(basename.to_s.gsub(/#{extname}$/, "")) | |
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
class Integer | |
def prime? | |
!2.upto(self/2).any?{|i| n % i == 0 } | |
end | |
def prime_factors | |
return [1] if self == 1 | |
n = self | |
i = 2 |
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 ruby | |
# coding: utf-8 | |
require 'date' | |
module DateTimeStringer | |
def to_sdate | |
strftime("%Y-%m-%d") | |
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
# coding: utf-8 | |
require 'nokogiri' | |
require 'active_support/core_ext' | |
module MakeBlankXML | |
class << self | |
def execute | |
org_doc = Nokogiri::XML(DAMMY_XML) |