Bits and Blocks

Serving Localhost to the Web with Reverse Ssh Tunnels

2 minute read Published:

So, you have a webpage on your computer you want to show to a remote person?
Note: If you don’t have a server already, check my last tip. This topic is always a little tricky, so, here’s the basic thing to know, as this is the most frequent use case. Suppose you have a development rails server running on your local computer. You can access this server via curl http://localhost:3000. Which is to say, it’s running on your localhost, on port 3000. You want your client to see it, to give you feedback, but they’re nowhere near you, and you just want a quick way to show it to them.

Saving Time With Tmux

3 minute read Published:

How I use tmux in my workflow to make my life better.
What is a terminal multiplexer, and why do I care? When you split up a terminal screen into sub-terminals, that’s called terminal multiplexing. This is nothing new, GNU Screen has been around since 1987. Tmux is just screen’s younger, nubile cousin. I’m about to explain how this simple technology can: Keep you organized. Lower the bar to get to work. Save you time. Enable teamwork. Here’s a quick demonstration:

Exporting A Zone File From Mediatemple

1 minute read Published:

How to get DNS info out of MediaTemple
I was in the process of moving my DNS from MediaTemple to Route53 and was having trouble making sure I’d moved all of the entries. I decided I’d just export a zone file to do a comparison in a text editor. Surprise! You can’t. Instead, here’s a quick bit of jQuery, which is already available in the MediaTemple control panel. Just navigate to the zone file editor, open your console, and use this:

Reducing The Size Of Alpine Docker Images

1 minute read Published:

Why the heck is my alpine docker image so huge? That’s a tough question to answer, especially when you have no idea what’s taking up all of the space. This is a dirty little one-liner that yields a sorted list of all of the packages on your alpine image by size. It does this by Getting the complete list from apk info Iterating over the results to ask apk for its size Removing the blank lines Combining the size lines and the name lines Sorting by size apk info | while read a; do apk info -s $a; done | awk NF | sed 'Ns/\n/ /' | sort -k4 -n It may be ugly, but now I can make an informed decision about wether or not there are binaries that can be axed.

What Process Is Hogging My Port On Mac Os

1 minute read Published:

Address already in use Damn. Did I leave a server running somewhere? Sometimes you’re not sure where you left a server running, or where something is running you never knew about. I’m finally writing this down, as I always have to look it up. I found this solution in a StackOverflow post. Here’s how to get all of the processes by what port they’re using. sudo lsof -iTCP -sTCP:LISTEN -n -P As A Shell Function Looking at it, I realized I would never remember it, given how infrequently I need it.

Why Choose Vim

3 minute read Published:

TLDR Choosing a text editor is a very personal decision. You grow with your editor, as your editor grows with you. As I use my text editor more and more over the years, I’m constantly constantly learning new techniques for working more efficiently. Some of them stick, others are forgotten. I find that sequences and shortcuts that I most use stay. But just as importantly VIM accommodates my changing needs through configuration, plugin, or otherwise.

A Single Singleton in Ruby

4 minute read Published:

What is a singleton anyway?
The singleton design pattern I’m relatively new the the concept of the singleton, even though I’ve been programming for a number of years. I’ve run into several instances in which I new that this was exactly what I needed, but did not have a name for it. Here, I’m going to try to explain it to myself a year ago. There are a few questions I’ll try to address.

The Mysteries of the Ruby Heredoc

4 minute read Published:

A few tips on the ruby heredoc.
As of writing this, I’m running Ruby version 2.3.0. Not all of this, particularly the stripped heredoc, is available in plain ruby before 2.3.0. Heredoc Basics So, you need a string that’s longer than a line, and you’re sick of quotes and backslashes? And you might like to retain formatting? You want string interpolation too? Enter, heredoc. Here’s your basic, run of the mill, heredoc. You’ll notice we use the <<- operator, and our safe-word, which we will use to end the heredoc.