Monday, December 28, 2009

Using Far Manager under Chinese XP

Far manager is an excellent orthodox file manager (aka Norton Commander clone for people who still remember DOS), the unicode version of which is open source. However, because it uses the console as the output, it suffers from text alignment and border display problems with Chinese, and presumably other DBCS, systems. Here are 2 methods to make it display properly:

Method 1: This is for v1.75 builds
Use a hex editor, open Far.exe, scan through it visually and patch the box characters to plain characters + - = |
The address of the box characters are unfortunately version dependent.
Install the addon FileCopyEx. Use this instead of Far's internal copy routine because Far's internal copy routine cannot handle certain Chinese names.
Create a shortcut for Far.exe and now right click on it to open the property tab of the shortcut. Now change the code page (Options tab) to Chinese, and add the /8 command line switch.
The example patch below works for v1.75 2616x86
Comparing files Far_original.exe and Far_patched.exe
000CA8C4: C5 2B
000CA8C5: B3 7C
000CA8C6: B3 7C
000CA8C7: B3 7C
000CA8C8: CF 2B
000CA8CC: D1 2B
000CA8CD: B3 7C
000CA8CE: B3 7C
000CA8CF: C1 2B
000D6F3C: B3 7C
000D6F3D: BA 7C
000D6F40: CD 3D
000D6F41: CD 3D
000D6F42: CD 3D
000D6F44: FB 3E
000D7050: C7 2B
000D7051: B6 2B
000D7052: C4 2D
000D7054: BA 7C
000D7055: BA 7C
000D7056: C4 2D
000D7058: C3 2B
000D7059: B4 2B
000D705A: C4 2D
000D705C: C3 2B
000D705D: B4 2B
000D705E: C4 2D
000D7060: CC 2B
000D7061: B9 2B
000D7062: CD 3D
000D7064: CC 2B
000D7065: B9 2B
000D7066: CD 3D
000D706A: B3 7C
000D706E: B3 7C
000D7070: D1 2B
000D7071: CF 2B
000D7072: B3 7C
000D7074: CD 3D
000D7075: CD 3D
000D7076: B3 7C
000D7078: C2 2B
000D7079: C1 2B
000D707A: B3 7C
000D707C: C2 2B
000D707D: C1 2B
000D707E: B3 7C
000D7080: CB 2B
000D7081: CA 2B
000D7082: BA 7C
000D7084: CB 2B
000D7085: CA 2B
000D7086: BA 7C
000D7088: C4 2D
000D7089: C4 2D
000D708A: C4 2D
000D708C: C4 2D
000D708D: C4 2D
000D708E: C4 2D
000D7090: CD 3D
000D7091: CD 3D
000D7092: CD 3D
000D7094: CD 3D
000D7095: CD 3D
000D7096: CD 3D
000D7098: B3 7C
000D7099: B3 7C
000D709A: B3 7C
000D709C: B3 7C
000D709D: B3 7C
000D709E: B3 7C
000D70A0: BA 7C
000D70A1: BA 7C
000D70A2: BA 7C
000D70A4: BA 7C
000D70A5: BA 7C
000D70A6: BA 7C
000D7309: B3 7C
000D730A: DA 2B
000D730B: C0 2B
000D730C: D9 2B
000D730D: BF 2B
000D730E: CD 3D
000D730F: BA 7C
000D7310: C9 2B
000D7311: C8 2B
000D7312: BC 2B
000D7313: BB 2B


Method 2: This is for v2.0 builds
Cut & paste lines below into a registry file e.g. boxchar.reg and import it
REGEDIT4

[HKEY_CURRENT_USER\Software\Far2\System]
"BoxSymbols"=hex:\
2E,00,6F,00,4F,00,7C,00,2B,00,2B,00,7C,00,2B,00,\
2B,00,2B,00,7C,00,2B,00,2B,00,2B,00,2B,00,2B,00,\
2B,00,2B,00,2B,00,2B,00,2D,00,2B,00,2B,00,7C,00,\
2B,00,2B,00,2B,00,2B,00,2B,00,3D,00,2B,00,3D,00,\
2B,00,2B,00,2B,00,59,00,58,00,52,00,53,00,6B,00,\
6A,00,18,00,0C,00,88,00,84,00,8C,00,90,00,80,00
Create a shortcut for Far.exe and now right click on it to open the property tab of the shortcut. Now change the code page (Options tab) to Chinese, and change the Font to a true type font (細明體). Start Far now and under options > File mode > Full mode untick Align file extensions and use the following values:
Column types: T,D,S,N
Column widths: 5,8,8,0
Status line column types: S,NR
Status line column widths: 23,0

Method 3: This is for v2.0 builds
Download conemu from http://code.google.com/p/conemu-maximus5/
Install conemu into same folder as far so conemu.exe is in the same folder as far.exe
Change Far's shortcut e.g. from c:\far2\far.exe to c:\far2\conemu.exe
Start Far (using the shortcut), right click and select settings
Change Font to 細明體
Change Charset to ANSI
C:0
Untick Monospace
Tick Fix FAR borders
And underneath it use Lucida Console, x0

Additional enhancements: conman can be used to start Far.exe (e.g. C:\Far\conman.exe C:\Far\Far.exe /8 /co -new_console_wx=170wy=50 ) to provide a scrollback buffer using the alternate console with the following registry file:
REGEDIT4

; registry settings for commands for console manager via Win+Key combination
; uncomment values which you want :)

[HKEY_CURRENT_USER\Software\HoopoePG_2x]
"Console1" = hex:5b,31 ;win + 1
"Console2" = hex:5b,32 ;win + 2
"Console3" = hex:5b,33 ;win + 3
"Console4" = hex:5b,34 ;win + 4
"Console5" = hex:5b,35 ;win + 5
"Console6" = hex:5b,36 ;win + 6
"Console7" = hex:5b,37 ;win + 7
"Console8" = hex:5b,38 ;win + 8
"Console9" = hex:5b,39 ;win + 9
"Console10" = hex:5b,30 ;win + 0
;"Console11" = hex:5b,7a ;win + F11
;"Console12" = hex:5b,7b ;win + F12
"NewConsole" = hex:5b,57 ;win + w
;"ComSpec" = hex:5b,43 ;win + c
"Next" = hex:5b,51 ;win + q
"Prev" = hex:10,5b,51 ;shift + win + q
;"VertInc" = hex:5b,28 ;win + Down
;"VertDec" = hex:5b,26 ;win + Up
;"HorInc" = hex:5b,27 ;win + Right
;"HorDec" = hex:5b,25 ;win + Left

;"TerminateConsole" = hex:5b,2e ; Win + Del
;"MaximizeWindow" = hex:5b,78 ; Win + F9
;"MinimizeToTray" = hex:5b,22 ; Win + PgDn

"AlternativeConsole" = hex:5b,41 ; Win + A
"AlternativeConsoleUp" = hex:28
"AlternativeConsoleDn" = hex:26
"AlternativeConsolePgUp" = hex:22
"AlternativeConsolePgDn" = hex:21
"AlternativeConsoleHome" = hex:24
"AlternativeConsoleEnd" = hex:23
"AlternativeConsoleClear" = hex:2e
"AlternativeConsoleCopyAll" = hex:0x11,0x43 ;Ctrl+C
;"CloseAlternativeConsole" = hex:1b


;"TerminateAll" = hex:5b,11,44 ;Ctrl+Win+D ;by default not mapped

Method 4: This is for Far v3.0 builds

For Chinese filename display in Far v3.0 I do the following:
- Use Consolas (or other true type) font for Far Manager shortcut: this is so you can display Chinese
- Far > Options > File panel mode > Full mode: untick Align file extensions.
- Options > Colors > Panel > Border: change foreground or background color to a color scheme that differs from Normal text.
- Options > Panel Settings: untick Highlight column separators
- Options > Interface settings: tick ClearType friendly redraw

Thursday, November 5, 2009

Biases and Rules of Thumb – Mental Pitfalls that Trap the Best of Us

Source
Biases and Rules of Thumb – Mental Pitfalls that Trap the Best of Us
by AJ Cilliers
November 2009

It’s not often that a psychologist wins the Nobel Prize for Economics, as Daniel Kahneman did in 2002. It’s also rare for two psychologists to revolutionise their own field, and penetrate related disciplines such as economics, finance, law, marketing, philosophy, and medicine. Kahneman has achieved this, and together with the late Amos Tversky has transformed the study of human judgement and decision making.

The names of Kahneman and Tversky are now synonymous with a unified conception of the mind, known by psychologists as the “heuristics and biases” approach. Heuristics are simple rules of thumb, or mental short-cuts, that we apply or take when making decisions in the face of large amounts of complex information. Biases, on the other hand, are the unconscious influences that affect our thinking – often, not for the better.

A common heuristic, known as “representativeness”, is caused for instance by our familiarity with a particular event. The more familiar we are with an event, the more likely we are to believe in its occurrence (compared to an event with which we are not familiar). So, because of the heightened media focus on violent death, most people would predict that death by homicide is far more likely than, say, death from diabetes, despite the far greater number of deaths from the latter.

One of the biases that severely affect our ability to make rational predictions and decisions is known as “anchoring”. The term was first coined by Kahneman and Tversky back in 1974, and describes the tendency of human beings to focus too heavily on a single piece of information when making forecasts. Rather than keeping an open mind, we tend to fixate on a specific number or event at the outset. This then forms the basis of our forecast; we make our predictions by adjusting the number or event that we have fixated on. Research has shown that this tendency can have powerful and often damaging effects on our investment decisions.

In one study of anchoring a group of currency traders was asked to estimate the future dollar-euro exchange rate. All of the traders were employed by the same firm, and all had access to the same information. So, while their individual estimates might differ, one would nevertheless expect them to produce broadly similar numbers. However, when researchers split the group in two, they achieved very different results simply by planting different “anchors” in the minds of the traders.

The first group was asked whether they expected the exchange rate to be above or below 0.6. Their average estimate then turned out to be 0.79. The second group, asked whether the rate would be above or below 1.6, guessed that on average it would come in at 1.28.

The huge gap in the predictions arose because the traders “anchored” on the numbers first given to them, even though the question provided no useful information on which to base their forecast. What is more disturbing is that other studies have shown that even unrelated information, when given as an anchor, can have the same effect.

Dan Ariely of MIT carried out a mock auction with his MBA students after first asking them to write down the last two digits of their social security numbers. This was clearly not relevant to the auction, yet half of the group (the students with the higher social security numbers) bid between 60% and 120% more than their low-number colleagues.

This has major implications for investors (both private and institutional), who might anchor on things such as company forecasts or the current share price when making investment decisions. Know too that simply being aware of the dangers of anchoring is not enough; research has shown that even when we are conscious of our tendency to anchor on a particular number, our judgement can still be affected. The question, then, is how we can get around this problem?

One way of circumventing the problem is to give yourself a broader range of options when faced with a decision. Two analysts at Asian brokerage CLSA, Chris Lobello and Connie Lacanilao, have done just that. They have been using their colleagues as guinea pigs, in an attempt to gauge the severity of the anchoring problem as well as establish ways of dealing with it. They split their equity sales team into two groups, and asked them to provide a forecast for the Japanese market’s closing index each Friday.

Each group was asked to predict a range of figures which they believed would be within 90% of the actual close. Before they made their forecasts, one group was sent an email that listed just the previous week’s closing figure. This group performed poorly; the actual close was within their predicted range just 41% of the time.

The other group was given extra data: they were provided with the largest previous weekly shift, in percentage terms, and were also told what index levels a similar sized move (both up and down) would equate to from the current level. This meant that the second group had three anchors – the current index level, a feasible low figure, and a feasible high figure. This group proved to be far more successful, with predicted closes that were within the allowed range 70% of the time.

The lesson then is to make sure that you are basing your investment decisions on more than just one piece of information, such as a share price or a PE ratio. Look at the underlying company’s history, consider its future prospects (given its management team, the industry that it is in and the competition it is facing), and evaluate its performance in the context of overall economic conditions.
For example, even when rumours of a coming sub-prime crisis were filtering into the markets and commentators had for some months been predicting an economic slowdown, investors still bought into rising share markets as though the bull would run for ever. While you don’t want to be trapped in “analysis paralysis” mode due to information overkill, you also want to ensure that you don’t anchor on the first number that comes to mind.

You should also be aware that anchoring can influence other financial decisions as well. Estate agents and sales persons are well aware of the anchoring phenomenon, and will exploit it by being quick to provide you with the price of their product, knowing that you are likely to anchor on it and negotiate from this base. Don’t fall for it! Do your research, establish the highest price that you are prepared to pay, and be quick to introduce an even lower figure than this before the sales person can get a word in. They will then have your number in mind as a starting point, and you are far more likely to end up with a better deal.

A few years ago, in an interview with the Journal of Financial Planning, Daniel Kahneman was asked how people could avoid making bad investment decisions. Kahneman explained that, as humans, we form impressions of events and people, then act on those impressions and our own intuitive judgement. The problem, though, is that our impressions are often wrong, leading to bad decisions. Kahneman suggests for instance that if we are aware that we are not great at evaluating shares, we should adopt the policy of buying index funds instead. Although this sounds simplistic, it implies taking a different approach, rather than trying to teach ourselves something that we’re not very good at.

Kahneman emphasises that adopting policies instead of taking individual decisions can help to overcome many of our behavioural problems. If you buy and hold an index, for instance, you are making fewer decisions. It’s a policy that you can enforce, and you won’t get distracted by anchors and heuristics. Kahneman points out that one of the key lessons of behavioural finance, in his opinion, is that if you are not constantly active and monitoring and checking, you’re likely to do better in the long run. (Which probably also explains why many passive fund managers perform better in the long run than the majority of their active colleagues).
When asked at the end of the interview whether he had applied his own insights to his personal decisions about money and investing, Kahneman had this to say: “It’s made me much more passive. I do less and worry less about it. I know I can’t do it very well myself. I’m quite relaxed about it.”

I don’t think it takes a Nobel Prize in economics to recognise the wisdom of this advice. Now if we could just get ourselves to follow it....

Sunday, November 1, 2009

Boot into Avira Antivir from Hard disk in XP

Update: see Avira's website for making an usb rescue disk
Some viruses can only be cleaned by booting into an anti-virus system. Avira Anti-virus supplies a free boot cd image for cleaning viruses, which can be booted from the hard disk and is much faster then booting from a CD. This also allows one to update the anti-virus definitions fairly easily. The method is as follows:

Download Avira Antivir Rescure System. Run it, don't burn to CD, but tell it to save to an iso file (e.g. avira.iso). Put the iso file in the root directory of a hard disk drive. Extract from the iso file the folders antivir and avupdate (with e.g. 7-Zip) and put those in the same drive, so now you would have e.g.

D:\avira.iso
D:\antivir\ (containing various .vdf virus definition files and so on)
D:\avupdate\ (and contents thereof)

Edit avupdate\windows\avupdate.bat so that avupdate.exe is invoked correctly.
avupdate\windows\avupdate.exe --config=.\avupdate.conf --product-file=/update/idx/rescuestick-linux_glibc22-en.idx --product-info-file=/update/idx/rescuesticklinux_glibc22-en.info.gz --skip-master-file
changed to
\avupdate\windows\avupdate.exe --config=.\avupdate.conf --product-file=/update/idx/rescuestick-linux_glibc22-en.idx --product-info-file=/update/idx/rescuesticklinux_glibc22-en.info.gz --skip-master-file
If you use a proxy server, edit avupdate.conf and add the entries from proxy-server
Proxy-Server=your_proxy_host_url
Proxy-Port=your_proxy_host_port

Download Grub4Dos. Extract grldr and menu.lst from the zip file and put it into your boot drive root (usually C:\). Add this entry to menu.lst
title Avira Antivirus
root (hd0,2)
find --set-root --ignore-floppies /avira.iso
map --mem /avira.iso (0xff)
map --hook
root (0xff)
chainloader (0xff)
You will need to edit the root(hd0,2) entry to match the location of avira.iso. hd0 = 1st hard disk (count starts from 0). 2 = partition 2 (count starts from 1). One should be able to guess the numbers from the way harddrives are laid out in Control Panel>Adminstrative Tools>Computer Management>Disk Management

Finally, add this entry to boot.ini (presuming c:\ is your boot drive)
c:\grldr="GRUB"

Next time you boot your PC, you can select Avira Antivirus by booting into "GRUB". Once inside the Avira Antivirus graphical interface click on the British flag to select the English language. Also in the configuration select Rename infected files. Now you can scan your PC.

To update your anti-virus definitions, boot into XP normally, open the avupdate\windows folder, and run avupdate.bat.

Update (18/6/2011):
For the newer version of avira also extract the system directory to the root drive (to e.g. d:\system).

Alternate (18/6/2011): The entire iso can be extracted (antivir and system folders must be in root directory - otherwise system check will fail) and booted directly:
title Avira AntiVir Rescue System
root (hd0,1)
find --set-root /vmlinuz
kernel /vmlinuz nofb ramdisk_size=108178 root=/dev/ram0 rw console=/dev/vc/4
initrd /initrd.gz
Modify root() entry as described earlier; vmlinuz and initrd.gz can be placed in other folders if desired (just remember to modify the path above). Also note newer version of grub4dos is needed (or you will get an invalid executable error).

Thursday, October 29, 2009

A study on incompetence

It is one of the essential features of such incompetence that the person
so afflicted is incapable of knowing that he is incompetent. To have
such knowledge would already be to remedy a good portion of the
offense. (Miller, 1993, p. 4)

http://www.apa.org/journals/features/psp7761121.pdf

An interesting read. Makes me wonder about myself...

Friday, October 23, 2009

File sorter

This batch file sort.bat sorts all my hentai manga files. It reads the file sort.lst and moves any file that contains the first word to a folder (the second word). You can use notepad to create the files and copy and paste both files below.

sort.bat - copy the lines below and save as "sort.bat"
@echo off
if '%1==' goto default
if %1==? goto help
if %1==/? goto help

:sort
if '%2==' goto one
md %2
move *%1* %2
goto :EOF

:one
md %1
move *%1* %1
goto :EOF

:default
FOR /F "eol=; tokens=1,*" %%i in (sort.lst) do if exist *%%i* call sort %%i %%j
goto :EOF

:help
echo Sorts file into directories according to pattern specified in sort.lst


sort.lst - copy and paste the lines below and save as "sort.lst"
;List file to sort files into directories
;First word = pattern to match, 2nd word = directory name (if not given then uses first word)

Akazawa
Akishima "Akishima Shun"
Amatarou
Amazake "Yoshu Ohepe"
Amazume "Ryuuta Amazume"
Ameno "Amano Ameno"
Asuka "Bai Asuka"
Azure "Konno Azure"
Black_Dog "Black Dog"
"Black Dog" "Black Dog"
Bosshi
Crimson
Cuvie
Daigo
Distance
Ei_Itou Itouei
Fueta "Fueta Kishi"
Fukudahda "Kensoh Ogawa"
Gakuen "Ringo Gakuen"
Garyuh "Garyuh Chitai"
Hanaharu "Naruko Hanaharu"
Mamoru "Hashia Mamoru"
Haganema
Hellabunna
Hidemaru
"Hi-per Pinch"
"Hi-PER_PINCH" "Hi-per Pinch"
Hootch "Shindo Eru"
[Inu] "Inu"
Inuboshi
Itaba "Hiroshi Itaba"
Itosugi "Masahiro Itosugi"
ITOUEI "Itouei"
Ishikei
Jingrock
Jouji "Jouji Manabe"
Jushirou "Jushirou Tsubaki"
John_K "John K Peta"
"John K" "John K Peta"
Jyogi "Tsukino Jyogi"
Juuzoh "Minazuki Juuzoh"
Kabao "Kikkawa Kabao"
Kazuaki "Saida Kazuaki"
Kensoh "Kensoh Ogawa"
Kirara "Moe Kirara"
Kisaragi "Gunma Kisaragi"
Kohakutei
Kokonoki "Nao Kokonoki"
Komine "Komine Tsubasa"
Konsaki
Kokoromi "Kokoromi Shingon"
Kouchaya "Ootsuka Kotora"
Koyanagi "Royal Koyanagi"
Kuroiwa "Menou Kuroiwa"
Kyoden "Sanbun Kyoden"
Makinosaka "Makinosaka Shinichi"
Maybe
Mayonnaise
Mikami "Mikami Cannon"
Mitarashi "Mitarashi Kousei"
Momoyama "Momoyama Jirou"
Mysterious "Ueshiba Riichi"
Nagare "Nagare Ippon"
Nakadera "Akira Nakadera"
Nakayama "Nakayama Tetsugaku"
Natsu "Otono Natsu"
Nekomori "Nekomori Maririn"
Nise_Midi "Ishikei"
"Nise Midi" "Ishikei"
Nisemidi "Ishikei"
Nitta "Nitta Jun"
Norutaru
Oda "Oda Non"
Okawari
Ohepe "Yoshu Ohepe"
Onikubo "Hirohisa Onikubo"
Onizuka "Onizuka Naoshi"
Oshigoto "Konno Azure"
Polinky
Risshin "Private Risshin Seminary"
Rate
Koyanagi "Royal Koyanagi"
Saegusa "Saegusa Kohaku"
Saigado
Sakazaki "Doi Sakazaki"
Sasagawa "Sasagawa Hayashi"
Sasakura "Ayato Sasakura"
Sasayuki
Shiden "Shiden Akira"
Shindo "Shindo Eru"
Shinobu "Tanei Shinobu"
Shiwasu "Shiwasu No Okina"
"Sister_and_Brother" Fuuga
Taira "Taira Hajime"
Takaoka "Takaoka Motofumi"
Takeda "Takeda Hiromitsu"
Takemura "Sessyu Takemura"
Takayuki "Asaki Takayuki"
Takla "Mahiro Takla"
Tenjiku "Tenjiku Rounin"
Tesshin "Azuma Tesshin"
Tomohiro "Tomohiro Kouda"
Toshiaki "Toshiaki Kaneko"
Tsutomu "Tsutomu Mutsuki"
Tuna "Tuna Empire"
Type.90 "Type 90"
Type_90 "Type 90"
Type90 "Type 90"
Udon-Ya
Unagimaru
U.R.C
Utamaro "Spark Utamaro"
Wamusato "Wamusato Haru"
Wanyanaguda
WonderSquare
Yamatogawa
Yoshihisa "Inoue Yoshihisa"
Toshiki "Yui Toshiki"
Yasui "Yasui Riosuke"
Youtarou "Sena Youtarou"
Yukimi
Yukimino "Yukio Yukimino"
Yuzuki "Yuzuki N"
Zukiki

You can add any number of entries to sort.lst, just note that the match is not case sensitive and it matches any file containing that first word. Note that you can use wildcards in that first word, for example "Oda?Non" where ? = match any single character, * = match any character(s).

*** Advanced ***
You can make sort.bat to be more specific, just change the 2 lines with
move *%1* %2
to
move %1 %2
Then it will only match the first word exactly, so then you have to add the wildcards yourself to the first word (so instead of say Zukiki, you will have to use *Zukiki* Zukiki.