Tuesday, November 10, 2009

Using mysql cli client in MAMP

I'm on a new contract and we're using OS X for development. Instead of getting the full LAMP stack for OS X, they use the MAMP (Mac, Apache, MySQL, PHP) collection for a one-click solution. http://www.mamp.info

MAMP includes the MySQL GUI tools, but I was wanting to use the command line version of the mysql client. Here's how...
/Applications/MAMP/Library/bin/mysql -uroot -p

Wednesday, June 10, 2009

(Semi) Secure Wrapper Script for mysqldump

I resurrected this script to do the backup of a client's MySQL database. I run it as a cron job once a day and keep the dump file on a separate server. The MySQL login info is kept in the mysql_access file which I have chmoded to be read-only for me. (chmod 400 mysql_access).

#!/bin/sh

#for debugging
#set -x

TODAY=$(date +"%D - %T")
HOST=$(hostname)
LOGFILE="${HOME}/TFP/logs/backup.log"
SHORTDATE=$(date +"%G%m%d")
DUMPFILE=${HOME}/TFP/dumps/tfp_${SHORTDATE}.sql

source ${HOME}/bin/mysql_access

echo "" >> $LOGFILE
echo "-------------------------------------------" >> $LOGFILE
echo "Date: $TODAY Host:$HOST" >> $LOGFILE
echo "-------------------------------------------" >> $LOGFILE
echo "" >> $LOGFILE

echo "Dumping $MYSQL_DB at $MYSQL_HOST to $DUMPFILE" >> $LOGFILE
mysqldump -h $MYSQL_HOST -u $MYSQL_USER $MYSQL_DB -p$MYSQL_PASSWORD > $DUMPFILE

echo "" >> $LOGFILE
WCSIZE=$(wc $DUMPFILE)
echo "wc for $DUMPFILE is" >> $LOGFILE
echo " $WCSIZE" >> $LOGFILE

echo "" >> $LOGFILE
FILESIZE=$(ls -lh $DUMPFILE)
echo "filesize for $DUMPFILE is" >> $LOGFILE
echo " $FILESIZE" >> $LOGFILE


The contents of the mysql_access include:

MYSQL_USER="some_username"
MYSQL_PASSWORD="password"
MYSQL_HOST="mysql.somedomain.com"
MYSQL_DB="some_database"


My hosting company sends me email with the output of the cron job. I include the size of the dump file in the output so I can just keep a running check on the output in case anything gets out of control.

Comments?

Thursday, May 14, 2009

NetBeans Rails Server, WEBrick or GlassFish?

The NetBeans 6.5.1 install on OS X defaults to GlassFish. On Kubuntu, it defaults to WEBrick. The server can be changed by right-clicking on the project and selecting Properties. Under the Rails category, there's a Server option, WEBrick or GlassFish.

Friday, May 8, 2009

Degree symbol, xubuntu

Degree symbol under Xubuntu (or other GtK app), press ctrl-shift u00b0

Heat to 350°F

Wednesday, April 22, 2009

Posting photos to FB from mobile phone

After setting up your mobile phone in your account settings, take the photo and email it to mobile@facebook.com. The subject of the email becomes the caption of the photo. Pretty easy... :-)

Sunday, April 19, 2009

Friday, April 17, 2009

sources.list for Ubuntu 8.04

## a “general” sources.list for Hardy Heron; all sources are uncommented.

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted

## Major bug fix updates produced after the final release of the
## distribution.

deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in

## universe WILL NOT receive any review or updates from the Ubuntu security
## team.

deb http://archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy universe

deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.

deb http://archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy multiverse

deb http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse

## Uncomment the following two lines to add software from the ‘backports’
## repository.

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.

deb http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical’s
## ‘partner’ repository. This software is not part of Ubuntu, but is
## offered by Canonical and the respective vendors as a service to Ubuntu
## users.

deb http://archive.canonical.com/ubuntu hardy partner
deb-src http://archive.canonical.com/ubuntu hardy partner

deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted

Wednesday, February 4, 2009

Objective-C for C++ Programmers

This document was very helpful to me in getting up to speed on Objective-C for iPhone development.

WordPress page breaks.

There's a plugin to do this (Evermore), but I prefer to have the flexibility to do this myself. To break a WP post up and have a "Continue reading>>" link to the rest of the post, switch to HTML mode in the editor and insert this tag where you
want the break to be.

See the blog for an example...

Tuesday, January 27, 2009

Extended desktop under OS X

Of course I now find out I need a mini DVI to DVI/VGA connector to use the new monitor with my Macbook. Sigh...

Saturday, January 24, 2009

Extended desktop under Linux

I've been working exclusively on laptops for about 6 months, now. I am really missing the screen real estate. Virtual desktops are just not he same. So, I just got a new monitor, Acer X223w, 22 inches, 1680x1050, $149 from TigerDirect (refurbished). It's sweet, very crisp, seems larger than 22".

So, naturally, I want it to work with all my laptops, IBM Thinkpad R50e running Kubuntu, Lenovo Thinkpad Z60m running Window XP Pro, and a Macbook running Leopard. I know XP will do extended desktop, but I hadn't been able to get extended desktop, under Linux, working ever on any Intel 855GM card. So here was the chance.

The xrandr command comes with the package x11-xserver-utils and is the Resize, Rotate and Reflection extension for the X-server. "xrandr -q" will display the screens that X knows about.

scott@kubu:~$ xrandr -q
Screen 0: minimum 320 x 200, current 2704 x 1050, maximum 2704 x 1818
VGA connected 1680x1050+1024+0 (normal left inverted right x axis y axis) 474mm x 296mm
1680x1050 60.0*+
1600x1200 59.9
1400x1050 60.0
1280x1024 75.0
1440x900 75.0 59.9
1280x960 59.9
1360x765 59.8
1152x864 75.0 74.8
1024x768 75.1 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
640x480 75.0 72.8 66.7 60.0
720x400 70.1
LVDS connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1024x768 59.3*+ 85.0 75.0 70.1 60.0
832x624 74.6
800x600 85.1 72.2 75.0 60.3 56.2
640x480 85.0 72.8 75.0 59.9
720x400 85.0
640x400 85.1
640x350 85.1

VGA is clearly the Acer screen, LVDS the Thinkpad screen. After lots of googling, I found a stanza I needed to add to the /etc/X11/xorg.conf file in the Screen section...

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
SubSection "Display"
Depth 24
Virtual 2704 1818
Modes "1680x1050@60" "1024x768@60"
EndSubSection
EndSection


I added the "SubSection" part. The Virtual line is the sum of the height and width of each of the two screens. The Modes line is just the modes from the two screens.

I restarted the X-server and the laptop came up normally. Now to resize the X-server with the following...

xrandr --output VGA --mode 1680x1050
xrandr --output LVDS --mode 1024x768
xrandr --output VGA --right-of LVDS

After the last command, the screen flickered and I had an extended desktop! It's kind of odd, the laptop is on the left, the Acer screen on the right. The laptop had my desktop icons in the upper left corner, but the KDE kicker is on the bottom of the Acer screen. It's actually the better layout, IMHO, but not what I expected. I thought the kicker would be on the bottom of the laptop screen. Anyway, the Macbook is next...

Friday, January 9, 2009

Squashing spam comments in Wordpress

Settings->Discussion has an entry box that takes words, usernames, email addresses and IP addresses to filter out spam.

Thursday, January 8, 2009

Removing Spam from Wordpress blogs

Logged into the admin account of my wordpress blog after a bit of an absense. Had 9000 spam comments to the About. Deleting by had would have been a tedious task, so I installed the Akismet plugin and it whacked marked all comments as spam and I was able to delete them with 1 click.

I got a php error a few times when it borked after processing about 2000 comments. I just reloaded the page and it eventually finished.

http://akismet.com/