Installing Maps onto Garmin Nuvi devices on OSX

June 18th, 2010

By default, even if you have no space for it, the Map Update program refuses to acknowledge if you have an SD card in the Garmin device (in the 650 and 200w I had access too, anyway). I found the source of my answer in a forum post.

Three files get installed: GMAPPROM.gma, gmapprom.img, and GMAPprom.unl.

To get the map installed, copy all the data from the Garmin device to the SD card, then run the update program. It will think your SD card is the Garmin. Make sure to make a backup, unless you want to go through the pain of copying 1.5 gigs of data over USB 1.0 each time you need to do this.

Once the map is installed, delete everything else and rename the key files: GMAPSUPP.gma, GMAPSUPP.unl, and gmapsupp.img.

Eject the card, plug it into the Garmin, and boot it up. In the system prefs, map, map info page you should see the latest map file (2011 NT when I got this to work).

Hopefully, Garmin will eventually fix this…

MegaRAID PERC 3/SC on Opensolaris

March 12th, 2010

Opensolaris (as new as snv_133) does not automatically detect disks on this hardware (specifically on an older Dell PowerEdge 6000SC). I did the following on the LiveCD to get it to work:

add_drv -i ‘pci1028,475′ lsimega

I got the numbers above from the “prtpicl” tool, using “prtpicl -v” and searching for MegaRaid:

:name      pci1028,475
sd (block, b6000002f8)
:class         scsi
:inquiry-device-type   0
:inquiry-vendor-id     MegaRAID
:inquiry-product-id    LD 0 RAID0  139G

Hope this helps someone other than myself. I also added a blank file named “ADD_DRV_IGNORE_ROOT_BASEDIR” to / as per a bug post but I do not believe that had any effect. I did stumble a bit before I found this (chasing around a PERC 5 driver) but I don’t recall trying to install this driver beforehand.

OpenSolaris – What do you do when your image-update doesn’t work?

March 4th, 2010

I’ve been a long time user of/tinkerer with OpenSolaris on my desktop (for the obvious reasons: Time Slider, ZFS, DTrace, etc). I am going to start posting tips & tricks. To start off, here is one way I have found to “fix” a “pkg image-update” failure. All it does is create a new boot environment and install to it, which can solve a lot of the problems that might occur when running on the pkg.opensolaris.org/dev repository when you update:

beadm create osol-snv_1XX
mkdir /mnt/osol-snv_1XX
beadm mount osol-snv_1XX /mnt/osol-snv_1XX
pkg -R osol-snv_1XX install SUNWipkg
pkg -R osol-snv_1XX image-update
bootadm update-archive -R /mnt/osol-snv_1XX
beadm activate osol-snv_1XX

Notes:

  1. osol-snv_1XX is simply the name you give the new boot environment. XX being the snv version (currently 133).
  2. beadm is the command for working with boot environments in zfs. Create makes a snapshot, mount mounts it to a particular directory, and activate makes it the default on the next reboot.
  3. pkg -R does the update on the alternate boot env.
  4. bootadm adds the boot environment to grub (update the archive using that directory as the root is what we are telling it to do here, just like the pkg -R cmd).

If someone visiting this blog has alternate methods, I’d be interested in knowing about it.

HOWTO: Scanned Images to Encrypted PDF in Linux

October 10th, 2009

I had scanned a bunch of images and needed to bundle them all up into PDF. It took about 20 minutes to figure out, which is way too long, so here’s the steps so I can remind myself in the future:

  1. scanimage –batch=”%d.tiff” –format=tiff –resolution 300 –bgcolor white –mode=Lineart
  2. ls -tr1 | xargs -Ixxx lp -d PDF -o fitplot -o page-top=0 -o page-bottom=0 -o page-left=0 -o page-right=0 “xxx”
  3. gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=finished.pdf `ls -tr1` OR pdftk `ls -tr1` cat output finished.pdf
  4. pdftk finished.pdf output enc.pdf user_pw <pass> allow CopyContents printing

Notes:

  • gs may be able to do step 2, but if it can’t you’ll need to install “cups-pdf” and restart cups.
  • gs may also be able to do 1-3 in 1 step.
  • Similarly, pdftk might be able to do most of this in 1 step, too. It just didn’t occur to me until after I used it for the encryption.

New public key

May 27th, 2009

My old one expired last April, and I hadn’t needed to used it since that time.  Here’s a new one:

—–BEGIN PGP PUBLIC KEY BLOCK—–
Version: GnuPG v1.4.9 (Darwin)

mQGiBEoeFE0RBACxOVfRasBEHbTIHWQADFqKD3PuyFq5sXZoUeEwBmcujEaXbiKD
khrhqUgZUgQPToLMSJjxzd9ZFDy4mFkh8eTtLyTFV1RdnU0tXgiE+xzfdvJs/3WW
IHeB0hib1jZUKCQnvGdJfwqTV5z/KL/jVxU4SXu7pcSTNYV4uuO9kuKKpwCguGZk
N4d7pgBnOMZv9iD/z4/viFED/2HPz9vWeGq1KzKzaWIqWooeDJFGQSB1HSbanr5I
bRjhFjBOeiADF5ExGt81cIwQBQPGt5dBoX5+oz9KKN4gqhS3VMCsw5f2Ao0eob7K
O+V9qdGtzpj6ODbagBVNRPXjPln3LuQLfs2ojIhHMGolZTYJ50jnU667lQ3oVKrk
9GWBA/4mVF1R4qXWcRRfQ9JaPD8SkyZK6zxcTRknFxzABu6PQcHP+KuV2YFMooJI
n9jYt40E1nDOeC4WSsBIXUWHeDzCfuhaI+jcyS6WI0ZORPB/rK64JcJfiJLJZQEW
f8M4XYRz30KOFZSBctR35xowy1cvtg0t7aEfZEdRXG5CmsVZWrQ2UmljaGFyZCBU
LiBDYXJiYWNrIElJSSAoUmljaykgPHJpY2suY2FyYmFja0BnbWFpbC5jb20+iGYE
ExECACYFAkoeFE0CGwMFCQHhM4AGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRC4
1gL03VwNnrMxAJ98kCtLsGHz+wrnpfg/oYBe6C12RwCgnYq5/snQUDwZtQXeQEUK
YrNld/O5BA0ESh4UTRAQAPN8ew6bR7×9JlQy4ZjOyBaGgg2PBElV3lv2+4pH+TMI
+tsvVKHbyPkXOWXMINp4ec9GwF2TR9T8D3712DyPSvH4yEuRN4t4SppP68qi+gIh
MEo9zXbM9WzS1zOFW7o90eqfoPaGKsRwc9jHaHzoMXX/aDyhNKC3xq5WGaIqfsr+
Rcx3smbpNTzhZ1jOJ8uFTFmbglDRqUdkLeTSNGw34WdIc9HWQhCb/hWVaXWAGBkj
7osAncrM3+qDlqsCx/R+oF7tZBjOrEPyKzxYhHrJAlduFiPTXSfXiJ4v6ONTU1OZ
dJtkpDad8uURBIp0IGOKoRyLpzGAQ2JLDIijwX3u1iuhSvV0dRAPJYfhus8l76gZ
//mssY2zV6eKfq9RFekX86F14wuCTIVRPw7qqjf/GoHpPySrMBYDohROGPJXY4b7
0TYcjv8UZzHUhB9/siB1j+QeX90A2H5eAbkJ2ZbahbGfpJJIw17yTTbr59oB8CKy
Q2hdzXU3tqSCbHvCrGPQ50EFHmB1MPuFW1XUPXSHtsBARu3O6MuLQClGg8JnvMGa
tnqzTKa+HrNiz0hSYZJaBNQNIGPrP18vXvC5QeH6kTOcyaiOmSiNPbxertiLpjvw
BY73rLOVJHAnPyMJ1v4z1b/nGAq3yM5Gw6hFNzRjIVPo80/pHL2Ilux9N1cwcObn
AAMFEACEQs7mC0XVVSSkdU+cTC6JqA7fsJQCzCR4SzDyDSYIDt85tIwxTKm29P/h
5g/sON48HbVXVE8oCgMtejKLrEPE7qDHDvMzHDTVaphhsAeAEjOMEINNqgv2Gk/R
kEWSwqYyaUBaiElvCHmvVfJvVyhaFc2KONsMfqymhi4TdBinN+LErzRBBRCO1SVb
PneZoSz1kTm531BkZQj4ezfAiPAms883ANvb6kZoNloItD1aIgJh7P7shnCv5o9i
a9Zhb+XomuKlc7Qg1D3yB/DNyf42EIP4THADGpLbraKJqNtR7cFveoOfC7FI/JNr
BR0OTFE2ZY0I0WilIFRvTVPnW7MGTe36l2MmV1zWkgMQJfJcIulr9TMv9sHUPUto
oBcK3z2×4YBF8XTTSGe23tTbPxM8hDqWZfvy7k33jYi926uYGjD+3XUanH8lAMNF
XZHkTpYsTaCzzr5R7Fz3Ajjz5ajPFR8phJcvC+tylsgiotxysplHGo8hVJRVJzKV
p6OZVBJHd34VHCpg2DPKUuG2v3+73XGi292ynSdaPcMNYZXm6LFrbnlZG3HU8h3p
n/l9ksZA4kk98LXNq8pfU0el6BEPy7jYESroM2GiOWBgeGC7GckjIdnQfGLNmWb/
GRrflnRdzgfE7FtdX/AALSn4eEGbg1jgym8OYwkVs24s4Afb/4hPBBgRAgAPBQJK
HhRNAhsMBQkB4TOAAAoJELjWAvTdXA2e/KgAoIzS4rwlPA/QNmZFlakLUeEJw+Ml
AJ9lACyS86y1QYJC2Qdo63JMuhf4ig==
=MFqF
—–END PGP PUBLIC KEY BLOCK—–

This will (likely) make it’s way to my website in June when I plan to do some maintenance on my website.

Java CMYK HOWTO

November 24th, 2008

Lately, I’ve been playing with printers-trying to control the amount of cyan, magenta, yellow, and black printed by the printer. For various reasons I’ve been doing it in Java,and I’ve run up against some brick walls. There is no good HOWTO available, so I decided to write my own…

Java supports RGB by default and it works well, but it treats everything else like the proverbial red headed step child. To get it to work you have to find an ICC_Profile (CMYK.pf), load the file dynamically, and then do all your image manipulation. I never looked far enough to find out for sure, but I believe you have to do some special work to get it to save as CMYK also. It’s a pain.

The other option is to extend ColorSpace to support CMYK. You still have to save in a funny way, but this is what I decided to do.

First, the ColorSpace extension (available here, note that the code here is all GPL):

public class CMYKColorSpace extends ColorSpace implements Serializable {

	private static final long serialVersionUID = -5982040365555064012L;

	/**
	 * Create a new CMYKColorSpace Instance.
	 */
	public CMYKColorSpace() {
		super(ColorSpace.TYPE_CMYK, 4);
	}

	/**
	 * Converts to CMYK from CIEXYZ. We cheat here, using the RGB colorspace
	 * to do the math for us. The toCIEXYZ function has a description of how
	 * this is supposed to work, which may be implemented in the future.
	 *
	 * @see java.awt.color.ColorSpace#fromCIEXYZ(float[])
	 * @see org.scantegrity.lib.CMYKColorSpace#toCIEXYZ
	 */
	@Override
	public float[] fromCIEXYZ(float[] p_colorvalue) {
		ColorSpace l_cs = ColorSpace.getInstance(ColorSpace.TYPE_RGB);
		float[] l_rgb = l_cs.toCIEXYZ(p_colorvalue);
		return fromRGB(l_rgb);
	}

	/**
	 * Converts a given RGB to CMYK. RGB doesn't really use black, so K will
	 * always be 0. On printers, the black should actually look dark brown.
	 * RGB (an additive space) is simply the backwards from CMY (a subtractive
	 * space), so all we do is:
	 *
	 * 		C = 1-R
	 * 		M = 1-G
	 * 		Y = 1-B
	 *
	 * @param p_rgbvalue - The color to translate
	 * @return a float[4] of the CMYK values.
	 * @see java.awt.color.ColorSpace#fromRGB(float[])
	 */
	@Override
	public float[] fromRGB(float[] p_rgbvalue) {
		/* TODO: Maybe we should do a better job to determine when black should
		 * be used and pulled out? -- At this time, it's not necessary for our
		 * (Scantegrity's) uses.
		 */
		float[] l_res = {0,0,0,0};
		if (p_rgbvalue.length >= 3) {
			l_res[0] = (float)1.0 - p_rgbvalue[0];
			l_res[1] = (float)1.0 - p_rgbvalue[1];
			l_res[2] = (float)1.0 - p_rgbvalue[2];
		}
		return normalize(l_res);
	}

	/**
	 * Converts the CMYK color to CIEXYZ. Because CIEXYZ is 3-component, we
	 * cheat, converting to RGB and then using the RGB colorspace function
	 * to do the conversion. Details on this colorspace are available on
	 * wikipedia:
	 *
	 * http://en.wikipedia.org/wiki/CIE_XYZ_color_space
	 *
	 * There is also an "ideal relationship" to CMYK, which might be implemented
	 * in the future (don't recall the reference we got this from, probably
	 * color.org):
	 *
	 * C = (C' - K)/(1 - K)
	 * M = (M' - K)/(1 - K)
	 * Y = (Y' - K)/(1 - K)
	 * K = Min(C', M', Y')
	 *
	 * X   41.2453 35.7580 18.0423 | 1-C'
	 * Y = 21.2671 71.5160 07.2169 | 1-M'
	 * Z   01.9334 11.9193 95.0227 | 1-Y'
	 *
	 * @see java.awt.color.ColorSpace#toCIEXYZ(float[])
	 */
	@Override
	public float[] toCIEXYZ(float[] p_colorvalue) {
		float[] l_rgb = toRGB(p_colorvalue);
		ColorSpace l_cs = ColorSpace.getInstance(ColorSpace.TYPE_RGB);
		return l_cs.toCIEXYZ(l_rgb);
	}

	/**
	 * Converts CMYK colors to RGB. Note that converting back will be lossy. The
	 * formula for this is:
	 *
	 * K = 1 - K (go to additive)
	 * R = K * (1 - C)
	 * G = K * (1 - M)
	 * B = K * (1 - Y)
	 *
	 * @param p_colorvalue The color in CMYK.
	 * @see java.awt.color.ColorSpace#toRGB(float[])
	 */
	@Override
	public float[] toRGB(float[] p_colorvalue) {
		float[] l_res = {0,0,0};
		if (p_colorvalue.length >= 4)
		{
			float l_black = (float)1.0 - p_colorvalue[3];
			l_res[0] = l_black * ((float)1.0 - p_colorvalue[0]);
			l_res[1] = l_black * ((float)1.0 - p_colorvalue[1]);
			l_res[2] = l_black * ((float)1.0 - p_colorvalue[2]);
		}
		return normalize(l_res);
	}

	/**
	 * Normalize ensures all color values returned are between 0 and 1.
	 *
	 * @param p_colors
	 * @return p_colors, with any values greater than 1 set to 1, and less than
	 * 0 set to 0.
	 */
	private float[] normalize(float[] p_colors) {
		for (int l_i = 0; l_i < p_colors.length; l_i++) {
			if (p_colors[l_i] > (float)1.0) p_colors[l_i] = (float)1.0;
			else if (p_colors[l_i] < (float)0.0) p_colors[l_i] = (float)0.0;
		}
		return p_colors;
	}
}

The color space is used to convert CMYK to RGB or CIEXYZ on demand, which is done whenever Java displays images on the screen, saves them, or copies them to any context in which the color space is different. It also allows you to create CMYK colors and to store the data in a custom color model/sample color model.

Creating CMYK Colors

This is self explanatory:

float[] l_colorComponents = {1, 0, 0, 0};
CMYKColorSpace l_cs = new CMYKColorSpace();
Color l_cyan = new Color(l_cs, l_colorComponents, 1);

Creating a BufferedImage with CMYK Colors

This piece is the most complicated becase you need to understand how Java models the colors in an Image Object. You may want something in-depth, but here’s a short explanation: Each color in java is represented as a “band,” and it is stored in a way defined by Model and stored in a generic “DataBuffer” object.  To get it working you create a (usually component) ColorModel, and then create a sample model with the specific layout (Interleaved, banded or one color per, etc). The sample model creates a Raster, which then creates the Image object.

CMYKColorSpace l_cs = new CMYKColorSpace();
ComponentColorModel l_ccm = new ComponentColorModel(l_cs, false, false,
						1, DataBuffer.TYPE_FLOAT);
int[] l_bandoff = {0, 1, 2, 3}; //Index for each color (C, is index 0, etc)
PixelInterleavedSampleModel l_sm = new PixelInterleavedSampleModel(
						   DataBuffer.TYPE_FLOAT,
						   (int)l_width, (int)l_height,
					     	   4,(int)l_width*4, l_bandoff);
WritableRaster l_raster = WritableRaster.createWritableRaster(l_sm,
							new Point(0,0));
BufferedImage l_ret = new BufferedImage(l_ccm, l_raster, false, null);

Graphics2D l_g2d = l_ret.createGraphics();

Saving CMYK Images

For this, I chose to use the iText library to save in PDF format. All you have to do is pull the DataBuffer out of the raster and save the bytes. You might also want to save in JPEG or another kind of format, which should be reasonably easy (just send the function the right bytes in the right order) once you’ve seen below:

Raster l_tmpRaster = c_img.getRaster();
DataBuffer l_db = l_tmpRaster.getDataBuffer();
byte[] l_bytes = new byte[l_db.getSize()];
for (int l_i = 0; l_i < l_bytes.length; l_i++) {
	l_bytes[l_i] = (byte)Math.round(l_db.getElemFloat(l_i)*(float)255);
}

com.lowagie.text.Image l_img = com.lowagie.text.Image.getInstance(
								l_tmpRaster.getWidth(),
								l_tmpRaster.getHeight(),
								4, 8, l_bytes);
l_img.setDpi(300, 300);
Document l_doc = new Document(new Rectangle(0,0,l_img.getWidth(), l_img.getHeight()));
l_doc.setMargins(0,0,0,0);
PdfWriter.getInstance(l_doc,
			new FileOutputStream("inkeratorout" + c_c + ".pdf"));
l_doc.open();
l_doc.add(l_img);
l_doc.close();

Everything else should work as normal (just remember that it is calling the colorspace functions to do it’s job).

I wrote this in a bit of a rush (i’m pretty busy today). I haven’t had any problems with it yet, but if you do please feel free to leave a note below.d

My Day as an Election Judge in the 2008 Election

November 6th, 2008

Cross posted on the Scantegrity Blog.

I had meant to post this yesterday, but I woke up not feeling well and spent the day in bed. I see that Ben Adida and Avi Rubin have already posted their experiences. Aleks Essex also posted his experiences a few weeks ago when he was a worker for the most recent Canadian election.

The chief judges invited all the site judges to meet up at the fire house the night before at 6:30 to make room for everything. We also plugged in the DREs, which you can conveniently do without opening the units. I didn’t ask, but the average age was likely in the 40s. We had 1 high school student who was 17, and my guess is that there was an even split between the 20-40 crowd and the 40+ crowd. There were 3 republicans, and the rest were democrats except for the unaffiliated high school student.

After we finished, the Chief Judges explained what would happen in the morning, and asked if there were any questions. The biggest concerns were potential turnout and if we’d get the extra machines we had up in time with the same number of judges as before. They also expressed concern about a technician showing up and staying for the whole day.

My Election Day Materials for 2008

My Election Day Materials for 2008

Getting Started

I woke up @ 4:30 and arrived a little after 5:30. Myself and another judge set up each DRE while 1-3 judges watched and recorded information. I recall it being a fairly simple process and working pretty well with the exception that the chief judge sometimes had trouble opening the printer compartment. I was a little concerned that the DREs, despite being plugged in all night, all registered only a 60-80% charge.

The electronic poll books were equally easy to set up although some instructions were confusing, telling the user not to plug the poll books into the UPS unit. I think what they meant is to plug a power strip into the UPS unit and then to plug the poll books into that strip, which is what the other judges decided to do.

Voting

Our longest line happened when we first opened the polls, which went all the way out the door and around the corner. People at the end of that line were still cheery, as they only ended up waiting approximately 15-20 minutes. We had a steady stream of people until about 10:30, which picked right up again at 11:00, and stayed mostly steady for the rest of the day with occasional 5-10 minute breaks in flow. Check-in time only took about a minute if you were listed in the poll book.  I’m not totally sure, but I believe voting varied from 1-10 minutes, although some voters probably took longer.

I served as a voting unit judge for the whole day, which is all standing (my legs were killing me that night)! This involved taking a voter authority paper, initialing it, writing the unit number you gave the voter, getting the voter started on the machine, explaining how it worked (if necessary), and dropping the the paper into an envelope on the side. The papers are tallied every hour, and the chief judges make rounds to verify the counts match the machine totals so far.

A majority of our 8 machines were in use for almost the whole day, and at the beginning and towards the end, we had periods of about an hour and a half where all of them were constantly in use. No one used the headset or keypad, although we did have a few voters who requested assistance or needed a chair. Many voters used the large text and apparently the button was not big enough as this was our most asked question.

Glitches

We had no major equipment failures during the voting day. The biggest equipment problem was that the smart cards were sometimes difficult for voters to get into the machine, which we solved by starting it in the machine for the voter, and letting him or her push it in until it snapped.

The other problems all involved the electronic poll books, which sported a confusing user interface to navigate. The judges managed and came up with troubleshooting steps. I was later told that a couple voters would not come up on the local polling site search, but when you went to the statewide search, they did and were registered at our local polling site.

I don’t know a specific number, but at least 15 people or so came in and had trouble during the check-in process. About half voted provisionally, and the rest either went to the correct polling place or admitted they knew they were not registered. I believe there might have been one person who walked out on us, which is really unfortunate. There needs to be a better way to deal with registration problems.

Although it mostly worked well for the vast majority of voters, a few voters were tripped up by the interface. At least one person asked me a question after having pressed cast ballot. Another couple asked why the judges question, a vote for 2 race, was red (because they had not voted for two candidates).

Ballot question wording was also an issue, and understandably so due to the legal language. A number of people called us over to ask me the meaning of various passages, and a few even to ask which answer was “yes”, and which was “no.” It would be best if the language were simple and clear.

Early in the day 1 voter complained about the privacy of the machines. We flipped down the screen for him so it faced the ceiling and told him we could angle the machine however he wanted. It turned out to be a more general problem because there was no curtain. That explains what happened later, when we got a call that someone complained that people were being watched as they voted, and someone from the central office came by to check in on us.

Lots of voters complained about the security of the machines. Some were curious why others did not think they were secure. I just tried to stay away from that discussion as much as possible.

Cleaning Up

At the end of the day, we had 1045 DRE voters, and 8 provisional ballot voters. The chief judges told us that the last major election had 300 out of about 1500-1600 registered voters for our precinct overall (about 200 voters per machine), which is a significant improvement in turnout over previous years.

We finished around 9:30. Tearing down was much worse than getting started, as you had to navigate through a bunch of menus that really didn’t need to be there. An “end election” button that printed the necessary information would have sped things up significantly. The accumulator machine did not recognize the modem, so results were phoned in and then the memory cards were driven back by both the chief judges.

Results

Poll-tape Results for our poll site (the English Consul Volunteer Fire Department, 13-8), were recorded by me as follows:

Candidate Totals
President
Obama/Biden 331
McCain/Palin 684
McKinney/Clemente 5
Barr/Root 2
Nader/Gonzalez 8
Baldwin/Castle 4
Write-In 8
Congressional District 03
Sarbanes 524
Harris 349
Write-In 5
Judicial Circuit 03
Bollinger 662
Stringer 500
Write-In 6
Judge, Court of Appeals, Appellate Circuit 02
Murphy Yes: 662, No: 152
Judge, Court of Special Appeals At Large
Eyler Yes: 675, No: 146
Zarnoch Yes: 627, No: 167
Statewide Ballot Questions
Q1 (Early Voting) Yes: 497, No: 445
Q2 (Slots) Yes: 696, No: 321
Local Ballot Questions
QA Yes: 363, No: 512
QB Excluded from ballot
QC Yes: 614, No: 317
QD Yes: 599, No: 320
QE Yes: 620, No: 291
QF Yes: 500, No: 396
QG Yes: 592, No: 307
QH Yes: 570, No: 319
QI Yes: 493, No: 402
QJ Yes: 535, No: 360
QK Yes: 597, No: 304

I hope I didn’t make a mistake. You may want to look at the ballot.

My 2008 Ballot

November 3rd, 2008
This is a cross-post from the Scantegrity Blog.
I vote in Maryland tomorrow. Here’s my ballot:
2008 Baltimore County Specimen Ballot

2008 Baltimore County Specimen Ballot

You can also download it in PDF. Only 2^44 unique marking patterns this time. Anyone want to determine how many legal patterns there are using my handy guide?

I’m also serving as an election judge. I’m looking forward to it.

Happy voting!

Dealing with Duplicate SQL Rows

October 28th, 2008

I was using the export/import functions in Wordpress to transfer stories to a new (clean) installation, and the import was causing a duplicate row problem in the wp_postmeta table which was causing the multiple authors plugin to list the importing user dozens of times for each story. My quick search yielded nothing, so I pulled out my arcane SQL knowledge and used some MySQL documentation to come up with this:

> create temporary table newmeta as select distinct post_id,meta_key,meta_value from wp_postmeta;

> truncate wp_postmeta;

> insert into wp_postmeta(post_id, meta_key, meta_value) select post_id,meta_key,meta_value from newmeta;

> delete from wp_postmeta where meta_key = ‘other_author’ and meta_value = ‘admin’;

> delete from wp_postmeta where meta_key = ‘other_author’ and meta_value = ”;

Note that you need to specify the column names that you know will reproduce the duplicate and you can’t use *. I had to do some additional cleanup because the import set ‘admin’ to be an author on every story, and produced some blank entries.

I also had to modify the multiple authors plugin due to this error that kept cropping up:

Warning: Invalid argument supplied for foreach() in
/blog/wp-content/plugins/multiple-authors.php on
line 46

Basically, I just made sure it checked that the variables it was using weren’t blank before it got to the foreach statement:

if ( $other_authors == “”) return; //INSERTED Line

foreach ($other_authors as $author) {

Pretty annoying, but not too hard to fix.

Changing Default xterm colors on OSX X11

October 23rd, 2008

This is a question that I am asked about constantly, and it is really simple: Edit the file /usr/X11R6/lib/X11/app-defaults/XTerm and add the following:

XTerm*background: black
XTerm*foreground: white

I usually do it after the savelines option. Most other names work, too (yellow, cyan, etc). For more info, you can check the manpage on xfree86.org and Thomas Dickey’s xterm site.