Tuesday, March 31, 2009

Affluenza

I heard word 'Affluenza' before. Today, I decided to read actual definition.
Affluenza - a painful, contagios, socially transimeeted condition of overload, debt, anxiety... An usustainable addiction to economic growth. Pursuit of the American Dream and etc.
More Information can be found in Wikipedia (http://en.wikipedia.org/wiki/Affluenza)

Monday, March 30, 2009

Paste (Unix command)

I'm using list for some time now. Accidentally found new command that is useful.
paste is a Unix command line utility that join files horizontally (parallel merging).
paste who where when > www

ntbstat

ntbstat - Display protocol statistics and current TCP/IP connections using (NETBIOS over TCP/IP) resolves NetBIOS names to IP addresses. NetBIOS name resolution , including local cache lookup, WINS server query, broadcast, LMHOSTS lookup, Hosts lookup and DNS server query. Nbstat is designed to help troubleshoot NetBIOS name resolution problems.

nbtstat help
nbtstat -A IP_Address (to get MAC from any computer on the subnet). Works only on Windows.

Sunday, March 29, 2009

File System Type (Linux)

To determine File System Type enter the command df -T

Regression Testing

Regression testing is any type of software testing which seeks to uncover software regressions. Such regressions occur whenever software functionality that was previously working correctly, stops working as intended. Typically regressions occur as an unintended consequence of program changes. Common methods of regression testing include re-running previously run tests and checking whether previously fixed faults have re-emerged.

Revision Control (RC)

Revision Control (aka version control , source control or (source) code management (SCM) is the management of changes to documents, programs, and other information stored as computer files.

Linux FileSystem Hierarchy

/bin - binary
/dev - devices (virtual directory, devices add to the directory at boot)
/etc - configuration settings
/home - home directory
/lib - shared library
/mnt - mount directory
/proc - virtual directory (current state of the system)
/root - root home directory (security user)
/sbin - security bin (Require Secure Access)
/tmp - temporary directory
/usr - unix system resources
/var - variable data (logs, crons, spool, db files)

Saturday, March 28, 2009

VI(m) commands

dw - delete word in VI (foreward)
D - Delete remainer of line

Friday, March 27, 2009

Man Pages Navigation

space - page down
b - page up
q - quit/exit
down arrow OR j - quit/exit
up arrow OR k - line up
g - top of the document
G - end of the document
/search_pattern - top of the document
?search_pattern - end of the document
n - repeat search
N - repeat search in opposite direction
h - help

Input and Output Redirection in Linux

Standard Input - 0
Standard Output - 1
Standard Error - 2

> - Output Redirection
< - Input Redirection

# Send an error when file doesn't exist
ls -l myfile.txt 2> test.txt (/bin/ls: adad: No such file or directory)

2>&1 (redirect input and error) into normal file
ls -l xxx.txt 2>&1 another_file

VIM settings (vimrc)

set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
syntax on (enable highlighting)

Putty Settings Summary

Below are settings that I recommend for Putty on Windows.

Putty Settings Summary
Category: Session
Connection type: SSH

Category: Window
Lines of scrollback: 20000

Category: Window > Appearance
Font: Lucida Console, 9-point
Font quality: ClearType
Gap between text and window edge: 3

Category: Window > Translation
Character set: UTF-8
Handling of line drawing characters: Unicode

Category: Window > Selection
Action of mouse buttons: xterm (Right extends, Middle pastes)
Paste to clipboard in RTF as well as plain text: enabled

Category: Window > Colours
Default Foreground: 85 85 85
Default Bold Foreground: 0 0 0
Default Background: 242 242 242
Default Bold Background: 255 255 255
Cursor Text: 85 85 85

Category: Connection
Seconds between keepalives (0 to turn off): 25

Category: Connection > SSH > X11
Enable X11 forwarding: enabled

For More Information, please refer to
Putty Settings on Windows

Thursday, March 26, 2009

bash commands

C-a # Move to the beginning of line
C-e # Move to the end of line
C-l # Clear screen
C-k # Kill the text from the point to the end

Linux distribution information

To get Linux Distribution information use:
cat /etc/issue

To get kernel info:
uname -a

PHP Logic & Bit Operations

Here is good example of bit operations in PHP:
Bit Operations in PHP

Wednesday, March 25, 2009

Pointer, Malloc in C

Pointer
Is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere
in the computer memory using addess. A pointer refereces a value stored elsewhere in memory, and obtaining
or requesting the value to which a pointer refers is called dereferencing. A pointer is a simple implementation of
general reference data type.

Malloc
Is a subrioutine provided in the C and C++ programing languages's standard libraries for performating dynamic memory
allocation. The C programming language manages memory either statically, automatically, or dynamically. Static-
duration variables are allocated in main (fixed) memory and persist for the lifetime of the program;
automatic-duration variables are allocated on the stack and come and go as functions are called and return.

Unix/Linux - find utility

find where-to-look creteria what-to-do

# find files changed in the last 1 day
find . ctime -1 -type f
# find files larger than 1 MB in /tmp
find /tmp -size 1M -type f
# find files newer than main.css in /~src
find ~/src -newer main.css
# files file with permission
find . -name -perm 664 -print

File Types (-type)
b - Block special file
c - Character special file
d - Directory
f - Plain File
p - Named Pipe File
l - Symbolic link
s - Socket

Useful Links:
http://content.hccfl.edu/pollock/Unix/FindCmd.htm

CVS HOW TO

Terminology:
CVS - Concurrent Versions System
RCS - Revision Control System (RCS)
Module - particular set of files kept in CVS
Repository - Location on CVS server where modules are kept
Tag - A certain milestone in a file or module's development
Branch - A fork of the module.

SETUP CVS:
1. export CVSROOT=/cvs (add to the path)
2. cvs init (create depository)
3. cd /home/mike/cvs/project_directory (change directory to projec directory)
4. cvs import -m "Sample Program" project sample start (import project to CVS repository)
5. cvs checkout projectname (get copy of the $projectname. Can be done from Linux(ssh/pserver or Windows(through ssh using WINCVS[http://www.wincvs.org/])

Most Useful Commands:
Add/Update changes to CVS - [cvs commit -m 'Message to the update' $filename]
Add a New File:
1. cvs add $filename (CVS to version control the file)
2. cvs commit $filename (CVS to check in the file to the repository)
3. cvs log $filename
4. cvs diff -r tag1 tag2 $filename

Remove:
1. rm $filename (remove file from the modulo)
2. cvs remove $filename (CVS to delete the file)
3. cvs commit $filename (perform the removal from the repository

SHELL (CVS over SSH) on Linux for bash:
1.export CVS_RSH=SSH
2.cvs -d :ext:USERNAME@host:/cvsroot CVS_COMMAND

Tuesday, March 24, 2009

The Programatic Programmer. Book authors: Andrew Hunt and David Thomas (notes)

Programmer Goals:
1. Learn at least one new language every year.
2. Read a technical book each quarter.
3. Read nontechnical books, too.
4. Take classes.
5. Participate in local user groups.
6. Experiment with different environments.
7. Stay current
8. Get wired.

DRY - Don't Repeat Yourself.

The Law of Demeter for functions attempts to minimize coupling between modules in any given program.

Metadata - is data about data. Put Abstractions in Code, Details in Metadata.

MVC is typically taught in the context of GUI development, it is really general-purpose programming technique.
- Model. The abstract data representing the target object. The model has no direct knowledge of any views or controllers.
- View. A way to interpret the model. It describes to changes in the model and logical events from the controller.
- Controller. A way to control the view and provide the mode with new data. It publishes events to both model and the view.

The O() Notation
Is a mathematical way of dealing with approximation. Some common O() notations

O(1) - Constant
(access element in array, simple statements)
O(log(n)) - Logarithmic (binary search)
O(n) - Linear (sequential search)
O(n lg(n)) - Worse the linear, but not much worse
(average runtime of quicksort, heapsort)
O(n2) - Square law (selection and insertion sorts)
O(n3) - Cubic (multiplication of 2 n x n matrices)
O(Cn) - Exponential (traveling salesman problem, set partitioning)


Common Sense Estimation
Simple Loops:
If a simple loop runs 1 to n, then the algorithm
becomes to be O(n)-time increases linearly with n.
Examples include exhaustive searches, finding the maximum value in an array, and generating checksums.

Nested Loops:
If you nest a loop inside another, then your algorithm becomes
O(m x n), where m and n are two loops' limits. This commonly
occurs in simple sorting algorithms, such as buble sort,
where the outter loop scans each element in the array in turn,
and the inner loop works out where to place that element in the
sorted result. Such sorting algorithms tend to be O(n2)

Binary Chop:
If your algorithm halves the set of thins is considers each time
around the loop, then it is likely to be algorithmic, O(lg(n)).
A binary search of a sorted list, traversing a binary tree, and
finding the first set bit in a machine word can all be O(lg(n)

Divide and Conquer:
Algorithms that partition their input, work on the two halves
independently, and then combine the result can be O(nlg(n)). The
classic example is quicksort, which works by partitioning the
data into two halves and recursively sorting each. Although
technically O(n2), because its behavior degrades when it is fed
sorted input, the average runtime of quicksort is O(nlg(n))

Combinatoric:
Whenever algorithms start looking at the permutations of things, their
running times may get out of hand. This is because permutations involve
factorials (there are 5! = 5 x 4 x 3 x 2 x 1) = 120 permutations of the
digits from 1 to 5). Time a combinatoric algorithm for five elements: it will
take six times longer to run it for six, and 42 longer for seven. Examples
include algorithms for many of the acknowledged hard problems - the traveling salesman problem, optimally packing things into a container, partitioning a set of numbers so that each set has the same total and so on. Often, heuristics are used to reduce the running times of these types of algorithms in particular problem domains.

March 24, 2009 - first post

This is my first post in the blog. I worked today (setup CVS, SUSE 10 and yast2). Walk after work for about 2 hours. I'm planning to use the blog for everything that I found interesting and useful in my life.

Note: yast2 is rpm packaging system for SUSE10.