Simple MySQL backup-script
Being an Oracle database admin for the greater part of the day makes me a paranoid person and I'm usually shocked when I find out people don't have any backups of their blogs or their mySQL databases in particular.
The following shell-script:
- Creates an export of all tables in a mySQL database
- Compresses each generated SQL-export file
- Deletes any backups older than a week - mine are sufficiently small to do this
It's a small, straight-forward script that does the job and is exactly why I love UNIX/Linux.
Manually or from crontab:
mySQL-backup.sh DB-NAME-PARAM > mySQL-backup.logmySQL-backup.sh
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash SUFFIX=$(date +%y%m%d) # Get parameter DBNAME=$1 # Run mysqldump command mysqldump --opt -uUSERNAME -pPASSWORD -h HOSTNAME $DBNAME > $DBNAME.$SUFFIX.sql # Zip all sql files individually find *.sql -exec gzip {} \; # Delete *.sql.gz files older than a week find *.sql.gz -mtime +7 -exec rm {} \; |
Notes:
- I've only tested this in BASH
- I didn't use TAR to package and compress the files. Personally, I usually use tar when I want to retain certain important file-permissions and structures - didn't really feel it was needed here
- In this case, there would be a separate crontab entry for each database - you could choose to back-up all your databases on a server in one go
Getting your own paparazzo
![]() |
How's this for a great idea:
“MethodIzaz is a unique photography experience. Subjects are unaware of the exact moment they will be photographed and of the photographer's identity. Instead, the subject is photographed completely naturally, living life as normal.
MethodIzaz will provide you with a portfolio of pictures representing the fleeting moments of an authentic lifestyle. The photographs will allow you to remember these moments later in life. They will also give you a new perspective on the everyday, letting you see yourself and your surroundings through the eyes of an artist.
Using information provided earlier about their weekly routine, the photographer will arrive on the scene, and unseen, take shots of the subject. The subject will be photographed walking through the streets, going about their daily business. Without posing and artifice, the camera captures only the natural beauty of the person.”
Smart Menu-Hover
When making a navigational menu or button of some sort, you might have an image for the normal state (a:link), the hover (a:hover), the active state (a:active) and even one for the visited state (a:visited). Usually, you would have an image load for each one like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #nav a:link { background-image:url(menu.jpg); } #nav a:visited { background-image:url(menu.jpg); } #nav a:hover { background-image:url(menu_hover.jpg); } #nav a:active { background-image:url(menu_active.jpg); } |
The browser would only load these images when these states have been activated. This would mean that the first time a user moves his mouse over the menu it wouldn't show anything different from the a:link background-image until the a:hover image loads.
There's a simple trick to get around this. Say you have a menu image like the this, you might want the first part to be the a:link and the 2nd part below it would be the a:hover background-image.
![]() |
In your CSS, you would use only 1 image (like the one one above). However, you would use a different background-position for each state:
1 2 3 4 5 6 7 8 9 10 11 12 13 | #nav a:link { background-image:url(menu.jpg); background-position:0px 0px; /*Use first part*/ } ... #nav a:active { background-image:url(menu.jpg); background-position:0px -98px; /*Use 2nd part*/ } |
![]() |
The -98px in the CSS comes from the dimensions of the image. This means that the image is loaded when the page is loaded, and thus, it also means that there is no loading for the other link states.
This method can be extended to work with the visited and active states too.
Photoshop: The split-toning effect
You might have seen this effect:
![]() |
It has become pretty easy to do in something like Adobe Lightroom. But - if you're interested in the manual process, here's one way of doing it:
- Convert an image to B&W using your preferred method (desaturate or channel-mixer or other)
- Duplicate layer (CTRL-J), use smart-sharpening filter (optional)
- Flatten (SHIFT-CTRL-E)
- Add a Colour Balance layer adjustment, select SHADOWS -> Move the yellow-blue sllider to the right. Move the cyan-red slider to the left.
- Add another colour balance layer adjustment, select HIGHLIGHTS -> Move the cyan-red slider to the right this time. Move the yellow-blue slider to the left.
- Select the blending options for the current layer-adjustment. In the blend-if section, select 'blue' from the drop-down
- Move the left slider first to about 60, then press ALT and drag it to about 200 till you have the effect you want.
- Flatten image
- You can reduce the saturation on it at this stage and you can also use the burn tool to emphasize shadows
My top WordPress plug-ins
After secretly messing around with WordPress on one of my servers, I decided to move my blog to an instance of it permanently. Being a very flexible and extensible CMS, I've been researching some plug-ins for it. So far, I've come up with this list.
- Akismet - helps block spam (and it's really good at it too). Needs an API key that's obtainable from WordPress. Plus, it's free for personal use.
- Maintenance mode - adds a maintenance splash page. When activated only authenticated users and admins will be able to browse the site.
- Search meter - keeps track of what visitors are searching for
- Feedburner Feedsmith - redirects all RSS and ATOM feeds to a feedburner RSS feed instead
- Sociable - Adds links to Digg, De.li.cio.us, Stumble-upon and other sites for you
- WP-Cache 2.0 - A really efficient page caching system and effectively makes your site faster and more responsive
- WP-PageNavi - Adds a more advanced page navigation to the bottom of pages
- Subscribe to Comments - Allows users to get e-mail notifications for any subsequent comments made
- Smilies Themer - an easy way to change the default smilies pack
- Google Analytics for WordPress - You could just add the script, but this makes it easier.
- WP-Syntax - Add syntax highlighting to code-snippets (supports many languages)
Web App: rsizr
Intelligently resize your images online. I haven't found a standalone application or Photoshop plugin that lets you do this kind of image-resizing (yet). But this is fantastic.
"rsizr is a Flash application that lets you resize JPG, PNG, and GIF images on your computer. With rsizr, in addition to normal image rescaling and cropping, you can also resize images using a new image resizing algorithm called seam carving (a method of image retargeting) that tries to keep intact areas in your image that are richer in detail.
Seam carving is a brilliant image resizing technique pioneered by Shai Avidan and Ariel Shamir. For their rockstar YouTube video and paper, click here."





