System language for Debian Linux

System language for Debian Linux - Chirag Patel December 30, 2008

I ran into a simple but typical issue.

I was installing Debian 4 (kernel 2.6) today using minimal boot image CD and out of curiocity I selected its installation language to Gujarati. All screens showed almost 90% of the content in Gujarati (incorrectly translated at many places though). I select “English -US” as my choice of language for system locales. But, after installation and reboot, all the user screens had weird characters on screen (I was expecting English). I kept looking for a way to change locales and did this:

- I opened root terminal.
- Entered following command:
chirag@work~# dpkg-reconfigure locales
- I selected “en-US-utf-8″ from the list shown.
- After OKing this and rebooting the system, I found characters known to me!

Posted under Infrastructure, Linux

This post was written by Chirag on December 31, 2008

Wordpress SQL hack

http://www.smashingmagazine.com/2008/12/18/8-useful-wordpress-sql-hacks/

Posted under MySql, Programming

This post was written by Chirag on December 28, 2008

PCI standard requirements

PCI standard requirements - compiled by Chirag Patel December 27, 2008

Payment Card Industry (PCI) requirements of Data Security Standard (DSS) include following basic compliances:

- Install and maintain firewall configuration to protect card holder data.
- Do not use vendor supplied defaults for system passwords and other secuirity parameters.
- Protect stored cardholder data.
- Encrypt transmission of cardholder data across open, public networks.
- Use and regularly update anti-virus software.
- Develop and maintain secure systems and applications.
- Restrict access to cardholder data by business need-to-know.
- Assign a unique ID to each person with computer access.
- Restrict physical access to cardholder data.
- Track and monitor all access to network resources and cardholder data.
- Regularly test security systems and processes.
- Maintain a policy that addresses information security.

(Ref: WEBSITE magazine November, 2008)

Posted under Infrastructure

This post was written by Chirag on December 28, 2008

Memory thrashing

Memory Thrashing - compiled by Chirag Patel December 27, 2008
(Ref: Embedded Systems Design June 2008)

Memory threshing is a typical problem that goes unnotices while programming time-critical systems. Translation Look-aside Buffers (TLB) are used for data and instruction cache. There are two main cache-replacement schemes: 1) Least Frequently Used (LFU) and 2) Least Recently Used (LRU). Memory accesses require address translations in modern systems. So, when a page table is is found in an on-chip TLB (a TLB hit), the lookup normally does not do translation. On TLB miss, the processor must look again and must calculate offset to find a byte physically.

When a system has multiple concurrent accesses, operating system schedules time slices for those processes. If we consider 32-entry LRU TLB and 6 processes each using different page memory, at least 12 pages are active at any given time (instruction + data). If every process uses double nested procedures (or jumps between 3 pages) in each time slice, there are 36 active pages. If operating system time slices sequentially, by the time 6th process is reached, 30 pages are accessed. By the end of 6th process time slice, 36 page accesses should have passed. So, the cache manager will discard first 4 accesses (LRU algorithm). When the time comes for the first process, it will have TLB misses for those first 4 page accesses. As the processor continues, it keeps discarding the pages that the next process in sequence will need. This memory thrashing greatly degrades system performance.

To avoid thrashing:
- Long unused variables should be declared absolutely rather than relatively.
- Macros should be expanded.
- Avoid nesting procedure calls whenever possible.
- Minimize number of concurrent tasks.
- Don’t use jumps larger than page size unless absolutely necessary.

Posted under Programming

This post was written by Chirag on December 28, 2008

Folding with VIM

Folding with VIM - Chirag Patel Dec 14, 2008

– Edit “~/.vimrc”

– Add following options
set fmr={,}
set fdm=indent

– To use syntax folding for a file, enter following command after opening it.
:set fdm=syntax

– To set no folding, edit “~/.vimrc”
set nofoldenable

– By default all available folds are folded. Change that to preferred max in “~/.vimrc”.
set fdn=1

1 is good value as it will close all top level folds to be closed (e.g. functions), but not any blocks inside.

– Some commands while in command in command mode:
zo ==> open fold under cursor
zO ==> open folds recursively under cursor
zc ==> close fold under cursor
zC ==> close folds recursively under cursor
zA ==> toggle folds recursively
zM ==> close all folds in a file
zR ==> open all folds in a file

Posted under Infrastructure, Linux

This post was written by Chirag on December 15, 2008

My VIM configuration

Vim Basic Configuration - Chirag Patel Dec 14, 2008

— Edit “~/.vimrc” file and add following tags per need

set autoindent ==> auto-indent code
set incsearch ==> start searching as we type word for search
set hlsearch ==> highlight all occurrences for search
set nowrap ==> disable line wrapping
set ts=4 ==> set tabsize to 4 space size
set softtabstop=4 ==> tabbing match my tabsize of 4
set shiftwidth=4 ==> shifting match my tabsize of 4
set noexpandtab ==> do not replace tab with spaces
set showmatch ==> highlight matching bracket/braces as we move cursor
set mat=5 ==> matching for search
set nocompatible ==> no vi compatibility
filetype on ==> vim detects file type
syntax on ==> highlight syntax words for file type
set ruler
set cindent ==> “C” indent rules for auto-indent
==> following command restores file position while re-opening
autocmd BufReadPost *
\ if expand(”:p:h”) !=? $TEMP |
\ if line(”‘\”") > 0 && line(”‘\”") following command postpones using “zv” until after reading the modelines
autocmd BufWinEnter *
\ if exists(”b:doopenfold”) |
\ unlet b:doopenfold |
\ exe “normal zv” |
\ endif

Posted under Infrastructure, Linux

This post was written by Chirag on December 15, 2008