2010年6月30日水曜日
2010年6月17日木曜日
テキストファイル内のタブをスペースに置き換えるには
1. linuxコマンドで実行する場合
expand --tab=4 before.txt > after.txt
2. vimで実施する場合
:set expandtab
:set ts=4
:retab
逆の動作をする場合
linux:
unexpand before.txt > after.txt
expand --tab=4 before.txt > after.txt
2. vimで実施する場合
:set expandtab
:set ts=4
:retab
逆の動作をする場合
linux:
unexpand before.txt > after.txt
2010年6月16日水曜日
2010年6月11日金曜日
How to: Meld for Git diffs in Ubuntu Hardy
Are you using Git in Ubuntu and want to use an external visual diff viewer? It's easy! I will be using Meld for this example but most visual diff tools should be similar. If you don't already have Meld, then install it:
sudo apt-get install meld
Ok. Now let's begin by breaking it. Enter this into a terminal:
git config --global diff.external meld
Then navigate to a Git tracked directory and enter this (with an actual filename):
git diff filename
Meld will open but it will complain about bad parameters. The problem is that Git sends its external diff viewer seven parameters when Meld only needs two of them; two filenames of files to compare. One way to fix it is to write a script to format the parameters before sending them to Meld. Let's do that.
Create a new python script in your home directory (or wherever, it doesn't matter) and call it diff.py. and "chmod 777 /home/nathan/diff.py"
#!/usr/bin/python
import sys
import os
os.system('meld "%s" "%s"' % (sys.argv[2], sys.argv[5]))
Now we can set Git to perform it's diff on our new script (replacing the path with yours):
git config --global diff.external /home/nathan/diff.py
git diff filename
This time when we do a diff it will launch Meld with the right parameters and we will see our visual diff.
sudo apt-get install meld
Ok. Now let's begin by breaking it. Enter this into a terminal:
git config --global diff.external meld
Then navigate to a Git tracked directory and enter this (with an actual filename):
git diff filename
Meld will open but it will complain about bad parameters. The problem is that Git sends its external diff viewer seven parameters when Meld only needs two of them; two filenames of files to compare. One way to fix it is to write a script to format the parameters before sending them to Meld. Let's do that.
Create a new python script in your home directory (or wherever, it doesn't matter) and call it diff.py. and "chmod 777 /home/nathan/diff.py"
#!/usr/bin/python
import sys
import os
os.system('meld "%s" "%s"' % (sys.argv[2], sys.argv[5]))
Now we can set Git to perform it's diff on our new script (replacing the path with yours):
git config --global diff.external /home/nathan/diff.py
git diff filename
This time when we do a diff it will launch Meld with the right parameters and we will see our visual diff.
2010年6月10日木曜日
class final 領域の初期化
public class Eval {
private static final HashMap sSceneResources
= new HashMap();
public String getString(Integer toget) {
String ret = (String)sSceneResources.get(toget);
return ret;
}
static {
sSceneResources.put(2,new String("2"));
sSceneResources.put(3,new String("3"));
}
}
private static final HashMap
= new HashMap
public String getString(Integer toget) {
String ret = (String)sSceneResources.get(toget);
return ret;
}
static {
sSceneResources.put(2,new String("2"));
sSceneResources.put(3,new String("3"));
}
}
登録:
投稿 (Atom)