Using an Arduino to keep a Seiki 4K Display On

I love my Seiki 4k Display for writing code on my Mac. The one downside is that it times out and goes to sleep after 2 or 4 hours of inactivity (from the remote, not the screen). I decided to fix this problem in a somewhat complicated way: With an Arduino Uno that I already had, and an IR control kit.

I used the IR receiver to find the Seiki “Volume Up” and “Volume Down” codes, which appear to be structured like NEC codes. Those are hardcoded because I haven’t really bothered to refine the setup or code any more. The IRBlaster library uses digital out 3 for the IR sends, and I used digital 8, 9, and 10 for red, yellow, and green indicators to give some indication of where in the refresh cycle things are. The code as-is sends the volume up and volume down signals every hour or so, and the indicators start with a slow blink on red, a slightly faster blink on yellow, and a fast blink before remote send on green.

IR Blaster set up (with IR receiver partially wired in still)
IR Blaster set up (with IR receiver partially wired in still)

IRsend irsend;
int led = 13;
int red = 8;
int yellow = 9;
int green = 10;

void setup()
  pinMode(led, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(yellow, OUTPUT);

  pinMode(green, OUTPUT);

int choice(int i) {
  if(i > 1300) {
    return red;
  } else if (i > 900) {
    return yellow;
  return green;

void ledOn(int i) {
  digitalWrite(choice(i), HIGH);
void ledOff(int i) {
  digitalWrite(choice(i), LOW);

void loop() {
  while(true) {
    irsend.sendNEC(1086232679, 32); // seiki volume up
    irsend.sendNEC(1086206159, 32); // seiki volume down
    for(int i=1800; i >=0; i--) {

2015 in Review

Monthly Summary


  • Started work on a solo project at work that pretty much gave me lots of experience building something from end to end.
  • Working from home 2/3rds of the time to work out any kinks for a possible move to Florida.
  • Thank yous going out to people who helped fund Emily’s medical mission to Kenya.


  • Emily is gone for 10 days on a trip to Africa.
  • I have to dress the kids by myself exactly one day of her absence.
  • …because the kids were off school due to snow the entire following week.


  • The small solo project goes into “User Experience auditing” mode and I get help actually meeting the demands.
  • The kids were off school due to snow (for entire week?) again.


  • Painting, final prep for selling the house.
  • Spent a week with mostly no cell signal in St George Island


  • Broke news to parents officially that we were moving.
  • Sold the house then listed it. (At least that was the order the offer versus official listing happened in.)


  • Packed up the house, closed on the house, vacated the house, and flew off for the Philippines in a span of 5 days (with our 12th wedding anniversary in between.)
  • Last times accompanying at various churches in Louisville.
  • Went to the Daluyon resort on the island of Palawan in The Philippines.


  • Celebrated my grandmother’s 100th birthday with the rest of the family in The Philippines.
  • Realized the madness that is flying to/from and traveling in a foreign country with very picky eaters as kids.
  • Flew back to the US, tried to adjust to jetlag in 2 days, drove our belongings not packed in a trailer to Florida in two cars (one with a broken A/C).
  • Scrambled to find a rental house that accepted a big dog in the school district we wanted, signed a lease, moved in (in a week from arriving in Florida)
  • Officially began my 100% remote work life.


  • Sister-in-law brought our dogs down.
  • Kids started at their new school.
  • I wilted on runs in the Florida sun and heat.
  • Transferred our licenses and cars to Florida officially.
  • Went to beaches


  • Emily waited around on callbacks from job applications.
  • Joined in with the Cathedral music program.
  • Went to beaches


  • Actually saw a decent amount of the area on foot–running.
  • Not so much with the beaches.
  • Emily started a new job!
  • Olivia made All County Chorus


  • Failed at Monkey (intentionally bailed at 11.5 miles, may have missed my bail out point a couple times.)
  • Drove back to Louisville, had good times, but way more hectic than expected.


  • Apparently the A/C can mostly not run in December in Florida.
  • Went back to Louisville for Christmas.



  • Quite a bit of Hamilton the Musical.
  • Surprisingly less music listened to at home office than on site. Strange.


  • 72 Books. Getting into Hamilton the Musical led me Chernow’s biography of Hamilton. Excellent book, very dense read.
  • Childhood’s End by Arthur C. Clarke and the Space Odyssey series were also exceptional (though I was a bit disappointed in 3001).
  • In following the post-apocalyptic/YA-ish series reads of past years, I got into the Extinction Point series by Paul Antony Jones
  • …less impressive was the Defiance trilogy (CJ Redwine), probably due to the believability of an alien race doing astounding things versus ordinary humans accomplishing futuristic feats in a world thrown back to the Dark Ages.

Rails 4, phantom ArgumentError: wrong number of arguments (0 for 1) on UserSession.find for AuthLogic

This was a total pain to locate, as the exceptions being raised were pointed to UserSession.find in Authlogic::Session::Persistence.

gems in question:

  activerecord-session_store 0.1.1
  authlogic 3.4.6
  activerecord 4.2.3
  rails 4.2.3

I noticed that the only meaningful difference between the two environments was the following instance variable in Rails.application.config:

irb> pp Rails.application.config

Commenting out this initialization in the environment allowed the application to work again.

   config.logger ='name of log'))

Searching on “usersession syslog rails 4” results in the following issue as the third search result: Version 0.1.1 breaks Syslog::Logger setups There is a fix in master, but it doesn’t seem to have been published. I had promoted activerecord-session_store to 0.1.1 because DEPRECATION WARNING: `#quietly` is deprecated in rails-4.2.0.beta4, but it looks like locking the gem at 0.1 will work otherwise except for noisy tests.

Pundit: NoMethodError (undefined method `verify_authorized’ for [WhateversController])

Sometimes, having done things several times before can make you miss the OBVIOUS.

After adding

  after_action :verify_authorized

to my ApplicationController to verify that Pundit was being used for authorization, I got the following error in rspec:

  2) Jobs GET /jobs works! (now write some real specs)
     Failure/Error: get jobs_path
       undefined method `verify_authorized' for #
     # ./spec/requests/jobs_spec.rb:6:in `block (3 levels) in '

Maybe there’s a problem with my RSpec? Nope:

Started GET "/" for at 2015-07-31 07:13:17 -0500
Processing by JobsController#index as HTML
  Job Load (0.1ms)  SELECT "jobs".* FROM "jobs"
  Rendered jobs/index.html.slim within layouts/application (0.5ms)
Completed 500 Internal Server Error in 8ms

NoMethodError (undefined method `verify_authorized' for #):

Okay, does ApplicationController have the method?!

irb(main):008:0> :verify_authorized
=> false

Ok, am I doing that wrong?

irb(main):010:0> :authenticate_user!
=> true

Sigh. *Rereads documentation.*

Screenshot 2015-07-31 07.25.24

What’s missing? Oh yeah, a simple `include Pundit’ in the ApplicationController

Bootstrap 3 radio-inline and checkbox-inline elements running together.

I was having issues with Bootstrap 3 radio buttons running together even though the labels had a “radio-inline” attribute.

After examining the layout of the html being generated, I realized that each individual label and radio button was being wrapped in its own containing element (in this case, a “td” element.)

The reason for this is the following CSS:

.radio-inline + .radio-inline, .checkbox-inline + .checkbox-inline {
  margin-top: 0;
  margin-left: 10px;

If the .radio-inline elements aren’t adjacent to each other, the ‘margin-left’ value will not trigger.

Unfortunately, it took a little too long to track down the source of the issue, but now I know.

The “Satirical News” Sites Need to Stop

The Onion has always been entertaining because it either operated at a very generic level or a very absurd level. While The Onion could be mistaken for real news, it was often involving a person that didn’t exist, a generic group of people, or things so absurd that no reasonable person could believe them to be real. Besides, The Onion was THE ONION.

However, now there’s a proliferation of “satirical news sites”.

The latest in the absurdity is Newslo, which is:

JUST ENOUGH NEWS… Newslo is the first hybrid News/Satire platform on the web. Readers come to us for a unique brand of entertainment and information that is enhanced by features like our fact-button, which allows readers to find what is fact and what is satire.

I’m trying out “SatiricAlert” to help me filter out this crap that has proliferated way too much to be entertaining anymore.

Hooking in an LDAP Test Server to Cucumber Tests

I managed to get a custom Devise strategy with LDAP working, but had no clear way of automating tests. I wanted to validate if I still had to keep the password fresh in the database, and needed to be able to write scenarios around that in case someone attempted to refactor out the code.

After trying to incorporate the spec strategy used in the development devise_ldap_authenticatable and failing, I found a ruby wrapper of ApacheDS called ladle that looked like it would serve my purposes.

I included in gem in my test group in my Gemfile:

  gem 'ladle'

At the top of my features/env.rb file for configuring cucumber, I turned off admin binding (wanted the connection as simple as possible):

::Devise.ldap_use_admin_to_bind = false

I then created an @ldap tag for my LDAP-dependent features than would start and stop the LDAP server in those instances. (Again, in my features/env.rb… probably need to clean that up.)

Around('@ldap') do |scenario, block|
  $ladle ||=
    :ldif => "spec/ldap/test_users.ldif",
    :domain => "dc=example,dc=org",
    :quiet => true

I then created an the spec/ldap/test_users.ldif (from following the example in the ladle project).

version: 1

dn: ou=people,dc=example,dc=org
objectClass: top
objectClass: organizationalUnit
ou: people

dn: uid=eadmin,ou=people,dc=example,dc=org
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Example Admin
sn: Admin
givenName: Example
uid: eadmin
# Password is "b44b44bl@cksh33p!"
userpassword: {SHA}Aedq5WHQSxglvJSfpX0kgdGRdHk=

I generated the password with:

  slappasswd -h {SHA} -s b44b44bl@cksh33p!

One stupid mistake that I did in the process was kicking off two Ladle servers (with slightly different parameters). In one iteration, I couldn’t bind to the user. Another, the server using the test file failed to start. Be aware that Ladle will run happily with default parameters, but that they won’t be much use to you.

If you want to test your configuration file:

require 'net/ldap'
require 'ladle'

$ladle ||=
  :ldif => "spec/ldap/test_users.ldif",
  :domain => "dc=example,dc=org",
  :quiet => true

ldap = 'localhost',
    :port => 3897,
filter = Net::LDAP::Filter.eq('mail', '') # or ('uid', 'eadmin') => 'ou=people,dc=example,dc=org', :filter => filter) do |entry|
  ldap.auth(entry.dn, 'b44b44bl@cksh33p!') # or whatever your password is

  entry.each do |attribute, values|
    puts "   #{attribute}:"
    values.each do |value|
      puts "      --->#{value}"

Kentucky Lottery Pick 3 Expected Payout

The expected payouts for the Kentucky Lottery Pick 3 game have an interesting idiosyncrasy. Playing the special “Straight Box” play pays out better than a separate 50¢ straight and 50¢ box play.

All other plays average 60¢ per dollar played, but the straight box seems to be 65¢ and 70¢, depending on the numbers played. Maybe my spreadsheet is wrong somewhere in here:

Kentucky Lottery Pick 3 Payouts and Odds

devise_ldap_authentication for your domain email on top of database_authenticatable

I have a devise user model named LoginUser whose authentication key is :login. I want normal users of the system to be database_authenticatable.

However, I want to be able to authenticate previously added users via internal LDAP. Furthermore, I didn’t want the underlying database_authenticatable password to be used or to expire on me (also using devise_security_extensions). Most of the work is in the LocalOverride custom strategy’s authenticate! method, with a few other hooks (such as default strategy added to devise.yml).


To allow all other strategies to be used, but still trap our domains for one-off LDAP auth, I added devise :ldap_authenticatable to a singleton class inherited from the user loaded by the custom strategy.

Also, removed the other two “fails” from the code. Not necessary and will result in a “Failed to Login” message for too many other Devise-related Unauthorized events.

In config/initializers/local_override.rb:

module Devise
  module Strategies
    class LocalOverride < Authenticatable
      def valid?

      def authenticate!
        if params[:login_user]
          user = LoginUser.find_by_login(params[:login_user][:login])
          # trap our domain only
          if params[:login_user][:login] =~ /
            # fail! halts the authentication chain completely
            return fail! unless ::Devise::LDAP::Adapter.valid_login?(params[:login_user][:login])
            class << user
              # make use of ldap_authenticatable for custom strategy only
              devise :ldap_authenticatable
            return fail! unless user.valid_ldap_authentication?(params[:login_user][:password])
            # use the after_ldap_authentication hook
            return success!(user)

Warden::Strategies.add(:local_override, Devise::Strategies::LocalOverride)

In config/initializers/devise.rb:

  # use local_override as default strategy
  config.warden do |manager|
    manager.default_strategies(:scope => :login_user).unshift :local_override

In config/models/login_user.rb:

class LoginUser < ActiveRecord::Base
  devise :database_authenticatable,
         :recoverable, :trackable, :secure_validatable,
         :authentication_keys => [:login]

  def after_ldap_authentication
    # force fresh password every log in
    self.password = self.password_confirmation =

defaults:  &defaults
  host: our.ldap
  port: 636
  attribute: mail
  base: dc=IDENT,o=Orgname
  admin_password: adminpassw0rd
  ssl: sslmethod

See local_override.rb for original tip that got me there.

One Year In: Prius 2014 Gas Mileage + Thule Carrier + Road Trip

Prius with Thule Cargo Box

The Prius has definitely been a very geeky car to play around with and figure out. It’s been fun to see how various environments and driving styles impact it.

My initial driving in the summer of last year yielded about 42.9 MPG. This was in stop-and-go traffic, but often stopped long enough that the engine would have to kick in to power the A/C while idle. I was able to optimize to about 45 MPG with 72ºF+ auto A/C and on a route that allowed for more constant movement.

The first road trip (1 adult, 2 kids) down I-65 to Florida in the summer yielded tanks MPG of 39-42 MPG. Another road trip to South Carolina with two adults and two kids yielded 39.6 MPG for the trip.

The brutal winter earlier this year was pretty frustrating on gas mileage. The only driving done in the car was done with the engine running constantly just to try and warm up, and I discovered that there’s no good way to get a Prius warm enough to melt the ice on your windshield unless you edge it into the sunlight. There were a few tanks that I got 33 MPG on.

We eventually installed Thule Aeroblades on our car which allowed mounting of a Thule Cargo Box. The car got under 40 MPG with the cargo box mounted, but did about 35.8 MPG on the highway drive down. The best tank MPG that I got on our Camry on 100% interstate was still under 35 MPG.

Of course, the biggest gas mileage benefit of the Prius was when we were driving 4-8 miles back and forth on St. George Island at 25-35 MPH. I’d occasionally make trips without the engine even turning on, and the average trip MPG was over 50 MPG.

Almost a year in, this car has been fun to play around with and a great road trip car (especially with the roof rack). The biggest surprise is how it has fascinated my geek side.