Hardwiring the Xantech ML85 IR Receiver to a Connecting Block

I recently added a Xantech ML85K IR repeater kit to my theater room. All of my equipment sits in the back of the room and I needed a solution for my remotes to work while pointing them at the screen as one would normally do.

The challenge with this kit is that the IR receiver comes with a standard 1/8″ (3.5mm) stereo mini plug designed to plug right into the 789-44 connecting block. Unfortunately, the cable in only 7 feet long and I needed to run over 30 feet through the walls and ceiling.

In this case I had two options:

  1. Use a 50ft stereo mini extender cable (or a 20ft and a 10ft)
  2. Use CAT6 wire

As I already had CAT6 laying around and it was better suited for in wall use, I decided to cut off the end of the IR receiver and splice the wires. The only problem is that Xantech doesn’t provide the mappings between wire color and function. They do however tell us what the tip, ring and sleeve of the mini-jack do.

So to make this work I did the only logical thing: I cut apart the mini jack to figure out the mappings my self. So you have them, here are the mappings:

  • Tip > White > Signal
  • Ring > Black > Ground
  • Sleeve > Red > +12VDC

While this works for the ML85, my guess is that it will work for other Xantech IR receivers as well.

Caching a Wildcard Domain Using Varnish With Multiple Virtual Hosts

At my company, TGFI, we have a handful of sites that run through Varnish to cache images, css, javascript and even full pages in memory. To date, all of this had been done with known domains (domain.host, www.domain.host). This week, however, we have a new application going live in the system that uses a wildcard domain. Despite looking around, I was unable to find documentation on how to handle a wildcard domain when varnish is setup to handle multiple sites.

Continue reading

Pain Is a Signal of Improvement

Be it programming or life, you have to push through your comfort zone to expand your capabilities. If you are unwilling to do that, you’ll lead a very unfulfilling life.

It is a fundamental law of nature that to evolve one has to push one’s limits, which is painful, in order to gain strength—whether it’s in the form of lifting weights, facing problems head-on, or in any other way. Nature gave us pain as a messaging device to tell us that we are approaching, or that we have exceeded, our limits in some way. At the same time, nature made the process of getting stronger require us to push our limits. Gaining strength is the adaptation process of the body and the mind to encountering one’s limits, which is painful. In other words, both pain and strength typically result from encountering one’s barriers. When we encounter pain, we are at an important juncture in our decision-making process.

Ray Dalio, Principles

Every day I try to push myself and challenge my beliefs from the day before. The more I read new topics or tackle difficult tasks, the better I feel.

Progress and Persistence

This quote from Steve Jobs has nothing to do with product design and everything to do with moving society forward.

Designing a product is keeping five thousand things in your brain and fitting them all together in new and different ways to get what you want. And every day you discover something new that is a new problem or a new opportunity to fit these things together a little differently. And it’s that process that is the magic.

Don’t rest on your laurels. Keep pushing.

Backing Up Your Heroku Database With PGBackups

Heroku recently announced that they are changing the way you backup your app’s database. They are deprecating their bundles add-on and have added a new PostgreSQL only backup feature. This is great news as the old bundles method included a copy of your source code as well. In one instance, our backups went from 90MB compressed to just 17MB uncompressed.

Installing the Heroku PGBackups Add-On

First, you’ll need to install the latest version of the heroku gem.

sudo gem install heroku

Next, go into your project directory and install the pgbackups add-on.

cd ~/projects/MyProject/
heroku addons:add pgbackups

Once installed you can easily make a backup to the cloud.

heroku pgbackups:capture --expire

There are two things to note here:

  1. This backup now happens synchronously instead of in the background. This makes automation much easier as you don’t have to sleep for a few minutes and hope it’s done.
  2. The ––expire parameter automatically deletes the oldest backup, making historical cleanup a cinch.

Once the backup completes you can fire the download command off. This will get a public url (heroku pgbackups:url) and download it using curl to a directory on your computer. The file is also renamed with a timestamp like 20101213 for easy sorting.

curl -o /MyComputer/Drobo/backups/MyProject/MyProject_pgbackup_`date '+%Y%m%d'`.sql `heroku pgbackups:url`

That’s it. They’ve really done a great job making it easier to backup your database and it works every time.

What else can you do?

For more information, checkout the Heroku documentation on pgbackups. They have a great example at the bottom for transferring your database between production and staging sites, something we do all the time.

Is Delayed Job :run_at => DateTime Giving You Fits?

I’ve been implementing Delayed Job to poll Twitter every minute for changes. However, it was immediately running everything and ignoring the run_at time in the database. Or so I thought.

Upon inspection of the code for Delayed Job, it is polling the database time to UTC and not local time.

def self.db_time_now
      (ActiveRecord::Base.default_timezone == :utc) ? Time.now.utc : Time.now
end

What was

Delayed::Job.enqueue PollTwitter.new(), 0, 1.minutes.from_now

has now become

Delayed::Job.enqueue PollTwitter.new(), 0, 1.minutes.from_now.getutc

Four hours is a large difference.

Note: Normally I would just run this as a cron job, but Heroku will only run cron once per hour.