Strip newlines from terminal output

Every so often I will need to take some kind of key file - like a PGP key, SSH, OpenSSL, that kind of thing, and be able to paste it into a one-line text entry somewhere. Maybe a .env file, or shell script, or some piece of infrastructure that just accepts a text field as the input (like CI configuration)....

Inspect zip file contents

If you’ve got a large zipfile, or just a badly named one and you’d like to quickly take a peek at what’s inside it, there’s a handy flag that can be passed to the unzip utility (apt install unzip): unzip -vl path_to_zip.zip This yields an output like: [email protected]:/usr/src/app# unzip -vl spec/fixtures/example.zip Archive: spec/fixtures/example.zip Length Method Size Cmpr Date Time CRC-32...

See recipients of a GPG encrypted message

gpg --list-only $infile e.g. gpg --list-only test.txt.gpg This command outputs recipient info, including recipient key ID and details if known: With an empty keyring (no public keys imported): gpg: encrypted with RSA key, ID 70F28839 With a populated keyring (public key of recipient imported): gpg: encrypted with 4096-bit RSA key, ID 70F28839, created 2018-05-29 "Josh McArthur <[email protected]>"

Cool utilities I've discovered this weekend

bat bat is cat with syntax highlighting, but is still compatible with pipes, etc. Really neat. I like the filename header. Github: https://github.com/sharkdp/bat jira A CLI for Jira. Maybe it’ll be faster than using the web interace??? Regardless, it supports a fancy config loading system that looks like I can configure it as part of my tmux setup to pop...

UNIX find case insensitive

I use the find all the time to (unsurprisingly), find files or directories I’m looking for. I prefer it to any UI built into my OS (currently Ubuntu, but all OSes seem to have this kind of thing - Alfred/Spotlight/Start Menu etc), because I usually know roughly where I’m looking, and I can be declarative about what I’m looking for...

My favourite HTTP client

It’s 2019. I’m writing code that needs to communicate with other APIs all the time. The code I post below reflects a snapshot of my current template API client. If I need to commuicate with a third-party in Ruby, I’m using this class. require "ostruct" class MyApiClient class Error < StandardError; end def initialize(configuration=nil, stubs=nil) @configuration = configuration || Rails.application.config_for(:my_api)...

See full Rails application logs on Heroku

I recently had an issue on an application that was deployed to Heroku. I could see from the frontend that I was getting a 500 status code in response to my request, but when I took a look at the Heroku logs (using heroku logs), I saw a single line containing my request, but no other details: 2019-10-15T02:47:56.555551+00:00 heroku[router]: at=info...

Fancy Postgres indexes with ActiveRecord

Another day, another undocumented Rails feature! This time, it’s that ActiveRecord::Base.connection.add_index supports an undocumented option to pass a string argument as the value for ‘column’. This string is passed directly to the SQL statement, making it possible to use all sorts of fun things to lock down the constraint. It also means that you can make an index more declaratively...

Crossing technical and personal boundaries: New project nerves

A really interesting thought from Chris Toomey from Thoughtbot’s ‘The Bikeshed’ podcast, that really elegantly clarifies my own thinking on imposter syndrome, feelings of inadequacy, and the strive to deliver value to a broad range of contexts. The work we do is purposefully somewhat challenging. We’re coming into organistions to try and help them, most often at sort of an...

Ubuntu laptop backup strategy

I recently upgraded my laptop from a 2013 Macbook Pro to a Lenovo Thinkpad T480. It’s great. I switched around my Ctrl key to the Windows key (where the Command key would be on a Mac keyboard), and everything has pretty much been perfect. One thing that I did need to rethink was my backup strategy, which, on my Macbook...

I'm Josh McArthur, a web developer specializing in Ruby on Rails and Phoenix. I contribute code on GitHub and write blog posts about technology and hiking here.