SELECT * FROM pg_stat_activity;
Wednesday, December 21, 2011
Tuesday, December 20, 2011
Detaching a shell with "screen"
If you want to protect yourself against connectivity lost with Unix / Linux, screen is the perfect command for you.
In a shell, type the command screen.
It will create a new shell.
Launch the command that you want and close your shell window.
We your are back, type screen -ls to show the list of active screen session.
You will get something like this:
[06:19:36]$ screen -ls
There are screens on:
11944.pts-0.myserver (Detached)
4859.pts-3.myserver (Detached)
12190.pts-4.myserver (Attached)
3 Sockets in /var/run/screen/S-user.
Attached => The shell window is still active.
Detached => No open shell window.
To join the screen session, type screen -r 11944.pts-0.myserver where the parameter is the session name.
To logout, simple type exit
In a shell, type the command screen.
It will create a new shell.
Launch the command that you want and close your shell window.
We your are back, type screen -ls to show the list of active screen session.
You will get something like this:
[06:19:36]$ screen -ls
There are screens on:
11944.pts-0.myserver (Detached)
4859.pts-3.myserver (Detached)
12190.pts-4.myserver (Attached)
3 Sockets in /var/run/screen/S-user.
Attached => The shell window is still active.
Detached => No open shell window.
To join the screen session, type screen -r 11944.pts-0.myserver where the parameter is the session name.
To logout, simple type exit
Complex find exec zgrep example
Suppose that we have a filesystem containing EDI transactions. Here's an example for the filesystem content:
/home/myhome/myfolder/mysubfolder/toto/good/toto.gz
/home/myhome/myfolder/mysubfolder/toto/fail/toto.gz
/home/myhome/myfolder/mysubfolder/tata/good/tata.xml
/home/myhome/myfolder/mysubfolder/tata/fail/tata.gz
/home/myhome/myfolder/mysubfolder/foo/good/foo123.gz
/home/myhome/myfolder/mysubfolder/bar/fail/ef3d.gz
We need to copy in the current directory all the EDI transactions (text file starting with ISA) from each folders (toto, tata, foo, bar) but the folder must start with a T. In our example we need to copy files from "toto" and "tata". The good transactions are in the folder "good". We must not copy transactions that are not contained in other folder than "good".
Also, the EDI files may be compressed. So we need to verify in compressed files... "toto.gz" contains an EDI file and "tata.xml" is a xml file.
The command is:
Will copy only "toto.gz"
find => Searching for something
-type f => Looking for files
-iwholename => The path should contains a specific word
-exec zgrep -l '^ISA' {} => Look for file including compressed one. File must start with ISA
-exec cp -rf {} . => Copy the data to the current directory
/home/myhome/myfolder/mysubfolder/toto/good/toto.gz
/home/myhome/myfolder/mysubfolder/toto/fail/toto.gz
/home/myhome/myfolder/mysubfolder/tata/good/tata.xml
/home/myhome/myfolder/mysubfolder/tata/fail/tata.gz
/home/myhome/myfolder/mysubfolder/foo/good/foo123.gz
/home/myhome/myfolder/mysubfolder/bar/fail/ef3d.gz
We need to copy in the current directory all the EDI transactions (text file starting with ISA) from each folders (toto, tata, foo, bar) but the folder must start with a T. In our example we need to copy files from "toto" and "tata". The good transactions are in the folder "good". We must not copy transactions that are not contained in other folder than "good".
Also, the EDI files may be compressed. So we need to verify in compressed files... "toto.gz" contains an EDI file and "tata.xml" is a xml file.
The command is:
find /home/myhome/myfolder/mysubfolder/ -type f -iwholename *good* -iwholename *mysubfolder\/t* -exec zgrep -l '^ISA' {} \; -exec cp -rf {} . \;
Will copy only "toto.gz"
find => Searching for something
-type f => Looking for files
-iwholename => The path should contains a specific word
-exec zgrep -l '^ISA' {} => Look for file including compressed one. File must start with ISA
-exec cp -rf {} . => Copy the data to the current directory
Monday, December 19, 2011
Remove a specific directory from hierarchy
To remove a directory named DIRECTORY_NAME from a directory hierarchy
find . -type d -iname DIRECTORY_NAME -exec rm -rf {} \;
Moving EDI files
Moving all EDI files where the name contains -- to a folder named EDI.
find . -type f -iname *--* -exec grep -Rl '^ISA' {} \; -exec cp -rf {} EDI/ \;
GUnzip all found files
GUnzip all the files from a directory hierarchy
Want to have a verbose output?
find . -type f -iname '*.gz' -exec gunzip {} \;
Want to have a verbose output?
find . -type f -iname '*.gz' -exec gunzip --verbose {} \;
Tuesday, December 6, 2011
Ruby on Rails -=- Formatting Rails text_field_tag
Hi!
If you want to format a Rails text_field tag, simply do the following:
Where my_var is my variable and where my_function is a function where I can apply a format. You can apply directly the format that you want in :value instead of using a function
If you want to format a Rails text_field tag, simply do the following:
<%= f.text_field :my_var, :value=> my_function(f.object.my_var) %>
Where my_var is my variable and where my_function is a function where I can apply a format. You can apply directly the format that you want in :value instead of using a function
Ruby on Rails -=- Removing trailing zero
Hi!
With RoR I'm always getting trailing zero for numeric fields.
Example, 23 will be 23.0
In order to round theses values, simply do the following
"%g" % my_valueWhere my_value is my variable
IE9 -=- Border on link images
With IE9, when we have anchor on images, Internet Explorer adds a border to this image. To remove it, simply use this CSS
a img {
text-decoration: none;
border: 0;
}
Sunday, December 4, 2011
Adobe Flash Player 11 on Fedora 16/15, CentOS/RHEL 6/5.7
Good tutorial that explains how to install flash on a CentOS / RedHat Linux machine
Adobe Flash Player 11 on Fedora 16/15, CentOS/RHEL 6/5.7
Adobe Flash Player 11 on Fedora 16/15, CentOS/RHEL 6/5.7
Subscribe to:
Posts
(Atom)