Skip to main content

Posts

Showing posts from January, 2013

Updating every nth row in MySQL table

I wanted to set a field on a MySQL table to one of 4 values for testing purposes. Let's say I want to set the "pet" field to one of {cat,dog,rabbit,hamster}. First, add a new field to the table: alter table test add column `id` int(10) unsigned unique key autoincrement; Now insert each of the four values: update test set pet = 'cat' where MOD(id, 4) = 1; update test set pet = 'dog' where MOD(id+3, 4) = 1; update test set pet = 'rabbit' where MOD(id+2, 4) = 1; update test set pet = 'hamster' where MOD(id+1, 4) = 1; Finally, drop the additional field: alter table test drop column `id`; I'm always interesting hearing better/alternative ways to do this sort of thing.

Serial console access with OSX

A couple of possibilities are screen and minicom screen /dev/ttyS0 19200 Or in my case (with a Keyspan USB serial adapter): screen /dev/tty.KeySerial1 minicom is available from homebrew, ie. brew install minicom .  I've not used it for a while, and it didn't work at my first attempt – probably needs some configuration.