Wednesday, November 1, 2017

Dumping PDF form fields in Linux

To see form fields in a fillable PDF:
pdftk pdf-file dump_data_fields

Note the operator (dump_data_fields) comes after the PDF file name.

Monday, March 6, 2017

How to dump your Ipod

A long time ago, in a galaxy nearby, I bought into the Apple-Unix fusion. Apple scrapped their weak OS and gave birth to OS X, essentially FreeBSD with a nice GUI. And it was good. Most of my Linux command line skills directly transferred, and I could manage Macs as easily as Red Hat boxen. But then time happened. Services started collapsing into Apple proprietary services. Config files and dot files morphed into XML registries with binary fields. Apple started fixing Unix until it was broken. I got off the bandwagon.

I always kept my data in neutral formats. Text, PDF, mp3. It was easy for me to transfer my data to a new system and pick up new programs, or crusty old programs. The one clinger was an ipod nano. I used my ipod in my Toyota mainly to run playlists and be able to play music when I was out of service for streaming. I spend a lot of time in the back country so being out of service is a common thing. Despite my disillusionment with Tim Cook and his wonder watch, the ipod was and is a state of the art music player. Itunes on the other hand, followed the same degrading path as OS X, becoming less usable, unfriendly, and more buggy with each new version. This became a real problem when the 5 year old ipod started to fail. Rebuilding it from scratch would not fix the issues with it and it was time to look for a new solution. Replacing that symbiotic ecosystem was not easy as I found out.

Where are all the ipod competitors? There are a few Chinese knock offs, but the big players have all given up. Microsoft dumped the Zune. Samsung stopped making their ipod competitor. A replacement required a hardware and software combo solution. After some trial and error, including trying one of the knock offs, I settled on Music Monkey (free) and a low profile USB flash drive. I bought a 32 GB SanDisk Cruzer Fit for $11.95 on Amazon.

I do development on Linux, but I have a Win10 machine for home use and game play. Media Monkey easily imported my music files and could dump them onto the Cruzer without problems. I had everything in a single flat directory. But things were not that simple. The Toyota music head (2015) would only index up to 999 files in a directory before giving up. This meant that even through my music was all on the USB flash drive, the car did not see it all. I went back and manually organized the files into directories by artist. This improved the situation, but the car created it's index not based on the physical layout (other than the 999 file restriction), but based on MP3 metadata tags. It was able to index more of the music but not everything. The work around for that was to clean up my metadata. Not an insignificant amount of work.

The final hurdle was to get playlists working. The car did not understand the standard playlist format from Media Monkey. What I did instead was use Genre. The Genre tag is so arbitrary that it is otherwise useless. When I want to change a playlist, I first create a true playlist in media monkey, select all the files and assign the playlist name to the Genre of all the files. Boom, done! A bonus hack is start all the Genre names with AA* so they all appear in the same place at the top of the genre index. For example, AABeatles for a Beatles playlist. It took some trial and error, but I have a better, cheaper solution for offline music and have abandoned the last vestiges of the company with the flying saucer HQ.

Monday, August 15, 2016


SSH Client

Common client files in the ~/.ssh/ directory

known_hosts => ip/hostname and fingerprints of servers that have been seen before
authorized_keys => concatenated list of public keys that can login as this user without a password

To generate a public/private RSA key pair (id_rsa and

ssh-keygen -t rsa -b 4096 Private keys must be readable only by the user or SSH will ignore it for safety. Also, the .ssh directory must be readable only by the user.

To copy the public key to a server

ssh-copy-id -i user@server
After completion, make sure the key was appended to the .ssh/authorized_keys file on the server.

SSHd server

The config file is /etc/ssh/sshd_config

Best practice security settings

  • On public facing servers, always disable root logins with PermitRootLogin no
  • For extra security, specifically limit the users that can login with AllowUsers neo trinity
  • Allow login via keys with AuthorizedKeysFile .ssh/authorized_keys
  • You can change the port that SSH listens on, but a good port scanner will find it wherever it is

Friday, September 25, 2015

Pulling single tables out of a large MySQL dump file

This is a problem I run into occasionally when I need to restore only one or two tables from a large database dump file in text format.

It can be done with many scripting languages, but I found a nice awk command on the T-sheets blog. To use the awk command, you need to know the names and order of the tables in the dump file. First, grep for "CREATE TABLE" to find the names and order of tables in the dump:

grep -n "CREATE TABLE" dumpfile.sql

The -n switch adds the line number which is not really needed. Next, plug in the name of the table you want to extract and the name of the table immediately following it:

awk ‘/Table structure for table .table-to-extract./,/Table structure for table .table-after./{print}’ dumpfile.sql > /tmp/extracted_table.sql

Next, I usually go in and add a "use my_database_name" command at the top and remove any unnecessary commands added by the mysqldump program. The last step is to feed the extracted table SQL to mysql.

Sunday, September 13, 2015

Netgear Nighthawk R7000 wireless router

After trying various tweaks to improve our home wireless network performance, I did some online research and decided to replace my organic patchwork of access points and extenders with a Netgear Nighthawk R7000 wireless router. I have AT&T DSL so needed to use the provided 2Wire modem, but turned off the wifi on it. The Netgear genie setup program let me use the same SSID and password that the 2Wire was using so I didn't need to reconfigure any of my devices.

The Nighthawk created two networks, one at 2.4 Ghz and the other at 5 Ghz. Performance was immediately improved on both levels of my house and in all corners. We can now stream 3 videos at a time without a hiccup on an 18 Mbps down (advertised) circuit. It was worth every penny.

Saturday, June 20, 2015

Printing from Android Phones to Epson printers

The problem of printing from mobile devices is somewhat involved. The main problem is that standards like WiFi Direct or bluetooth printing are still in early stages of deployment. Some vendors have their own solutions that work pretty well with their devices, but they tend to be islands. Google has cloud print, but that requires a dedicated print server on the local network running headless Chrome to route the print jobs. I don't know the details of Apple Cloud Print, but it probably works in a similar way, with some local device acting as the print server.

On my Samsung Galaxy S6, I decided to download the Epson Print Enabler from the Play Store. Once it was installed and enabled, I took the phone to close proximity of my printer, and Epson WF-3520 multi-purpose wireless inkjet and tried to print a web page from Chrome. Chrome defaults to printing to a PDF document, but I was able to select the Epson from a drop down list, deselect the pages I did not want to print and send a single page of the web site to the printer. It worked like magic.

This is one of the island solutions that might only work with Android phones and Epson wireless printers, but it does work without any print server set up or routing through the Internet. The Epson printer is the best wireless inkjet I've owned and is highly recommended whether you want to use the Android printing features or not.