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.

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
      dummy_method_actually_under_test
    end
  end
end
 
it 'example do test' do
  get :dummy_action #etc...
  # validate dummy_method_actually_under_test did the thing
end

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
      dummy_method_actually_under_test
    end
  end
  Rails.application.routes.draw do
    get 'application/dummy_action/:id', to: 'application#dummy_action'
  end
end

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
  Rails.application.reload_routes!
end

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/libphp7.so
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.

Resolution

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/libphp5.so

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

2017 Year in Review

January

  • Pigeon Forge field trip as chaperone
  • Pinewood Derby

February

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

March

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

April

  • Mad Violin
  • Blueberry Festival

May

  • Wife quit job
  • Savannah to OBX

June

  • Lighthouses
  • Sea Catchers
  • Dan TDM in Jacksonville

July

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

August

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

September

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

October

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

November

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

December

  • 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

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.)

Golang

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.

Migrating WordPress Install From Dreamhost to Linode

Migrating hosts has always been a tedious process for me, and I've often stayed on horrible hosting providers just because I've dreaded it. Linode (referral link) and similar providers at least have a wealth of information on how to set up your new hosts, but I still found myself jumping around a lot to remember how to do certain things. Hopefully, this post helps put (most) of the information in one place.

Experience level required: You have logged into your own Linux box and have done *something* useful.

Grabbing your content from Dreamhost

Login using the shell username associated with your domain name that you're moving. Assume the domain name is example.com.

Grab the WordPress install complete with content using tar.

I'm using the domain name as part of the tar file name to keep things straight, but the name before the .tar file can be whatever works for you. (Note: you can be more surgical and just grab the content and have a fresh WordPress install, but then you'll be chasing after even more loose ends.)

tar pcvf example.com.tar example.com

Dump your mysql database.

 

Open your wp-config.php for you domain and note your DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST.

Run the following mysqldump command line:

  • DB_NAME as the first argument
  • DB_HOST after the --host argument
  • DB_USER as the -u argument.
  • The -p argument will cause mysqldump to prompt you for a password.
  • Redirect output (> filename) to whatever file you want, but again, I'm using something like "domain.name.sql" for consistency and clarity in my move.

Transfer your files down.

scp username@dreamhost_host_name:~/example.com.tar .
scp username@dreamhost_host_name:~/example.com.sql .

Sign Up for Linode

I'd appreciate you signing up through my referral link for Linode . I chose the Linode 2048 Standard Instance , Deployed an Ubuntu 16.04 LTS image to it, and started it up.

From there, you need to set up the LAMP stack. Note: these instructions will install PHP 7, and I found at least one plugin (Sociable?) that used deprecated calls in php and caused me a few 500 errors.

Add non-root user

Be sure to also follow Securing Your Server recommendations for automatic updates and such, but for our purposes:

adduser example_user
adduser example_user sudo

Upload Your Site to Linode

scp example.com.tar example_user@linode_instance_ip:~
scp example.com.sql example_user@linode_instance_ip:~

Enable .htaccess if you use any rewrites

/etc/apache2/apache2.conf (AllowOverride)  It's possible you *don't* need this if you have WordPress, but I haven't had an install that didn't.

Enable apache mods

sudo a2enmod ssl rewrite mpm_prefork

Add other PHP and related mods that your plugins may need

sudo apt-get install php7.0-mbstring

sudo apt-get install php7.0-gd sudo apt-get install php7.0-curl php7.0-json php7.0-cgi sudo apt-get install php7.0 php-pear libapache2-mod-php7.0 sudo apt-get install php7.0-mysql

Set up your virtual host

/etc/apache2/sites-available/example.com.conf

Create subdirs and set permissions properly

sudo mkdir /var/www/html/example.com

sudo mkdir /var/www/html/example.com/{logs,public_html} sudo chown -R www-data:www-data /var/www/html/example.com

Untar your content

Because of the way Dreamhost has their domain subdirectories set up, you'll end up with two layers of example.com folders. (You could have also tarred from the folder, etc... but I just decided to keep this pattern.)

cd /var/www/html/example.com
sudo -u www-data tar xvf ~/example.com.tar .
cd example.com # from the tar file
sudo -u www-data mv .htaccess ../public_html
sudo -u www-data mv * ../public_html
ls -a # this should be empty now.
cd ..
pwd # be sure you're in /var/www/html/example.com
rm -rf example.com

Setup and Load Your DB

cd to the location of your sql dump.

CREATE DATABASE wp_example_com;
CREATE USER 'examplecom' IDENTIFIED BY '!@(87P@ss';
GRANT ALL PRIVILEGES ON wp_example_com.* TO 'examplecom';
USE wp_example_com;
SOURCE example.com.sql;

Change your wp-config.php for the DB setup

Your DB host is now localhost (unless you created a new DNS entry for your DB host)

Enable your site

sudo a2ensite example.com

Add a DNS zone in Linode and change your DNS servers to point to Linode.

Add SSL

For more details start at "Install Let's Encrypt to Create SSL Certificates"

I had to experiment a bit with the SSL configuration to get Let's Encrypt to generate the keys and certs.

Lastly... I had to add renewal of the SSL certs to my crontab (sudo crontab -e)