http://www.math.iitb.ac.in/~srg/LaTeX/howto.html
use global substitution
:g/cntrl-v cntrl-m/s// /g
Monday, December 6, 2010
Checking memory
try sar(system activity reporting), it is a good alternative to top. My rhel box was having i/o wait which I could find using sar.
sar 1 200
Other commands : free (-m) tells you the total memory, memory used for cache etc.
sar 1 200
Other commands : free (-m) tells you the total memory, memory used for cache etc.
Wednesday, October 27, 2010
Python
Issue 1: python ImportError No module named
Resolve 1: The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.
Resolve 1: The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.
Sunday, September 26, 2010
Shell
To remove duplicates in your .bash_history file, export this variable in the .bashrc file:
HISTCONTROL=erasedups
To increase the .bash_history size from 500 to 1000 commands, export this variable in the .bashrc file:
HISTSIZE=1000
alias hs='history | grep $1'
HISTCONTROL=erasedups
To increase the .bash_history size from 500 to 1000 commands, export this variable in the .bashrc file:
HISTSIZE=1000
alias hs='history | grep $1'
Wednesday, September 22, 2010
Wednesday, July 14, 2010
Few interview questions.
Q1) Factorial of a large num ?
The main difficulty in computing factorials is the size of the result.
Constant Limit = 1000; %Sufficient digits.
Constant Base = 10; %The base of the simulated arithmetic.
Constant FactorialLimit = 365; %Target number to solve, 365!
Array digit[1:Limit] of integer; %The big number.
Integer carry,d; %Assistants during multiplication.
Integer last,i; %Indices to the big number's digits.
Array text[1:Limit] of character;%Scratchpad for the output.
Constant tdigit[0:9] of character = ["0","1","2","3","4","5","6","7","8","9"];
BEGIN
digit:=0; %Clear the whole array.
digit[1]:=1; %The big number starts with 1,
last:=1; %Its highest-order digit is number 1.
for n:=1 to FactorialLimit do %Step through producing 1!, 2!, 3!, 4!, etc.
carry:=0; %Start a multiply by n.
for i:=1 to last do %Step along every digit.
d:=digit[i]*n + carry; %The classic multiply.
digit[i]:=d mod Base; %The low-order digit of the result.
carry:=d div Base; %The carry to the next digit.
next i;
while carry > 0 %Store the carry in the big number.
if last >= Limit then croak('Overflow!'); %If possible!
last:=last + 1; %One more digit.
digit[last]:=carry mod Base; %Placed.
carry:=carry div Base; %The carry reduced.
Wend %With n > base, maybe > 1 digit extra.
text:=" "; %Now prepare the output.
for i:=1 to last do %Translate from binary to text.
text[Limit - i + 1]:=tdigit[digit[i]]; %Reversing the order.
next i; %Arabic numerals put the low order last.
Print text," = ",n,"!"; %Print the result!
next n; %On to the next factorial up.
END;
Monday, June 28, 2010
database operations
http://www.1keydata.com/sql/sql-create-index.html
Copying table:
CREATE TABLE copyname SELECT * FROM originalname
Creating key across multiple columns :
alter table tbl_name add primary key(col1,col2,col3);
If there are duplicates rows in a db across this combination:
alter ignore table judgments add unique index `idx_nm` (col1,col2,col3);
and then drop the idx: alter ignore table judgments drop idx_name
Connections:
Q)How to check the number of connections to a db ?
A) show processlist;
Q)How to see the current indexes?
A) show indexes from table_name;
A table index helps SQL statements run faster. The syntax for creating an index is:
CREATE INDEX IDX_CUSTOMER_LAST_NAME
on CUSTOMER (Last_Name)
on CUSTOMER (Last_Name)
Copying table:
CREATE TABLE copyname SELECT * FROM originalname
Creating key across multiple columns :
alter table tbl_name add primary key(col1,col2,col3);
If there are duplicates rows in a db across this combination:
alter ignore table judgments add unique index `idx_nm` (col1,col2,col3);
and then drop the idx: alter ignore table judgments drop idx_name
Connections:
Q)How to check the number of connections to a db ?
A) show processlist;
Q)How to see the current indexes?
A) show indexes from table_name;
Subscribe to:
Posts (Atom)