Skip to content

Instantly share code, notes, and snippets.

View ediblecode's full-sized avatar

Ian Routledge ediblecode

View GitHub Profile
@ediblecode
ediblecode / OrderedDeep.ts
Last active March 9, 2022 10:44
Recursively add a property in TypeScript
import { type Primitive } from "type-fest";
export type BuiltIns = Primitive | Date | RegExp;
/**
* Add's a numeric `order` property to all objects within arrays, recursively.
* Used for creating nodes from nested arrays when we want to keep the same order
* as the feed.
*
* Based on type-fest's `ReadonlyDeep`
@ediblecode
ediblecode / focus-visible.css
Created February 3, 2021 16:06
Progressively enhanced focus visible CSS
a,
button,
input {
&:focus {
/* More subtle style for older browsers */
outline: 1px dashed black;
}
&:focus:not(:focus-visible) {
outline: none;
}
@ediblecode
ediblecode / update-all-packages.sh
Created July 22, 2020 19:14
Update all npm packages to latest
npx npm-check-updates -u
@ediblecode
ediblecode / kill-chromedriver.bat
Created July 3, 2020 19:23
Kill all Chromedriver processes
# Run this in CMD
taskkill /im 2.43-x64-chromedriver /f
@ediblecode
ediblecode / octo-exe-.url.txt
Created June 19, 2020 15:50
Octo command line tools latest version
http://octopusdeploy.com/downloads/latest/CommandLineTools
@ediblecode
ediblecode / background-docker-pull.sh
Created June 18, 2020 20:22
Pull docker images in the background
# See https://github.com/moby/moby/issues/16106#issuecomment-310781836 for pulling images in parallel
# Nohup (no hang up) with trailing ampersand allows running the command in the background
# The </dev/null bits redirects the outputs to files rather than strout/err
nohup sh -c "echo selenium/hub:3.141.59-zirconium mcr.microsoft.com/dotnet/core/aspnet:3.1 | xargs -P10 -n1 docker pull" </dev/null >nohup.out 2>nohup.err &
@ediblecode
ediblecode / try-catch-finally.sh
Created June 12, 2020 08:38
Simple try/catch/finally in bash
#!/bin/bash
set -Ee
somethingThatWorks() {
echo "somethingThatWorks"
}
somethingThatErrors() {
echo "somethingThatErrors"
@ediblecode
ediblecode / slugify-pascal.js
Created May 7, 2020 10:38
Slugify a pascal cased string
"PrescribingInfo".replace(/(.+)([A-Z])/g, (s, p1, p2) => `${p1}-${p2}`)
@ediblecode
ediblecode / run-elastic.sh
Created February 6, 2020 15:59
Run ElasticSearch locally for NICE
docker run -d -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" -p 9200:9200 -v "/$(pwd)/ElasticConfiguration/synonyms.txt:/usr/share/elasticsearch/config/synonyms.txt" -v "/$(pwd)/ElasticConfiguration/stemmer_override.txt:/usr/share/elasticsearch/config/stemmer_override.txt" --name elasticsearch docker.elastic.co/elasticsearch/elasticsearch:6.5.2
@ediblecode
ediblecode / 9pm-every-week-day
Last active January 28, 2020 20:43
Cron 9pm every week day
0 21 * * 1-5