Skip to content

Instantly share code, notes, and snippets.

View sterlingwes's full-sized avatar
🍉

Wes Johnson sterlingwes

🍉
View GitHub Profile
@sterlingwes
sterlingwes / README.md
Created October 8, 2019 17:57
Generate SSH public key fingerprint (github key check)

Useful for comparing the fingerprint shown by github at https://github.com/settings/keys against the public key on your machine to see whether it's a match:

ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub

This lists the MD5 fingerprint

Source

@sterlingwes
sterlingwes / README.md
Created October 13, 2019 14:42
Viewing deleted files on unix that are still open (lost disk space)

lsof -nP | grep '(deleted)'

@sterlingwes
sterlingwes / injected.snippet.js
Created January 3, 2016 21:06
Squarespace Parse Query String and Prefill Email Field in Contact Form
function parseSearchString () {
var qs = window.location.search
qs = qs.replace(/^\?/,'')
var parts = qs.split('&')
var params = {}
parts.forEach(function (part) {
var pair = part.split('=')
params[pair[0]] = decodeURIComponent(pair[1])
})
return params
@sterlingwes
sterlingwes / README.md
Last active January 20, 2021 12:55
Debugging a third party gradle plugin

A third party Gradle plugin can be difficult to debug. In my case, I couldn't figure out why an input in my build.gradle file wasn't causing the plugin to add a desired task to a build. It's also not straightforward to inspect the source code of a plugin that arrives prebuilt. Fortunately if the plugin is open source, you can breakpoint in the source.

This thread forms the basis of these steps:

  • clone the source code for the plugin, and checkout the commit or version tag reflecting the version of the plugin you want to debug
  • open the repo in IntelliJ IDEA / Android Studio and allow gradle to sync
  • create a run configuration, selecting Attach to Remote JVM
  • make your breakpoints in the source code
  • in the project with the gradle build you want to debug, run ./gradlew --no-daemon -Dorg.gradle.debug=true app:uploadBugsnagReleaseSourceMaps, gradle will wait for a debugger to attach
  • back in the source code repo for the plug
@sterlingwes
sterlingwes / Resuable Github Action.md
Last active August 16, 2022 18:37
Reusable Github Action Steps (Local Composite Action)

Crafting a Reusable Github Action

The documentation for this common use case is sorely lacking...

Why this was needed:

  • I had a bunch of CI jobs (lint, test, type checking) that I wanted to run as separate jobs but share the same common steps for running checkout & dependency install

File structure

@sterlingwes
sterlingwes / reading_netcdf.md
Last active July 1, 2023 14:14
Reading specific data from a NetCDF file

My Goal

I have a NetCDF I downloaded from firesmoke.ca (Bluesky Canadian Wildfire Smoke Forecasting System) and I wanted to retrieve the PM 2.5 value fo a given geo coordinate or nearest lat / lon.

Exploration Notes

The NetCDF file can't be opened as a textfile as it's a binary format but there's a few tools I used to inspect the data model inside:

@sterlingwes
sterlingwes / tourney.html
Created December 3, 2012 23:42
Tournament Bracket Generator (Javascript + CSS, no tables)
<!DOCTYPE html>
<html>
<head>
<title>Tournament Bracket Generator</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
$(document).on('ready', function() {
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes)
@sterlingwes
sterlingwes / README.md
Created August 14, 2023 21:23
Script for diffing code asset change for lambda function from AWS CDK diff

Written in typescript and can be run with ts-node. You'll also need colordiff (brew install colordiff). Assumes much about the cdk.out file structure and CLI output format which may certainly change. This should give you two prompts: one for your environment (and the stack to run the diff for), and one showing you a list of lambda functions where assets have changed for which you can run a colordiff.

Replace the inline stack names, in this case mine are BackgroundJobsStackStaging and one for prod.

Useful for understanding the impact of deploying bundled code when it's changed. In my case, my lambda code bundles share common code with my API so it can change quite often with no impact on the lambda itself necessarily.

@sterlingwes
sterlingwes / README.md
Created August 24, 2023 21:42
Prevent imports from barrel files (index js / ts)

In my case I wanted to avoid importing unused modules into a built JS bundle for a lambda environment using a shared codebase. Using a nested eslint file I could prevent this kind of import: import {ModelA, ModelB} from 'src/models' and instead encourage this kind of import: import {ModelA} from 'src/models/model-a'

{
  "rules": {
    "no-restricted-imports": [
      "error",
      {
        // prevent barrel file imports to have more control over what ends up in the js bundle
 "patterns": ["src/models", "!src/models/"]
@sterlingwes
sterlingwes / README.md
Created January 31, 2016 02:05
Converting a scanned PDF to EPUB ebook (or other format)

Caveat

You're not going to get a beautiful EPUB out the other end - if that's what you're looking for, expect to do some manual clean-up work yourself.

Basic order of operations:

  • Convert your PDF to an OCR-friendly format
  • OCR that shit into plaintext
  • Convert that plaintext into your format of choice (in this case, an EPUB)