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 / readline_on_win_issue_for_virtualenv.patch
Created December 22, 2011 07:10
imp.find_modules could not detect correct version of readline.py in virtualenv on windows. Then just skip it.
diff -u a/virtualenv.py b/virtualenv.py
--- a/virtualenv.py Thu Dec 22 16:03:56 2011
+++ b/virtualenv.py Thu Dec 22 16:02:49 2011
@@ -1105,6 +1105,8 @@
def copy_required_modules(dst_prefix):
import imp
for modname in REQUIRED_MODULES:
+ if modname == 'readline':
+ continue # imp.find_modules is nats for readline on windows.
if modname in sys.builtin_module_names:
@tkfm-yamaguchi
tkfm-yamaguchi / singleton_wx.py
Created January 5, 2012 01:01
Do not run wx app more (python)
class appMain(wx.App):
"""Application class
"""
def OnInit(self):
""" Construction event handler
Called by wx when application launch.
Check whether the app already running,
if it has been running, abort launching.
@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)
@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 / 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);
#!/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.
#!/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.
@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
@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 / 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'
})