When Shane Makes Bread


Regular Expression Lookarounds

Let’s keep this simple.

  • (?=pattern) positive lookahead
  • (?!pattern) negative lookahead
  • (?<=pattern) positive lookbehind
  • (?<!pattern) negative lookbehind

Lookarounds can be nested, and lookbehinds can generally only be of a fixed length.

Where available, you can use lookarounds with grep -P. The -o flag will only output the match, instead of the full matching line.

That’s all.

Sublime Text Plugins

I use several plugins every day in Sublime Text 3 that I’ve grown very used to having, and now find I couldn’t work without them. I last updated this post on April 21, 2016.

  • Package Control
    • This one is essential for any Sublime Text user, and makes installing other plugins very simple and fast.
  • Git, SidebarGit, or SublimeGit (commercial) from Package Control
    • All can be used together, or just pick the one you prefer
  • GitGutter
  • SublimeLinter - I use these sub-plugins:
    • SublimeLinter-php
    • SublimeLinter-jshint (Requires Node.js, npm install -g jshint)
  • DocBlockr
  • Markdown Preview
  • XDebug Client

Code formatting is also nice sometimes, these are great for that:

  • HTML-CSS-JS Prettify
  • Indent XML
  • JsFormat

And if you’re using languages not natively supported by Sublime, here are some great packages:

  • SCSS
  • LESS
  • INI
  • ApacheConf.tmLanguage

I use the Soda Dark theme, installable via Package Control, with a modified Monokai color scheme that increases the contrast.

Here’s my User Preferences file, with the parts requiring custom packages removed:

    "auto_complete_commit_on_tab": true,
    "auto_find_in_selection": true,
    "auto_match_enabled": true,
    "copy_with_empty_selection": true,
    "default_line_ending": "unix",
    "ensure_newline_at_eof_on_save": true,
    "font_face": "Menlo",
    "font_options": [
    "font_size": 9,
    "highlight_line": true,
    "highlight_modified_tabs": true,
    "ignored_packages": [
    "save_on_focus_lost": true,
    "shift_tab_unindent": true,
    "show_encoding": true,
    "show_full_path": true,
    "trim_trailing_white_space_on_save": true,
    "word_wrap": true

This used to, but no longer includes my absolute favorite code font, ProFont, designed to be incredibly readable at small sizes. Use ProFontIIx if you’re on Mac, it’s beautiful. I’ve since switched to Menlo, because I’m working longer days and can’t focus on tiny text that long anymore :(

Also note the save_on_focus_lost option, which does exactly what it says it will.

I also have custom hotkeys for SublimeGit commands, which I have bound to G-keys on my Logitech keyboards, as well as re-bindings of Ctrl+Tab and Ctrl+Shift+Tab that make more sense to me.

Windows keymap:

    { "keys": ["ctrl+,"], "command": "open_file", "args": {"file": "$packages/User/Preferences.sublime-settings"} },
    { "keys": ["ctrl+alt+p"], "command": "prompt_select_workspace" },
    { "keys": ["ctrl+k", "ctrl+m"], "command": "toggle_minimap" },
    { "keys": ["ctrl+tab"], "command": "next_view" },
    { "keys": ["ctrl+shift+tab"], "command": "prev_view" },

    { "keys": ["ctrl+shift+g", "l"], "command": "git_pull" },
    { "keys": ["ctrl+shift+g", "p"], "command": "git_push" },
    { "keys": ["ctrl+shift+g", "a"], "command": "git_add_current_file" },
    { "keys": ["ctrl+shift+g", "s"], "command": "git_status" }

OS X keymap, including adjustments to Home and End keys:

    { "keys": ["super+k", "super+m"], "command": "toggle_minimap" },
    { "keys": ["super+tab"], "command": "next_view" },
    { "keys": ["super+shift+tab"], "command": "prev_view" },

    { "keys": ["super+shift+g", "l"], "command": "git_pull" },
    { "keys": ["super+shift+g", "p"], "command": "git_push" },
    { "keys": ["super+shift+g", "a"], "command": "git_add_current_file" },
    { "keys": ["super+shift+g", "s"], "command": "git_status" },

    { "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
    { "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
    { "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} },
    { "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } },
    { "keys": ["super+home"], "command": "move_to", "args": {"to": "bof"} },
    { "keys": ["super+end"], "command": "move_to", "args": {"to": "eof"} },
    { "keys": ["super+shift+home"], "command": "move_to", "args": {"to": "bof", "extend": true} },
    { "keys": ["super+shift+end"], "command": "move_to", "args": {"to": "eof", "extend": true} }

Programming described accurately

The human brain isn’t particularly good at basic logic and now there’s a whole career in doing nothing but really, really complex logic

You immerse yourself in a world of total meaninglessness where all that matters is a little series of numbers bent into a giant labyrinth of symbols and a different series of numbers or a picture of a kitten came out the other end.

Source: Programming Sucks, an essay on the amazing Still Drinking website by Peter Welch.

Fire TV Fun

The Amazon Fire TV is an amazing device. The current app selection might be disappointing, but with a little effort you can get just about any Android app working beautifully on a Fire TV, and some apps designed for tablets feel like they were truly made to be on a TV.

This is basically my guide to everything Fire TV.

The first thing to note is that the Fire TV is compatible with most USB keyboard and mice, but only has a single USB port, so it’s best to have a keyboard and mouse that use a single wireless dongle. The Logitech unifying ones work great for me.

Keyboard/Mouse Usage

The mouse has a pretty simple function, acting as a pointer to use apps as if you had a touch screen, with the primary mouse button acting as a tap/drag. The scroll wheel also works well in most applications, and is particularly nice in web browsers.

The keyboard works pretty much as you’d expect, with a few important things to note:

  • F12 acts as the Home button
  • Tab is the same as the Play/Pause button on the remote
  • Alt+Tab opens the Recent Apps overlay for quickly switching applications

Don’t touch the volume keys. If you do, you might need to install a volume control app with ADB to get your sound back.

Installing Apps

Unlike a Chromecast, Apple TV, or Roku, the Fire TV is left very open, with ADB over the local network easily enabled from Settings. ADB allows you to access the filesystem and install applications from APK packages, which can be extracted from other Android devices or found the app developer’s website.

Install ADB and add it to your path, there are tons of guides for this, so I won’t detail it here. Next, find your Fire TV’s IP address in Settings > System > About > Network. You can then connect to your Fire TV by running the following commands:

  • adb connect <ip address> Connects ADB to your Fire TV
  • adb install <apk filename> Installs the specified application
  • adb shell Opens an interactive shell on the Fire TV (Advanced users)

Applications installed through ADB won’t be shown on the launcher, but are accessible through Settings > Applications.

These are the apps I’ve tried that work well:

Awesome apps that work all right, but have some broken features:

  • Play Music
  • …I’ll add more later as I test them

I also tried installing the stock Play Store app, but it has a lot of other requirements that I wasn’t willing to take the time to find. When launching the app without those requirements, it crashes, then causes the Fire TV to do a hard reboot. Not exactly usable. :P


A photo of my Fire TV running CPU-Z, showing some system specs: CPU-Z Photo

My personal favorite App on my Fire TV so far, Microsoft Remote Desktop: Microsoft Remote Desktop Amazingly, the keyboard works almost seamlessly on Remote Desktop, and as long as your LAN is fast enough, it works great for streaming media that isn’t supported another way.

Once the Fire TV is a bit easier to root, I’ll probably write a thorough guide on that, and the things you can do after rooting, because seriously these things are just awesome.

If I’m missing something or something is incorrect, please let me know, I’m @alanaktion on Twitter.