Very simple MySQL backup bash script

This code backups up mysql databases and gzips them into the current working directory. If you want to backup the mysql table, remove it from the for loop.

#!/bin/bash

usage(){
        echo "Usage $0 <mysql_user> <mysql_password>"
        exit 1
}

if [[ "$2" != "" && "$2" == "" ]]
then
        usage
fi

USER=$1
PASS=$2
if [ "$3" != "" ]
then
  DB_HOST=$3
else
  DB_HOST="localhost"
fi

for db in `mysql -u$USER -p$PASS -h$DB_HOST -e 'show databases' | cut -f2 | awk '{ print $1 }' | grep -v "Database\|mysql\|information_schema\|test"`;
do
  echo "Working with $db"
  mysqldump -u$USER -p$PASS -h$DB_HOST $db > $db.sql
  gzip $db.sql
done;

echo "Finished";
Posted in bash, Commands, Linux, MySQL | Leave a comment

Installing php-ffmpeg on CentOS 5.x

This can be a pain due to a bug in the ffpmeg_frame.c file … here are the commands to get up and going

yum -y install ffmpeg ffmpeg-devel
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download
tar jxvf ffmpeg-php-0.6.0.tbz2
sed -i 's/PIX_FMT_RGBA32/PIX_FMT_RGBA/g' ffmpeg-php-0.6.0/ffmpeg_frame.c
cd ffmpeg-php-0.6.0 && phpize
./configure && make && make install
echo 'extension=ffmpeg.so' > /etc/php.d/ffmpeg.ini && /etc/init.d/httpd restart
php -v && php -m | grep ffmpeg

In this process you:
use yum to install ffmpeg and the ffmpeg development files
download php-ffmepg from sourceforge and extract it
apply the bug fix to the ffmpeg_frace.c file
change directories to the php-ffmpeg directory and phpize the module
configure, make and install the shared object (extension)
add the extension to the loaded php extensions
restart apache and verify no errors are shown on php startup and that ffmepg is loaded

If all is well, you should see your version of PHP with the copyrights on 3 lines and the last line showing ffmpeg

Posted in Commands, Internet, Linux, PHP | Tagged , , , | Leave a comment

Common Power Amp Resistance Watt Forumlas

P is Power, also known as Volts, also known as Electromotive Force (EMF).
I is Resistance, measured in Ohms
E is Amps, also known as Current
W is Watts, the multiplication of Power and Amperes.
kW is kilo-Watts, also known as 1000 Watts
kWh is kilo-Watt Hours, which is how many Watts are used in 60 minutes.

P = W / E
I = P / E
E = W / P
W = P * E

Alternatively:

Volts = Watts / Amps
Ohms = Power / Amps
Amps = Watts / Volts
Watts = Power * Amps

Posted in Electricity, Electronics | Leave a comment

Plaintext Offender : BidVertiser

If you have an account with BidVertiser, your password is stored in plain text and emailed back to you when you request it. This also means customer service can look up your account and get your password.

I informed them of this and their response was:

Done by: Customer Service, Publishers & Referral Status: Closed Action Date: Monday, 07/04/2011 03:30 PM
Respond:
Dear Travis,

The option to include login information in our contact emails is available through your control panel, through Account Management – Edit Profile. I have disabled the option for you.

Best Regards,
BidVertiser Support Team

To which I replied:

Done by: customer Status: Follow Up Action Date: Monday, 07/04/2011 02:03 PM
Customer Comment:
You’ve missed the point. Passwords are not to be stored in plain text and emailed out to your users over insecure connections. Passwords should be reset, not sent. If someone were to get into your database without your knowledge, they would also be able to compromise each account without any sort of password attack, since you guys would just show the passwords to them.

We’ll see if they even care.

### edit ###

Response:

Dear Travis,

Noted.

Best Regards,
BidVertiser Support Team

###

I guess they do not care.

Posted in Internet, Security | Tagged , | Leave a comment

Search / Replace in files with Linux

I used this command to search over some Apache 2 vhost files to change them from port 8080 to port 80 with Debian.

find /etc/apache2/sites-enabled -name "*com" -exec sed -i 's/8080/80/g' {} \;
Posted in Commands, Linux | Leave a comment

Low Level Format Disk Drive with Linux

Doing a log level format with linux is super easy. Make sure the drive you want to format is not mounted and determine the device in /dev/ i.e. /dev/sdb

Enter the following command to turn all the bits on the drive to 0

dd if=/dev/zero of=/dev/sdb

Wait a few hours and you have a completely wiped disk drive

Posted in Linux, Security | Leave a comment

Use HackIt and Revolution ROM to sexify your HTC Inspire

Got an HTC Inspire 4G? Tired of all the bloatware and running apps. Tired of have to kill those apps over and over? Root your phone (root is the superuser account in Linux, which Android runs on)! This voids all warranties, but it is worth it. Use HackIt to permanently root your HTC, then download the HTC Revolution ROM and flash your phone with it. Then install Terminal Emulator to access your phones root shell. You’ll also want Gemini App Manager (Free), hit Menu to go into Expert Mode and you can uninstall ANYTHING, even your keyboard (which you should NOT do).

All you need to know is located at this web site: http://www.addictivetips.com/mobile/install-android-revolution-4g-rom-on-htc-inspire-4g/

Posted in Android, Electronics, Internet, Linux, Operating Systems, Security | Tagged , , | Leave a comment

Use mogrify to rotate and scale your images on the Linux command line

First, make sure you have ImageMagick installed:

#Ubuntu/Debian
sudo apt-get install imagemagick

#RedHat, Fedora, CentOS
sudo yum install imagemagick

After that, it’s super easy.

mogrify -resize 800 -rotate 90 image.jpg

The above command would resize image.jpg to 800 pixels wide maintaining aspect ratio and rotate the image 90 degrees clockwise.

To define your own dimensions (discarding aspect ratio) use the following:

mogrify -resize 800x600! -rotate 90 image.jpg

The above command does the same as the other, but resizes to 800 x 600.

No more need to open GIMP just to resize and rotate an image!

Posted in Commands, Linux | Tagged , , , | Leave a comment

Node.js Trademarked — Next Up: Buyout (Sellout)

Well, Node.js has been trademarked to “protect the brand”. What does that usually mean? “We need a nice brand to sell.”

http://blog.nodejs.org/2011/04/29/trademark/

Posted in Internet, Node.js / Socket.io | Tagged | Leave a comment

Blowing an LED … sort of.

Today I learned that you can supply just enough amperage to a light emitting diode to destroy the gases that emit photons but not destroy the circuit. I did it twice … just to make sure I wasn’t crazy of course. ;) This was verified by a series of two LEDs, one red and one green. The green one is damaged but the current still flows to allow the red LED to emit photons. Replacing the green LED with another red LED proves the damaged LED still allowed a current due to the replacement red LED emitting photons.

Posted in Electronics | Tagged , , | Leave a comment