Skip to content

Instantly share code, notes, and snippets.

View tkfm-yamaguchi's full-sized avatar

Takafumi Yamaguchi tkfm-yamaguchi

View GitHub Profile
@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'
=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 / gfm.rb
Created September 6, 2012 05:48 — forked from Takazudo/gfm.rb
GitHub Flavored Markdown parser for use with Jekyll and Marked.app
#!/usr/bin/env ruby
require 'rubygems'
require 'redcarpet'
require 'pygments.rb'
class HTMLwithPygments < Redcarpet::Render::HTML
def block_code(code, language)
Pygments.highlight(code, :lexer => language.to_sym, :options => {
:encoding => 'utf-8'
})
@tkfm-yamaguchi
tkfm-yamaguchi / gist:3422660
Created August 22, 2012 05:50
submoduleをレポジトリから削除
#REF: http://d.hatena.ne.jp/oppara/20101116/p1
# .git/configの編集はしないver.
#
# 1. .gitmodulesから該当行を削除
# 2. cacheをrm
git rm --cached path/to/hoge
git commit
# 3. init
@tkfm-yamaguchi
tkfm-yamaguchi / Table.md
Created August 17, 2012 02:16
Alingment limitation for table (Markdown)

Favorite git alias

Valid Table Style for markdown:

alias_name command
st status
co checkout
cm commit
br branch
#!/usr/bin/env ruby
# coding:utf-8
# = Summary:
#
# Set#classify Example.
#
# Returns Hash instance whose key is date, and value is the set object
# consist from date instances within from date_range's first date to
# date_range's last date.
#!/usr/bin/env ruby
# coding: utf-8
# Please set the authentication
# information here to send the mail.
#
# * address : mail sending server name.
# * prot : mail sending server's port number.
# * user_name : auth user name to send mail.
# * password : auth passwd of user_name.
@tkfm-yamaguchi
tkfm-yamaguchi / sprintf_E.c
Created August 8, 2012 00:54
Mystery of "sprintf"
#include <stdio.h>
void main(void) {
int i;
double x;
char buff[256];
x = 1.15;
sprintf(buff, "1. sprintf(%f) => %.1E", x, x);
puts(buff);
@tkfm-yamaguchi
tkfm-yamaguchi / excoltoNum.rb
Created July 11, 2012 07:05
エクセルのカラム形式文字列(AAなど)を序数に変換
class String
def byte_num(index=0)
bytes.to_a[index]
end
end
def excoltoNum(str) # :nodoc:
return 0 if str.empty?
raise ArgumentError.new("string includes invalid charactor as column name") unless str =~ /^[a-zA-Z]+$/
@tkfm-yamaguchi
tkfm-yamaguchi / swing_dot.rb
Created June 26, 2012 07:14
Bash's active wating prompt
# dot swings...
STDOUT.sync = true
print "Take a rest for about 10s ... zzz ..."
sleep(1)
3.times do
print "\033[2D\033[0K"
sleep(1)
print "."
sleep(1)