Removing a Broken Headphone Plug from an iPhone

Broken Headphone Plug and iPhone. 😱

The headphone jack is a pretty key port for anyone not on an iPhone 7 or later, so a broken headphone plug shoved in the jack renders a phone pretty much useless. It's also too small a space for needle nose pliers.

So what do you do if something breaks off in it? Well, searching around on iFixit lead me to the existence of a headphone plug extraction tool (for $50!!!) Unfortunately, my daughter actually uses her phone for school, so the wait (plus $50) was unacceptable if we could find another solution.

Other solutions?

  • Crazy glue the broken headphones to its counterpart (and risk sealing it up for good?!)
  • Small drill bit.
  • Bamboo toothpick.
  • Soda straw cut to squeeze around the broken plug.

Ok, the soda straw sounded reasonable and, if nothing else, low risk. So I tried with some IKEA straws and got close to extracting a piece out, but no further. The problem was that there was too much in the plug. (The headphone plug is concentric cylinders that had been shoved all the way in.)


So I kept reading... CUTICLE SCISSORS! My wife had a small pair that worked well to extract one of the pieces. Grab what you can with the scissors, push the straw around the remainder and tug to extract. The plug tip slid far enough out in this process to grab with my fingernails.

Below is the final carnage with extraction tools.

Cuticle scissors, straw, headphone plug pieces

Dyson DC 40 Shuts Down from Overheating

This is the second time in about a month that my Dyson DC 40 has shut down from overheating. The symptoms start with loss of suction from the head assembly (leaving dust bunny trails, etc.) while the hose end still had good suction.

I started out by disassembling the head unit and cleaning out the long dog hairs there, but there wasn't any change in the amount of suction when vacuuming carpet and dust bunnies were still being left behind.

I also made sure to empty the canister of all of the collected dog hair, but there was no change in suction. Finally, I decided to remove the cover on the HEPA filter to let it cool down.

HEPA filter cover

Once disconnected, I more clearly saw the hose connection that clogged the last time, and sure enough, a combo of dog hair and something perfectly sized to get wedged and stuck had completely blocked off the flow of air.

Dyson Hose connection that clogs

Unfortunately, now the vacuum cleaner has shut down until it resets and cools down. Maybe Dyson would like to study the special properties of our dog's hair?

Update: Leaving the cover open and the vacuum unplugged for about 30-45 minutes brought it back to life.

Update (February 25, 2018, one week after this post): The DC 40 stopped working. We checked all the clog points, cleared the filters, unplugged, let things cool down, and replugged... It never came back. We ended up buying the Shark Rotator NV650 at our local Walmart instead. The price was only $20 more than my refurbished DC 40 cost, and is much quieter and more portable.

rspec-rails tricks: Hacking Your Routes for a Spec

I don't know that this is so much a reminder of "What can be done with rspec-rails" as a note that, "If you do this will rspec-rails, you will also need to undo it."

Today's note: If you hack the application routes for a controller test, you have to reload routes.

The original problem

This all came down to a spec that was attempting to test a method in ApplicationController. In our Rails 3 setup (rspec-core and rspec-rails 3.7.0), the tests only needed a monkey patched ApplicationController to happen prior to the test:

before do
  class ApplicationController
    def dummy_action
it 'example do test' do
  get :dummy_action #etc...
  # validate dummy_method_actually_under_test did the thing

The fix

In Rails 4 with the same gem versions, we'd end up with the "No route matches..." which could be remedied by redefining the routes.

before do
  class ApplicationController
    def dummy_action
  Rails.application.routes.draw do
    get 'application/dummy_action/:id', to: 'application#dummy_action'

Great! The test passes now! (Insert philosophical argument about whether the person writing the test should have tested a method in this way.)

Or not...

..until you run the rest of the suite, of course. Now *every* subsequent controller test has a "No route matches" issue. (Insert philosophical argument about whether you should be writing controller tests.)

This should serve as a periodic reminder to clean up after your tests, which in this case is:

after do

Apache Crashing with PHP 7 Enabled after High Sierra Upgrade

Upgrading (partially) for a System PHP 7

I finally got around to upgrading to High Sierra, which has PHP 7 as a system PHP instead of PHP 5.6. As part of that upgrade, my quick hacks of httpd-vhosts.conf for a couple of small projects had disappeared, since bringing up those virtual hosts would bring up the default site.

In the process of restoring these changes, I checked the main /private/etc/apache2/httpd.conf and noticed that
LoadModule php7_module libexec/apache2/
was commented out. So I uncommented it, much like I seem to recall doing for prior Apache setup.

Problems and Debugging

Strangely, after sudo /usr/sbin/apachectl restart, I was getting a connection refused. I checked for instances of httpd processes running:
ps aux | grep httpd
I found none.

Eventually, I figured out that I could do a -k option on apachectl:

sudo /usr/sbin/apachectl -k restart
httpd not running, trying to start
/usr/sbin/apachectl: line 92: 37326 Segmentation fault $HTTPD "$@"

Searching around on StackOverflow, I found that conflicting PHP versions were potentially the problem. So I commented out the php7 module again, restarted, and loaded a page with phpinfo(); on it. Sure enough, PHP 5.6 was running.


Searching in /private/etc/apache2 for other php module mentions, I found /private/etc/apache2/other/+php-osx.conf and commented out the following line:

LoadModule php5_module /usr/local/php5/

Restoring the php7_module in httpd.conf, I restarted Apache, and magically phpinfo(); displayed the 7.1.7 PHP version.

2017 Year in Review


  • Pigeon Forge field trip as chaperone
  • Pinewood Derby


  • Double Bridge Run
  • Manatees
  • Mardi Gras Parade in Pensacola


  • New Pergola
  • New Patio
  • New Piano
  • Trip to Louisville to meet Poland team
  • New beds


  • Mad Violin
  • Blueberry Festival


  • Wife quit job
  • Savannah to OBX


  • Lighthouses
  • Sea Catchers
  • Dan TDM in Jacksonville


  • Palafox Application
  • Etsy shop
  • Wife got a new job


  • 41
  • Traveled to Clayton, GA to see total eclipse
  • Sang with bishop installation choir


  • Palafox Market
  • Solar install
  • Hurricane Irma panic
  • Baby Musical accompaniment


  • Solar up and running
  • Hurricane prep and Tropical Storm hit


  • Webelos weekend
  • Pow-Wow for Thanksgiving
  • RubyConf NOLA
  • Blue Angels Homecoming


  • New treadmill
  • Trip back to Louisville

IntelliJ Spring MVC @RequestMapping Not Registering

I've been trying to reintroduce myself to Spring MVC @RequestMapping and working with Java in IntelliJ after 5 years away from Java and having primarily used Netbeans for any development. My last experience with Java was with Netbeans helping manage a Maven build.

I had my @RequestMapping annotations set up, and IntelliJ is launching Tomcat directly (vs. deploying to an already running instance). I created my *-servlet.xml configurations, and had my .jsp files placed properly. Everything seemed to be in good shape and compiling fine, but the routes I specified we not showing up with the project was run.

Eventually, I went to Build -> Build Artifacts -> ...:war:exploded -> Edit... and went the Project Settings -> Artifacts tab and noticed "Library 'org.springframework:spring-web:4.3.13-RELEASE' required for module '...' is missing from the artifact". Upon clicking "Fix" and adding the dependency. Some combination of that dependency and 'org.springframework:spring-webmvc:4.3.13-RELEASE' missing prevented the org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler from processing my @RequestMapping annotations.

Multiple Postgres Schemas and Rails db:test:prepare

In our Rails databases, we use multiple Postgres schemas. This is partly for partitioning archive data from fresh data. On a new Rails 5 project, I started having tests fail once the models had the "archivable" concern added, which depended on an archive schema existing.

Ultimately, the problem is that the archive schema wasn't being created in the test database, because rake db:test:prepare performs a db:test:load which was loading the db/schema.rb, which is completely ignorant of the Postgres-specific schema concept.

In order to fix this without attempting ugly hacks, the simplest solution was just to switch to using structure.sql for the Rails schema dump.

In config/application.rb, insert the following in your Application class definition:

config.active_record.schema_format = :sql

If you haven't already added the additional schema(s) to your schema_search_path in your config/database.yml.

database: whatever_db
schema_search_path: 'main,main_archive,public'

You'll need to run rake db:migrate to force structure.sql generation before running tests again. Also, be sure to switch from schema.rb to structure.sql if you're committing this file.

Postgres 9.4 via Homebrew on macOS

I needed to run an old version of Postgres in order to be supported by the version of Rails I was working with, and I had a new Mac with High Sierra installed. Found out after a bit of "Why doesn't this postgres formula link its executables?" that it was precisely because of the age of the version that it wasn't linking. (In my old Linux days I would have just automatically added the PATH or made the link, but I also would have probably rebuilt the Linux install within a few months, anyway.)


Go Concurrency Benchmarking on a Raspberry Pi

In hindsight, no one claimed that a Raspberry Pi of any model was a powerhouse machine. However, I had thoughts about how to benchmark computing power after leaving Dreamhost and noticing that even tar and gzipping my WordPress installs performed like an ancient machine despite the processor statistics. That made me think about a raw benchmarking metric that could deployed anywhere. I was also learning Go and trying to understand Go concurrency. I ended up with a "concurrency" of 2 because the lower power systems didn't get any more out of an additional goroutine.

The program requires 13,135,013 sha3 hashes and conversions to base 64 to come up with a string that starts with "TEST".

My work workstation's output:

[Specs: Late 2013 Retina MacBook Pro 15", 2.3 GHz Core i7 - (I7-4850HQ)]

  • Single thread: 16 seconds
  • Concurrency of two: 10 seconds
  • Compared with PassMark:
    • 9066
    • Single thread 1964

A Late 2011 MacBook Pro 13", 2.4 GHz Core i5 (I5-2435M):

  • Single thread: 34 seconds
  • Concurrency of two: 19 seconds
  • Compared with PassMark:
    • 3269
    • Single Thread 1347

A Core i3-5010U 2.10 GHz NUC (Windows 10 Pro)

  • Single thread: 27 seconds
  • Concurrency of two: 17 seconds
  • Compared with PassMark:
    • 3060
    • Single Thread 1171

A Mid 2009 MacBook Pro 13", 2.26 GHz Core 2 Duo (P7550)

  • Single thread: 57 seconds (Originally was 83 on go1.3.3, but better results with 1.8.3)
  • Concurrency of two: 32 seconds (Originally was 80 on go1.3.3)
  • Compared with PassMark:
    • 1521
    • Single Thread 892

A ThinkPad 11e with A4-6210 APU (1.8 GHz - Windows 10 Home)

  • Single thread: 135 seconds
  • Concurrency of two: 65 seconds
  • Compared with PassMark:
    • 2143
    • Single Thread 697

Raspberry Pi 3B

  • Single thread: 1265 seconds
  • Concurrency of two: heat warnings!

For the purposes of this "performance" benchmark, there is definitely a non-linear relationship between a canned benchmark score and the score in a brute force operation that has a heavy calculation component. I'm also isolating only one aspect of system performance. There is a SATA SSD on the newest machine, a SATA HDD on the 2011 and 2009 machines, and an SD card on the Raspberry Pi. The RAM is different in every machine as well. Still, it was a fun experiment that motivated me to spend a little extra time in Go and learning Go Concurrency.

Whitespace is Significant

While I was in my first couple years of college, Python was gaining traction as a hot new programming language. I had been programming in C since high school, but was curious about new languages. I took an interest in learning more about Python. A classmate told me that whitespace (at least indentation) was significant in Python. I changed my mind.

The Holy Wars of Indentation Style

It's interesting that would've been so turned off by a language that placed significance on whitespace and indentation, when I had fantasized about holy wars revolving around C indentation style (Horstmann is the only way!) and tabs vs. spaces (tabs, tab width 4!). I wretched at anything in the GNU C coding style (okay, I still do...), but the funny thing was, I never was able to program in a consistent style: There were other co-workers who had a slightly different preferred style. I was also learning myself, so relative importance of information in code changed, and my opinions on bracing style evolved.

Non-C Languages that Use Curly Braces for Things

It was a combination of Java, JavaScript, Perl, and Ruby that altered my perception of "proper" bracing style (BUT NOT SPACES OVER TABS!). A new line after a conditional or function declaration/call before the brace either took up unnecessary amounts of space, or changed the meaning of the code altogether (e.g., blocks in ruby, for which adding a newline = syntax error). And so, I evolved into declaring that 1TBS style was the only proper way to write C (WITH TABS!)


Ruby has a generally accepted coding style that is enforced by no one except for code reviewers and maybe draconian RuboCop build configurations. I'd link to the coding style, if I had any certainty that the one I grabbed was 99% correct. Even RubyMine doesn't format code to the same standards as RuboCop.  (Continuation indent and spacing around braces were two settings I had to tweak.)

Small inconsistencies aside, Ruby code has ended up being the most consistent—visually—to support and add code to. I've introduced tighter RuboCop configurations on newer projects to try to adhere more closely to generally accepted coding style for Ruby.

Ruby also introduced me to an acceptance of significant whitespace. While C code often gets sloppy with spacing around punctuation markers in code, Ruby developers take more care in proper whitespace around the conditionals, braces, etc. Some C/C++ projects like Mozilla do similar standards. However, Ruby is the first language that I've seen a community-wide interest in code that presents in the same manner. Of course, most of this code isn't syntactically significant, but it is of human significance--and humans have their own mental compilers that optimize on standard patterns.

Still, this isn't the largest impact Ruby has had on my opinion of significant whitespace. Through Ruby, I've been exposed to YAML, HAML, and Slim. (I have dibs on forming a band of Rubyists with that name!) All three languages are unforgiving about inconsistent indentation. They take out explicit expression of boundaries and create visually implicit boundaries via hierarchies of indents. You don't need to look for an end or closing brace to know that the context has moved up a level. The indentation tells you where that happens.

(And yes, because of the generally accepted coding style in Ruby, I use 2 spaces instead of tabs now.)


And yet, Ruby coding style is informal. You can code in improper style and still commit your code and/or run it. There's something about having the freedom to write improper style and being able to be a good "citizen" on your own that is comforting.

Go does not do this. Writing Go in any editor configured to code in it (I've been using the vim-go plugin) automatically formats via gofmt.  It's pretty unsettling. I longed for the ability to become dictator over coding styles, and then was okay when Ruby dictated one, but gave us the autonomy to do the right thing. This auto-formatting? This is tyranny!

But, perhaps, it's time. We can mentally chunk pieces into larger concepts for storage, if code that does the same thing looks the code. Instead of having to remember every brace as an individual piece, we can put "for loop that iterates and prints" as a single chunk.

A stray brace isn't going to permanently prevent distillation into larger chunks; it will just take a higher cognitive load to get there. This in turn will require more experience with the language before a programmer can make that leap. Being able to break things into large chunks helps us discover the what instead of dwelling on the how.