Skip to content

Instantly share code, notes, and snippets.

🦆 🦆 🦆 🦆

Henrik Nyh henrik

🦆 🦆 🦆 🦆
View GitHub Profile
henrik /
Last active Sep 16, 2021
Notes from running Dokku on Digital Ocean.

My notes for Dokku on Digital Ocean.

These may be a bit outdated: Since I originally wrote them, I've reinstalled on a newer Dokku and may not have updated every section below.


Install dokku-cli (gem install dokku-cli) for a more Heroku-like CLI experience (dokku config:set FOO=bar).

# List/run commands when not on Dokku server (assuming a "henroku" ~/.ssh/config alias)
ssh henroku dokku
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:


start new with session name:

henrik / hash_deep_diff.rb
Created Jul 14, 2009
Recursively diff two Ruby hashes.
View hash_deep_diff.rb
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <> 2009-07-14 under the MIT license.
# Example:
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
henrik / ocr.markdown
Created Mar 3, 2012
OCR on OS X with tesseract
View ocr.markdown

Install ImageMagick for image conversion:

brew install imagemagick

Install tesseract for OCR:

brew install tesseract --all-languages

Or install without --all-languages and install them manually as needed.

henrik /
Created Apr 6, 2016
"Self-assigned IP" error with TP-link and Sky on OS X. #googlefood
henrik / will_paginate.rb
Created Sep 13, 2011 — forked from isaacbowen/will_paginate.rb
Extends will_paginate to play well with Twitter's Bootstrap ( Suggested location: config/initializers/will_paginate.rb
View will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
class BootstrapLinkRenderer < LinkRenderer
henrik / gist_search.rb
Created Jan 10, 2011
Search your own public Gists from the command line. Because the site only provides global search. There's not yet an API for private Gists.
View gist_search.rb
require "open-uri"
require "rubygems"
require "json"
USERNAME = "henrik"
query = ARGV.first.downcase
gists = JSON.parse(open("{USERNAME}").read)['gists']
henrik /
Last active Aug 6, 2021
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript:
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

henrik / google_art_project.rb
Created Feb 5, 2011
I'M AFRAID THIS SCRIPT NO LONGER WORKS! MAYBE OR DOES. SEE COMMENTS. Google Art Project fullsize image downloader. Specify the page URL and the tiles are downloaded, stitched and trimmed.
View google_art_project.rb
# Google Art Project fullsize image downloader.
# By Henrik Nyh <> 2011-02-05 under the MIT license.
# Requires Ruby and ImageMagick.
# I'm afraid this script no longer works! See the Gist comments.
# Usage e.g.:
# ruby google_art_project.rb
henrik /
Last active Jul 4, 2021
Automatically launch Cuphead (from Steam) on a Mac when a Nimbus Bluetooth game controller is connected.

The only game I play on the Mac Mini connected to our TV is Cuphead.

I wanted the game to launch automatically when I turn on one of our Nimbus game controllers, which connect via Bluetooth.

This is how:

  • Save the .scpt file below as e.g. ~/Library/Scripts/LaunchCupheadIfControllerIsConnected.scpt
    • In the .scpt, change "Nimbus" if your Bluetooth game controllers have some other name.
  • Save the .plist below as e.g. ~/Library/LaunchAgents/henrik.launch_cuphead_if_controller_is_connected.plist
    • In the .plist, change media to whatever your username is.