Lazyweb, here’s a quick question for you. On a FreeBSD system, suppose I own a directory called “foo”. Inside that “foo” directory are some files (file1, file2, file3) owned by the “nobody” user. How do I delete those files? When I type the command “rm file1″ I get the response “rm: file1: Permission denied” even though I own the parent foo directory.
Any suggestions? It’s on a machine where I don’t have root access.
Update: Problem solved, but in an annoying way. The files were created by a PHP script, so I wrote a new PHP script to remove the files in question. It looked something like
<?php
unlink(”./advanced-cache.php”);
unlink(”./wp-cache-config.php”);
unlink(”./cache/meta/wp-cache-33c58158f712bca22c3414a8df924c46.meta”);
unlink(”./cache/meta/wp-cache-8f9198130973778a72a378ce93042c4b.meta”);
…
unlink(”./cache/meta/wp-cache-a9e95ca4074fc06d9672d81133751b8e.meta”);
rmdir(”./cache/meta”);
?>
This forum thread from 2001 describes the idea (thanks to Mark and the people that commented).
In case you’re wondering, pair Networks’ FreeBSD systems really don’t work well with the WordPress “WP Cache” or “WP Super Cache” plug-ins, because both plugins make files owned by the “nobody” user which appear to be impossible to delete from the SSH command-line.
This is my personal blog. I don’t run my draft posts by Google’s PR or legal team, other than maybe 2-3 times when I thought a post might have legal implications. But I have learned a few hard-won lessons. So, when someone recently asked me for tips about talking to the public, I couldn’t resist. Whether you blog for the company officially or unofficially, here are my top three rules of thumb:
Sometimes other companies will throw dirt in your direction. In that case, the challenge is to correct any misperceptions without picking a fight. But first ask yourself: do you really need to respond at all? If not, then maybe it’s better not to get pulled into an argument where everyone involved loses a little credibility. So far I’ve written 10-15 draft posts (and who knows how many I’ve written in my head) where I was snarky about another search engine, and then not published the post. Each time when I look back after a few months, I’m glad that I didn’t post.
I’ve broken each of these rules, and regretted it almost every time. What tips would you suggest when blogging about your company?
Bookmarklets are very handy pieces of JavaScript code that you can bookmark. In HTML, if you want a link to open in a new window, you’d write it like this:
<a href=”http://www.mattcutts.com/blog/” target=”_blank”>Matt Cutts</a>
Go on, try it on this link: Matt Cutts
If you wanted to create a bookmarklet to open a new window or tab, you’d do it like this:
javascript:(function(){ window.open(’http://www.cnn.com/’); })();
so the actual bookmarklet link that would appear in your HTML as
<a href=”javascript:(function(){ window.open(’http://www.cnn.com/’); })();”>CNN</a>
and if you want to play with it, here’s the trivial CNN example bookmarklet. On Firefox, you can drag the bookmarklet to your bookmarks bar. On Internet Explorer, you can right-click and select “Add to Favorites...”.
The reason I mention this is that bit.ly is a url shortening service that I like, and they have a bookmarklet, but it replaces the page that you’re shortening. Their bookmarklet looks like this:
javascript:location.href=’http://bit.ly/?url=’+encodeURIComponent(location.href)
So suppose you find a new page that you want to twitter about or shorten the url for some reason. You want a bookmarklet that opens the bit.ly url in a new window or tab instead of replacing the current page. Combining the two bookmarkets, you’d get
javascript:(function(){ window.open(’http://bit.ly/?url=’+encodeURIComponent(location.href)); })();
and here is a bookmarklet for bit.ly that opens your bit.ly url in a new window or tab. You can just drag the bookmarklet to your bookmarks folder.
That’s enough to get you started with bookmarklets, but you can find more info about bookmarklets by searching or by looking at example bookmarklets around the web. For example, industrial-strength bookmarklets often load JavaScript dynamically from a webserver. That way if you want to upgrade or improve the functionality of the bookmarklet, you can change the code on the webserver instead of asking every user to update their bookmark. On the other end of the spectrum, some quick-and-dirty bookmarklets don’t even bother escaping the url.
I want to open a new tab, not a new window!
Some webmasters want to choose between a link opening a new tab vs. a new window. I believe that you don’t get that choice -- it’s up to the user and their web browser. For example, in Firefox a user can select their desired behavior under Tools → Options → Tabs → “New pages should be opened in:” and choose “a new tab”. Or to tweak the setting directly, the user can type “about:config” into the location bar/address bar and then modify the “browser.link.open_newwindow” option to be one of the following values:
1 = open new windows in the existing window
2 = open new windows in a new window
3 = open new windows in a new tab (this is the default in Firefox 2 and Firefox 3)
See this about:config page for more info.
Likewise in Internet Explorer, the user can go into Tools → Internet Options → “Settings” button in the Tabs section and then under “When a pop-up is encountered:” choose “Always open pop-ups in a new tab”.
I know what you’re thinking: “Matt, I hacked my original iPhone. Now I want to share in the iPhone 3G fun, but I’m worried that something horrible will happen if I upgrade to the iPhone 3G.”
Buck up, fellow iPhone hacker. I’ll tell you how to upgrade from your hacked Apple phone and keep all the settings you love from your original iPhone. The good news is that it’s not hard and there’s a set of five steps that will combine the comfort of your old settings with the joy of the new 3G iPhone. I’ll lead you through the steps.
1. Upgrade iTunes and sync your old hacked iPhone
Upgrade to iTunes 7.7 (or whatever the latest version is). Plug your hacked iPhone into your computer and make sure that you sync. When you sync, a backup of your iPhone’s settings data is stored in iTunes. Recharge the power in your old hacked iPhone and turn it off. If you want to be ultra-safe, see my post about how to backup iPhone data.
2. Buy an iPhone 3G
This step is time-consuming, but not hard. Apple has a page for its stores and after 9 p.m. you can check the Apple iPhone availability to find a store that has the new iPhone 3G. Hint: if there are multiple stores in your area, call each to see which has the shortest wait. When you buy the iPhone 3G, you don’t need to mention to the salespeople that your previous phone was hacked. Just buy the iPhone 3G and let them activate the phone in the store.
3. Restore the backup of your hacked iPhone to your iPhone 3G
(If you decide to “start fresh” with your new iPhone 3G and don’t want to restore contacts, bookmarks, music, etc. from your old phone, skip this step.)
Resist the temptation to start immediately customizing your iPhone 3G. You’re just going to override any changes when you restore your old iPhone’s settings anyway. In particular, make sure you keep the passlock (where you have to type a PIN to unlock your iPhone) off for the time being. Go home and plug your new iPhone 3G into the same computer with iTunes 7.7 where you did a sync on your old iPhone. iTunes will ask if you want to register your iPhone. I registered my iPhone, but I don’t think it was necessary -- looking back, I think iTunes asked me to register to get permission to send me email offers. Next, iTunes will ask if you want to try 60 days free of MobileMe. I didn’t want that, so I declined. Only after those two offers did iTunes ask if I wanted to set up the new iPhone 3G as a new phone or restore from a backup. The choice looks like:

Choose to restore from a backup and the last sync of your old hacked iPhone should be offered as a choice. Let iTunes restore the backup data and settings from your hacked iPhone to your new iPhone 3G. Once it’s done, pretty much everything should be like it was on your hacked iPhone. The iPhone 2.0 firmware adds some new options, so make sure you explore the settings menu and set any new options the way that you want. Also, if your iPhone is configured to fetch email, your email passwords on the new iPhone 3G will be empty. You will need to re-enter your email passwords.
Finally, if you want to use the Apple App Store, you may need to add a credit card or authorize your computer to purchase things, even if you only want to download free applications. I have a personal policy not to put my data where I can’t get it back out, so I tend to buy MP3s instead of buying music with proprietary Digital Rights Management (DRM) from the Apple Store. As a result, my computer had never been authorized to buy things from the Apple Store. To authorize your computer, in the iTunes program click Store->Authorize Computer... and enter your Apple ID. Once your computer is authorized, you might need to click Store->Check for Purchases... if you tried to download an application from the App Store before your computer was authorized.
4. Upgrade your old iPhone to firmware version 2.0
The iPhone running software version 2.0 has been hacked, so there’s no need to keep running old firmware on your old hacked iPhone. Plug your old hacked iPhone into the computer running iTunes 7.7 and make sure that iTunes is running. Under the “Devices” entry on the left hand side of iTunes, when you click on the iPhone device, you should see a screen with a “Check for Update” button. Click that button. I was running firmware version 1.1.1 and at first it offered me firmware version 1.1.4. So I exited iTunes, restarted iTunes, and clicked “Check for Update” again. Then it offered me firmware version 2.0. Click to install firmware version 2.0 on the old hacked iPhone.
5. Erase the settings and data on your old iPhone
One nice thing about the iPhone’s firmware version 2.0 is that it adds a “secure wipe” that attempts to erase all data completely from your iPhone. That means you can sell the old iPhone or give it to a friend without worrying about all those crazy pictures you took, the 1-900 numbers in your contacts, the SMS messages that reveal things you want to keep private, etc. Here’s how to erase everything on your old iPhone. Eject the phone in iTunes, disconnect the phone from the computer, then press Settings, then General, then Reset, then Erase All Content and Settings, then Erase iPhone. You may have to confirm a couple times that yes, you really want to wipe your iPhone. The process takes about an hour, so I connected my iPhone to a cable that was plugged into a power outlet to ensure that the iPhone wouldn’t run out of power in the middle of wiping it.
When the iPhone is finished erasing itself, it’s suitable for giving to a family member or selling on eBay or whatever.
I’ve been learning how to stop receiving junk mail, and I thought I’d share what I’ve learned.
Reducing Junk Mail
There are several services that will help you reduce your junk mail:
- GreenDimes offers a free basic service, but I decided to do their $20 one-time fee because it offered a few extra things I wanted. GreenDimes walks you through some easy steps that will reduce unsolicited mail, and also lets you decline catalogs. Each time you receive an unwanted catalog, you go to GreenDimes and type the name of the catalog in. GreenDimes takes care of removing you from that catalog’s mailing list. I’ve been quite happy with this service, especially since it’s a one-time fee.
- ProQuo is a free junk-mail reduction service. In the future, they intend to make money when consumers opt-in to request offers; ProQuo will make money from those advertisers. I tried this service today. It lets you stop many services with just a couple mouse clicks per service, but for about 50% of the marketers (maybe 10-15 of them) you have to print and send a letter or leave to an external website to complete a form. It’s still better than nothing though, because even if you’re lazy you can opt out of a lot of junk mail with just your mouse for free. Overall, the service is free, easy, and helps you opt out of a wide variety of lists.
- Catalog Choice is a site solely for opting out of catalogs. It doesn’t tackle things like credit card offers, PennySaver, or list brokers, but the site is clean with a really nice user interface. One of the founders, Daniel Katz, has been interviewed by Bill Moyers, so I trust that they’re a legit organization, even though their WHOIS information is private and there’s very little information about the group on their site. It sounds like three different environmental groups formed Catalog Choice as a non-profit. One piece of advice for Catalog Choice: please give a little more information about yourselves (e.g. history, founders, press) so that people can easily see that you’re legitimate.
- 41pounds.org charges $41 for five years of service. The name comes from the fact that they claim to block 41 pounds of junk mail per year for you. I haven’t tried this service.
Contacting services directly
- You can visit the webpage of the Direct Marketing Association (DMA) to opt-out online so that you don’t receive mail from companies that use DMA lists. The pretty url http://www.dmaconsumers.org/cgi/offmailinglist takes you to the url https://www.dmachoice.org/MPS/proto1.php where you want to select option #3 (”Remove your name from DMA Member Prospect Lists”). You will have to provide a valid credit card number, but your credit card will not be charged.
- You can opt out of ADVO online.
Other options
- While you’re at it, why not place yourself on the “Do not call” list at www.donotcall.gov to prevent most telemarketers from calling you? All you need to give is your phone number and an email address, and you will be permanently opted out. Read more about the do-not-call list if you’re interested.
All these actions won’t eliminate junk mail completely, but it will prevent a lot of the junk from showing up in your mailbox. These aren’t affiliate links, just stuff that I think people will find handy. Good luck!
I wanted to write down 3-4 easy steps to protect yourself from identity theft and help you check your free annual credit reports.
Credit check options
- If you haven’t checked your credit in the last year, visit the official site that lets you get a free credit report from each of the three major credit bureaus. The site is annualcreditreport.com and you’ll have to be on the lookout for upsells like “Find out your credit score for $5.95″ or “Sign up for a credit monitoring service.” But this option is a safe and free way to get access to your credit report from Experian, TransUnion, and Equifax.
- Suppose you don’t want credit card companies sending you offers by snail mail. After all, a thief could steal the offer from your mailbox and use it to open a credit card in your name. Again, there’s a free, official service from the three major credit bureaus to stop getting “free credit cards” offer by postal mail. The site is www.optoutprescreen.com. You can opt-out online for five years, or print out and mail a piece of paper to do a permanent opt-out.
- If you had any type of open credit account between 1987 and May 28, 2008 (which is probably most adults in the United States), you can receive nine months of free credit monitoring. TransUnion, one of the big three credit unions, is settling a class action lawsuit and provides this monitoring for free if you sign up before September 24, 2008. The official site is www.listclassaction.com and you can choose from several options. I chose the nine month credit monitoring service.
If you think you might have been a victim of identity theft or are at higher risk for identity theft (e.g. someone stole a laptop that might have had personal information on it), you have a couple options. A fraud alert requests that before a new lender opens up an account, they take extra steps to verify your identity like calling you on the phone. It should be free if you call the credit bureaus, but it only lasts for 90 days, so you would need to renew the fraud alert every three months.
Meanwhile, a credit freeze is just what it sounds like. It freezes your credit record completely, so that identity thieves should not be able to open new credit accounts in your name. A credit freeze costs $10 per credit bureau each time you want to freeze or un-freeze your credit record.
I used the first three websites earlier to get my free credit report, opt out of getting more credit card offers, and sign up to for a credit monitoring service. Again, all of these are free or official sites; I don’t get any money for recommending them.
Other options
If you’re feeling ambitious, you can also get a public records report on yourself to see what turns up. I believe you can get this report free once a year as well from ChoicePoint. You can get more information here but I believe the short answer is that you need to print, fill out, and mail this one-page form (PDF link). You need to include a photocopy of your driver’s license or other ID and a copy of a utility/phone/credit card bill -- see the instructions for the form (PDF link) for more info.
Do you know of other ways to protect yourself from identity theft or otherwise monitor your credit record or score?
I’m trying to replace my Windows applications with Linux applications. On Windows, I use I use Juice to download podcasts as MP3s. Recently I decided to switch over to Linux for receiving podcasts. After looking around at various podcast catchers (especially ones that ran on the command-line, so that I could automate them with a cron job), I ran across Podracer. I decided to combine Podracer with a script to split long MP3s into shorter MP3s so that I could play them more easily in my car. Here’s what I did on my Ubuntu Linux machine:
Step 1: Install and configure podracer
I used these commands:
sudo apt-get install podracer
mkdir ~/.podracer
vim ~/.podracer/subscriptions
and add the url of a podcast, e.g. http://feeds.webmasterradio.fm/tdsc for The Daily SearchCast.
cp /etc/podracer.conf ~/.podracer/podracer.conf
Edit ~/.podracer/podracer.conf so that you can pick the download directory you want. I changed
#poddir=$HOME/podcasts/$(date +%Y-%m-%d)
to
poddir=$HOME/rawpodcasts
because I want all my podcasts in one directory where I can do a batch process over them afterwards. Go ahead and run “mkdir ~/rawpodcasts” to create the directory that podcasts will be stored in.
sudo vim /usr/bin/podracer
(it’s okay, Podracer is a shell script). Find the line that says
m3u=$(date +%Y-%m-%d)-podcasts.m3u
and comment it out so that podracer won’t automatically create an .m3u playlist as it downloads podcasts.
Run podracer in “catchup” mode to avoid downloading all the old podcasts from your subscriptions with “podracer -c”. podracer will create a file ~/.podracer/podcast.log to keep a record of all the podcasts that have been downloaded (the “-c” catchup mode creates this text file without actually downloading the MP3s). If you want to re-download a file (e.g. while you’re testing your configuration), you can edit the file ~/.podracer/podcast.log and just delete the line for any MP3 you want to re-download.
Step 2: Install and configure mp3splt (optional)
At a terminal window, type “sudo apt-get install mp3splt”. In Step 1, we configured Podracer to download podcasts as MP3s into a “rawpodcasts” directory. In this step, we’re going to take those long MP3s and split them into individual segments into a new “finishedpodcasts” directory. Make the “finishedpodcasts” directory with the command “mkdir ~/finishedpodcasts”.
Make a file /home/username/download-mp3s-and-process.sh that looks like this.
#!/bin/bash
# Run podracer to download any new podcasts
/usr/bin/podracer# Now split the podcasts into segments
for i in /home/username/rawpodcasts/*.mp3
do
nicename=`basename $i .mp3`
# Send both stderr and stdout to /dev/null so that this is a quiet cron job
mp3splt -eqd /home/username/finishedpodcasts -o $nicename-@n $i &> /dev/null
done
This script will run podracer to download any new podcasts. Then we list all the MP3 files in the rawpodcasts directory and run mp3splt on each podcast. If you had a file test.mp3, you would be running the command
“mp3splt -eqd /home/matt/finishedpodcasts -o test-@n test.mp3 &> /dev/null”
for example. What do the options to mp3splt mean?
-e means “split on sync errors.” If someone created an mp3 by concatenating multiple mp3s (e.g. with a program such as mp3wrap), that could cause sync errors. mp3splt looks at those sync errors to split the concatenated mp3 back into multiple mp3 files.
-q stands for “quiet.” Don’t ask user to respond to any questions. Normally “-e” says something like
Mp3Splt 2.1 (2004/Sep/28) by Matteo Trotta
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
MPEG 1 Layer 3 - 44100 Hz - Joint Stereo - 256 Kb/s - Total time: 35m.04s
Processing file to detect possible split points, please wait…
Total tracks found: 6
Is this a reasonable number of tracks for this file? (y/n)
Quiet mode suppresses this interactive question on the last two lines above.
-d is the directory to place the split mp3s.
-o lets you specific an output file. “@n” stands for the track number after splitting. So if test.mp3 were made out of two mp3 files, the output of the command above would be two files (in the finishedpodcasts directory) named test.mp3-001.mp3 and test.mp3-002.mp3 . It doesn’t hurt to run mp3splt on existing mp3s because it will just overwrite any old files that had been created.
Step 3: Periodically download and process podcasts
To download podcast files periodically and process them, make a crontab entry for podracer or your script. This will make the cron daemon run your script every few hours to download new mp3s.
I typed “crontab -e” and made the file look like this:
# At 3:03 am, 8:03 am, 10:03 am, 12:03 pm, and 4:03 pm, run this script
3 3,8,10,12,16 * * * /home/username/download-mp3s-and-process.sh
Whenever you’re ready to put the podcasts on some type of media (SD Card, iPod, iPhone, whatever), just copy over anything from the finishedpodcasts directory (if you used mp3splt in step 2) or the rawpodcasts directory if you skipped step 2. Then delete anything left over in either directory.
I really like Gmail, but I also like having backups of my data just in case. Here’s how to use a simple program called getmail on Unix to backup your Gmail or Google Apps email. We’ll break this into four steps.
Step 0: Why getmail?
If you browse around on the web, you’ll find several options to help you download and backup your email. Here are a few:
Step 1: Install getmail
On Ubuntu 7.10 (Gutsy Gibbon), you would type
sudo apt-get install getmail4
at a terminal window. Hey, that wasn’t so bad, right? If you use a different flavor of Linux, you can download getmail and install it with a few commands like this:
cd /tmp
[Note: wget the tarball download link found at http://pyropus.ca/software/getmail/#download ]
tar xzvf getmail*.tar.gz
cd (the directory that was created)
sudo python setup.py install
Step 2: Configure Gmail and getmail
First, turn on POP in your Gmail account. Because you want a copy of all your mail, I recommend that you choose the “Enable POP for all mail” option. On the “When messages are accessed with POP” option, I would choose “Keep Gmail’s copy in the Inbox” so that Gmail still keeps your email after you back up your email.
For this example, let’s assume that your username is bob@gmail.com and your password is bobpassword. Let’s also assume that you want to back up your email into a directory called gmail-archive and that your home directory is located at /home/bob/.
I have to describe a little about how mail is stored in Unix. There are a couple well-known methods to store email: mbox and Maildir. When mail is stored in mbox format, all your mail is concatenated together in one huge file. In the Maildir format, each email is stored in a separate file. Needless to say, each method has different strengths and weaknesses. For the time being, let’s assume that you want your email in one big file (the mbox format) and work through an example.
Example with mbox format
- Make a directory called “.getmail” in your home directory with the command “mkdir ~/.getmail”. This directory will store your configuration data and the debugging logs that getmail generates.
- Make a directory called gmail-archive with the command “mkdir ~/gmail-archive”. This directory will store your email.
- Make a file ~/.getmail/getmail.gmail and put the following text in it:
[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = bob@gmail.com
password = bobpassword[destination]
type = Mboxrd
path = ~/gmail-archive/gmail-backup.mbox[options]
# print messages about each action (verbose = 2)
# Other options:
# 0 prints only warnings and errors
# 1 prints messages about retrieving and deleting messages only
verbose = 2
message_log = ~/.getmail/gmail.log
- Added: Run the command “touch ~/gmail-archive/gmail-backup.mbox” . If you change the path in the file above, touch whatever filename you used. This command creates an empty file that getmail can then append to.
The file format should be pretty self-explanatory. You’re telling getmail to fetch your email from pop.gmail.com via a POP3 connection over SSL (which prevents people from seeing your email as it passes between Gmail and your computer). The [destination] section tells where to save your email, and in what format. The “Mboxrd” is a flavor of the mbox format — read this page on mbox formats if you’re really interested. Finally, we set options so that getmail generates a verbose log file that will help in case there are any snags.
Example with Maildir format
Suppose you prefer Maildir instead? You’d still run “mkdir ~/.getmail” and “mkdir ~/gmail-archive”. But the Maildir format uses three directories (tmp, new, and cur). We need to make those directories, so type “mkdir ~/gmail-archive/tmp ~/gmail-archive/new ~/gmail-archive/cur” as well. In addition, change the [destination] section to say
[destination]
type = Maildir
path = ~/gmail-archive/
Otherwise your configuration file is the same.
Step 3: Run getmail
The good news is that step 2 was the hard part. Run getmail with a command like “getmail -r /home/bob/.getmail/getmail.gmail” (use the path to the config file that you made in Step 2). With any luck, you’ll see something like
getmail version 4.6.5
Copyright (C) 1998-2006 Charles Cazabon. Licensed under the GNU GPL version 2.
SimplePOP3SSLRetriever:bob@gmail.com@pop.gmail.com:995:
msg 1/99 (7619 bytes) from <info@example.com> delivered to Mboxrd /home/bob/gmail-archive/gmail-backup.mbox
msg 2/99 (6634 bytes) from <sales@example.com> delivered to Mboxrd /home/bob/gmail-archive/gmail-backup.mbox
…
99 messages retrieved, 0 skipped
Summary:
Retrieved 99 messages from SimplePOP3SSLRetriever:bob@gmail.com@pop.gmail.com:995
Hooray! It works! But wait — I have over 99 messages, you say. Why did it only download 99 messages? The short answer is that Gmail will only let you down a few hundred emails at a time. You can repeat the command (let getmail finish each time before you run it again) until all of your email is downloaded.
Step 4: Download new email automatically
A backup is a snapshot of your email at one point in time, but it’s even better if you download and save new email automatically. (This step will also come in handy if you have a ton of Gmail and don’t want to run the command from Step 3 over and over again for hours to download all your mail.)
We’re going to make a simple cron job that runs periodically to download new email and preserve it. First, make a very short file called /home/bob/fetch-email.sh and put the following text in the file:
#!/bin/bash
# Note: -q means fetch quietly so that this program is silent
/usr/bin/getmail -q -r /home/bob/.getmail/getmail.gmail
Make sure that the file is readable/executable with the command “chmod u+rx /home/bob/fetch-email.sh”. If you want to make sure the program works, run the command “/home/bob/fetch-email.sh”. The program should execute without generating any output, but if there’s new email waiting for you it will be downloaded. This script needs to be silent or else you’ll get warnings when you run the script using cron.
Now type the command “crontab -e” and add the following entry to your crontab:
# Every 10 minutes (at 7 minutes past the hour), fetch my email
7,17,27,37,47,57 * * * * /home/bob/fetch-email.sh
This crontab entry tells cron “Every 10 minutes, run the script fetch-email.sh”. If you wanted to check less often (maybe once an hour), change “7,17,27,37,47,57″ to “7″ and the cron job will run at 7 minutes after every hour. That’s it — you’re done! Enjoy the feeling of having a Gmail backup in case your net connection goes down.
Bonus info: Back up in both mail formats at once!
As I mentioned, mbox and Maildir have different advantages. The mbox format is convenient because you only need to keep track of one file, but editing/deleting email from that huge file is a pain. And when one program is trying to write new email while another program is trying to edit the file, things can sometimes go wrong unless both programs are careful. Maildir is more robust, but it chews through inodes because each email is a separate file. It also can be harder to process Maildir files with regular Unix command-line tools, just because there are so many email files.
Why not archive your email in both formats just to be safe? The getmail program can easily support this. Just change your [destination] information to look like this:
[destination]
type = MultiDestination
destinations = (’[mboxrd-destination]’, ‘[maildir-destination]’)[mboxrd-destination]
type = Mboxrd
path = ~/gmail-archive/gmail-backup.mbox[maildir-destination]
type = Maildir
path = ~/gmail-archive/
Note that you’ll still have to run all the “mkdir” commands to make the “gmail-archive” directory, as well as the tmp, new, and cur directories under the gmail-archive directory.
Bonus reading!
What, you’re still here? Okay, if you’re still reading, here’s a few pointers you might be interested in:
- The main getmail site includes a page with lots of getmail examples of configuration files. The getmail website has a ton of great documentation, too. Major props to Charles Cazabon for his getmail program.
- This write-up from about a year ago covers how to back up Gmail as well.
- The author of getmail seems to hang out quite a bit on this getmail mailing list. See the main site for directions on signing up for the list.
- If you’re interested in a more powerful setup (e.g. using Gmail + getmail + procmail), this is a useful page.
- For the truly sadistic, learn the difference between a Mail User Agent (MUA) and a Mail Transfer Agent (MTA) and how email really gets delivered in Unix.
- I’ve been meaning to write all this down for months. Jeff Atwood’s recent post finally pushed me over the edge. Jeff describes a program that offers to “archive your Gmail” for $29.95, but when you give the program your username/password it secretly mails your username/password to the program’s creator. That’s pretty much pure evil in my book. And the G-Archiver program isn’t even needed! Because Gmail will export your email for free using POP or IMAP, it’s not hard to archive your Gmail. So I wrote up how I back up my Gmail in case it helps anyone else. Enjoy!
Added March 16, 2008: Several people have added helpful comments. One of my favorites led me to a post by commenter Peng about how to back up Gmail with IMAP using getmail. Peng describes how to back up the email by label as well. He mentions that you could use the search “after:2007/1/1 before:2007/3/31″ and assign the label FY07Q1 to the search results, for example. Then you can back up that single label/mailbox by making the getmail config file look like this:
[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
username = username
password = password
mailboxes = (”FY07Q1″,)[destination]
type = Mboxrd
path = ~/.getmail/gmail-backup-FY07Q1.mbox
Peng also mentions a nice bonus: since you’re backing up via IMAP instead of POP, there’s no download limit. That means that you don’t have to run the getmail program repeatedly. Thanks for mentioning that Peng!
Google: Matt Cutts: Gadgets, Google, and SEO
Google
productivity
Gadgets/Hack
to
Google/SEO
how
linux/ubuntu
Have you ever wanted to add a new feature to Google’s search results? There’s a really nice way to do it right now. If you’re not familiar with this functionality, it’s called a Subscribed Link, and it lets you “create custom search results that users can add to their Google search pages. You can display links to your services for your customers, provide news and status information updated in near-real-time, answer questions, calculate useful quantities, and more.” That page has a whole list of different ways to add new features to Google’s search results:
* Create search results specific to your product, service, or expertise.
* Design a basic version in minutes to see how it works.
* Build a dynamic version using XML, TSV, or RSS files or feeds.
* Include images in your Subscribed Links.
* Include Google Gadgets in your Subscribed Links.
* Test your Subscribed Links interactively and get debugging messages.
* Define query patterns using lists of keywords or regular expressions.
* Invoke the calculator to help construct your results.
I like that Google provides an open system to add functionality to our search results. If this sounds interesting to you, check out this blog post by Google OS (an unofficial blog), read through the subscribed links developer guide, or check out the Subscribed link FAQ.
Let’s walk through an example. I often need to know what my IP address is. Usually I go to Google, search for [ip address], and click on one of the top results. That works okay, but I discovered that there’s an even easier way. Go to this page and click on the “Subscribe” button.
Now when you go to Google and type a query like [my ip], you’ll see the answer right in your search results, like this:

I painted out my actual IP address, but you get the idea. Now if only aruljohn.com would add the query [ip address] to the list of queries that triggers a subscribed link, that will let me be lazy and continue doing the query that I’m used to.
If you’d like to add some new functionality to Google, why not try it for yourself today? I made a simple subscribed link that looks like this:

in about a minute. It looks like you can make a subscribed link out of feeds very quickly. It looks like you can even add your own flexible gadget to Google’s search results, and it looks like this:

By the way, I originally wrote this post a little while ago focusing on how to find out your IP address with a specific subscribed link. After Yahoo announced their “SearchMonkey” project tonight (congrats to the Yahoo folks!), I figured I’d add in some details about Google’s Subscribed Links and how to make a rich snippet result using Subscribed Links.
Have you ever wanted to add a new feature to Google’s search results? There’s a really nice way to do it right now. If you’re not familiar with this functionality, it’s called a Subscribed Link, and it lets you “create custom search results that users can add to their Google search pages. You can display links to your services for your customers, provide news and status information updated in near-real-time, answer questions, calculate useful quantities, and more.” That page has a whole list of different ways to add new features to Google’s search results:
* Create search results specific to your product, service, or expertise.
* Design a basic version in minutes to see how it works.
* Build a dynamic version using XML, TSV, or RSS files or feeds.
* Include images in your Subscribed Links.
* Include Google Gadgets in your Subscribed Links.
* Test your Subscribed Links interactively and get debugging messages.
* Define query patterns using lists of keywords or regular expressions.
* Invoke the calculator to help construct your results.
I like that Google provides an open system to add functionality to our search results. If this sounds interesting to you, check out this blog post by Google OS (an unofficial blog), read through the subscribed links developer guide, or check out the Subscribed link FAQ.
Let’s walk through an example. I often need to know what my IP address is. Usually I go to Google, search for [ip address], and click on one of the top results. That works okay, but I discovered that there’s an even easier way. Go to this page and click on the “Subscribe” button.
Now when you go to Google and type a query like [my ip], you’ll see the answer right in your search results, like this:

I painted out my actual IP address, but you get the idea. Now if only aruljohn.com would add the query [ip address] to the list of queries that triggers a subscribed link, that will let me be lazy and continue doing the query that I’m used to.
If you’d like to add some new functionality to Google, why not try it for yourself today? I made a simple subscribed link that looks like this:

in about a minute. It looks like you can make a subscribed link out of feeds very quickly. It looks like you can even add your own flexible gadget to Google’s search results, and it looks like this:

By the way, I originally wrote this post a little while ago focusing on how to find out your IP address with a specific subscribed link. After Yahoo announced their “SearchMonkey” project tonight (congrats to the Yahoo folks!), I figured I’d add in some details about Google’s Subscribed Links and how to make a rich snippet result using Subscribed Links.
Unless you want registered users to be able to edit your blog posts, you should update your WordPress installation to version 2.3.3. It’s a small change, and if you want to you can just replace your xmlrpc.php file with a newer version.
By the way, if you followed the advice in my recent security tips for WordPress post, you wouldn’t have to read about the update on my blog. Instead, you would already be subscribed to the WordPress security/developers’ feed (Atom feed link) that is suitable for subscribing in Google Reader or your favorite feed reader. I highly recommend subscribing to that feed so that you’re less likely to be caught by surprise when there’s a security issue with WordPress.
One of Google’s goals is that you should be able to throw just about anything into a search box (package tracking numbers, airline flight numbers, etc.) and Google will try to do something reasonable, such as return the status of a flight. Recently I was trying to reverse engineer a USB protocol and needed to convert some numbers between base 16 (hexadecimal) and base 10 (decimal). On a hunch, I threw the conversion into a Google search box. Sure enough, it worked fine.
Converting hexadecimal to decimal with a search query like [0×607a in decimal]:

Convert decimal to hexadecimal with a Google query like [1854 in hex]:

You can even convert hexadecimal to binary with a query like [0×770 in binary]:

Of course, you can also use alternate queries like [convert 0×770 to base 2]. Pretty handy.
Bonus tip: did you know that you can do currency conversion too? Just type something like [one dollar in yuan]:

If you have favorite tips for searches, leave them in the comments.
One of Google’s goals is that you should be able to throw just about anything into a search box (package tracking numbers, airline flight numbers, etc.) and Google will try to do something reasonable, such as return the status of a flight. Recently I was trying to reverse engineer a USB protocol and needed to convert some numbers between base 16 (hexadecimal) and base 10 (decimal). On a hunch, I threw the conversion into a Google search box. Sure enough, it worked fine.
Converting hexadecimal to decimal with a search query like [0×607a in decimal]:

Convert decimal to hexadecimal with a Google query like [1854 in hex]:

You can even convert hexadecimal to binary with a query like [0×770 in binary]:

Of course, you can also use alternate queries like [convert 0×770 to base 2]. Pretty handy.
Bonus tip: did you know that you can do currency conversion too? Just type something like [one dollar in yuan]:

If you have favorite tips for searches, leave them in the comments.
Unless you want registered users to be able to edit your blog posts, you should update your WordPress installation to version 2.3.3. It’s a small change, and if you want to you can just replace your xmlrpc.php file with a newer version.
By the way, if you followed the advice in my recent security tips for WordPress post, you wouldn’t have to read about the update on my blog. Instead, you would already be subscribed to the WordPress security/developers’ feed (Atom feed link) that is suitable for subscribing in Google Reader or your favorite feed reader. I highly recommend subscribing to that feed so that you’re less likely to be caught by surprise when there’s a security issue with WordPress.
Sometimes when you install Ubuntu (a flavor of Linux) and then try to install new packages, you get this annoying message:
Media change: please insert the disc labeled
‘Ubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016)’
in the drive ‘/cdrom/’ and press enter
To fix that message, click on
System->Administration->Software Sources and uncheck the “CD-ROM/DVD” option at the bottom of the menu:

Wow, I can’t believe how many people commented on my late-Friday night post about desired features for Gmail. If you want to suggest something for Gmail, that thread is the better place to do it. But looking through the comments, I saw a few requests that can already be done today. Considering that real Gmail users didn’t know about these options, I’m going to call them power tips.

I would like to have a feature for inserting prepared text blocks, so I dont have to write some things over and over again.
Julian, if you use Firefox, check out the Signature firefox extension to insert text macros. That might work for you.
Crazy feature: I’d like to be able to have an easy way to migrate my entire Google account to a different gmail address, because I can’t find a step-by-step guide or anything to help me switch emails without losing various things.
According to this post you can enable POP on your old account (look under Settings, then “Forwarding and POP/IMAP”), then import the emails (also using POP) into the new account. I think you could use Gmail’s Mail Fetcher utility to do this. To configure Mail Fetcher on the newer account, click on Gmail’s Settings link, then “Accounts” and then “Add another mail account.” Google Operating System (an unofficial blog that discusses Google often) has a couple relevant posts with a walkthough of using Gmail’s Mail Fetcher and a write-up on how to back up your Google account.
I would love to integrate my google apps account with my default gmail account. Although right now google allows to associate email address there is no way to integrate or link two google accounts (say one @gmail.com and another yourdomain.com powered by google apps).
Right now the only solution is to forward mails from one box to another! If google makes integration possible we can use a single inbox to check mails from all those email address
I’m not as familiar with the interaction of regular Gmail versus Gmail on Google Apps. This post described a scary-looking way that might work. If there’s a better way, maybe someone will stop by and let me know?
The ability to open Word, Excel, PowerPoint and PDF without going to another page and using another software
S.E.W, this post from Lifehacker mentions that Gmail can offer HTML view or Google Doc options for Word and Excel.
I’d love to be able to resize the email composition box on the default page - so instead of having to click the icon to open the whole draft in a new resizable window, I’d be able to click and drag to make the draft box bigger (especially vertically).
Easton, check out the Resizeable text area extension for Firefox. It lets you click on the border of any form textarea and drag the border so the textarea expands. I haven’t checked how it works on the latest version of Gmail though.
I don’t know if this would be possible, but how about, when clicking on the compose link (or reply etc) if I hold some key as I click on Compose, it opens the new email in its own window? Same thing could go for Replies etc.
Diego, instead of using ‘c’ to compose a new email, type ‘C’ and you’ll open a new window to compose your email. It looks like using ‘R’ instead of ‘r’ to reply will open a new email for replies too.
I heard a lot of great suggestions that I wouldn’t even have thought of. For example, I liked the idea of a “bounce” option for unwanted emails to make it look as if your email address didn’t exist. Oh, and since so many people asked for cool features, let me add one more feature I want: let me set a different vacation message for co-workers compared to people outside Google. Maybe in Google Apps for Gmail, if you are managing example.com, let people on example.com set a different vacation message for people on example.com vs. other domains?
By the way, what was the funniest suggestion I saw? Jeff Hall won with “A USB breathalyzer kit for a friend who forgets how embarrassing her e-mails are when she gets drunk. The e-mails could be delayed until she provides a negative sample.”
And here’s your bonus tip. If you’re a Gmail power user, three links to check out are the Gmail tag on Lifehacker, the official Gmail blog, and Google Operating System. Lifehacker does so many posts per day that limiting to the Gmail tag will narrow down the posts you see. The Gmail blog is the best place to get official Gmail news first. And Google OS seems to have Gmail-related posts pretty often.
A while ago I was looking around for how to make my own comments a different color on my blog. Most of the advice was along the lines of “Add code to check if the commenter’s email is the same as the email address of the blog’s author.” Can you spot the flaw in that logic? If a commenter knows the email address of the blog author, she could use the blog owner’s email address in her comment and get her own comment highlighted. Worse yet, someone could try to discover the blog owner’s email address by trying lots of email addresses until they saw their comments change to a different color.
So I dug a little deeper and found a good answer on this support thread. The trick is simple: instead of checking the author’s email address, check their user id to see if it’s the user id of the blog owner. Pretty smart. After that, it was a simple matter of
1. Changing my theme to add an “authcomment” style
I edited style.css and near the bottom added these lines:
.authcomment {
background-color: #B3FFCC !important;
}
2. Editing my comments.php file to add a little code
My comments.php file had a line that looked like this:
<li class=”<?php echo $oddcomment; ?>” id=”comment…
and I changed it to more or less look like this:
<li class=”<?php
/* Only use the authcomment class from style.css if the user_id is 1 (admin) */
if (1 == $comment->user_id)
$oddcomment = “authcomment”;
echo $oddcomment;
?>” id=”comment…
That’s about it. Now I have a distinctive color for my own comments, so you can quickly scan a thread to see when I circle back around to leave a comment.
I’ve got some pent-up techie/gadget blogging in me, and I know that not everyone wants to read that. I’ve mentioned before how to get just my Google/SEO posts, but I’ll repeat in case you didn’t see it the first time.
The short answer is to subscribe to
http://www.mattcutts.com/blog/type/googleseo/feed/
instead of my main blog feed at
http://www.mattcutts.com/blog/feed/
This trick works with any category, so you could (for example) subscribe to my Movies/Videos category by clicking on the “Movies/Videos” category over on the right-hand side of my blog and then adding “feed” to get http://www.mattcutts.com/blog/type/movies/feed/ . (This trick works with lots of WordPress blogs, by the way. Ain’t WordPress great?)
Now that you know how to get only the SEO/Google posts, I refuse to be guilt-tripped about doing some non-SEO posts, especially when my top-two traffic posts in 2007 were geek/Linux/iPhone posts instead of SEO posts. ![]()
Here are three easy but important ways to protect yourself if you run a WordPress blog:
AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName “Access Control”
AuthType Basic
order deny,allow
deny from all
# whitelist home IP address
allow from 64.233.169.99
# whitelist work IP address
allow from 69.147.114.210
allow from 199.239.136.200
# IP while in Kentucky; delete when back
allow from 128.163.2.27
I’ve changed the IP addresses, but otherwise that’s what I use. This file says that the IP address 64.233.169.99 (and the other IP addresses that I’ve whitelisted) are allowed to access /wp-admin/, but all other IP addresses are denied access. Has this saved me from being hacked before? Yes.
And here’s a bonus tip: in the header.php file for your theme, you might want to check for a line like
<meta name=”generator” content=”WordPress <?php bloginfo(’version’); ?>” /> <!-– leave this for stats please -->
I’d just go ahead and delete that line or at least the bloginfo(’version’). If you’re running an older version of WordPress, anyone can view source to see what attacks might work against your blog.
Hat tip to Reuben Yau and Shoe.
Update: In the comments, Joshua Slive pointed out that the .htaccess file shouldn’t have a <LIMIT GET> around the IP addresses. That would have allowed IP addresses to POST, for example. Joshua, thanks for the pointer to the Apache docs on this point.
Suppose you want to include a child iframe on your page. You’d like to resize the height of the child iframe so that it doesn’t show a scrollbar. That is, you want something that looks like this:

Here’s one way you can do it. First, make the iframe that you want to include. I made a file “child-frame.html” that looks like this:
<html>
<head> <title>Child frame</title> </head>
<body bgcolor=”#000000″><font color=”#ffffff”>
<p>Child frame.</p>
<p>Child frame.</p>
<p>Child frame.</p>
<p>Child frame.</p>
<p>Child frame.</p>
<p>Child frame.</p>
<p>Child frame.</p>
<p>Child frame.</p>
</font></body>
</html>
Now in the parent frame, you can make code like this:
<html>
<head> <title>Parent frame</title> </head><body onload=”resizeFrame(document.getElementById(’childframe’))” bgcolor=”#cccccc”>
<script type=”text/javascript”>
// Firefox worked fine. Internet Explorer shows scrollbar because of frameborder
function resizeFrame(f) {
f.style.height = f.contentWindow.document.body.scrollHeight + “px”;
}
</script><p>Parent frame.</p>
<p>Parent frame.</p>
<p>Parent frame.</p>
<p>Parent frame.</p><p>
<iframe frameborder=0 border=0 src=”./child-frame.html” name=”childframe” id=”childframe”>
</iframe>
</p></body>
</html>
You can also see a live example of resizing an iframe height dynamically.
What does this code do? When the body of the parent frame loads, it looks up the document element “childframe” which corresponds to the iframe. Then the page calls a function resizeFrame(). The function sets the height of the frame to be the scrollHeight, which effectively removes the scrollbar.
The only tricky bit is the “frameborder=0 border=0″ attributes on the frame. If you leave off the frameborder attribute, Internet Explorer will assume that the frame should have a nonzero border, but it won’t include the frame border in the value it returns for scrollHeight. The net effect is that IE will show a scrollbar unless you add “frameborder=0″.
It always annoys me to dive into cross-browser development when it feels like things should be standardized. Looks like it annoys other people too.
Anyway, feel free to rip on my code in the comments, but I was looking for a simple, working example of setting an iframe’s height so that the iframe wouldn’t have a scrollbar.
If you didn’t see this post about better date-based searching by Ionut Alex Chitu, I highly recommend that you check it out. As Google has gotten fresher, our advanced search page started showing more useful options for restricting searches by date. The shortest time frame used to be something like three months; now you can look for things that are less than 24 hours old.
What GoogleOS noticed is that the advanced date search affects a url parameter called “as_qdr” and Chitu figured out so