Wednesday, January 2, 2013
Restore the packages list in your Debian Linux box
Backup
Restore
Labels:
apt
,
apt-get
,
backup
,
debian
,
dpkg
,
dselect-upgrade
,
get-selections
,
list
,
package
,
restore
,
set-selections
Want to apply just a part of your patch(Only on few files or even a few lines)?
Starting tag = MY_PORTION_START
Ending tag = MY_PORTION_END
You have to insert these tags into your patch file depends on your need.
Saturday, March 24, 2012
Python - Converting character string to HEXA string
ord(c): Given a string of length one, return an integer representing the Unicode code point of the character when the argument is a unicode object, or the value of the byte when the argument is an 8-bit string.
href=http://docs.python.org/library/functions.html
hex(n): Convert an integer number to a hexadecimal string
We do not need first to characters in the hex output.
zfill(witdh): Return the numeric string left filled with zeros in a string of length width.
Put of together,
Reference:
href=http://docs.python.org/library/functions.html
Labels:
characters
,
convert
,
hexa
,
python
,
string
,
string manipulation
Friday, March 23, 2012
Perl - Converting character string to HEXA string
Substitution Operator Modifiers
Here is the list of all modifiers used with substitution operator
Modifier Description i Makes the match case insensitive m Specifies that if the string has newline or carriage return characters, the ^ and $ operators will now match against a newline boundary, instead of a string boundary o Evaluates the expression only once s Allows use of . to match a newline character x Allows you to use white space in the expression for clarity g Replaces all occurrences of the found expression with the replacement text e Evaluates the replacement as if it were a Perl statement, and uses its return value as the replacement text
References:
http://icfun.blogspot.com/2009/05/perl-convert-character-string-into-hex.html
http://www.tutorialspoint.com/perl/perl_regular_expression.htm
Labels:
characters
,
convert
,
hexa
,
perl
,
string
,
string manipulation
Saturday, March 26, 2011
Command-line dictionary
It just parse the website wordnetweb and extract the meaning of the word/phrase given. You need lynx to run this script successfully.
References:
http://ubuntuforums.org/showthread.php?t=371482
http://wordnetweb.princeton.edu/perl/webwn
References:
http://ubuntuforums.org/showthread.php?t=371482
http://wordnetweb.princeton.edu/perl/webwn
Labels:
awk
,
Bash
,
dictionary
,
grep
,
linux
,
lynx
,
Shell scripting
,
wordnetweb
Sunday, January 9, 2011
Heapsort
Heap
Sort in place
Binary tree
Worst case runtime (n lg n)
MIN_HEAP
Maintain the max-heap propert
Heap Sorting
Priority queues
One of the main usage is that we can use max-priority queues to schedule jobs on a shared computer.The max-priority queue keeps track of the jobs to
be performed and their relative priorities. When a job is finished or interrupted,the scheduler selects the highest-priority job from among those pending by calling EXTRACT-MAX. The scheduler can add a new job to the queue at any time by calling INSERT.
Reference: Introduction to Algorithms By Thomas H . Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein
Sort in place
Binary tree
Worst case runtime (n lg n)
PARENT(i) -> i/2 Left (i) -> 2i Right (i) -> 2i + 1MAX_HEAP
A[PARENT(i)] >= A[i]
MIN_HEAP
A[PARENT(i)] <= A[i]MAX-HEAPIFY
Maintain the max-heap propert
MAX-HEAPIFY (A, i) l = LEFT (i) r = RIGHT (i) if l <= A:heap-size and A[l] > A[i] largest = l else largest = i if r <= A.heap-size and A[r] > A[largest] largest = r if largest != i exchange A[i] with A[largest] MAX-HEAPIFY (A, largest)
Heap Sorting
HEAPSORT (A) BUILD-MAX-HEAP (A) for i = A.length downto 2 exchange A[1] with A[i] A.heap-size = A.heap-size - 1 MAX-HEAPIFY (A, 1)
Priority queues
One of the main usage is that we can use max-priority queues to schedule jobs on a shared computer.The max-priority queue keeps track of the jobs to
be performed and their relative priorities. When a job is finished or interrupted,the scheduler selects the highest-priority job from among those pending by calling EXTRACT-MAX. The scheduler can add a new job to the queue at any time by calling INSERT.
Reference: Introduction to Algorithms By Thomas H
Labels:
algorithms
,
C
,
data structures
,
interview
,
Programming
,
questions
,
sorting
Friday, January 7, 2011
Subscribe to:
Posts
(
Atom
)