Things I can’t remember.

Linux Commands

I have one set of styles that I use for all of my sites. Rather than have dozens of copies that get out of synch, I use a symbolic link to the styles folder. To create a symbolic link to a folder use the ln command with the -s option. First CD to the directory where you want the new folder. The location of the folder you want to link to is first and the new folder that you are creating comes last.

ln -s /www/Styles/ Styles

For files, leave out the trailing slash.

ln -s /www/Styles/s_gray.css s_gray.css


tar
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

Explanation:
cd / – change to root directory of the machine
; – separator for multiple commands on the same line
tar – tape archiver—the name is archaic, it’s the utility that compresses the data
-c – create new archive, write supplied files to 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 (or directory) to include in the archive, in this example www is in the root

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

Here’s how I tar up a MySql backup.


sudo tar -czvf mysql-backup.tar  mysql-backup.sql

Making URLs compliant

If you encode your pages as UTF-8, no BOM and include this


    <meta charset="utf-8">

line in your header to tell the browser how to interpret the text, you shouldn’t have any problems with displaying characters. However, if you read text from a database or have special characters in URLs then you may need to convert them. I use these two sites to look up the HTML codes for special characters.

HTML Characters

Special HTML Characters

Fixed Size Browser Window

We’re doing screen shots of sites we’ve designed and wanted to make each window the same size. A simple javascript bookmarklet lets us do that.

javascript:self.moveTo(0,0);self.resizeTo(1000,800); self.location="http://slipintoview.com/";

Constrain image to div

To keep an image from overflowing its box, constrain the width.

div#flow img {
  float: left;
  padding-right: 1em;
  padding-bottom: .5em;
  max-width: 100%;
}

Turning Off Google Analytics Site Overlay

When you first enter the site overlay you’ll notice that your URL has #gaso and a bunch of letters and numbers appended.

http://www.learningfundamentals.com/#gaso=z2mqTCUBAAlak123jdnkSSSG

The only way to turn off the overlay is to open Preferences and search for the gaso cookie. Delete it and you’re good to go.

Avoiding ISP redirects when a site is not found

I frequently mis-type a site name and instead of getting a browser error and quickly correcting my typing, I get a redirect to my ISPs spam page. Using Google for DNS lookup avoids that. Link.

Comparison Operators

PHP has a comparison operator that checks to see if the values being compared are of the same type. The operator is

$a === $b  Identical  TRUE if $a is equal to $b, and they are of the same type.

For example, I have a bunch of pages from the NACO Airport/Facility Directory (A/FD). They are saved as AFD_1.inc, AFD2.inc, etc. I want to check whether the $page variable contains AFD, and if it does then display the correct page. If no page is given, then display a spash page, and if a page is requested using the old style format (State abbreviatons), then indicate that they need to use the new format. If the page starts with AFD one of the string functions I can use to determing that is strpos. It returns the position of the first occurrence of the string and FALSE if it is not present. Now FALSE and 0 are the same value, but different types. So if I use the == comparison operator, it returns TRUE if the $page starts with AFD and returns TRUE if $page doesn’t start with AFD. However, if I use === then it works as expected since 0 and FALSE are different types.
This is what my code looks like: (WordPress has trouble with this so it’s commented.)

//  if(strpos($page, 'AFD') === 0) {
//    include("./AFD_17DEC2009/$page.inc");
//  } else if ($page == '') {
//  } else {
//    include("./Missing.inc");
//  }

Browser Size

Determining the appropriate display size for websites is fairly difficult. You don’t have any control over how users set up their browser windows so you have to guess how your site looks to visitors. I just found this tool from Google that lets you see you site is probably viewed. Google Labs. Type your site address into the text box at the top and you can see what percentage of visitors can see your site without scrolling, with vertical scrolling, and how many need to scroll horizontally.

Hiding Photoshop

When OSX started using Command-H to hide applications and Command-Tab to switch between open applications, I was ecstatic. However, Photoshop never adapted to the new behavior so typing Command-H does something else—I’m not sure what. It’s been a real annoyance for years. I looked all over the Photoshop Preferences and couldn’t find a way to change the behavior. I was reading a blog post today and found out that Adobe puts Keyboard Shortcuts in the ‘Edit’ menu. Select it and look for the Hide Photoshop section. In the shortcut field, hold down the Command Key and hit the H.

Turn off inline viewing of PDFs in Safari

I usually prefer to view PDFs in Preview rather than the Safari browser so I copied this command to the terminal. Sometimes, you need to view the PDF in Safari so you can submit it online. Change YES to NO and it turns the view feature back on. For some sites, you may also need to turn Adobe Acrobat back on.

defaults write com.apple.Safari WebKitOmitPDFSupport -bool YES

Embedded Fonts

Link

MooModernizr

This tool seems like it will come in handy. MooModernizr 1.1 tests the browser’s CSS3 and HTML5 capabilities. This by extending MooTools’ Browser. Features object with a variety of CSS3 and HTML5 features. It is a MooTools 1.2 port of Modernizr 1.1.

Clean up CSS for HTML Mail

Premailer

24 Ways

Lots of posts on web crafting. I reference a few frequently.

Rock Solid HTML Emails
Going Nuts with CSS Transitions
Working With RGBA Colour
Forms

Choose a random row from the MySQL database.

ORDER BY rand() LIMIT 1";

Pilot Humor

A woman was flying from Seattle to San Francisco . Unexpectedly, the plane was diverted to Sacramento along the way. The flight attendant explained that there would be a delay, and if the passengers wanted to get off the aircraft the plane would re-board in 50 minutes.

Everybody got off the plane except one lady who was blind. The man had noticed her as he walked by and could tell the lady was blind because her Seeing Eye dog lay quietly underneath the seats in front of her throughout the entire flight.

He could also tell she had flown this very flight before because the pilot approached her, and calling her by name, said, ‘Kathy, we are in Sacramento for almost an hour. Would you like to get off and stretch your legs?’ The blind lady replied, ‘No thanks, but maybe Buddy would like to stretch his legs.’

Picture this:

All the people in the gate area came to a complete standstill when they looked up and saw the pilot walk off the plane with a Seeing Eye dog!

The pilot was even wearing sun glasses.. People scattered. They not only tried to change planes, but they were trying to change airlines!

Remember…

Things aren’t always what they appear.

Obscure humor

Q: What tool is used to measure a hole in the head?

A: A Phineas gage.

A red blood cell walked into a busy restaurant. The hostess asked, “Would you like to sit at the bar?”
The red cell answered, “No thanks, I’ll just circulate.

Why did the magnet see a magnet therapist?
It was bi-polar.

I’m so excited! My first authentic Nigerian scammer!!

Sure I’ve gotten the bulk mail scams from “Mrs. Colonel Akrun Abnor” asking for my help in getting $40,000,000 of her late husband’s money out of the country. But this is the first time it’s been personal.

This scam is different in that the scammer had to do a bit of work first to identify me as a target. It looks like the strategy was to appear as a legitimate reseller with a largish order and when I was looking forward to getting the order, slip in the scam.

They started off asking about distribution terms for our software. It was a bit odd that someone in New Zealand would write a letter where English was clearly not the native language, but it happens. I sent them pdf’s of our terms and price lists. They didn’t appear to actually read the emails I sent and asked for price lists. Now that information is on our website and included in the distribution terms that I sent them. It’s also a bit odd that they want to resell something and they didn’t have a clue about what the list price was. So it started to be a bit odd, but I’ve had real customers to the same thing—usually when one of their customers wants a bunch of software and also wants some of our titles. So I went along and we exchanged a few emails.

Now, several emails later, they placed an order for $2,300 which is fairly large sized for me. They also told me that they needed it quickly. Even though I told them that it would be very expensive, they wanted me to ship to New Zealand with UPS or FedEx. But UPS couldn’t find the address that they gave me for shipping. They hadn’t given me a postal code and when I asked for it and verification of the address, they said their agent in LA (a 4 hour drive away) would pick the software up. However, they used the zip code for Louisiana (LA) instead of Los Angeles.

Up to that point, I figured that they weren’t the best communicators and their knowledge of California geography was sketchy, but I’ve had legitimate orders with almost as much confusion. But their final email makes it an official scam. They want me to assist them in making a purchase from another vendor.

They’re probably targeting small companies, raising your expectations with each email, hoping you’ll feel invested in the process, and wanting the money badly enough to go along with their scheme.

Beware.

On Fri, Jun 19, 2009 at 1:11 PM, Sales Support wrote:

On Jun 19, 2009, at 1:13 PM, Joy Jnr wrote:

On Fri, Jun 19, 2009 at 1:45 PM, Sales Support wrote:

On Fri, Jun 19, 2009 at 1:59 PM, Joy Jnr wrote:

On Fri, Jun 19, 2009 at 2:07 PM, Sales Support wrote:

I know how this scam works using fake cashier’s checks or money orders, but I’m not sure how they do it with credit cards. I’m guessing that the credit card number is stolen but the card isn’t and that I’d get a chargeback when the owner of the card got the bill.

I like the way they try make you feel guilty about not going along with their scheme. Oh and they’ll give me $100 for my trouble. As an aside there are 10 Western Union offices in Wellington, NZ. Up until they asked me to help with purchasing “other items i ordered from different countries” (which makes no sense), they could have been any of a half dozen legitimate customers I’ve had over the years.

I was a bit surprised that I didn’t get at least one more pleading email, but I guess they had other prospects that looked more promising.

And just in time for this post, I got a simple Nigerian scam from the Ivory Coast.

And for something different, a puppy scam. I love the commas instead of periods, the complete lack of paragraphing, and the avoidance of plurals. The way this one works is that you wire money for the puppy and then “unanticipated expenses” delay the shipment and you need to wire just a few dollars more and everything will be OK. The scam continues as long as you send money.

And here’s a new one. The FBI found some of my money! Grammar’s not too bad but clearly not a native speaker. Scammers do seem to have a preference for the phrase “the sum of”. And what’s with the USD? This clearly marks the mail as originating from overseas—not from the FBI.

Maybe it’s just me, but I’d be much more likely to believe that some government agency owed me a few hundred dollars and they put it on a debit card than that they owe me the sum of 2.5 million dollars.

And another from New Zealand. I guess the scammers don’t realize that people in New Zealand speak English and their choice of words and punctuation is odd. They do appear to have learned that excessive politeness isn’t a characteristic of English prose.

Update 2009-09-13. The standard scam. I haven’t seen one of these for a while.

Anti-vax death watch

A four-week-old baby died from whooping cough recently because vaccine rates are too low in that part of Australia to provide herd immunity. A heart rending appearance by the parents is available on YouTube with more details at Bad Astronomy.

A correspondent for the Guardian was “lucky”. His 11 month-old daughter didn’t die from measles—she just had to go through needless suffering because parents in his part of England aren’t vaccinating their children. His child was too young for the MMR vaccine—it is usually given at 13 months—and should have been able to rely on herd immunity to keep her free from the disease. Unfortunately, vaccine rates have dropped all over England and preventable diseases are making a comeback.

In an article on Friday he made an analogy that sums the situation up eloquently.

The decision by many of my neighbours not to vaccinate their children is on a par with the drunk who decides to get into his car to drive home. It is a personally reckless action that also endangers the lives of everyone else on the road. Society should view the MMR refuseniks with the same degree of scorn.