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.