At the dayjob, we do payments, both credit card and bank transfers. Over the years, I’ve done over a dozen integrations to support the banks our customers use, using a mix of HTTP and SFTP. The latest one we had was working with a bank that used an HTTP API to submit transactions, but was extremely picky about how the request was made. We needed to make an HTTP call with: a custom Authorization…
Recently at work we passed a major milestone on our codebase, and I wanted to see if I could run some analysis over time on authorship and see how long some early contributors’ work stuck around in the product. A bit of experimentation and random googling left me with these three scripts. The first is dig.sh , which will accept the path to the git repository to analyze (because I’m making a few…
Today at work, I determined that my current work in progress branch was going to want to be merged into production ahead of our next scheduled merge/deploy of master. To make it easier to merge into our production branch for a hot-fix deploy, I want to have the branch based off production instead of master. So, I could do this manually: 1 2 3 4 5 6 7 $ git reset HEAD~ # move HEAD commit back to…
I was needing to do some object cleanup in our rails app the other day, and purge some malformed objects, so I put together a quick script using some ActiveRecord reflection to walk the object chain. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 # Squelch SQL logs, if you're running from rails console ActiveRecord ::…
Update 2023: Just use direnv with layout ruby . Bundler is pretty darn good. Installing all your gems globally sucks. bundle install --path does a great job of fixing that but it means you need to bundle exec any shell commands you want to run, which again sucks. There are lots of attempts to fix this , but they’re all fairly convoluted. I’m a fan of simpler solutions wherever possible. I use zsh…
At work, we provide an API for our app and maintain web-based documentation for said API. We originally had the documentation in a separate git repo, but as it makes much more sense to maintain the docs directly alongside the code it documents we wanted to merge the two repositories. This was done in two steps. Moving files First, we need to prep the docs repo such that the content is in a…
The Problem: You have a database column with some data serialzed as JSON in it that you’d like to pull out into its own column to index it. The Solution: Run a data migration to pull the value out. Table has 5 million rows and you don’t want to round trip all that data through ActiveRecord? Just parse the json directly with some SQL: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24…
Rails 3 is now very friendly with regards to dropping Bundler support, only loading it if it’s installed and a Gemfile exists. Since Isolate is so awesome, I thought I’d just drop a quick script in here to convert an existing Rails app to use Isolate instead of Bundler. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #!/usr/bin/env ruby require 'fileutils' File . open (…
In changing this blog over to jekyll, my urls changed (there’s now a trailing slash). Easy enough to tell google about it, just set up redirects, but there’s no easy way to tell Disqus about it so my comments migrate over. The good news is that it’s pretty straightforward using their API, the only bad news is that I can’t delete the new threads auto-generated for the new urls, so I’m just moving…
The base install of Jekyll at the moment doesn’t let you run any arbitrary ruby code. This is so that they can use it for github pages and not need to worry about making a super-secure sandbox just to generate some HTML. Unfortunately, that means we’re out of luck for creating custom liquid filters. The most annoying deficiency for me is tags. The way the default liquid map filter works isn’t…