IT Base of Knowledge’s Weblog

November 11, 2009

Find duplicate in a database

Filed under: Uncategorized — itbdc @ 7:10 pm


SELECT my_key, count(*) FROM my_table GROUP BY my_key HAVING count(*) > 1;

November 5, 2009

Insert timestamps with a loop

Filed under: Database, PostgreSQL — itbdc @ 9:18 am

This sql command allow you to test data writting in your database. It can be useful to benchmark your disk performances or check the impact of a lock.


INSERT INTO table SELECT timeofday()::timestamp FROM generate_series(1,1000000) WHERE pg_sleep(1) IS NOT NULL;

April 7, 2009

Draw a rectangle on an image

Filed under: Uncategorized — itbdc @ 5:44 pm

convert -draw “rectangle x0 y0 x1 y1″ -fill none -stroke red -strokewidth 5

February 6, 2009

Create an iso from a directory

Filed under: Linux — itbdc @ 11:11 am

genisoimage -R -r -J -joliet-long --hide-rr-moved -iso-level 4 -V "Label" -o label_name.iso /tmp/directoryToSave

January 9, 2009

Install VMWare on Ubuntu

Filed under: Linux — itbdc @ 10:02 am

At first install those package:

apt-get install linux-headers-`uname -r` libx11-6 libx11-dev xspecs libxtst6 psmisc build-essential

Then download binaries on http://www.vmware.com/download/server/ (server & mui tgz source).

During the download, get a license number (http://register.vmware.com/content/registration.html) it’s totally free!

If you use kernel 2.6.27 please launch:
wget -c http://www.insecure.ws/warehouse/vmware-update-2.6.27-5.5.7-2.tar.gz

Then launch ./vmware-install.pl on each directory (update&mui or install&mui).

At the end of the mui installation you will get a starting failed message, to correct this bug please change in /etc/init.d/httpd.vmware file:

start)
vmware_exec "Starting httpd.vmware:" vmware_start_httpd
;;
stop)
vmware_exec "Shutting down http.vmware: " vmware_stop_httpd
;;

by

start)
if [ ! -d /var/run/vmware/httpd ]
then
echo "Directory: var/run/vmware/httpd Not found. Creating it."
mkdir /var/run/vmware/httpd
echo "Setting user and group ownership to: User: www-data, Group: nogroup"
chown www-data:nogroup /var/run/vmware/httpd
echo "Setting directory permissions to: RWX------ (700)"
chmod 700 /var/run/vmware/httpd
fi
echo "Starting httpd.vmware:"
vmware_start_httpd
;;
stop)
echo "Shutting down http.vmware: "
vmware_stop_httpd
;;

If you use Intrepid version and can’t launch vmware console please dl patch available at this page: http://www.monarialx.it/en/vmwareserver

December 24, 2008

Add a password access to a directory of your website

Filed under: Linux — itbdc @ 12:09 pm

At first you need to create a file containing your password

htpasswd -c /var/www/itbdc/.htpasswd itbdc

Then create a file in your website: /var/www/itbdc/.htaccess

AuthType Basic
AuthUserFile /var/www/itbdc/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword

require user itbdc
require valid-user

Then edit your httpd.conf and check those two lines:

AccessFileName .htaccess
<Directory>
	[...]
    AllowOverride All
	[...]
</Directory>

/etc/init.d/httpd restart

November 18, 2008

How to drop oracle database

Filed under: Database, Oracle — itbdc @ 4:04 pm
shutdown abort;
startup mount exclusive restrict;
drop database;
exit

Drop all tables in a tablespace

Filed under: Database, Oracle — itbdc @ 10:17 am

select ‘drop table ‘, table_name, ‘cascade constraints \;’ from user_tables;

November 17, 2008

How to insert a character in a delimited chain

Filed under: Bash, Linux — itbdc @ 9:52 am

echo “e_ff_0123_1″ | awk -F_ ‘{print $1″_”$2″_”$3″_0″$4}’

October 31, 2008

Deactivate beep in console mode linux

Filed under: Linux — itbdc @ 3:11 pm

setterm -blength 0

Next Page »

Blog at WordPress.com.