Some times you may need to alter the access date of files and folder. You can do it by a recursive touch command.
find . | xargs touch
About Me
Thursday, 24 September 2009
psql output to file
Below is the command to redirect psql output to a file.
psql> \o /tmp/file.txt
psql> select * from table
This should allow output to custom file.
psql> \o /tmp/file.txt
psql> select * from table
This should allow output to custom file.
Friday, 18 September 2009
Removing control characters - python
You want a regex to remove control characters (< chr(32) and > chr(126)) from
strings ie.
line = re.sub(r"[^a-z0-9-';.]", " ", line) # replace all chars NOT A-Z,a-z, 0-9, [-';.] with " "
1. What is the best way to include all the required chars rather than list them all within the r"" ?
You have to list either the chars you want, as you have done, or the
ones you don't want. You could use
r'[\x00-\x1f\x7f-\xff]' or
r'[^\x20-\x7e]'
line = re.sub(r'[\x00-\x1f\x7f-\xff]', "", "test ^A ^B testing this again")
strings ie.
line = re.sub(r"[^a-z0-9-';.]", " ", line) # replace all chars NOT A-Z,a-z, 0-9, [-';.] with " "
1. What is the best way to include all the required chars rather than list them all within the r"" ?
You have to list either the chars you want, as you have done, or the
ones you don't want. You could use
r'[\x00-\x1f\x7f-\xff]' or
r'[^\x20-\x7e]'
line = re.sub(r'[\x00-\x1f\x7f-\xff]', "", "test ^A ^B testing this again")
Intresting tip abt tcpdump
Searched for a tool like wireshock in windows and came to know this!. This help me to dump the soap requests.
Here is the simple command.
sudo tcpdump -XX -s0 -i lo -w k "tcp port 80"
-XX: Print packets in hex and ASCII
-s0: Print whole packets, not only first 68 chars.
-i is the interface to monitor.
"tcp port 80" Filter expression.
-w output file.
This dumps all the requests and responses which are passing through tcp port 80!.
Here is the simple command.
sudo tcpdump -XX -s0 -i lo -w k "tcp port 80"
-XX: Print packets in hex and ASCII
-s0: Print whole packets, not only first 68 chars.
-i is the interface to monitor.
"tcp port 80" Filter expression.
-w output file.
This dumps all the requests and responses which are passing through tcp port 80!.
Wednesday, 2 September 2009
Apache Module mod_deflate
Looking to tune the apache for performance, then this should help you out.
The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network
This is a simple sample configuration for the impatient.
Compress only a few types
AddOutputFilterByType DEFLATE text/html text/plain text/xml
The following configuration, while resulting in more compressed content, is also much more complicated. Do not use this unless you fully understand all the configuration details.
Compress everything except images
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network
This is a simple sample configuration for the impatient.
Compress only a few types
AddOutputFilterByType DEFLATE text/html text/plain text/xml
The following configuration, while resulting in more compressed content, is also much more complicated. Do not use this unless you fully understand all the configuration details.
Compress everything except images
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
Subscribe to:
Posts (Atom)