Skip to content

Instantly share code, notes, and snippets.

View djm's full-sized avatar

Darian Moody djm

View GitHub Profile
@djm
djm / .envrc
Created September 20, 2022 23:17
YunoJuno Nix Developer Environment
export OP_ACCOUNT=yunojuno.1password.com
# Create .env.local if it does not exist
if [ ! -f .env.local ]
then
echo "Creating .env.local"
cat <<EOF > .env.local
# Place secret env variables from 1Password and custom overrides here
#
# Any variables here will override ones set in .env.native.dist
@djm
djm / AuthorizerConfigurationException-problem.txt
Last active October 13, 2023 00:22
Fix for AWS API Gateway Custom Authorizer Error => AuthorizerConfigurationException (message: null)
Problem: you've created a Custom Authorizer Lambda and have hooked it up with Amazon AWS's API Gateway.
But now all of your responses return the following HTTP response with the "AuthorizerConfigurationException"
and your Cloudwatch logs for your Authorizer function are next to useless..
-----
HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Content-Length: 16
Content-Type: application/json
@djm
djm / workflow.yml
Created January 9, 2021 18:28
Problem: pulling docker images with dynamically generated tags, using just the GitHub Action yaml syntax
name: Build Docker image & run dependent jobs that pull tagged image
# Desires:
#
# 1) First job builds, pushes and tags docker image with ref/pr-number/sha - something specific to that branch.
# 2) n-jobs after this depend on success of first job, and will pull an image based on tag used in first job.
# 3) The n-jobs mount host GA workspace, or checkout code within the container itself. Not bothered which.
# 4) Rely on GitHub Action's yaml docker constructs only, rather than calling docker @ the cli
# This is not a _true_ requirement! I know how to get around it, but it is what I originally
# set out hoping to do - because it works very nicely when you're dealing with static tags
@djm
djm / README.md
Last active March 16, 2023 04:02
Create a Chrome GitHub Repo Search Shortcut
@djm
djm / letting_agent.py
Created January 19, 2023 18:34 — forked from AndrewIngram/letting_agent.py
Django Queryset capabilites example
"""
This snippet will return all the letting agents, bucket into discrete bands based on distance from
an origin point (for example, the user's current location), then sorted alphabetically within each
bend. The goal being to prioritise agents in close proximity, but not execessively so -- all agents
within the same band should be given equal distance-related priority.
If there's a search term, we then boost the distance score based on the name's similiarity to the
search query.
"""
qs = LettingAgentLocation.objects.select_related("agent").filter(postcode__isnull=False)
@djm
djm / itunes-to-feed-url-bookmarklet.js
Created April 22, 2012 17:05
Bookmarklet: Convert iTunes Store Podcast URL into actual feed URL
(function() {
/* Bookmarklet that displays the actual podcast feed
* URL when ran on an iTunes store page for a podcast.
*
* Simply grabs the Artist ID from the URL and does
* an iTunes Store API lookup to get the hidden (original)
* podcast feed URL (whatever format that may be in).
*
* @author: Darian Moody <mail@djm.org.uk>
* @date: Working as of Sun.22.Apr.2012
@djm
djm / migrate.py
Created July 4, 2022 17:38 — forked from bennylope/migrate.py
PostgreSQL migration script, Heroku -> Crunchy
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
import time
# Required so we don't generate tons of logs during restore
disable_logging_sql = "ALTER USER postgres RESET pgaudit.log;"
@djm
djm / gym.py
Created September 28, 2021 20:17 — forked from Alir3z4/gym.py
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@djm
djm / 1.tailwindUnderlineColor.js
Last active September 20, 2021 20:21
Underline Color Utilities Plugin for Tailwind (v1.2.0)
const plugin = require('tailwindcss/plugin')
/*
Creates colored underline utility classes.
Explanation: https://css-tricks.com/almanac/properties/t/text-decoration-color/
Browser Support: https://caniuse.com/#search=text-decoration-color
e.g
@djm
djm / cuid.sql
Created June 3, 2021 15:17 — forked from srfrog/cuid.sql
CUIDs for PL/PgSQL
-- Collision-resistant ids optimized for horizontal scaling and performance, for PL/PgSQL.
-- Based on https://github.com/ericelliott/cuid
-- Version 1.0.0
-- Usage: SELECT cuid();
-- BEGIN CONFIG ---
-- Put a unique host ID (int) here per server instance.
-- Once set, this value should not be changed.