Monday, February 5, 2018

Drinking on a budget: Dollar Tree martini glasses!

We had a very nice set of (I think) six martini glasses, some well-known brand, that we bought as a set perhaps somewhere around five years ago. Every year or so, I accidentally break one of the glasses by dropping it, or the dishwasher decides it's time to crack one of them. So now I'm down to one and it was time to restock. But, I'm on a budget here in Miami. The solution: Dollar Tree!

What could be simpler? They look great. They hold as much as our previous martini glasses, though they look a tiny bit smaller. They also seem a bit sturdier as far as glass and stem thickness. They clean up very nice in the dishwasher. And they're only a dollar each. I'm sold!

I think we're not the only ones sold on Dollar Tree martini glasses. We went to a very famous local restaurant recently, one known for crab claws, and they served us a round of cocktails in glasses that looked suspiciously like these ones. Can't say that I blame them, especially if these are sturdier than average.

Thursday, February 1, 2018

Linux: Redirecting or Silencing Script Output

I've been writing shell scripts on *nix systems for more than twenty years. You'd think that by now I'd have this memorized, but I don't. Since I'm tired of looking it up every time, I'll post this here so that it can help jog my memory next time around.

Repeat after me: redirecting stderr and stdout is easy.

To run your script while silencing any and all possible output, execute it like this:
./ > /dev/null 2>&1

To silence it only when it runs via cron, to make it not send you an email after it runs, put it in your crontab like this:
0 5 * * 1 /home/aiverson/ > /dev/null 2>&1
(all on one line)

If you're running a command inside a script and you want to capture both possible errors and standard  output in the same way, so that you can parse it easily, do this:
OUTPUT=`lynx -dump "http://website" 2>&1`
If you don't add the 2>&1, any error message returned by lynx is sent to the active window running your script, instead of into the $OUTPUT variable.

Sunday, January 21, 2018

Linux: Scraping web output with wget

This is probably a tip that smarter folks than me know already, but I just ran into this today and decided I'd write it down for future reference.

I'm writing a simple unix shell script that scans the web interfaces of a bunch of internal servers, looking for a specific error message. Very light touch, fairly simple stuff.

Lots of simple stuff like this:
lynx -source "" | \
grep "error code"

It turns out that the server I need to install this on doesn't have lynx installed. It does have wget, however. But wget defaults to dumping the output into a file instead of to standard output, which is annoying when you don't actually care about saving the output.

Unless you do it like this:
wget -qO - "" | \
grep "error code"

That makes these two bits of sample code (one with lynx, the other with wget) work exactly the same way. The "q" flag is to quiet wget's normally verbose output, and the "O -" flag is telling wget to dump the output to stdout ("-") instead of to a file.

Which one is faster? In my entirely non-scientific testing, lynx seems to be faster. My suggestion is that if you can, test. Or just use lynx if your system has it installed (or if it can be installed), and use wget as a backup only. (And I didn't even really get a chance to test curl. Sorry!)

For now, I've got a solid workaround to get my script to work on a server that doesn't have lynx and where I'm not an administrator.

Thus ends today's lesson in stupid shell script tricks.

Thursday, December 21, 2017

How to block Fox News in Apple News and Google News

If, like me, you prefer not to give clicks and ad revenue to the Fox News website, here's how you can keep their results from showing up in Google News and Apple News.

Blocking Fox News in Google News:
  1. Go to the Google News website at
  2. Click on the "Gear" icon near the top right of the page.
  3. Select "Sources."
  4. In the "Block" section, type "Fox News" and then click on the first website result.
  5. If you want to block all the variants of Fox News (that I know about as of this writing), block the following: Fox News, Fox Business, Fox News Latino, FoxNews, FOX News Radio, FOX News Magazine, Fox News Insider
Extra tip: Also check out the "Preferred Sources" setting on this screen. In my preferences, I added "Washington Post" and "NPR" as preferred sources. That way if Google News has multiple articles on a topic, it will be more likely to recommend an article from one of those two sources. Why? Because I pay for a Washington Post subscription, thus I'm unlikely to run into a paywall versus if the link is to Wall Street Journal or New York Times, and because I trust National Public Radio (NPR).

Blocking Fox News in Apple News:
  1. On your iOS device, open the "News" application.
  2. Find an article published by Fox News.
  3. Don't open the article; just click on the "Share" icon underneath the article. It's the box with an arrow poking up out of it. It's located at the bottom of the article entry, under the headline, over to the right.
  4. A menu pops up. The first choice is "Airdrop" but if you look down below, there are options for "Dislike Story" and "Dislike Channel." Select "Dislike Channel."
  5. That should do it. You should now no longer see any stories from that source.
Note: Depending on your version of iOS, the menu selection might be called "Mute Channel."

Here's more information on liking / disliking channels in Apple News.

Friday, September 8, 2017

On Quick & Dirty Email Attachments in Unix

Need to export a file from Unix/Linux via email? Got uuencode? Do you even remember uuencode? It's how we used to encode files for file sharing, back before you were born.

Here's a handy one-liner that will wrap your file up as a UUEncoded attachment and mail it to the address you specify. The email should come through with a properly formatted attachment that you can then download.

Just do this:
% cat | uuencode | mail [email protected]

Or you can get a bit fancier and add a subject line and a proper from address (if your system doesn't add one already):
% cat | uuencode | mail -s "Export of" -a "From: Me <[email protected]>" [email protected]

Or you can do it as part of a shell script, with bits that look something like this:

FROM="Just Me <[email protected]>"
TO="[email protected]"
cat $FILE | \
uuencode $FILE \
mail -s "Export of $FILE attached" \
-a "From: $FROM" \

I know there's probably some better way to do this, but this simple example has saved me endless amounts of time lately. Hope you find it useful, too.

Monday, August 21, 2017

On Nasty Women Week

Samantha Bee has proclaimed this week to be Nasty Women Week. To celebrate, I suggest that you pre-order the new book NASTY WOMEN: FEMINISM, RESISTANCE AND REVOLUTION IN TRUMP'S AMERICA, edited by Samhita Mukhopadhyay and my wife, Kate Harding.

Monday, August 14, 2017

On Working From Home

I've worked from home the whole time I've had my current job--a pretty long time now.

It's not so much that I intended to work from home. But when I got this job offer, I had just moved to a new city, and wasn't able to just pack up again and move a second time. The person hiring me was also based in another city and knew that it was possible to be a productive member of a team and organization even if you're not based in the same city or office as your coworkers.