January 23rd, 2007

public restroom tips

Two things I’ve been meaning to post for a long time… Nothing profound, just a couple tips for you to absorb, in case someday they happen to come in handy. Feel free to post your own tips in the comments (please keep it reasonably clean/relevant though)!

1. Temporarily disabling automatic-flushing

I hate automatic-flushing toilets. When I was traveling a lot for business a couple years ago, I was annoyed by automatic toilets on many occasions. I’d sometimes roll my suitcase into a bathroom stall, hang my laptop bag on the stall door’s hook, urinate, then grab my laptop bag and wheel the suitcase out. During this simple process, in which I clearly only used the toilet one time, the stupid thing would usually flush between 4-7 times. Yes, sometimes it flushed 7 times just for pee. A little excessive, if you ask me.

Worse yet is when taking a small child to a public bathroom that has automatic-flushing toilets. The sensors often do not notice the child, especially when the kid leans over to get TP or moves their head AT ALL. So then you have a little kid sitting on a toilet which suddenly makes extremely loud noises and may even splash a little water on them. Not fun. So, at some point I figured out a simple solution:

Cover the sensor temporarily while using the toilet, then uncover it when you’re done. I’ve done this at least 15-20 times, now, and it has always worked flawlessly. I put a tiny bit of saliva on one square of toilet paper and stick it on the sensor. When I (or my kid) is done, I take the square off and drop it in the toilet.

The only thing I don’t like about this is that I’m putting my spit/germs on the wall. But, honestly, I don’t think anybody ever needs to touch the sensor, and if they do, they are probably cleaning it or fixing it, which means they should come prepared to mess with a public toilet, and my spit would probably be the least of their concerns. My wife suggested wetting a little bit of paper towel on your way into the bathroom, instead, and that sounds like a pretty good idea as well.

2. Making a toilet flush when it’s being stubborn

This will probably work in very few instances, but it usually works in my current office’s restrooms. If the toilet is a professional/industrial type (not sure what they’re really called.. the kind you find in public bathrooms, not the type people generally have in their homes), with the handle that sticks out the side from visible pipes.

These toilets have a very powerful flushing mechanism, but sometimes, for some reason, they do not fully empty the bowl. I’ve found that–at least with these toilets at work–if I hold the handle down (rather than just pushing it and letting it go when it starts flushing), it tries harder.

This might work in other, similar, public toilets. I haven’t had to try it anywhere else since I figured this out.

August 21st, 2006

How to send an SMS from cell phone to an AIM user

I’m not sure if this is common knowledge or not, but I only learned about it recently. Some cell phones let you sign on to instant messenger clients (usually AIM), but that can be less than ideal. When I did that a couple years ago, every single communication my phone did with AIM counted as a text message. That includes messages you send or receive, as well as sign-on related messages, and even disconnection messages. I’d get disconnected fairly frequently, and every time that happened, it would cost me 2-3 text messages to sign back on. At 10 cents a pop (unless you pay for a plan with a bucket of monthly text messages), that got annoying pretty fast.

Well, I recently found out that you can send a message to an AIM user, using your cell phone, without logging on with any actual AIM client. Just send an SMS text message with the following format:

Recipient: 265010
Message: AIM_screen_name: message text

I know there are all sorts of “mobile AIM” features, but this is one simple one that has come in handy several times for me, already.

August 10th, 2006

How to list just directories in bash

This morning, I was trying to find a way to list just the subdirectories in the current directory, in a bash shell script I was writing. I thought it would be simple, but everything I tried seemed to either take an extraordinarily long time, or felt like an ugly hack.

The first thing I tried was:
find . -type d

But this was extremely slow, because it was recursively searching inside every subdirectory as well. I just wanted a list of subdirectories inside the current directory. I won’t bore you/clutter this post up with any more of my less-than-ideal methods.

What follows are a couple of ways of doing what I was trying to do, which I found in a post (and its comments) on the Ubuntu Blog, “List only the directories“:

ls -l | grep “^d”

This works, but gives a ‘long’ directory listing, when all I wanted was a list of directory names.


find . -type d -maxdepth 1 -mindepth 1This one was my favorite, since it used the method I originally tried, but it fixed the slowness by using parameters to avoid recursion. It gave me a couple warnings about the order of the parameters, though, so I changed it to this:
find . -maxdepth 1 -mindepth 1 -type d


ls -d */This gave me the same output as the ‘find’ method did, but some timing tests showed me that the ‘find’ method was about 2 times faster.

July 15th, 2006

finding unique ips in access log that have something in common

search for a string in access log, extract only ip address from matching line, sort the list of ip’s and remove duplicates, output the [shortened] list…

for ip in `grep -i firefox /cygdrive/w/resin/log/access.log \
| grep -o “^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}” \
| sort -u \
| wc -l`; \
do echo $ip; \
done

July 13th, 2006

Generating a random fake name from the commandline

Today I needed to come up with a list of lots of fake names for test data. In the past, I either manually entered well-known fictional character names (e.g. Homer J. Simpson), or used strings of characters (like ‘asdf g. hjkl’ or ‘aaaaaaaaaaaaaa’).

I remembered seeing some sort of test data generator, somewhere, recently, so I googled for “fake name generator test data“.

What I found was http://www.fakenamegenerator.com, which generates realistic test data based on country, name origin, and gender specifications. More info on the site at the end of this post. Here’s a set of commands that I put together to retrieve one fake name from that site:

curl -s -b agreement=Yes “http://www.fakenamegenerator.com”
| grep -o ‘on Google”>\([^<]\+\)’
| sed -e “s/[^>]*>\([^<<]\+\)<.*/\1/g”

When you use the site like a normal human being, the fake data that is generated includes full name, address, email address (usable, provided by an anonymous email service), phone number, mother’s maiden name, date of birth, and credit card number (+ expiration date). Very cool! For a very small fee, you can also order a bulk batch of data, which also includes fake Social Security Numbers).

However, being the penny-pinching and geeky type, I wanted to be able to generate my own list of fake names (without all the other info), for free. The set of commands listed above work right now, from a cygwin bash shell, but will probably break sometime in the future, when the HTML structure of the page changes. Oh well.

Oh yeah, don’t forget to read their terms of service* before using the service… Right now, I could not find anything prohibiting the use of automated tools to generate and retrieve names, but use the above set of commands at your own risk!

* The terms of service page only displays one time, unless you clear/disable your cookies.