Skip to content

git cmds

1. Create central repo:
ssh <user>@<host>
cd path/above/repo
git init –bare my-project.git

2. Clone a local copy:
git clone <repo> [<directory>]
git clone ssh://john@example.com/path/to/my-project.git
cd my-project

3. configuration:
git config –global user.name “Wang Jun”
git config –global user.email a@b.com
git config –system core.editor vim
#git config –global –edit

repo specific

4. log
git log –author=”<pattern>”
git log –grep=”<pattern>
git log <since>..<until>
git log –author=”John Smith” -p hello.py

5. checkout
git checkout a1e8fb5 hello.py
git checkout HEAD hello.py
git revert <commit>
git rebase <base>

# Start a new feature
git checkout -b new-feature master
# Edit files
git commit -a -m “Start developing a feature”
# Edit more files
git commit -a -m “Fix something from the previous commit”

# Add a commit directly to master
git checkout master
# Edit files
git commit -a -m “Fix security hole”

# Begin an interactive rebasing session
git checkout new-feature
git rebase -i master

Git best practices:
https://wiki.duraspace.org/display/FCREPO/Git+Guidelines+and+Best+Practices#GitGuidelinesandBestPractices-CommitMessages

calculating x to power of 100 where x is a digit in the range of 0..9

#include <iostream>
#include <string>

std::string power(const char c, unsigned int p) {
    switch (c) {
        case '0': return "0";
        case '1': return "1";
        case '2': case '3': case '4':
        case '5': case '6': case '7':
        case '8': case '9':
                  {
                      //  return times2(a);
                      std::string r(1, c);
                      int m = c - '0';
                      for (int i = 0; i < p; ++i) {
                          int cf = 0;
                          std::string nr = "";
                          for (int j = 0; j < r.size(); ++j) {
                              int d = r[r.size() - 1 - j] - '0';
                              int v = d * m + cf;
                              char nv = v % 10 + '0';
                              cf = v / 10;
                              nr = std::string(1, nv) + nr;
                          }

                          if (0 != cf) {
                              char f = cf + '0';
                              nr = std::string(1, f) + nr;
                          }

                          r = nr;
                      }
                      return r;
                  }
        default:
                  throw "input range: 0..9";
        return "";
    }
}

int main() {
    std::cout << power('9', 100) << std::endl;
}

05:49:51@Local: /workspace/quantcast/
$ g++ power.cpp; ./a.exe
2390525899882872924049031898322016641463101073880550463771174655651832418111719646949462291396009

Further thought:
1) One byte could store up to 255, but it only used to store a single digit up to 9, quite a big waste in terms storage. What about making full usage of 255 values – effective way to converting base 16 to base 10 for an ordered set of bytes
2) a^4 could be calculate using either a*a*a*a or (a*a)^2, what’s the difference in terms of complexity
3) If (a*a)^2 is the more efficient, what’s the optimal way to partition 100 – integer partition problem: 100 = 64 + 32 + 4?
and dynamic programming ?
4) It’s always better to do some search on any problem encountered first time – most problems are solved already – check http://www.apfloat.org/apfloat/

Haskell notes – learn you a haskell for great good

– Putting a space between two things is simply function application. The space is sort of like an operator and it has the highest precedence.
– the ++ function is much more expensive than :, so we usually use right folds when we’re building up new lists from a list.
- the $ function has the lowest precedence. Function application with a space is left-associative (so f a b c is the same as ((f a) b) c)), function application with $ is right-associative.

- Function application: f, x could both be some expressions rather than single value
($) :: (a -> b) -> a -> b
f $ x = f x

– Function composition: Function composition is right-associative
(.) :: (b -> c) -> (a -> b) -> a -> c
f . g = \x -> f (g x)

– A fixity states how tightly the operator binds and whether it’s left-associative or right-associative. For instance, *’s fixity is infixl 7 * and +’s fixity is infixl 6. That means that they’re both left-associative (4 * 3 * 2 is (4 * 3) * 2) but * binds tighter than +, because it has a greater fixity, so 5 * 4 + 3 is (5 * 4) + 3.

– class Functor f where
fmap :: (a -> b) -> f a -> f b
f is a type constructor that takes one type parameter – Maybe, Either a, []
instance Functor [] where
fmap = map
– A concrete type is a type that doesn’t take any type parameters and values can only have types that are concrete types. Types are little labels that values carry so that we can reason about the values. But types have their own little labels, called kinds. A kind is more or less the type of a type.

– class (Functor f) => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b

<*> is left-associative
instance Applicative Maybe where
pure = Just
Nothing <*> _ = Nothing
(Just f) <*> something = fmap f something

(<$>) :: (Functor f) => (a -> b) -> f a -> f b
f <$> x = fmap f x

instance Applicative [] where
pure x = [x]
fs <*> xs = [f x | f <- fs, x <- xs]

instance Applicative IO where
pure = return
a <*> b = do
f x ) r) where
pure x = (\_ -> x)
f <*> g = \x -> f x (g x)

instance Applicative ((->) r) where
pure x = (\_ -> x)
f <*> g = \x -> f x (g x)

instance Functor ((->) r) where
fmap f g = (\x -> f (g x))
==> which is function composition:
instance Functor ((->) r) where
fmap = (.)

(+) <$> (*3) <*> (+5)
1. ==> pure (+)  <*> (*3) <*> (+5)
2. ==> f = \_ -> (+) g = (*3) ==> f x = (+) ==> f <*> g = \x -> (+) ((*3) x)
3. ==> f = \x -> (+) ((*3) x) g = (+5) ==> f x = (+) ((*3) x)
==> f <*> g = \x -> (+) ((*3) x) ((+5) x)
(+) <$> (*3) <*> (+5) $ 2 = (+) (*3 2) (+5 2) = 13

(r->a->b->c)->(r->a->b)->r->b->c
f <*> g = \x -> f x $ g x
– Apply function to value within context – Functor
– Apply function within context to value within context – Applicative
– The context above means any type has a kind *->*

– Because one type can’t have two instances for the same typeclass, the ZipList a type was introduced, which has one constructor ZipList that has just one field, and that field is a list.
newtype ZipList a = ZipList { getZipList :: [a] }
instance Applicative ZipList where
pure x = ZipList (repeat x)
ZipList fs ZipList xs = ZipList (zipWith (\f x -> f x) fs xs)

– the ZipList a type doesn’t have a Show instance, so we have to use the getZipList function to extract a raw list out of a zip list.
– The (,,) function is the same as \x y z -> (x,y,z). Also, the (,) function is the same as \x y -> (x,y).

liftA2 :: (Applicative f) => (a -> b -> c) -> f a -> f b -> f c
liftA2 f a b = f a b
it just applies a function between two applicatives,
(a -> b -> c) -> (f a -> f b -> f c). When we look at it like this, we can say that liftA2 takes a normal binary function and promotes it to a function that operates on two functors.

- If you just want your type signatures to look cleaner and be more descriptive, you probably want type synonyms. If you want to take an existing type and wrap it in a new type in order to make it an instance of a type class, chances are you’re looking for a newtype. And if you want to make something completely new, odds are good that you’re looking for the data keyword.

- A monoid is when you have an associative binary function and a value which acts as an identity with respect to that function.

class Monoid m where
mempty :: m
mappend :: m -> m -> m
mconcat :: [m] -> m
mconcat = foldr mappend mempty

instance Monoid [a] where
mempty = []
mappend = (++)

– when there are several ways for some type to be an instance of the same type class, we can wrap that type in a newtype and then make the new type an instance of the type class in a different way. We can have our cake and eat it too.
step 1: (we usually don’t add constraint to data type declaration, but to function signature)
newtype Product a = Product { getProduct :: a }
deriving (Eq, Ord, Read, Show, Bounded)
step 2:
instance Num a => Monoid (Product a) where
mempty = Product 1
Product x `mappend` Product y = Product (x * y)

newtype Any = Any { getAny :: Bool }
deriving (Eq, Ord, Read, Show, Bounded)
instance Monoid Any where
mempty = Any False
Any x `mappend` Any y = Any (x || y)

newtype All = All { getAll :: Bool }
deriving (Eq, Ord, Read, Show, Bounded)
instance Monoid All where
mempty = All True
All x `mappend` All y = All (x && y)

instance Monoid Ordering where
mempty = EQ
LT `mappend` _ = LT
EQ `mappend` y = y
GT `mappend` _ = GT

instance Monoid a => Monoid (Maybe a) where
mempty = Nothing
Nothing `mappend` m = m
m `mappend` Nothing = m
Just m1 `mappend` Just m2 = Just (m1 `mappend` m2)

ghci> :t foldr
foldr :: (a -> b -> b) -> b -> [a] -> b
ghci> :t F.foldr
F.foldr :: (F.Foldable t) => (a -> b -> b) -> b -> t a -> b

data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show, Read, Eq)

instance F.Foldable Tree where
foldMap f Empty = mempty
foldMap f (Node x l r) = F.foldMap f l `mappend`
f x `mappend`
F.foldMap f r

– monads are just applicative functors that support >>=. The >>= function is pronounced as bind.
(>>=) :: (Monad m) => m a -> (a -> m b) -> m b
>>= takes a monadic value, and a function that takes a normal value and returns a monadic value and manages to apply that function to the monadic value.

class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b

(>>) :: m a -> m b -> m b
x >> y = x >>= \_ -> y

fail :: String -> m a
fail msg = error msg

Monad laws
1. left identity: return x >>= f = f x
2. right identity: m >>= return = m
3. associativity: (m >>= f) >>= g = m >>= (\x -> f x >>= g)

(.) :: (b -> c) -> (a -> b) -> (a -> c)
f . g = (\x -> f (g x))

(<=<) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c)
f <=< g = (\x -> g x >>= f)

instance Monad Maybe where
return x = Just x
Nothing >>= f = Nothing
Just x >>= f = f x
fail _ = Nothing

foo :: Maybe String
foo = Just 3 >>= (\x ->
Just “!” >>= (\y ->
Just (show x ++ y)))

foo :: Maybe String
foo = do
x <- Just 3
y >= f = concat (map f xs)
fail _ = []
ghci> [1,2] >>= \n -> [‘a’,’b’] >>= \ch -> return (n,ch)
[(1,’a’),(1,’b’),(2,’a’),(2,’b’)]
ghci> [(n, ch) | n list comprehension is syntactic sugar for using list as monad
listOfTuples :: [(Int,Char)]
listOfTuples = do
n ch MonadPlus m where
mzero :: m a
mplus :: m a -> m a -> m a

guard :: (MonadPlus m) => Bool -> m ()
guard True = return ()
guard False = mzero

sevensOnly :: [Int]
sevensOnly = do
x<-[1..50]
guard (‘7’ `elem` show x)
return x

Empty class – not so empty

Conclusion:

1. Both g++ and msvc implemented base class optimizations.

2. MSVC does a better job than g++ with respect to empty base class optimization when base class is derived class as well

#include <iostream>

//A virtual base class subobject occurs only once in the derived class regardless of the number of times it occurs within the class inheritance hierarchy.
//Static data members are maintained within the global data segment of the program and do not affect the size of individual class objects.
class X {};
class Y : public virtual X {};
class Z : public virtual X {};
class A : public Y, public Z {};

class Y1 : public X {};
class Z1 : public X {};
class A1 : public Y1, public Z1 {};

class Y2 {};
class Z2 : public X {};
class A2 : public Y2, public Z2 {};

int main() {
using namespace std;
cout << “virtual inheritance” << endl;
cout << “sizeof(X) : ” << sizeof(X) << endl;
cout << “sizeof(Y) : ” << sizeof(Y) << endl;
cout << “sizeof(Z) : ” << sizeof(Z) << endl;
cout << “sizeof(A) : ” << sizeof(A) << endl;

cout << endl << “non virtual inheritance” << endl;
cout << “sizeof(X) : ” << sizeof(X) << endl;
cout << “sizeof(Y1) : ” << sizeof(Y1) << endl;
cout << “sizeof(Z1) : ” << sizeof(Z1) << endl;
cout << “sizeof(A1) : ” << sizeof(A1) << endl;

cout << endl << “non virtual inheritance 2” << endl;
cout << “sizeof(X) : ” << sizeof(X) << endl;
cout << “sizeof(Y2) : ” << sizeof(Y2) << endl;
cout << “sizeof(Z2) : ” << sizeof(Z2) << endl;
cout << “sizeof(A2) : ” << sizeof(A2) << endl;
return 0;
}

 

Output:

Cygwin g++

$ ./a.exe
virtual inheritance
sizeof(X) : 1
sizeof(Y) : 4
sizeof(Z) : 4
sizeof(A) : 8

non virtual inheritance
sizeof(X) : 1
sizeof(Y1) : 1
sizeof(Z1) : 1
sizeof(A1) : 2

non virtual inheritance 2
sizeof(X) : 1
sizeof(Y2) : 1
sizeof(Z2) : 1
sizeof(A2) : 1

 

Output

MSVC cl.exe

$ ./empty.exe
virtual inheritance
sizeof(X) : 1
sizeof(Y) : 4
sizeof(Z) : 4
sizeof(A) : 8

non virtual inheritance
sizeof(X) : 1
sizeof(Y1) : 1
sizeof(Z1) : 1
sizeof(A1) : 1

non virtual inheritance 2
sizeof(X) : 1
sizeof(Y2) : 1
sizeof(Z2) : 1
sizeof(A2) : 1

 

and linux g++ 64bits

$ ./a.out
virtual inheritance
sizeof(X) : 1
sizeof(Y) : 8
sizeof(Z) : 8
sizeof(A) : 16

non virtual inheritance
sizeof(X) : 1
sizeof(Y1) : 1
sizeof(Z1) : 1
sizeof(A1) : 2

non virtual inheritance 2
sizeof(X) : 1
sizeof(Y2) : 1
sizeof(Z2) : 1
sizeof(A2) : 1

template calls – c++

struct Bar
{
template
void func() const { }

template
static void sfunc() { }
};

template
void Foo1(T const & t)
{
t.template func();
T::template sfunc();
}

template
void Foo2(T const * pT)
{
pT->template func();
}

int main()
{
Bar bar;
Foo1(bar);
Foo2(&bar);
}

Linux/Cygwin Utils and setup (at the end)

1. install cygwin, mrxvt

2. config X to open mrxvt terminal on startup
$ cat .startxwinrc
mrxvt -C -geometry 175×65+2+5

3. config mrxvt to open 4 tabs on startup

mrxvt sample config

4. config bash to start X in .profile
# start X server
if [ “$DISPLAY” = “” ]; then
/usr/bin/startxwin > /dev/null 2>&1
fi

# start the cron
if [ -z “`ps -ef | grep cron`” ]; then
/usr/sbin/cron.exe & > /dev/null 2>&1
fi

# enable sshd demon
if [ -z “`ps -ef | grep sshd`” ]; then
net start sshd & > /dev/null 2>&1
fi

5. customized .bashrc
export PS1=”\[$(tput setaf 3)\]\T\[$(tput setaf 5)\]@\[$(tput setaf 6)\]Local:\[$(tput setaf 5)\] \w \n$ \[$(tput sgr0)\]”
export GREP_OPTIONS=”–color=auto –binary-files=without-match –exclude-dir=*\_make\* –exclude-dir=*\.svn* –exclude=tags ”

export DISPLAY=:0

# to work with dircolors
export SHELL=’/bin/bash.exe’

# work together with shopt -s force_fignore
export FIGNORE=.svn

# This is used by cron
export TERM=rxvt

alias vim=’vim -O’
alias bc=’bc -l’
alias ls=’ls –color=auto -F –group-directories-first’

# bash completeoin speed up
shopt -s checkhash
shopt -s cdspell
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -s dotglob
shopt -s dirspell
shopt -s force_fignore

# Enable alias expansion
shopt -s expand_aliases

export HISTIGNORE=”&:ls:[bf]g:exit:[ \t]*”
export HISTCONTROL=erasedups

6. passwordless access – SSH setup
1. genearate keys id_rsa and id_rsa.pub
cmd: ssh-keygen.exe -t rsa

2. Append id_rsa.pub to server ~/.ssh/authorized_keys file
cmd: cd ~/.ssh; cat id_rsa.pub >> authorized_keys

Testing and if there are problems, Check:
a. On client side: check .ssh/config file configures to use generated id_rsa above

b. On Server side: check ssh server configuration file enables the following options
RSAAuthentication yes
PubkeyAuthentication yes
and restart sshd deamon

Debug
ssh -vv user@server
-q suppress message
on server touch ~/.hushlogin

7. config access different servers with different private keys/IDs

$cat ~/.ssh/config
Host dev*.xxx.com
IdentityFile /workspace/.ssh/id_rsa_dev
User abc
Host uva*.xxx.com
IdentityFile /workspace/.ssh/id_rsa_uva
User abc2

IdentityFile /workspace/.ssh/id_rsa
User axxxx

8. config vim settings .vimrc
” for cygwin
set shell=C:/cygwin/bin/bash

ab aW w! /home/xxx/vimfiles/tmp.a
ab aW r /home/xxx/vimfiles/tmp.a
” disable swap file
“set noswapfile
set dir=/tmp
” vim will put the filename and some other information in tht title bar
set title
set titlestring=%f
set tags+=~/tags
” Spaces instead of tabs
set expandtab

–some cmds:
unique rows/remove duplicate rows
:sort u/n/i
delete non matching lines:
:v/warning/d
reverse lines:
:g/^/m0
vim greedy vs non-greedy match
Instead of .* use .\{-}.
ctags -R -a –tag-relative -f ~/tags *

9. GIT workflow
git checkout -b develop
…make some changes…
…notice master has been updated…

git checkout master
git pull
…bring those changes back into develop…

git checkout develop
git rebase master
…make some more changes…
…commit them to develop…
…merge them into master…

git checkout master
git pull
git merge develop

10. Bash (just a few sample)
$ ls compile.bs tags sqlnet.log
$ ls !:2
ls tags

!! – Last command (!-1) !-n nth cmd from the last
!foo – Run most recent command starting with ‘foo…’ (ex. !ps, !mysqladmin)
!foo:p – Print command that !foo would run, and add it as the latest to command history
!$ – Last ‘word’ of last command (‘/path/to/file’ in the command ‘ls -lAFh /path/to/file’, ‘-uroot’ in ‘mysql -uroot’)
!$:p – Print word that !$ would substitute
!* – All but first word of last command (‘-lAFh /path/to/file’ in the command ‘ls -lAFh /path/to/file’, ‘-uroot’ in ‘mysql -uroot’)
!*:p – Print words that !* would substitute
^foo^bar
`cp file{.bk}` runs `cp file file.bk`

11. Driver installation
Installation –
1. add library path to /usr/lib/oracle/11.2/client64/lib to /etc/ld.so.conf
2. run /sbin/ldconfig

sample ODBC
In unixODBC ODBC drivers are defined in the odbcinst.ini file
$ odbcinst -j
unixODBC 2.3.1
DRIVERS…………: /usr/local/unixODBC/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/unixODBC/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/unixODBC/etc/ODBCDataSources
USER DATA SOURCES..: /home/xxxx/.odbc.ini
SQLULEN Size…….: 8
SQLLEN Size……..: 8
SQLSETPOSIROW Size.: 8

export ODBCSYSINI=$HOME/myodbcconfig
SYSTEM DSN file: odbc.ini
driver definitions: odbcinst.ini

list user and system data sources with:
$ odbcinst -q -s

list all installed ODBC drivers with:
$ odbcinst -q -d

testing connection
$isql -v DSN_NAME db_username db_password
sqlplus username/password@//host.sg.xxx.com:1621/schema

12. program debug
export LD_DEBUG=files/bindings/libs/versions
ldd: the list of the shared libraries used by a program
/lib/ld-linux.so.N : the library that loads all other libraries
libc.so.N : the C library

1. Find all the dependent DLLs using objdump:
05:59:42@Local: /workspace/xxx/dist
$ cat dependentDlls.sh
objdump -p $1 | grep “DLL Name” | cut -d”:” -f2 | tr -d ” ”
06:02:53@Local: /workspace/xxx/dist
$ ./dependentDlls.sh RunTime.dll
WSOCK32.dll
WS2_32.dll
MSVCP90.dll
MSVCR90.dll

$cat dependent.sh
dependentDlls()
{
objdump -p $1 | grep “DLL Name” | cut -d”:” -f2 | tr -d ” ”
}

checkDll()
{
dllPath=`grep $1 dll.tmp -i | head -1`
if [ -z $dllPath ]; then
echo “DLL $1 missing”
else
dependentDlls $dllPath
fi
}

dep()
{
for i in `checkDll $1`
do
dep $i
done
echo “Dependents for DLL: $1”
}

dep $1

=================================
http://x.cygwin.com/docs/ug/using-window-managers.html
Cygwin/X packages are located in the X11 category.

1. xorg-server (required, the Cygwin/X X Server)
2. xinit (required, scripts for starting the X server: xinit, startx, startwin (and a shortcut on the Start Menu to run it), startxdmcp.bat )
3. xorg-docs (optional, man pages)
4. X-start-menu-icons (optional, adds icons for X Clients to the Start menu)
5. You may also select any X client programs you want to use, and any fonts you would like to have available.
6. You may also want to ensure that the inetutils or openssh packages are selected if you wish to use telnet or ssh connections to run remote X clients.

Modify the cygwin.bat file. The .bat file specifies the commands and their sequence that bash must go through. Where the “Unix” directory on the “C” drive contains the traditional Unix directories, you can name it anything you want as long a you do not use any characters that confuse Unix, e.g., hyphens, spaces, etc. Configure your cygwin.bat file using a text editor such as Notepad. Do not use Microsoft Word or anything that imparts formatting. The C:\Cygwin directories, and C:\unix directories include your crucial home directory. Configure the .bat file so that it looks like this:
@ECHO OFF
SET MAKE_MODE=Unix
SET CYGWIN=notty
SET HOME=C:\unix\HOME\[your home directory name]
SET TERM=VT100
CHDIR C:\Unix\HOME\[your home directory name]
SET PATH=C:\Unix\BIN;C:\Unix\USR\LOCAL\BIN;C:\CYGWIN\BIN;%PATH%
BASH

Openssh
http://openbsd.org.ar/pub/OpenBSD/OpenSSH/portable/

The following commands will do that:
$ cygrunsrv –stop cron
$ cygrunsrv –remove cron
$ cygrunsrv –install cron -p /usr/sbin/cron -a -D
$ cygrunsrv –start cron

mrxvt sample config

# Sample configuration for mrxvt-0.5.0. To use, copy it to ~/.mrxvtrc.
#
# This sets up a pseudo-transparent terminal with black tinted background, Xft
# font, a transparent Firefox style tab-bar, and a next style scroll bar.
#
# Additionally, using the -name option you can get the following behaviour:
#
#   Full screen:
#     Start mrxvt with “mrxvt -name FullScreen”. Produces a full screen
#     terminal.
#
#   Kitchen Sink:
#     Start mrxvt with “mrxvt -name KitchenSink”. This produces an mrxvt
#     window with three tabs on startup. It loads your shell in the first tab,
#     and vim and mutt in the other two tabs. There aren’t any other
#     applications you need to load anyway… 😉
#
#   FvwmConsole:
#     Produces a small blue tinted terminal, mainly for use as an fvwm
#     console. Just load the FvwmConsole module with
#
#         FvwmConsole -terminal mrxvt
#
#     and these settings will be used.
#
#   Root:
#     Start mrxvt with “mrxvt -name Root”. This produces a green tinted mrxvt
#     windows which loads a root shell in the first tab. Ctrl+Shift+t opens a
#     new tab as root, and Ctrl+Shift+n opens a new tab as a regular user.
#
#
# —————————–   TAB-BAR OPTIONS —————————— #
#

# Open three tabs at startup
Mrxvt.initProfileList:      0,0,0,0
Mrxvt.tabBackground:        yellow

# Initial window size
Mrxvt.geometry:             175×65+2+5
Mrxvt.bottomTabbar:         True

# Only show the tab bar if there is more than one tab.
Mrxvt.autohideTabbar:       True

# The number of tabs to attempt to keep visible. The width of tabs will shrink
# to keep at least these many tabs visible.
Mrxvt.minVisibleTabs:       8

# The max width in chars for each tab (only used with x11 fonts, or if xftPFont
# is not specified).
# Mrxvt.maxTabWidth:      17

# Hide left / right / close buttons in the tab bar.
Mrxvt.hideButtons:      True

# Make the terminal title the same as the active tab title.
Mrxvt.syncTabTitle:       True
# Mrxvt.syncTabIcon:      true

# Display the tab number in the title. Useful so that you can use Alt+digit to
# quickly switch between tabs.
Mrxvt.titleFormat:        %n. %t

# Highlight inactive tabs only when they sound a bell (and not whenever they
# produce output).
Mrxvt.highlightTabOnBell: True

# Tab bar colors
Mrxvt.itabBackground:     #101010
Mrxvt.tabBackground:      #000000
Mrxvt.itabForeground:     #909090
Mrxvt.tabForeground:      #9a9a9a

# Mrxvt.tabbarPixmap:     tabbarbg.png
# Mrxvt.tabUsePixmap:     false

# Monitor tabs for activity or inactivity
# (alternate arguments for MonitorTab macro : “INACTIVITY” / “ACTIVITY”)
Mrxvt.macro.Ctrl+Shift+g:     MonitorTab AUTO
#Mrxvt.monitorTimeout:         2000
#Mrxvt.monitorCommand:           play ~/.ding_sound.wav
#Mrxvt.monitorCommand:           aosd_cat –fontdesc=”Trebuchet 20″ –ypos=50 –delay=4000 Alert on tab %n :: %t
#Mrxvt.monitorCommand:           xmessage Monitor alert on tab %n

#
# ———————- SCROLLING / SCROLLBAR OPTIONS ———————– #
#

Mrxvt.scrollBar:            true
Mrxvt.scrollbarRight:       true
Mrxvt.scrollbarStyle:       rxvt

# Number of lines to save in the scroll back buffer for all tabs
Mrxvt.saveLines:            3500

# Don’t scroll to the bottom every time some output is produced.
Mrxvt.scrollTtyOutputInhibit: true

# Scroll to the bottom when a key is pressed.
Mrxvt.scrollTtyKeypress:  true

# Scroll bar colors
Mrxvt.scrollColor:        #808080
Mrxvt.troughColor:        #202020

# Mrxvt.scrollbarPixmap:  scrollbarbg.jpg
#
# ——————————- TRANSPARENCY ——————————- #
#

# True translucency (using Xorg’s composite extension).
# Mrxvt.opacity:      75
# Mrxvt.opacityDegree:        5

# Pseudo transparency. As long as you set the background using an esetroot
# compatible program (e.g. feh), then the following will work. It is pretty
# resource friendly too :).
Mrxvt.transparent:        True
Mrxvt.transparentScrollbar:   True
Mrxvt.transparentTabbar:  True
Mrxvt.transparentMenubar: False

# Color / degree to which the root background should be tinted.
Mrxvt.tintColor:      #000000
Mrxvt.shading:            75

#
# ———————————- FONTS ———————————– #
#
Mrxvt.xft:            1
Mrxvt.xftFont:            Bitstream Vera Sans Mono
Mrxvt.xftSize:            13
Mrxvt.xftAntialias:       1

# The options below are better set using ~/.fonts.config. Mrxvt will use the
# defaults passed to the fontconfig library.
#
# Mrxvt.xftHinting:       1
# Mrxvt.xftAutoHint:      1
# Mrxvt.xftGlobalAdvance: 1
# Mrxvt.xftRGBA:      rgb
# Mrxvt.xftslow:      1

# Don’t load a multi-char font. This will reduce the line space if your multi
# char font has different dimensions than the regular font. You might need to
# comment it out if you want to use XIM and non-english fonts.
Mrxvt.xftNomFont:     1

# Font to use for tab bar / menus. This need not be mono-spaced ;).
Mrxvt.xftPFont:           Bitstream Vera Sans
Mrxvt.xftPSize:           10

# Shadow text
# Mrxvt.textShadow:       red
# Mrxvt.textShadowMode:       botright

#
# XIM input / multi char support. To use this, you should also comment out the
# xftNomFont line above.
#
# Mrxvt.xftmFont:     SimSun
# Mrxvt.multichar_encoding:   GB
# Mrxvt.inputMethod:      SCIM

#
# ———————————- CURSOR ———————————- #
#
Mrxvt.cursorBlink:        true
Mrxvt.cursorColor:        #00ff00
Mrxvt.cursorColor2:       #000000

#
# ———————————- COLORS ———————————- #
#

# Setup colors for a black background.
Mrxvt.background:     #000000
Mrxvt.foreground:     #9a9a9a

Mrxvt.color0:         #000000
Mrxvt.color1:         #af0000
Mrxvt.color2:         #00af00
Mrxvt.color3:         #afaf00
Mrxvt.color4:         #0000af
Mrxvt.color5:         #af00af
Mrxvt.color6:         #00afaf
Mrxvt.color7:         #9a9a9a
Mrxvt.color8:         #5f5f5f
Mrxvt.color9:         #d70000
Mrxvt.color10:            #00d700
Mrxvt.color11:            #d7d700
Mrxvt.color12:            #0000d7
Mrxvt.color13:            #d700d7
Mrxvt.color14:            #00d7d7
Mrxvt.color15:            #d7d7d7

# Display bold and underlined text in color, rather than using the terminal
# attributes. This makes reading man pages a little easier.
Mrxvt.colorBD:            #00afaf
Mrxvt.colorUL:            #00af00
# Mrxvt.colorRV:      #000040

# Display the X selection as highlighted instead of using reverse video.
Mrxvt.highlightColor:     #303060

# Colors when terminal window looses focus. (Does not work well with Xft).
# Mrxvt.ufBackground:     yellow
# Mrxvt.backgroundFade:       50

#
# ——————————- MISC OPTIONS ——————————- #
#

# Display menu
Mrxvt.showMenu:         False

# The value of the TERM environment variable. Default is rxvt. If you have
# trouble, try uncommenting the following line.
# Mrxvt.termName:     xterm

# Default title of each tab.
Mrxvt.tabTitle:           mrxvt

# Border to leave around terminal text
Mrxvt.internalBorder:     2

# Make double click select whole URL’s
Mrxvt.cutChars:           :=/~#@?%&_-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0abcdefghijklmnopqrstuvwxyz

# Blank the mouse pointer on keystrokes or after 10 seconds of inactivity.
Mrxvt.pointerBlank:       True
Mrxvt.pointerBlankDelay:  10

# Don’t close the tab if the secondary screen is displayed (e.g. when running
# vim).
Mrxvt.protectSecondary:       True

# Run as a login shell.
# Mrxvt.loginShell:       True

# Enable session management
# Mrxvt.sessionMgt:       true

#
# ——————————— PROFILES ——————————— #
#

# Root console on profile 1. Matrix like green font for root :).
Mrxvt.profile1.foreground:    #809a70
Mrxvt.profile1.background:    #002000
Mrxvt.profile1.command:       su
Mrxvt.profile1.tabTitle:  su

# Better to start root consoles in root’s home directory (and not the current
# directory).
Mrxvt.profile1.workingDirectory:/root
# Mrxvt.profile1.Pixmap:  matrix.jpg

# Vim on profile 2. Vim is run in a shell, so after Vim exits, you’ll get the
# shell prompt.
Mrxvt.profile2.command:       !vim
# Mrxvt.profile2.Pixmap:  vim.png

# Mutt on profile 3. Kill the scroll back buffer, to save a little memory.
# Mrxvt.profile3.Pixmap:  email.jpg
Mrxvt.profile3.saveLines: 0
Mrxvt.profile3.command:       mutt
Mrxvt.profile3.workingDirectory:

#
# —————————- KEYBOARD SHORTCUTS —————————- #
#

# Open profiles 1 — 4 on Ctrl+Shift+F1 — F4.
Mrxvt.macro.Ctrl+Shift+F1:    NewTab -1
Mrxvt.macro.Ctrl+Shift+F2:    NewTab -2
Mrxvt.macro.Ctrl+Shift+F3:    NewTab -3
Mrxvt.macro.Ctrl+Shift+F4:    NewTab -4

#
# Save the scroll back buffer to a file, and open it (in less / vim) in a new
# tab. Useful for searching, or cut/paste from the scroll back buffer.
#
Mrxvt.macro.Primary+Ctrl+Shift+question: PrintScreen -ps perl -e ‘$_=join(“”,<STDIN>); s/\n+$/\n/g; print’ > /tmp/%p-scrollback
Mrxvt.macro.Primary+Add+Ctrl+Shift+question: NewTab “(Tab %n scrollback)” \!less -ifLR +G /tmp/%p-scrollback; rm /tmp/%p-scrollback

Mrxvt.macro.Primary+Ctrl+slash: PrintScreen -s perl -e ‘$_=join(“”,<STDIN>); s/\n+$/\n/g; print’ > /tmp/%p-scrollback
Mrxvt.macro.Primary+Add+Ctrl+slash: NewTab “(Tab %n scrollback)” \!view +”syn off| set nospell notitle noreadonly modifiable buftype=nofile |normal G” /tmp/%p-scrollback; rm /tmp/%p-scrollback
#
# When running a shell, this clears the scroll back buffer and executes the
# current command. Useful if you’re going to (or have just) run a command that
# produces a lot of output. (Primary screen only).
#
Mrxvt.macro.Primary+Shift+Return: Esc \ec
Mrxvt.macro.Primary+Add+Shift+Return: Str ^M
# —————————————————————————- #

#
#             CLASS SETTINGS
#

#
# ——————————- FULL SCREEN ——————————– #
#
FullScreen.bottomTabbar:  False

# Set a large font 😉
FullScreen.xftSize:       17
FullScreen.xftPSize:      12

# Keep as many tabs as possible on screen
FullScreen.minVisibleTabs:    15

# Set the window size increment to 1, so that the X server can resize our window
# to the screen size without leaving any border.
FullScreen.smoothResize:  True

# Request a full screen window from the window manager. Requires a EWMH
# compatible window manager. This certainly works on OpenBox, Fvwm, KDE, and
# possibly many others.
FullScreen.fullscreen:        True
#
# ——————————- KITCHEN SINK ——————————- #
#
# Number of tabs to launch initially
KitchenSink.initProfileList:      0,1,2,3
#
# ——————————- FVWM CONSOLE ——————————- #
#
FvwmConsole.initProfileList:      4
FvwmConsole.profile4.tabTitle:        FvwmConsole
FvwmConsole.profile4.background:    #101020
FvwmConsole.profile4.holdExit:        4

FvwmConsole.xftSize:              12
FvwmConsole.tintColor:            #181830
FvwmConsole.geometry:             60×15
FvwmConsole.scrollBar:            False

#
# ——————————- ROOT CONSOLE ——————————- #
#

Root.initProfileList:         1
Root.tintColor:               #002000
Root.itabBackground:          #002000

# —————————————————————————- #
# vim: set ft=mrxvtrc ts=4 sts=4:

Linear Algebra Revisit- Inspired by Gilbert Strang

\setlength{\unitlength}{0.75mm}  \begin{picture}(60,40)  \put(30,20){\vector(1,0){30}}  \put(30,20){\vector(4,1){20}}  \put(30,20){\vector(3,1){25}}  \put(30,20){\vector(2,1){30}}  \put(30,20){\vector(1,2){10}}  \thicklines  \put(30,20){\vector(-4,1){30}}  \put(30,20){\vector(-1,4){5}}  \thinlines  \put(30,20){\vector(-1,-1){5}}  \put(30,20){\vector(-1,-4){5}}  \end{picture}  {\tiny Image\, adapted\, from\, LATEX2"\, in\, 157\, minutes}
Four subspaces of a m x n Matrix

Subspaces Notation Dimension In space of Equation
Column Space C(A) r R^{m} Ax = b
Left Null Space N(A^{T}) m – r R^{m} A^{T}x = 0
Row Space C(A^{T}) r R^{n} A^{T}x = b
Null Space N(A) n – r R^{n} Ax = 0

Two vectors u, v are perpendicular to each other when u^{T}v = 0
The Column Space of A is perpendicular to its Left Null Space, both in R^{m}
The Row Space of A is perpendicular to its Null Space, both in R^{n} 

Matrix Factorizations

Rectange Matrix Symmetric Matrix
A = LU
Solve Ax = b in two steps
1. Ly = b \t 2. Ux = y
E[A|I] = [U|E]$
A = LDL^{T} = L\sqrt{D}\sqrt{D}L^{T} = (L\sqrt{D})(L\sqrt{D})^{T}
Cholesky decomposition:
A = CC^{T}\, where\, C = L\sqrt{D}
Application to basket options pricing using Monte Carlo Simulation to generate correlated asset price paths. 
Here A is the assets variance-covariance Matrix. 
Applying C to a vector of uncorrected samples, u, produces a sample vector Cu with the desired covariance
A = QR
Q: Othorgonal matrix, stable \big\| x \big\| = 1
R: R is Triangular
Gram-Schmit method: find the othorgonal basis through recurisive projection
In mechanics, Q can be thought as rotation, and R is the strecthing
A = S \wedge S^{-1}
(distincted eigenvalues)
A = Q \land Q^{T}
A = SVD
Both S and D are othogonal (squared othonormal matrix)
One to one mapping from row space to column space Au_i = \sigma v_j
AA^T = SVD(SVD)^T = SVDD^TSV^TS^T = SV^2S^T
S formed by the eignvectors of AA^T \,and\, V^2 are the corresponding eignvalues
Similiarly, A^TA = (SVD)^TSVD = D^TV^TS^TSVD = DV^2D^T

Positive definite matrix
x^T A x > 0
Properties:
1. All pivots p_k > 0
2. All left upper submatrix det(d_k) > 0
3. All eignvalues \lambda_i > 0
Application – Minimization
P(x) = \frac{1}{2} x^T A x + x^T b \qquad minimized\, at \qquad x = A^{-1} b

Books:

Matrix computations

 
Numerical Analysis == Scientific Computing