Index . 블로그창고 . Any comments?

\cat etc

Useful Tips

ThinkPad X201
Blank screen with Linux 2.6.34
PuTTY
SSH port forwarding for Remote Desktop Connection
MS-Windows
Atbroker.exe application error - CTRL-ALT-END in a remote session
Can't ping unqualified hostname, but nslookup resolves it
Assigning a password to Guest
File sharing with the firewall turned on
Condensing figure caption references
Swapping Ctrl and Caps Lock keys
Printer
Brother Laser Printer HL-5170DN under FreeBSD
dbf
Double precision bug patch
QEMU
Mounting the raw disk image under FreeBSD
Printer setting
MS-Windows key
FreeBSD patch
Google Maps
GET Method URLs
evilwm
Patch
Vim
Word counting in Vim
vimspell bug fix for unicode encodings
mlterm
Recognizing shifted function keys like <S-F5> in Vim
Using Hangul
Sony VAIO VGN-S360
Setting the LCD brightness under FreeBSD
Getting the sound card work under FreeBSD
msmtp
How to get the server's certificate for IMAP
Configuring Gmail SMTP
Fetchmail
Fetching Gmail via POP3
XHTML 1.1
Changing stylesheet in the body
Hanterm
Color setting
Mutt
<f1> key binding in xterm
Using UTF-8 mutt under FreeBSD
Searching encoded mails
Firefox
Don't use cache!
Alt+Accesskey
Extension updates for Firefox 2
Sage
Keyconfig functions
Using external editors in the textarea field with Firefox 1.0PR
Paper CD case

ThinkPad X201

Blank screen with Linux 2.6.34

tips/i915-fix.diff from http://slack.isper.sk/pub/misc/i915-fix.diff

More discussion: intel 945 + current = blank screen

PuTTY

SSH port forwarding for Remote Desktop Connection

  1. PuTTY Configuration -> Connection -> SSH -> Tunnels
  2. Connection from the SSH client to the SSH server or local to remote forwarding (Local):
    • Source port: L3390 (SSH and RDC client)
    • Destination: localhost:3389 (SSH and RDC server, localhost to this server)
  3. Connection from the SSH server to the SSH client or remote to local forwarding (Remote):
    • Source port: R3390 (SSH server and RDC client)
    • Destination: localhost:3389 (SSH client and RDC server, localhost to this SSH client)
  4. Forwarded ports look like the following:
    L3390 localhost:3389
    R3390 localhost:3389
    
  5. To summarize, [LR]source_port_from_RDC_client localhost:destination_port_to_RDC_server where L for the SSH client to server direction and R for the SSH server to client direction.

MS-Windows

Atbroker.exe application error - CTRL-ALT-END in a remote session

CTRL-ALT-END (CTRL-ALT-DEL for remote sessions) followed by ESC

Can't ping unqualified hostname, but nslookup resolves it

When I set up my home network with DHCP and DNS services using dnsmasq, Windows 7 was not able to ping unqualified hostnames that dnsmasq defines while Linux machines successfully resolved and pinged those hostnames. Windows 7 by default adds the primary/connection-specific DNS suffix to unqualified hostnames, but, in my case, there is no DNS suffix defined for my LAN.

  1. Control Panel
  2. Network and Sharing Center
  3. Click your connection
  4. Properties
  5. Internet Protocol Version 4 (TCP/IPv4)
  6. Properties
  7. Advanced...
  8. DNS
  9. Check "Append these DNS suffixes (in order):".
  10. Click "Add..." under the above radio button.
  11. Type "." and click "Add".
  12. OK, OK, Close, Close, ...

Assigning a password to Guest

Windows XP Home edition uses the Simple File Sharing, which allows anybody who can see the computer to access shared folders and files via the Guest account because this account is not allowed to have a password by default. Even if the Guest account is turned off, this account is used for file sharing in the background. Because this behavior causes severe security problems, we need to assign a password to Guest. In the command prompt,

net user guest "password"

File sharing with the firewall turned on

For security reasons, we may want to turn on the firewall in Windows XP Home edition. However, this prevent file sharing too. The IP address and TCP port for file sharing are 127.0.0.1 and 445, respectively. You can add this service in Network Connections->Local Area Connection->Properties->Advanced->Settings.

Condensing figure caption references

Referenced in Figures { QUOTE { REF _Ref111111 \h } \* "Arabic" } to { QUOTE { REF _Ref22222 \h } \* "Arabic" }

To create a new field, select "Figure *" and press Ctrl+F9.

Swapping Ctrl and Caps Lock keys

Go to \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout and create a binary entry Scancode Map with the value of 00000000 00000000 03000000 3A001D00 1D003A00 00000000.

Printer

Brother Laser Printer HL-5170DN under FreeBSD

tips/hl5170dn.tar.gz

Brother does not support FreeBSD, but the driver for Linux works well. It's even faster than CUPS with BR5170_2_GPL.ppd.gz. Actually, I had a problem with the PostScript emulation built in the printer. Whenever I submitted multiple print jobs successively using CUPS, the printer failed to print out the second job. This forced me to submit one job at a time and it was really annoying, so I decided to try the Linux driver and it did work!

This package is a slightly modified version of hl5170dnlpr-1.1.2-1.i386.rpm to make it run under FreeBSD. You may want to install some Linux compatibility ports to use this driver.

dbf

Double precision bug patch

tips/dbf-0.8.3.1.patch

dbf has the bug that puts garbage values in place of double precision numbers. This patch fixes the bug.

QEMU

Mounting the raw disk image under FreeBSD

This method only works with the raw format image.

mdconfig -a -t vnode -f image_file -u 0
mount -t msdos /dev/md0 ~/mnt

Get your job done and unmount it.

umount ~/mnt
mdconfig -d -u 0

Printer setting

tips/qemu-0.7.1.patch

It would be great if we can share printers with a guest OS running on QEMU. For this, Samba needs to be configured to support printing. However, the current smb.conf created by QEMU doesn't have any printer specific variables. The above patch adds the -smb-conf option to append a user configuration file to the smb.conf so that the user can easily add various settings, especially printer, to the Samba server.

If you use the BSD style printing system, create ~/.qemu/smb.conf as follows:

[global]
printing = bsd
printcap name = /etc/printcap
# REPLACE 'user' WITH YOUR USER ID ON UNIX
print command = /home/user/bin/smbprint %p %s
guest account = user
[printers]
path = /var/spool/samba
printable = yes
writeable = no
guest ok = yes
use client driver = yes

Now, run qemu with "-smb-conf ~/.qemu/smb.conf" option and add a network printer, "\\smbserver\lp", with any HP PostScript printer driver (e.g., HP LaserJet 6P/6MP PostScript). Your default printer on UNIX, lp, must be a PostScript printer or configured with a magic filter like apsfilter, which converts PostScript to a language that your printer understands. I'll leave it to you to add more variables like "lpq command" or "lprm command".

/home/user/bin/smbprint looks like the following:

#!/bin/sh
dev=/dev/ulpt0
ps=$HOME/qemu/lp/`date +%Y-%m-%d_%H:%M:%S`.ps
p=$1
s=$2

pjl_to_ps()
{
	grep -v "@PJL\|ProductName" $1
}

if [ -e $dev ]
then
	pjl_to_ps $s | lpr -r -P$p -
else
	pjl_to_ps $s > $ps
fi
rm -f $s

If a USB printer is attached, print the document. Otherwise, save it as a PS file in $HOME/qemu/lp. Using ps2pdf, you can export any file to PDF. Isn't it great?

MS-Windows key

tips/qemu-0.7.1.patch

This patch also enables MS-Windows key and menu key.

FreeBSD patch

tips/qemu-0.7.1.patch

With this patch, QEMU will compile on FreeBSD.

Google Maps

GET Method URLs

Search

http://maps.google.com/maps?q=

Near

http://maps.google.com/maps?near=

From To

http://maps.google.com/maps?saddr=&daddr=

evilwm

Patch

tips/evilwm-0.99.23.patch tips/evilwm-0.99.18.patch

Vim

Word counting in Vim

Tip #689: Word Count

g<ctrl-g>

vimspell bug fix for unicode encodings

tips/vimspell.patch

vimspell (an on-the-fly spell checker for vim) has a bug with unicode encodings. The cursor moves two characters right when you insert <Space> within a word. This patch fixes the bug.

mlterm

Recognizing shifted function keys like <S-F5> in Vim

tips/patch-xwindow:x_screen.c

mlterm does not differentiate between shifted and non-shifted function keys. This causes problems in Vim when using some combinations of keystrokes such as <S-F5>. I patched the mlterm-2.9.2.tar.gz source code. If you use FreeBSD, you can compile yourself in /usr/ports/x11/mlterm: run "EXTRA_PATCHES=/tmp/patch-xwindow:x_screen.c make install clean".

Using Hangul

tips/install-baekmuk.sh

mlterm supports UTF-8 Hangul input with unicode fonts. Download and install the Baekmuk font using tips/install-baekmuk.sh: run "./install-baekmuk.sh /usr/X11R6/lib/X11/fonts/local" in the same directory where the font files reside. Now, create your ~/.mlterm/font file:

ISO10646_UCS4_1_BIWIDTH = -misc-gulim-medium-r-normal-ko-12-120-75-75-c-120-iso10646-1
ISO10646_UCS4_1 = -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1

Sony VAIO VGN-S360

Setting the LCD brightness under FreeBSD

http://docs.freebsd.org/cgi/getmsg.cgi?fetch=82303+0+/usr/local/www/db/text/2001/freebsd-mobile/20010513.freebsd-mobile

tips/setbrightness.c

Getting the sound card work under FreeBSD

http://lists.freebsd.org/pipermail/freebsd-bugs/2004-December/010970.html

tips/sound.patch

The sound card has implemented AC97 EAPD in an inverted sense.

msmtp

How to get the server's certificate for IMAP

openssl s_client -connect mail.mac.com:993 -showcerts

Configuring Gmail SMTP

I tried many times to set up ssmtp to send mails through the Gmail SMTP server. It sometimes worked, but mostly not, so I decided to change it to msmtp and it was easy to configure with mutt as "m" in msmtp stands for "m"utt.

Don't forget to change the permission of ~/.msmtprc to 600 because the file contains passwords for your accounts.

~/.msmtprc

account USER
from USER@gmail.com
host smtp.gmail.com
port 587
tls
user USER
password USERPASSWORD

account USER2
from USER2@gmail.com
host smtp.gmail.com
port 587
tls
user USER2
password USER2PASSWORD

~/.mutt/USERrc

set sendmail='/usr/local/bin/msmtp -a USER'
source ~/.mutt/muttrc
source ~/.mutt/USER_aliases
set from='USER <USER@gmail.com>'
set spoolfile=/var/spool/mail/USER
set mbox=+USER
set record=+USER
set postponed=+USER_postponed

~/.mutt/USER2rc

set sendmail='/usr/local/bin/msmtp -a USER2'
source ~/.mutt/muttrc
source ~/.mutt/USER2_aliases
set from='USER2 <USER2@gmail.com>'
set spoolfile=/var/spool/mail/USER2
set mbox=+USER2
set record=+USER2
set postponed=+USER2_postponed

Fetchmail

Fetching Gmail via POP3

Recently, Google started POP3 service for Gmail, so I tried many times to set up fetchmail without success. The reason was simple. Gmail POP3 does not support LAST/TOP commands, which fetchmail uses by default. TOP is optional in POP3 specification, but fetchmail sends the command to retrieve each message. To work around this problem, RETR should be used instead of TOP. RETR is used when fetchall option is given, which means that it retrieves all messages and deletes them on a remote server. Fortunately, Gmail provides the "keep Gmail's copy in the Inbox" feature to prevent fetchmail from flushing retrieved messages.

Multiple accounts can be configured, but messages from all accounts are saved in one spool file by default. It is sometimes useful but can be annoying because it eventually means that I have only one email account regardless of how many Gmail IDs I have. I played with procmail and fetchmail options with no luck. Finally, I added a dummy user in /etc/passwd by copying a real one and modifying ID and it worked! Now, I can access each spool file by "mutt -F ~/.mutt/USERrc" and "mutt -F ~/.mutt/USER2rc."

~/.fetchmailrc

set logfile "/var/log/fetchmail.log"
set postmaster "USER"
set bouncemail
set no spambounce
set properties ""
set daemon 60
poll pop.gmail.com via pop.gmail.com protocol pop3
 user 'USER' there with password 'PASSWORD' is 'USER' here ssl fetchall
poll pop.gmail.com via pop.gmail.com protocol pop3
 user 'USER2' there with password 'PASSWORD2' is 'USER2' here ssl fetchall

/etc/passwd

...
USER:*:1001:1001:USER:/home/USER:/bin/sh
USER2:*:1001:1001:USER:/nonexistent:/usr/sbin/nologin
...

~/.mutt/USERrc

source ~/.mutt/muttrc
source ~/.mutt/USER_aliases
set from='USER <USER@gmail.com>'
set spoolfile=/var/spool/mail/USER
set mbox=+USER
set record=+USER
set postponed=+USER_postponed

~/.mutt/USER2rc

source ~/.mutt/muttrc
source ~/.mutt/USER2_aliases
set from='USER2 <USER2@gmail.com>'
set spoolfile=/var/spool/mail/USER2
set mbox=+USER2
set record=+USER2
set postponed=+USER2_postponed

~/.mutt/muttrc

set folder=~/mail
set sort=reverse-threads
set strict_threads=yes
set mail_check=60
set timeout=60
set beep_new=yes
set move=ask-yes
set thorough_search=yes
set send_charset=us-ascii:iso-8859-1:euc-kr:utf-8
set charset=euc-kr
charset-hook ks_c_5601-1987 euc-kr
auto_view text/html
ignore *
unignore from: date: subject: to: cc:

XHTML 1.1

Changing stylesheet in the body

It's not compliant with XHTML 1.1 to put a <link> tag in the body, so changing stylesheet requires some javascripting.

<script type="text/javascript">
//<![CDATA[
 var link = document.getElementsByTagName('link');
 for(var i=0; i<link.length; i++)
  link[i].setAttribute('href', 'http://alternative.css');
//]]>
</script>

Hanterm

Color setting

When a cursor moves in mutt, inversed background and foreground colors get broken. Add the following to ~/.Xdefaults:

hanterm*termName:               vt100
hanterm*background:             black
hanterm*foreground:             white
hanterm*vt100*colorBDMode:      on
hanterm*vt100*boldMode:         off
hanterm*vt100*colorULMode:      on
hanterm*vt100*underLine:        off
hanterm*vt100*color0:           black
hanterm*vt100*color1:           red3
hanterm*vt100*color2:           green3
hanterm*vt100*color3:           yellow3
hanterm*vt100*color4:           blue3
hanterm*vt100*color5:           magenta3
hanterm*vt100*color6:           cyan3
hanterm*vt100*color7:           gray90
hanterm*vt100*color8:           gray30
hanterm*vt100*color9:           red
hanterm*vt100*color10:          green
hanterm*vt100*color11:          yellow
hanterm*vt100*color12:          blue
hanterm*vt100*color13:          magenta
hanterm*vt100*color14:          cyan
hanterm*vt100*color15:          white
hanterm*vt100*colorBD:          cyan
hanterm*vt100*colorUL:          yellow

Mutt

<f1> key binding in xterm

The <f1> key binding doesn't work with xterm if TERM is set to "xterm," which is the default value. In this case, run mutt like the following:

TERM=xterm-vt220 mutt

Using UTF-8 mutt under FreeBSD

Mutt includes code supporting UTF-8 charset. However, it requires external libraries like ncurses or slang. Recent version of ncurses allows input/output wide characters with the wide character version of the library, libncurses*w. Unfortunately, both the system ncurses and the default port don't compile with this feature. To compile ncursesw libraries, add --enable-widec flag to CONFIGURE_ARGS variable in /usr/port/devel/ncurses/Makefile:

CONFIGURE_ARGS= --datadir=${PREFIX}/share/misc --disable-overwrite \
                --disable-termcap --includedir=${PREFIX}/include/ncurses \
                --with-profile --with-shared --without-debug \
                --without-curses-h --with-termlib --program-prefix= \
                --enable-safe-sprintf --disable-root-environ    --enable-widec

and run the following:

cd /usr/port/devel/ncurses
make install clean
cd /usr/port/mail/mutt
WITH_NCURSES_PORT=yes make install clean

The UTF-8 feature should be enabled in xterm. Add the following line to ~/.Xdefaults:

xterm*utf8:	1

Now, configure mutt to use UTF-8 charset in ~/.mutt/muttrc:

set charset=utf-8

Searching encoded mails

~/.mutt/muttrc

# decode mails before searching
# e.g., base64 encoded body
set thorough_search=yes
# view a text/html attachment as a body so that mutt can search the body
# e.g., quoted-printale encoded text/html attachment
auto_view text/html

Firefox

Don't use cache!

Go to about:config and set browser.cache.check_doc_frequency to 1.

Alt+Accesskey

Go to about:config and set ui.key.contentAccess to 4.

Extension updates for Firefox 2

None of the following extensions were created by me:

Sage

tips/sage-1.3.6-fx+mz_geni.xpi

Sage fails to check updates even if some links are actually modified because it checks not only the last modified times of articles but also the signatures of their titles. It is sometimes needed or useful to keep the title of an article when the content is updated. This slightly modified version of Sage does not check signatures.

Keyconfig functions

http://www.calmar.ws/firefox/index.php

user_pref("keyconfig.main.addBookmarkAsKb", "shift][B][");
user_pref("keyconfig.main.focusURLBar", "shift][O][");
user_pref("keyconfig.main.focusURLBar2", "control][O][");
user_pref("keyconfig.main.goBackKb", "][,][");
user_pref("keyconfig.main.goForwardKb", "][.][");
user_pref("keyconfig.main.goHome", "][A][");
user_pref("keyconfig.main.key_find", "][/][");
user_pref("keyconfig.main.key_findAgain", "][N][");
user_pref("keyconfig.main.key_findPrevious", "shift][N][");
user_pref("keyconfig.main.key_fullScreen", "][F][");
user_pref("keyconfig.main.key_gotoHistory", "shift][H][");
user_pref("keyconfig.main.key_openDownloads", "][D][");
user_pref("keyconfig.main.key_reload", "][R][");
user_pref("keyconfig.main.key_search2", "][O][");
user_pref("keyconfig.main.key_viewInfo", "][I][");
user_pref("keyconfig.main.key_viewSource", "][S][");
user_pref("keyconfig.main.viewBookmarksSidebarKb", "][B][");
user_pref("keyconfig.main.xxx_key36_cmd_findAgain", "][N][");
user_pref("keyconfig.main.xxx_key37_cmd_findPrevious", "shift][N][");
user_pref("keyconfig.main.xxx_key_PageUp", "][U][][goDoCommand('cmd_scrollPageUp');");
user_pref("keyconfig.main.xxx_key_ScrollBottom", "shift][G][][goDoCommand('cmd_scrollBottom');");
user_pref("keyconfig.main.xxx_key_ScrollLeft", "][H][][goDoCommand('cmd_scrollLeft');");
user_pref("keyconfig.main.xxx_key_ScrollLineDown", "][J][][goDoCommand('cmd_scrollLineDown');");
user_pref("keyconfig.main.xxx_key_ScrollLineUp", "][K][][goDoCommand('cmd_scrollLineUp');");
user_pref("keyconfig.main.xxx_key_ScrollPageDown", "][ ][][goDoCommand('cmd_scrollPageDown');");
user_pref("keyconfig.main.xxx_key_ScrollRight", "][L][][goDoCommand('cmd_scrollRight');");
user_pref("keyconfig.main.xxx_key_ScrollTop", "][G][][goDoCommand('cmd_scrollTop');");
user_pref("keyconfig.main.xxx_key_findTypeLinks", "][;][][goDoCommand('cmd_findTypeLinks');");

Using external editors in the textarea field with Firefox 1.0PR

  1. Install http://downloads.mozdev.org/mozex/mozex-1.07.xpi.
  2. Close all Firefox windows.
  3. Add the following to prefs.js:
    user_pref("mozex.general.tmpdir", "c:\\temp");
    user_pref("mozex.command.download", "");
    // here specify your favorite editor
    user_pref("mozex.command.textarea", "c:\\progra~1\\vim\\vim62\\gvim.exe %t");
    user_pref("mozex.command.source", "c:\\progra~1\\vim\\vim62\\gvim.exe %t");
    user_pref("mozex.command.irc", "");
    user_pref("mozex.command.ftp", "");
    user_pref("mozex.command.aim", "");
    user_pref("mozex.command.ed2k", "");
    user_pref("mozex.command.telnet", "");
    user_pref("mozex.command.news", "");
    user_pref("mozex.command.mailer", "");
    user_pref("mozex.intercept.mailto", false);
    user_pref("mozex.intercept.news", false);
    user_pref("mozex.intercept.ftp", false);
    user_pref("mozex.intercept.irc", false);
    user_pref("mozex.universal.schemes", "");
    user_pref("mozex.universal.command", "");
    
  4. To use the UTF-8 charset, overwrite chrome/mozex.jar with the file from http://openlook.org/blog/happyhacking/0404MozexHangul.html.

Paper CD case

http://www.sci.fi/~tenu/origami.html

tips/2CD.gif


All the works in this site except software and copyrighted materials by others (e.g., 문학) are licensed under a Creative Commons License. 소프트웨어 및 문학과 같이 다른 이에게 저작권이 있는 작품을 제외하고 모두 크리에이티브 커먼즈 라이센스를 따른다.
Tue Feb 12 23:26:50 2019 . XHTML . CSS (lightbox.css is not part of Uniqki. ;-) . Powered by Uniqki!
refresh . edit . loginout . index