More things I can’t remember.

Manipulate a phone number

To change a phone number from a string of digits, e.g. 8051230123 to a formatted value e.g. 805.123.0123 you can use the following grep pattern to parse the string


([0-9]{3})([0-9]{3})([0-9]{4})

and

\1\.\2\.\3

to replace the parsed string with dots.

Tar up a folder

Someone wrote this up for me years ago and I still refer to it from time time.

Assuming you want to copy the site onto your local machine:
The following will tar and compress up the entire www tree and
put the archive file in your home directory (on the server).

cd /; tar -czvf ~/www.tgz www

to decipher:
tar – tape archiver
-c – create new archive, write supplied files too it
-v – verbose – print out names of files as they are added to archive
-z – compress archive using gzip (gnutar only, as used on OS X)
-f ~/www.tgz – write output to file www.tgz in home directory
www – the file to include in the archive

To extract it again:


cd /where/you/want/it; tar -xzvf /path/to/www.tgz
 

will unarchive the www tree under the directory /where/you/want/it

Wordlist

My favorite words list has formatting in the CSS to make the first word of the definition (the part of speech) capitalized.


.definition p:first-line {
  font-weight: bold;
  font-variant: small-caps;  
}

Some words can be used as Verbs and Nouns, or Verbs and Adjectives, so I need to change the formatting of the part of speech.


<span class="boldSmallCaps">Adjective</span><br />

So the part of speech is now formatted with this CSS

.boldSmallCaps {
  font-weight: bold;
  font-variant: small-caps;  
}

Frequencies for equal-tempered scale

Link

Prevent your ISP from redirecting mis-typed URLs

My ISP started to hijack mis-typed URLs and open up their search engine page—which makes it difficult to correct typos. You can bypass your ISPs DNS server by using OpenDNS (208.67.222.222 , 208.67.220.220) or Google Public DNS (8.8.8.8 , 8.8.4.4 ). If you are using OSX, open up the Network Panel in System Preferences and then click on the Advanced button. In the DNS tab, replace the default IP address with one of the ones above.

Block access to javascript from Tynt, the Copy/Paste Jerks

For my word of the day I frequently copy a sentence with the target word and lately I’ve noticed that I get the URL with it. It’s annoying to delete the URL and apparently it annoys John Gruber too. The solution is to edit your /etc/hosts file and block their server. Add this line to the end:
127.0.0.1 tcr.tynt.com

Make files invisible

SetFile file -a V

phpMyAdmin Notes

I ran across a couple of things when uploading data to our MySql database that kept me puzzled for a few hours. I was trying to load data from the FAA on airports. There are 19,755 airports in an xls file. Last month I converted the records to semi-colon delimited fields and imported them without a problem. This month I wanted to add a few more fields, so I thought I’d just create the new fields and import the data in the same step. I used

INSERT INTO `Airports_NFDC` (`id`, `NFDC_id`, `type`, 
`FAA_id`, `state`, `city`, `name`, `owner`, `access`,
 `lat`, `lon`, `elev`, `var`, `TPA`, `DistCBD`, `DirCBD`,
 `Activation`) 
VALUES

to insert the data. However, it appears that this takes forever and my query would time out without importing any records. (It could be that something else was causing the termination, but I managed to get 5,000 records to import, so I’m reasonably certain that it is a transaction time issue.)

I converted the data to CSV delimited by a ‘;’ and within a minute the file was uploaded. One glitch occurred. It gave me an error on the last record. The last record did not have an end-of-line marker and the importer didn’t know that an end-of-file must mean that the line had ended as well. Inserting a return after the last line fixed the problem.

Faking Out The Vistaprint List Importer

One of the things that made us try out Vistaprint was the extremely well documented image format requirements. The same cannot be said of the mailing list formats. After some experimentation, I think I’ve found out how they turn your data into mailing labels.

If you have a simple customer list, using their .xls template should work fine. Export your data from you database, import it into another sheet and past the info into the appropriate columns. If you want to use comma separated lists—and your info is database matches their format—it is fairly stratghtforward. Just remember to use the .csv suffix on your file. You should also save the file as ‘Western ISO Latin’ so that it picks up special characters from other languages, like ñ, é, á, etc. Their algorithm detects Mac, Windows, and Linux line endings so you don’t have to worry about them.

I’ve been working on the same customer database since 1994. We’ve copied and pasted names and addresses form email and webs sites and added entries by hand. In the process lots of unprintable characters made their way into the database. My text editor (BBEdit) can remove the ‘gremlins’ so if you have a text editor that can zap them you should, otherwise you’ll have a bunch of records rejected without knowing why. If you can view invisible characters, you might want to do that as well to catch anything that wasn’t zapped.

The header line is not the same as in the .xls file. It should look like this—but all on one line:

Salutation,First Name,Middle Name,Last Name,Title,   
Company Name,Address Line 1,City,State,ZIP Code

You can leave out fields that you do not use.

The labels will print the info in the following order
Salutation,First Name,Middle Name,Last Name
Title
Company Name
Address Line 1
City,State,ZIP

You can also use Address Line 2 but I can’t figure out the rules for using two address lines so I don’t recommend using it.

My main customer database doesn’t match their format so it took a bit of experimenting to fake out their input algorithm. I noticed that you can put anything you want into the fields before Address Line 1 and it will print it in the order that it appears.

My database has a customer number, contact name—first name then last and sometimes initials for degrees or credentials, sometimes it has a company name, and company names often run over to a second line. Some companies have a department or building that is entered on the second line. I always have one street address line, city, state, and zip code so they aren’t a problem.

Their algorithm cares about the address, city, state, and zip but doesn’t check the data in the first fields. So I put the customer number into Salutation. the full contact name into Last Name, the first line of the company into the Title, and the department or second line of the company name into Company Name. The labels print out correctly.

This is what my data looks like:

Salutation,Last Name,Title,Company Name,
"487","Grey, Harrison A PhD","Community Speech & Hearing Ctr",""
"43","Arlene Johnson","Adult & Pediatric","Speech And Language"
"345" "Judith Krantner","Mankato State University","Communication Disorders"
"2490","Mary Patricia Connelly","University Of Florida","P K Young Dev Research School"
"2662","Julie Blaine, SLP","","",

Update: People have been buying my Spanish-language apps and I wanted to send a mailing to them. Unfortunately, VistaPrint mangles the non-ASCII characters in their names and addresses, e.g. ñ, é, á. It turns out that if you encode your .csv file as Western (ISO Latin 9) instead of Unicode (UTF 8) it works fine.