Tuesday, April 16, 2013

File Associations in Windows Regsitry

See [1] for the description of HKLM, HKCU, and HKCR. According to [2], HKCR provides a merged view of HKCU and HKLM. For ProgID, see [3]. For file extension, see [5].

File extensions config examples (see [7] for valid keys/entries):

for .rar:

  • HKLM/SOFTWARE/Classes/.rar has a key "(Default)" with ProgID "7-Zip.rar"
  • HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts/.rar
    • child: OpenWithProgids has a key named "7-Zip.rar" (appear in "open with" menu)
for .txt:
  • HKLM/SOFTWARE/Classes/.txt (apply to all users)
    • keys: (Default)=txtfile; Content Type=text/plain (txtfile is ProgID)
    • child: OpenWithProgids (appear in "open with" menu)
    • child: ShellNew
  • HKCU/SOFTWARE/Classes/.txt (apply to the interactive user)
    • Does not exist in my case
  • HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts/.txt (apply to the interactive user)
    • child: OpenWithProgids has a ProgID "txtfile"
    • child: UserChoice has a key named "Progid" with value "Applications/notepad++.exe" (!important)

Applications with ProgID:

  • HKLM/SOFTWARE/Classes/7-Zip.rar/shell/open/command (7-Zip.rar is ProgID)
  • HKLM/SOFTWARE/Classes/txtfile/shell/open/command: the value of "(Default)" is the command used to open files.

How a file extension (e.g. .txt) is mapped to a file type?

  • "UserChoice" takes the first precedence. If it is not set, key "(Default)" stores the ProgID which can be found under [HKCU|HKLM}/SOFTWARE/Classes/.

For gvim.exe, you should have HKLM/SOFTWARE/Classes/Applications/gvim.exe/shell:

  • edit/command[(Default)] = command
  • open/command[(Default)] = command
    Notes: "gvim.exe" is ProgID, see [3] for more detail.

How to change the default app when a file is double-clicked? (Take .c as an example)

  • Solution 1 (use entries for Explorer)
    1. For HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/FileExts/.c/UserChoice, set the value of key "UserChoice" to "Applications/gvim.exe".
    2. For HKLM/SOFTWARE/Classes/Applications/gvim.exe/shell/edit/command, set the value of key "(Default)" to '"C:\Program Files (x86)\Vim\vim73\gvim.exe" -p --remote-tab-silent "%1" "%*"'
    3. Open "Control Panel\Programs\Default Programs\Set Associations", you will see .txt has been associated with gvim.exe.
  • Solution 2
    UserChoice should not be set in this solution (you can delete it first).
    1. make sure HKLM/SOFTWARE/Classes/.c has the key "(Default)" set to "cfile".
    2. For HKLM/SOFTWARE/Classes/cfile/shell/open/command, set "(Default)" to the gvim command above.

References

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/ms724475%28v=vs.85%29.aspx
[2] http://msdn.microsoft.com/en-us/library/windows/desktop/ms724498%28v=vs.85%29.aspx
[3] http://msdn.microsoft.com/en-us/library/windows/desktop/dd542719%28v=vs.85%29.aspx
[4] http://msdn.microsoft.com/en-us/library/windows/desktop/ms690440%28v=vs.85%29.aspx
[5] http://msdn.microsoft.com/en-us/library/windows/desktop/ms678415%28v=vs.85%29.aspx
[6] http://msdn.microsoft.com/en-us/library/windows/desktop/hh127445%28v=vs.85%29.aspx
[7] http://msdn.microsoft.com/en-us/library/windows/desktop/cc144148%28v=vs.85%29.aspx#fa_optional_keys_attributes

Sample reg file

Be careful, it will overwrite the current value!!!
============================================

Windows Registry Editor Version 5.00 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.c] 
@="cfile" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\cfile\shell\open\command] 
@="\"C:\\Program Files (x86)\\Vim\\vim73\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\"" 
============================================
Note: the value must be a string put in double quotations!
  

Monday, March 18, 2013

Eclipse shortcuts

   
Ctrl+Shift+O organize imports
Ctrl+Shift+M Add imports
Ctrl+Alt+H Show call hierarchy
Ctrl+T Show type hierarchy
Ctrl+1 quick fix
Alt+Shift+J Add comments
Ctrl+I correct indentation
Ctrl+Shift+Space show parameter hints
   
Ctrl+D delete a line
Ctrl+Shift+Delete Delete to the end of line
Alt+Up/Down move current line
Ctrl+Q jump to last-edit place
Alt+/ auto-completion
Ctrl+Alt+J Join lines
Shift+Alt+Up Select Enclosing Element
Shift+Alt+Left Select Previous Element
Shift+Alt+Right Select Next Element
   
Ctrl+O open outline dialog
Ctrl+Shift+R open resource dialog
Ctrl+E show opened files
Ctrl+Shift+E open a dialog showing opened files
   
Ctrl+Shift+P jump to matching parenthesis
   

Saturday, October 13, 2012

Git cheatsheet


My random notes on Git use.

   
   
   
g checkout path for path, reset WT to Index (change WT)
g checkout tree-ish path for path, reset WT and Index to tree-ish (change WT and Index)
g checkout branch switches branch by updating the index, working tree, and HEAD to reflect the specified branch (current branch is switched)
g checkout commit_id check out a commit for inspection and discardable experiments.
(current branch is switched)
g checkout -p commit_id don't switch branch; update working tree and Index interactively.
E.g. g checkout -p HEAD
g checkout -b branchname\
    start_point
create a new branch from start_point and switch to it.
(current branch is switched)
g checkout not sure yet!
   
g reset path for path, reset index to HEAD (WT and branch are not touched)
g reset commit path for path, reset index to commit (WT and branch are not touched)
g reset --option commit reset HEAD to commit, and reset index or WT according to option
(http://www.kernel.org/pub/software/scm/git/docs/git-reset.html)
--soft only reset HEAD
--mixed (default) reset HEAD and index
--hard reset HEAD, index, and WT
--merge reset HEAD and index;
for each file:
    HEAD != commit, then reset WT;
    Index != WT, then don't reset WT;
    HEAD != commit && Index != WT, then abort.
--keep reset HEAD and index;
for each file:
    HEAD == commit, then don't reset WT;
    HEAD != commit && WT == Index && Index == HEAD, then reset WT;
    HEAD != commit && has local changes, then abort.
   
git rebase -i upstream interactively rebase. You can choose to squash commits.
E.g. git rebase -i HEAD^4, git rebasei HEAD@{4}

Friday, September 14, 2012

Jabberd2 and OpenFire notes

Resources:
http://www.24100.net/2009/11/federate-google-wave-sandbox-with-your-own-fedone-server/

If you have a pkcs12 that contains your private key and certificate chain, use following command to convert it to pem:

openssl pkcs12 -in startssl.p12 -out startssl.pem –nodes

Maybe you need to manually adjust order of certificates in the generated pem file. You client cert should appear first, then certs from intermediate CAs, and root CA cert.

Read comments in file http://codex.xiaoka.com/svn/jabberd2/trunk/etc/c2s.xml.dist.in

<id register-enable='true'
    require-starttls='true'
    pemfile='/home/gerald/ongoing/jabberd2/startssl.pem'>129-79-49-197.dhcp-bl.indiana.edu</id>

Don’t put it this way for readability:

<id register-enable='true'
    require-starttls='true'
    pemfile='/home/gerald/ongoing/jabberd2/startssl.pem'>
129-79-49-197.dhcp-bl.indiana.edu</id>

You will get “Host Unknown” error :-(

FedOne

router.xml
local –> secret

run-config.sh
XMPP_SERVER_PORT=5347

sm.xml: sm->id

c2s.xml: c2s->local –>id

Certificate for you domain

openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out wave1.example.com.key
openssl req -new -nodes -sha1 -days 365 -key wave1.example.com.key -out wave1.example.com.csr
Note: Common Name (eg, YOUR name) []: wave1.wave.zhenhua.info

DNS

SRV

Settting
_xmpp-server._tcp.wave1.example.com               wave1.example.com 5269
_xmpp-server._tcp.wave.wave1.example.com      wave1.example.com 5269

Priority and weight are not so important in our SRV settings.

Testing
dig +short -t SRV _xmpp-server._tcp.wave1.example.com
dig +short -t SRV _xmpp-server._tcp.wave.wave1.example.com

A

wave1.example.com    your_server_ip_address

FedOne server config

WAVE_SERVER_DOMAIN_NAME=wave1.example.com     # not wave.wave1.example.com

XMPP_SERVER_PING=initech-corp.com

Use ./check-certificates.sh to check your certificate settings.

 

Hostname used set in OpenFire and FedOne server should match (wave1.example.com in our example).

edit /etc/openfire/openfire.xml, change <setup>true</setup> to <setup>false</setup>. restart the server.

Server Manager –> Server Information, section “Server Properties”:
Server Name: wave1.example.com

OpenFire

Add a user named “username”. Your users will have accounts like username@wave1.example.com

Test

Open client console: ./run-client-console.sh username

type /new, /open 0, /add your_wavesandbox_account, then type a message. You should see the message in your wavesandbox page. There is delay (for me about 1 minute).

In google wave sandbox, add user@wave1.example.com to your address book

windows migration notes

Bakcup
Following is the default profile/configuration file locations for some programs. It may vary because of your customized setting during installation.

  • Messenger
    c:\Users\gerald\Documents\My Received Files\jenvor381158107\
  • WLW
    c:\Users\gerald\Documents\My Weblog Posts\
    c:\Users\gerald\AppData\Roaming\Windows Live Writer\
  • Skype
    c:\Users\gerald\AppData\Roaming\Skype\
  • Filezilla
    c:\Users\gerald\AppData\Roaming\FileZilla\
  • Totalcmd
    c:\Users\gerald\AppData\Roaming\GHISLER\
    Change file wincmd.ini: to add a section for your resolution (like [1024 x 768])
  • Firefox
    c:\Users\gerald\AppData\Roaming\Mozilla\
  • SecureCRT
    c:\Users\gerald\AppData\Roaming\VanDyke\Config\
  • Outlook
    pst files: c:\Users\gerald\AppData\Local\Microsoft\Outlook\
    Accounts: go to registry Current_User/Software/Microsoft/WindowsNT/Messaging Sub Systems/Outlook/Profile, export and import it
  • FileZilla server
    The installation directory. cert

Thursday, May 03, 2012

Vim Latex Suite Reference Card

Found a great reference card at http://michaelgoerz.net/refcards/vimlatexqrc.pdf. I made a picture out of it so that you can direct read it.

vimlatex_ref_card

Sunday, April 29, 2012

Wrap acronyms with \ac in Vim

:s/\(\W\)\(\u\{2,10\}\)\(\W\)/\1\\ac{\2}\3/g
:s/\(\W\)\(\u\{2,10\}\)$/\1\\ac{\2}/g
:s/^\(\u\{2,10\}\)\(\W\)/\\ac{\1}\2/g
:s/^\(\u\{2,10\}\)$/\\ac{\1}/g

Sunday, February 19, 2012

implement readLine using read

http://www.mitbbs.com/article_t/JobHunting/32042617.html
char *readLine() {
    int bufSize = 1024;
    static char *buf = malloc(sizeof(char) * (1 + bufSize));
    static int bytesAfterNewLine = 0;   // number of bytes left from last call
    static int lastpos = 0;             // where the leftover starts

    int totalBytes = 0; // total number of bytes in the array
    int foundLineBreak = 0;

    if (bytesAfterNewLine != 0) {
        memmove(buf, buf + lastpos, bytesAfterNewLine);
        totalBytes = bytesAfterNewLine;
        lastpos = 0;
    }

    while (true) {
        for (; lastpos < totalBytes; ++lastpos) {
            if (buf[lastpos] == '\n') {
                buf[lastpos] == '\0';
                bytesAfterNewLine = totalBytes - lastpos - 1;
                foundLineBreak = 1;
                lastpos = (last + 1) % bufSize;
                break;
            }
        }
        if (foundLineBreak) break;

        if (bufSize == totalBytes) {
            bufSize *= 2;
            buf = realloc(buf, bufSize + 1);
        }

        int bytes = 0;
        while (true) {
            bytes = read(buf + totalBytes, bufSize - totalBytes);
            if (bytes != 0) break;
        }

        if (bytes == -1) {
            buf[totalBytes] = '\0';
            break;
        }

        totalBytes += bytes;
    }

    if (totalBytes == 0 && foundLineBreak == 0) {
        return NULL:
    } else {
        return buf;
    }
}

Saturday, February 18, 2012

How to delete the blank page after a table in Microsoft Word

This stupid and simple problem has been bugging me for ages!!! There is a simple workaround for me.
Select the blank paragraph, go to Font dialog, in tab "Font", select "Hidden", then the annoying blank page just disappears.

Note: if you turn on "Show paragraph marks and other hidden formatting symbols", the hidden text will be shown.

Monday, December 12, 2011

RabbIT

Enable filter rabbit.filter.ReverseProxy, by adding it to the front of httpinfilters value.
Configure values for sector rabbit.filter.ReverseProxy.
httpinfilters=rabbit.filter.ReverseProxy,rabbit.filter.HttpBaseFilter,rabbit.filter.DontFilterFilter,rabbit.filter.BlockFilter,rabbit.filter.RevalidateFilter
......
[rabbit.filter.ReverseProxy]
# This filter is not enabled by default, add it to httpinfilters if you want it.
# This Filter makes rabbit work as an accellerator for one web site.
# Change requests
transformMatch=^/(.*)
transformTo=http://<target_host>:
<port>/$1
# Deny proxy requests, you probably want this.
# deny=^http(s?)://.*
deny=
# If we want to allow admin access.
allowMeta=true
Run RabbIT:
java -jar jars/rabbit4.jar -f conf/rabbit.conf
Resource: http://www.khelekore.org/rabbit/