Skip to content

Instantly share code, notes, and snippets.

View FGtatsuro's full-sized avatar

FGtatsuro FGtatsuro

View GitHub Profile
@FGtatsuro
FGtatsuro / gen_methodlist.py
Created December 28, 2011 09:18
generate method list from javadoc
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import os.path
import sys
import lxml.html
import xlwt
@FGtatsuro
FGtatsuro / svn_clean.sh
Created December 28, 2011 09:23
remove files related to svn + show diff between treeA and treeB
sh tree_diff.sh
svn_dir=`diff ./tmp1 ./tmp2 | egrep "\/\.svn\/" | cut -c 2- | sed -e "s/\(.*\/\.svn\/\).*/\1/g" | uniq`
for i in $svn_dir; do
ls -ald $i
rm -rf $i
done
#-*- coding:utf-8 -*-
"""
This script compare a package installed by pip and the latest version
in PyPI. And it is also possible to upgrade it then and there.
For now work on Windows and Linux.
And I'm not MACer.(Probably run.)
require: Python 2.6, 2.7 or 3.x
If you using Python 2.5 or below, check at gist:1153625
@FGtatsuro
FGtatsuro / GenericListConverterSample
Created January 13, 2012 16:34 — forked from nagise/GenericListConverterSample
ジェネリックなListの詰替えサンプル
public static <T,U> List<U> hoge(List<T> in) {
class InstanceGenerator<X> {
X instance(X ... x) throws InstantiationException, IllegalAccessException {
Class<?> xArrayClass = x.getClass();
Class<X> xClass = (Class<X>) xArrayClass.getComponentType();
return xClass.newInstance();
}
}
InstanceGenerator<U> d = new InstanceGenerator<U>();
List<U> out = new ArrayList<U>();
@FGtatsuro
FGtatsuro / p1.py
Created January 14, 2012 02:47
program 1 in Euler
reduce(lambda x, y: x+y, [i for i in range(1,1000) if i % 3 == 0 or i % 5 == 0])
@FGtatsuro
FGtatsuro / p2.py
Created January 15, 2012 03:21
program 2 in Euler
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def fibo():
a, b = 1, 2
while True:
yield a
a, b = b, a + b
ans = []
@FGtatsuro
FGtatsuro / file0.txt
Created January 16, 2012 17:17
Djangoのモジュールをインタープリタで読み込む ref: http://qiita.com/items/1748
In [1]: import django.shortcuts
(...)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
@FGtatsuro
FGtatsuro / file0.txt
Created January 18, 2012 04:17
Gitでn番目のコミットハッシュを取得するワンライナー ref: http://qiita.com/items/1776
python -c "n = 1; import re ;from subprocess import Popen, PIPE;import sys; sys.stdout.write([commit.split(' ')[1] for commit in re.split('\n*', Popen(['git', 'log'], stdout=PIPE).communicate()[0]) if commit.startswith('commit ')][n])" | pbcopy
@FGtatsuro
FGtatsuro / .zshrc
Created January 18, 2012 14:38
devブランチのn番目のコミットをmasterブランチにcherry-pick + 中央のSVNサーバにコミット(git svn dcommit)した後にdevブランチを最新にする(git svn rebase)ワンライナー
# aliases for git/git svn
alias ga='git add'
alias gb='git branch'
alias gc='git commit'
alias gco='git checkout'
alias gd='git diff'
alias gl='git log'
alias gm='git merge'
alias gr='git rebase'
alias gs='git status'
@FGtatsuro
FGtatsuro / install_homebrew.rb
Created January 20, 2012 19:16 — forked from mxcl/install_homebrew.markdown
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end