Skip to content

Instantly share code, notes, and snippets.

View M1ke's full-sized avatar

Mike Lehan M1ke

View GitHub Profile
@M1ke
M1ke / markdown-to-github-pdf.sh
Created July 15, 2021 11:39
Simple command line tool using python's grip library and wkhtmltopdf to generate a PDF file from a Markdown file. Basically starts a server, captures it as a PDF and then kills the server (that's the complex bit!)
#!/bin/bash
# Install grip $ pip install grip
# Install wkhtmltopdf $ sudo apt-get install wkhtmltopdf
md=$1
pdf=$md.pdf
port=$(( ( RANDOM % 6000 ) + 5000 ))
echo $port
@M1ke
M1ke / bitbucket-pipelines.yml
Created February 14, 2022 17:49
Composer update pipeline in Bitbucket
pipelines:
# Manually triggered Pipelines
custom:
composer-update:
- step:
name: Composer Update
image: prooph/composer:<pick your version, e.g 7.4>
script:
- export COMPOSER_BRANCH="composer-update-auto-$(date +"%Y-%m-%d")"
- git checkout -b "$COMPOSER_BRANCH"
@M1ke
M1ke / psalm-query.php
Created April 27, 2022 15:06
This tool processes a SQL query and generates a guess at an appropriate Psalm object-like array definition
<?php
const PSALM_STRING = ': string';
const SELECT_ALL = '*';
// These must be upper case to avoid accidental positives
const SQL_SELECT = 'SELECT';
const SQL_FROM = 'FROM';
const ARG_DEBUG = '--debug';
// This is lower case as the field names are forced to lower case
const SQL_AS = ' as ';
@M1ke
M1ke / apigw-express.ts
Created September 21, 2022 10:46
Quick helper functions when testing local serverless applications (Typescript + AWS Lambda) to translate `express` req/res objects into the appropriate types for API Gateway
const apiGWEventFromReq = (req: Request): APIGatewayEvent => {
const [headers, multiValueHeaders] = Object.keys(req.headers).reduce((parts, key) => {
const val = req.headers[key]
if (!val) {
return parts
}
const [headers, multiValueHeaders] = parts
if (Array.isArray(val)) {
multiValueHeaders[key] = val;
} else {
@M1ke
M1ke / .jq
Created February 12, 2024 20:35
~/.jq for handy jq pipes
# https://stackoverflow.com/a/28641626/518703
def decode_ddb:
def _sprop($key): select(keys == [$key])[$key]; # single property objects only
((objects | { value: _sprop("S") }) # string (from string)
// (objects | { value: _sprop("NULL") | null }) # null (from boolean)
// (objects | { value: _sprop("B") }) # blob (from string)
// (objects | { value: _sprop("N") | tonumber }) # number (from string)
// (objects | { value: _sprop("BOOL") }) # boolean (from boolean)
// (objects | { value: _sprop("M") | map_values(decode_ddb) }) # map (from object)
// (objects | { value: _sprop("L") | map(decode_ddb) }) # list (from encoded array)
@M1ke
M1ke / tech-debt.md
Created February 7, 2025 16:51
My notes on the "Tech Debt" roundtable discussion at Branch, a CTO & engineering leader group in Manchester

Branch: Tech debt

Poor quality notes, by Mike

This is some notes I took during our discussion; at the start I did try to attribute names to quotes, but as it went on a) people interjected more and it was harder to give direct attribution and b) I got a few peoples' names confused early on and that messed the rest up!

We began with the question of "define technical debt" and in fact this was the only question Dave really got to ask, as our discussion progressed naturally from trying to define it to trying to identify causes.

A few early point were made:

  • Measured decision, understand the interest rate. "Different kinds of debt need different kinds of remedies"