I'm using it to try to solve problems in Ruby without actually looking up syntax (looking at you, inject) and getting some practice using MiniTestinstead of RSpec which I use 99% of the time.
Day 2 was kind of fun to be able to implement a tiny virtual machine in Ruby.
Day 3 had me stumped until I just when for a naive solution in which I just created a list of all the coordinates visited instead of trying to figure out an elegant way to calculate the answer... an approach which actually paid off in the second half.
Day 4 has been the problem that I spent the most time fighting with (specifically the second part) after thinking that I had it solved. It was one of those scenarios in which I pretty much starting chasing my own tail after the solution I thought should work didn't. I ended up with 4 state variables in addition the input variable itself.
I've had 30 years of experience fighting with keyboard instruments in both church services and for musicals.
Electronic keyboards are very much a case of getting what you pay for, up to a certain point. However, beyond a certain price point (~$2k), each brand has a few unique characteristics and then a few features that are made more or less usable as you upgrade for other features.
In playing a couple weekends with the Roland HP-603A, I discovered a few of these.
The dual sound on this digital piano has an option that I haven't found on other keyboards (Kurzweil, Yamaha)... you can specify the balance of the sound between the two voices.
However, just like the Kurzweil and Yamaha, the order of selection when selecting two voices determines the "primary" voice. You can separately select to "edit" voice 1 and voice 2 and scroll through options, but that's not as useful while playing.
The Roland has a few organ settings, 2 or 3 which are "pipe organ" and a few which are "jazz/gospel/electronic organ", but one interesting one that I found was the "Nason Flute 8'"... which is an oddly specific description, but is a good instrument for quiet underscoring but with a breathy "flute" attack.
The organ notes sustain in response to the damper pedal on the keyboard, which is totally wrong, but very convenient. (The Kurzweil does the same, but the Yamaha that I have does not.) Trills on the organ settings articulate distinctly, but are not as detached as I've experienced on a Yamaha.
As far as I could tell, the organ settings *do* respond to attack, which is a little bit weird and/or surprising, but you just have to make sure not to suddenly emphasize random notes.
Transposition has a transpose button and then you + or - the transposition. About half the keyboards I've used have made it either non-obvious *how* to transpose, or made it slightly difficult to pull it off relatively quickly.
Strings and Bass:
The "Symphonic Strings" setting had a nice sound without being too slow on the attack or too harsh. I almost always use strings as an ambient addition to a piano-like instrument selection, so I didn't try actually leading with the instrument.
This is the first keyboard that I've seen in a while, however, that *didn't* have a string bass + ride option. The walking bass on the left hand just becomes more obvious when a ride cymbal is tapping along.
While I'm not sure that I'd purchase one for my own home, the Roland works better in an accompaniment situation than the mid 4-figure Yamahas in my experience.
I have my prompt in zsh setup to display what Kubernetes context I am pointing to, so that I will notice if I'm somehow pointed at production environments, but I'm still wary of being asked to check things in production and then forgetting to point back to a "safe" environment before doing something else.
So I set up a preexec and precmd hook to store state for the session that I'm in. In the preexec, I save off whatever command was run.
In the precmd, I check to see that command matches "switching over to production", mark the time, and clear the command out (otherwise, pressing <return> on the shell will keep the same command).
If I have marked the time I switched to production (PROD_TIME is not an empty string), then I check the current time and if it's past a threshold (15 seconds in the current case), then I run the command to switch back.
The last few lines clear the prexec and precmd function hooks and set them to the "safety" functions.
Chat tools are great for being able to work remotely, at least until you get bombarded by one chat after another. I've often wondered if I could come up with a way to track who my chats are with and how much time was spent chatting with each person. My initial attempts involved trying to connect the HipChat API, but I would get rate-limited before I even got through the full set of contacts, much less the rooms themselves. And as far as I could tell, I had to cycle through all public and/or subscribed rooms and not just the rooms that I subscribed to.
(You might be familiar with RescueTime doing similar for webpages, but it doesn't appear to do that for HipChat or Microsoft Teams as far as I've been able to tell.)
A Simpler Algorithm
What if I could just log periodically when I'm chatting with a specific person or on a specific topic? I started playing with the Accessibility Inspector to try and figure out if I could get a specific path to the name display so that I could track who I was chatting with/what room I was in.
I could an incredibly long tree down to the name display, so I went directly into Script Editor with some AppleScript to dump the UI elements of HipChat (commented out below), but found that the display was too generic... so I switched to grabbing the entire contents:
For HipChat, the above produces a long list of element hierarchies, but static text is mentioned in the hierarchy (I used somebody else's name because your own name appears in more windows in the view, but there may be multiple hierarchies that display the name you're looking for):
static text "Thomas Powell" of group 1 of group 13 of group 4 of UI element 1 of scroll area 1 of group 1 of group 1 of group 1 of group 1 of window "HipChat" of application process "HipChat" of application "System Events",
So I would remove the last bit of the hierarchies, and ask for the "name of" or "value of" the remainder of the hierarchy.
nameof UI element of group 2of group 1of group 3of UI element 1of scroll area 1of group 1of group 1of group 1of group 1of window "HipChat"ofapplication process "HipChat"ofapplication"System Events"
Ultimately, "name of" was the key to getting the display value I was looking for, but the chat rooms had a slightly different hierarchy, and both required trial and error to find the correct hierarchy. Ultimately, the value I was looking for was in a list within the "name of" the UI element at the bottom of the hierarchy, so I continued the inspection in Script Editor until I got to the correct value.
(Disclaimer: I am barely able to write AppleScript that parses, much less AppleScript that looks good.)
I ended up creating an application the allows me to select a log file for output. Then I created a giant loop that checks if HipChat (or Microsoft Teams or RubyMine) or the front applications and then logs a usage with name or project in a log file + timestamp separated by a semicolon. (I used Ruby to generate the statistics based on this... sorry.)
I don't wait for any period if none of the applications I'm looking for are currently in front. If one of them is, I delay 15 seconds.
HipChat had *by far* the hardest hierarchy to find the name / chat room info in. For RubyMine, the file path and file name are in the window title and the git project are in one of the static texts near the top level. Microsoft Teams was similarly friendly in that the title of the window reflected the context it was being used in.
Hammerspoon looks a little more promising for doing anything more complex and/or DRYing this up, but there's something to be said for being able to quickly hack your way to the data you want vs. actually having to plan things out.
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.
Crazy glue the broken headphones to its counterpart (and risk sealing it up for good?!)
Small drill bit.
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.
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.
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.
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.
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:
it 'example do test' do
get :dummy_action #etc...
# validate dummy_method_actually_under_test did the thing
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.
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.)
..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:
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.
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.