Thursday, April 10, 2014

Test post

I don't ordinarily write test posts, but that's what this is. And I'm updating it, too.

Friday, January 31, 2014

Pet Peeve: "infinite number of"

Welcome to my long list of pet peeves, "infinite number of"!!

Why say "infinite number of monkeys" when you can just say "infinite monkeys"??

Tuesday, January 28, 2014

Solaris TAR with Excluded Directories

It's been a long time since I had to use Solaris, and tar is bad enough without the differences between Linux and my previously favorite Unix!

$ tar cfX - /tmp/excludes . | gzip > ~/excluded.tgz

where /tmp/excludes looks like this:

./sub1
./sub2
./sub3

So it's not just a list of what's excluded, it's starting with the dot!

hattip: thank you, My Couple Of Cents!!

Saturday, November 02, 2013

Android SQLite queries and numeric predicates

The typical code for making an Android SQLite query goes something like this:

Uri uri = MyProvider.URI;
String[] projection = ...;
String where = COLUMN_NAME + "=?";
String[] whereArgs = new String[] { someValue };
String sortOrder = SORT_COL + " " + sortDir;
Cursor c = getContentResolver().query(uri, projection, 
  where, whereArgs, sortOrder);

But what if someValue isn't a String? What if you want to query your database on a numeric column? I was bashing my head against this and getting wrong results until I stumbled onto the suggestion that the "?" argument needs to be converted to a number. How to do it? Just add zero.

long someValue = ...;
Uri uri = MyProvider.URI;
String[] projection = ...;
String where = COLUMN_NAME + "=(?+0)";
String[] whereArgs = new String[] { Long.toString(someValue) };
String sortOrder = SORT_COL + " " + sortDir;
Cursor c = getContentResolver().query(uri, projection, 
  where, whereArgs, sortOrder);

You have to pass your selection arguments as an array of strings, so you'll use toString for that. But the query itself can use an addition operation to convert the string argument to a number. See the "+0" in the where string? That's it.

Maybe there's another, even better way, but this solved my problem - my queries now return just what they're supposed to. All you need is plus.

Tuesday, October 22, 2013

World Series Match-Ups

How many times have the Red Sox and Cardinals played each other in the World Series? This is the fourth time. The others were in 1946, 1967 and 2004. I was alive for two of those - can you guess which ones?

In case you're wondering about other match-ups, here is the complete list of which teams have played each other how many times.

11 Dodgers & Yankees
 7 Giants & Yankees
 5 Cardinals & Yankees
 4 Athletics & Giants
 4 Braves & Yankees
 4 Cubs & Tigers
 3 Cardinals & Red Sox
 3 Cardinals & Tigers
 3 Reds & Yankees
 2 Athletics & Cardinals
 2 Athletics & Cubs
 2 Athletics & Dodgers
 2 Athletics & Reds
 2 Braves & Indians
 2 Cubs & Yankees
 2 Giants & Senators
 2 Orioles & Pirates
 2 Phillies & Yankees
 2 Pirates & Yankees
 1 Americans & Pirates
 1 Angels & Giants
 1 Astros & White Sox
 1 Athletics & Braves
 1 Athletics & Mets
 1 Blue Jays & Braves
 1 Blue Jays & Phillies
 1 Braves & Twins
 1 Brewers & Cardinals
 1 Browns & Cardinals
 1 Cardinals & Rangers
 1 Cardinals & Royals
 1 Cardinals & Twins
 1 Cubs & Red Sox
 1 Cubs & White Sox
 1 Diamondbacks & Yankees
 1 Dodgers & Orioles
 1 Dodgers & Twins
 1 Dodgers & White Sox
 1 Giants & Indians
 1 Giants & Rangers
 1 Giants & Red Sox
 1 Giants & Tigers
 1 Giants & White Sox
 1 Indians & Marlins
 1 Indians & Robins
 1 Marlins & Yankees
 1 Mets & Orioles
 1 Mets & Red Sox
 1 Mets & Yankees
 1 Orioles & Phillies
 1 Orioles & Reds
 1 Padres & Tigers
 1 Padres & Yankees
 1 Phillies & Rays
 1 Phillies & Red Sox
 1 Phillies & Royals
 1 Pirates & Senators
 1 Pirates & Tigers
 1 Red Sox & Reds
 1 Red Sox & Robins
 1 Red Sox & Rockies
 1 Reds & Tigers
 1 Reds & White Sox

Source: Wikipedia, of course! ��

Wednesday, August 07, 2013

MySQL Reference

Doing some MySQL work over the past couple of days, I googled a couple topics I needed help with, and both times I ended up at the same place.

So thanks, nixCraft, for the assist!!

Tuesday, July 02, 2013

Upgrading Debian

Upgrading from Squeeze to Wheezy

Why? Why not!!

Actually, it's because of the whole google-chrome-stable and gconf-blah-blah business. It's scrolled off my screen, but it's all over the internets.

Mainly I'm following the steps I found here at HowtoForge.

Updated my sources.list, just replacing squeeze with wheezy

Did an update and an upgrade, started to do a dist-upgrade, but got this error:

E: Could not perform immediate configuration on 'openjdk-6-jre'. Please see man 5 apt.conf under APT::Immediate-Configure for details. (2)

Did this to continue:

sudo apt-get remove default-jre
sudo apt-get remove openjdk-6-jre

Now it's running... we'll see what happens next!

How about being WAN'd in via SSH and my end goes sleepy or wonky? Yikes!! But I did a:

sudo dpkg --configure -a

and the dist-upgrade is chugging along again.

A word of advice to whoever is responsible for configuration files: It sure would be nice if I could resolve all of the config conflicts either before or after the upgrade. Having the upgrade pause for me to Z and cp and blah blah blah, that's annoying.

And it's done. Now to fix the above:

sudo apt-get install default-jre
sudo apt-get install google-chrome-stable



Ta-da! It works! Even Chrome is back!!