Blog

  • Sniffing TCP Packets With Python

    Inspired by this StackOverflow question, [“How do I sniff on a port for log messages using python?”][so_question], I decided to figure out how to capture and process packets in Python. It turns out to be quite easy once you work out the kinks. Except the kinks were a pain to determine.

    [so_question]: http://stackoverflow.com/q/28870666/47078

    Sample output:

    $ sudo python capture.py
    10:27:44.016601    hello ('127.0.0.1', 61129)
    10:27:44.016614    hello ('127.0.0.1', 61129)
    10:27:54.019731    hello ('127.0.0.1', 61137)
    10:27:54.019741    hello ('127.0.0.1', 61137)

    (more…)

  • Qt XML Parsing Continued

    In a [previous post], I compared the different methods for parsing XML in Qt. After a comment about XQuery’s performance, I [added some code] to test performance using a simple, but large (304MB) XML file. Times are sorted and normalized to the smallest value.

    | Run Time | Method |
    | :——: | :—————————————————- |
    | 1 | XQmlStreamReader – processElementsByTagNameHierarchy – text() |
    | 1.1 | XQmlStreamReader – processElementsByTagNameHierarchy |
    | 1.1 | XQmlStreamReader – processElementsByTagName |
    | 2.2 | QDomDocument |
    | 4.0 | XQuery |

    [previous post]: http://3gfp.com/2014/07/three-ways-to-parse-xml-in-qt/
    [added some code]: https://github.com/sr105/international_trade/
    (more…)

  • Emacs Tramp and Speedier SSH Access

    # Tramp #

    I often find myself editing files in terminals on remote machines, and I really need to add [Tramp] to my muscle memory. Tramp is an Emacs package (installed by default?) for editing remote files via ssh. It allows you to open files with urls like this: `/ssh:user@host#port:/path/to/file`.

    Note: I use `ssh` instead of `scp` (used in all of the examples) because the webpage says it’s faster and also because it supports the `#port` piece while `scp` does not. Also, the `user@` and `#port` pieces are optional. So feel free to use the minimum: `/ssh:host:/path/to/file`.

    [Tramp]: http://www.emacswiki.org/emacs/TrampMode

    (more…)

  • Formatting SD Cards for Speed and Lifetime

    Have you ever re-formatted an SD card and noticed the performance degrade? You formatted it FAT32 just like it came from the factory, but it runs slower. Except you didn’t actually format it like the factory. The following is a document I wrote mid-2013 about formatting microSD cards with a single FAT32 partition with a layout that is optimized for speed and lifetime. It also includes details about using this card as a bootloader source for TI OMAP3/4 processors.

    (more…)

  • Three Ways To Parse XML in Qt

    **Update 1/12/2015:** I’ve written a [follow-up] to this post comparing the performance of the different parsers. I’ve also fixed a few mistakes in the code and text below. I’ve also changed my mind about QXmlSimpleReader now that I’ve found a simple way to use it.

    [follow-up]: http://3gfp.com/2015/01/qt-xml-parsing-continued/

    For this past February’s [CoderNight] meetup, I thought I would write the solution using Qt and take the time to explore qdoc, Qt’s excellent documentation tool. So, of course, I spent all my time  figuring out the three native ways to parse XML using Qt and completely ran out of time for qdoc. While researching the XML parsing, I couldn’t find any webpages addressing and comparing the methods all at once. Since then, I’ve discovered that the documentation for Qt 5 has an XBEL bookmarks example for each of the methods and you can compare those examples to get a feel for the differences, but there’s still no Qt XML parsing rosetta stone page. Here’s a shorter, incomplete comparison of the three methods.

    [CoderNight]: http://www.meetup.com/CoderNight/events/162795772/
    (more…)

  • Minimum Set of DB-9 Adapters Needed

    I wanted to build the minimum set of adapters necessary to connect an RS-232 USB-to-Serial adapter to any other board with a DB-9 connector. It turns out that you only need two:

    • Male-Female Null Adapter
    • Female-Female Gender Changer

    DB9 Chart

  • Replacing the Battery in a Boogie Board

    Boogie Board
    My son’s Boogie Board from Brookstone recently stopped working and I suspected that he had given it the stated 6 years of use in 2 years time. Unfortunately, Improv Electronics, the manufacturer, chose to save a few cents and used a soldered battery. I needed to solder something for my work, so I thought fixing his board might provide a dry run of my soldering skills before I ruin a customer’s hardware. (more…)

  • With hgsubversion, you can pick and choose.

    Something that was not obvious (to me) in the hgsubversion documentation is that you can clone any part of a subversion repository. (more…)

  • Pushing a new feature from a mercurial repo into an SVN repo

    Update: Added optional code to show how you would put feature in a branch first rather than just committing directly to the trunk. (more…)

  • Spotlight Fails Again

    It’s like a broken record. It’s like a broken record. Here’s another example.

    Spotlight Fails Again to Find File Shown in Finder Window