Thursday, November 25, 2010

mysql find duplicate record

I take it from here. Put in my own blog cause I keep using them
http://www.petefreitag.com/item/169.cfm

SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

SELECT email
FROM users
GROUP BY email
HAVING ( COUNT(email) = 1 )

31 May 2011
It turns out these code was pretty awesome when I want to make a dynamic drop down selection
I can make it display unique value and sorted by most use at the top

Thursday, November 4, 2010

Redhat I always use command

Last update, 25 April 2011
This is not only for Redhat, but for most of Linux machine (I think)

Source of this command is from here. I keep using them
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/4/html/Step_by_Step_Guide/s1-manipulate-current.html
http://redhat.activeventure.com/71/gettingstartedguide/s1-managing-working-with-files.html

This is a good reference for VI - Visual Editor (Command line interface for text editor)
http://www.cs.colostate.edu/helpdocs/vi.html

Check folder size
du -hs /path/to/directory


Check harddisk space
df


List all the content within the current folder (or path)
ls OR ls -all


Remove file
rm thefilename.txt


Move file
mv thefilename.txt /home/asipo/


Delete directory and all its content
rm -rf /home/asipo/backupdocuments


Zip a file or folder
zip -r iWantTheZipFileNameToBeLikeThisOkay.zip theActualFileName.txt


Unzip a file (not sure for folder)
unzip thefilename.zip


Change folder owner
chown -R asipo.asigroup '/var/www/smellynomore/app/tmp'


Change folder permission
chmod -R 777 '/var/www/smellynomore/app/tmp'


Copy all except one folder

shopt -s extglob
cp -r A/!(B) dest_dir


Execute bin file
chmod u+x qt-sdk-linux-x86-opensource-2010.05.1.bin
./qt-sdk-linux-x86-opensource-2010.05.1.bin

Connect to server and control it (Telnet / SHH I think)
ssh -p 22 asipi@langit.com.my