It’s Boulder Startup Week. With so many tech startups in town, there a lot of focus on code and coders. How do you become a developer? What developer career paths are there? Where do I find work? Etc. Etc.

Coincidentally, my mom, who is pruning, sent me a copy of a letter I wrote, more than 30 years ago now, when I was applying to colleges. It I describe how I first learned to program. I had forgotten this story, but I think it’s relevant and worth sharing.

A couple of posts back, I showed off some functions to pop up notifications when a host became pingable again or when a port became reachable. Today’s (semi) quick tip is how to use BASH’s autocomplete functionality add hostname autocompletion to those notifications functions.

BASH autocompletion is a system that provides tab completion of command arguments. You’re familiar with it’s default behavior which is to complete filenames and paths.

1
2
3
4
~ ls enctypt<TAB>
encrypt              encrypt-only-sym.rb  encrypt-time.rb
encrypt-decrypt.rb   encrypt-sym.rb       encrypt.rb
~  ls encrypt

You can override this behavior by providing BASH with a list of possible completions. The list can be a literal list of words, or it can be a function that looks at the current environment ($PWD, user, time on day, etc) and generates context aware list.

OK, so you know how to get data into AWS S3, what about getting it out? Previously, we uploaded entries from an imagined photo contest into a bucket. We sent a pair of files, a JSON file with the form data and the image. Let’s presume there’s a Rails app, it’s details don’t matter, but it has a model ContestEntry and we want to populate it from the S3 data. We’re going to write a script to do the import.

dd is the *NIX byte copying utility. It’s typically used for copying disks, creating disk images, or initializing disks from images. It can also be using to recover damaged files that can’t otherwise be copied. I mostly use it to make create bootable USB sticks for server installs. However, it’s also pretty opaque.

Previously, I covered uploading to S3 from a Rails app using a presigned-url. This works just fine, but means the data flows from the visitors computer to your server before heading to S3. I’ve previously showed how to upload the file directly to S3, which requires a world-writable bucket.

There’s also a hybrid solution that has the server generate a presigned-url which the browser then uses to go direct to S3, allowing the data to bypass the server. Let’s look at two ways to do this.