Skip to content

Instantly share code, notes, and snippets.

View tkfm-yamaguchi's full-sized avatar

Takafumi Yamaguchi tkfm-yamaguchi

View GitHub Profile
=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)
@tkfm-yamaguchi
tkfm-yamaguchi / vimpr-plugin-manager.rb
Created October 31, 2012 07:39
vimpr-plugin-manager
#!/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'
# 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
@tkfm-yamaguchi
tkfm-yamaguchi / custom_prettyprint.rb
Created November 22, 2012 02:32
Customize pp output
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
# make empty element
echo '<hoge></hoge>\n' | sed -E 's/<([^>]+)>\s*\n*<\/\1>/<\1\/>/'
* 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;
# coding: utf-8
require 'pathname'
require 'fileutils'
class Pathname
def basename_without_ext
Pathname(basename.to_s.gsub(/#{extname}$/, ""))
end
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
#!/usr/bin/env ruby
# coding: utf-8
require 'date'
module DateTimeStringer
def to_sdate
strftime("%Y-%m-%d")
end
# coding: utf-8
require 'nokogiri'
require 'active_support/core_ext'
module MakeBlankXML
class << self
def execute
org_doc = Nokogiri::XML(DAMMY_XML)