Ryan Wersal

Thoughts on programming, Emacs, and other topics.

Make HDMI Out Work on the Acer Aspire V5

Another day, another linux distro and another issue with Ubuntu variants and the hardware in my new Acer Aspire V5. However, this time it is with UbuntuGnome and HDMI audio not working at all. There are countless questions and answers strewn about the web about HDMI Audio Out just not working (including numerous on AskUbuntu). Unfortunately all of what I found was a lot of speculation (regretfully the original posters never seemed to comment back on what worked for them). I did end up finding something that worked for me, so I figured I’d share it in the hopes that someone else finds it useful!

The gist of the fix is to use the latest alsa drivers (in my case I opted for the dailies so, as usual, your mileage may vary). I have seen recommendations both ways to add it as a ppa or just download the requisite deb package; I ended up going with the ppa approach:

1
2
3
4
sudo add-apt-repository ppa:ubuntu-audio-dev/alsa-daily
sudo apt-get update; sudo apt-get upgrade; sudo apt-get dist-upgrade
sudo apt-get install oem-audio-hda-daily-dkms
sudo reboot

With any luck you will have working HDMI audio after the restart!

Fix Brightness Keys in Ubuntu for Acer Aspire V5

Today my newly purchased Acer Aspire V5 arrived. I immediately purged Windows 8 and replaced it with Linux Mint 14.1. Unfortunately, for a mysterious reason the brightness setting (and keys) were not being respected. As I appreciate not having my retinas seared I did some searching and found a solution/workaround that worked for me.

We need to update the grub menu (sudo nano /etc/default/grub) and replace the following:

1
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

with:

1
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"

Finally you will need to update grub:

1
sudo update-grub

The above ended up being the minimum required to get backlight control working for me. As with most things like this, your mileage will vary, but hopefully it helps! If, like me, tinkering with this results in a non-booting system, make sure you have a LiveCD or Live Flash Drive available along with this AskUbuntu answer on running update-grub from a LiveCD.

UPDATE 4/29/13: Added the update-grub command to actually apply the changes.

Fixing Amazon Prime Streaming ‘Updating Player’ Error on Ubuntu

As I’ve been attempting to switch my primary operating system over to Linux Mint I have encountered a couple unfortunate issues. One specifically is getting Amazon Prime Streaming working on Ubuntu/Linux Mint due to the incessant “Updating Player” error. After some searching, I came across a blog post containing a solution that worked for me: simply install hal:

1
sudo apt-get install hal

Git Koans

Git. Never before have I used a tool that I appreciate to this degree yet has frustrated me beyond belief. Frankly, I’ve found no better description of my issues with Git than Git Koans:

“How should I change to a different branch?” asked the programmer.

“Use git checkout.”

“And how should I create a branch?”

“Use git checkout.”

“And how should I update the contents of a single file in my working directory, without involving branches at all?”

“Use git checkout.”

Obviously Naming Consistency isn’t the only crucial kind of consistency: interface consistency is also incredibly important (at least unless you want to constantly reference documentation or ask numerous StackOverflow questions).

App Pricing Expectations

Reading through my ADN feed a few days ago I came across this wonderful (but tragic) post:

“Wonder if this movie’s good.” $10.
“Try the new Burginator Deluxe!” $6.
“Haven’t heard of *that* beer before.” $3-5.
“New restaurant in town!” $30-$200

“Huh, an app. I really need a free trial.” $0.99

This pains me as people’s general unwillingness to pay much for mobile apps is one of the factors that scared me out of pursuing native mobile development. Worse, @billkunz has spent far more time than I would ever dream spending trying to make Felix, an excellent iOS app for ADN, only to have people complain about the minimal $5 price tag.

I wonder how many developers will be able to, or willing to, weather these kind of conditions before they look elsewhere for a more sustainable market.

Repeatable Tasks

I’ve been reading a decent amount about Blink and I came across an excellent blog post by Alex Russell. This post not only gave an interesting perspective on the whole Blink situation, but contained a wonderful quote:

…the highest good you can do as an engineer is to make your fellow engineers more productive.

This struck a chord with me as I’ve found a passion for improving the meta-work of my trade (writing code/documentation, compiling, tool workflows, etc). Spending time up front to improve your life as well as the lives of coworkers and other developers is rarely time wasted. There is, of course, a balancing act to maintain as you don’t want to spend all of your time improving or tinkering with your tools and no time shipping. However, if you’re able to strike that balance, the rewards are truly sublime.

Mimic Sublime Text’s Go to Beginning of Line

Over the past several months I had used Sublime Text 2 nearly exclusively. Now that I’ve returned to Emacs there are a couple features I miss that I’ve been working to reproduce. One of these is the subtle difference in behavior of Sublime Text’s go to beginning of line functionality as compared to Emacs’.

Essentially, if the insertion point is currently on the first non-whitespace character of the line, go to column 0. Otherwise, go to the first non-whitespace character on the line. Although I am still very new to Emacs Lisp, I was able to come up with a function that reproduces this behavior:

1
2
3
4
5
6
7
8
(defun st2-like-beginning-of-line ()
  "Reproduce ST2 beginning of line functionality.
Go to the position of the first non-whitespace character.
If already there, go to actual beginning of line."
  (interactive)
  (let ((col (current-column)))
    (back-to-indentation)
    (if (= col (current-column)) (move-beginning-of-line nil))))

Naming Consistency

There are only two hard things in Computer Science: cache invalidation and naming things.

Phil Karlton

As I’ve been slowly gaining some competency with Emacs Lisp (and Emacs at large) I’ve been encountering one big problem: the lack of naming consistency among functions. For instance, we can go from wonderfully mirrored functions such as scroll-up-line and scroll-down-line (although their meaning is still a bit ambiguous) to the inconsistency of current-column and line-number-at-pos.

This results in more brain power being spent on remembering these various function names or repeatedly trying to determine the correct name of the function you need. Emacs does a somewhat decent job of helping with this with the apropos command, but you still need some part of the function name that is distinct enough to return a usable set of results.

However, there are far more subtle consistency issues out in the wild and, as a result, there are a few guidelines that are key to making sure you don’t have to consult the documentation excessively.

  1. Make sure that your names are consistent in their capitalization. Otherwise you end up getting build errors when you mistake, yet again, the capitalization on setCachedSql() compared to setSQL().
  2. Ensure that functions with identical behaviors accept identical (if possible) parameter types in the same order. If you don’t, you end up with one variant such as link(href, text, args) and another that is link(text, href_and_args) which causes you to get the opposite result you were expecting.
  3. As above, attempt to maintain mirrored names for functions that have mirrored behaviors. Instead of current-column and line-number-at-pos, it is better to name them current-column and current-line or even column-number-at-pos and line-number-at-pos.

Naming is indeed hard but aiming for consistency saves time and productivity, particularly when you no longer have to incessantly bounce between your editor and the documentation.

Simplicity Matters

I recently watched Rich Hickey’s keynote from Railsconf 2012 titled “Simplicity Matters” and one particular quote really struck me:

We build these objecty, verby things in our programs but as soon as someone says that it should be on another server we immediately stop doing that style of progamming. Why do we do that?

I mean, how true is that? My first job out of college was all about layered architecture: database layer, database access layer, business object layer, business logic layer, app layer, and so on. Worse, each layer was just another mess of objecty, verby things (and interfaces, oh the interfaces) built upon each other. A layer cake of awful.

When I first started my current job, I was introduced to a world of passing data back and forth. At first it didn’t seem like such a grand idea. “How do you do anything?” I remember thinking. Once I got out of that flawed mindset, however, I realized that sending and operating upon plain data structures was not only easy but incredibly effective. In fact, our codebase has near identical methods for running code on the client or on a server. Merely changing the name of the function will result in that code being run on an entirely different box. I’d like to see my old employer’s architecture try to manage even half that.