Skip to content

Instantly share code, notes, and snippets.

View earnubs's full-sized avatar

Stephen Stewart earnubs

View GitHub Profile
@earnubs
earnubs / docker.sh
Created July 3, 2024 09:37
Bash trap and cleanup Docker
#!/usr/bin/env bash
set -xeuo pipefail
# Docker use is only as an example, this is just to demonstrate cleanup
function cleanup()
{
echo "Removing containers..."
docker rm -f echo
}
#!/usr/bin/env bash
#
###
# Creates a stacked set of upgrade branches from outdated npm modules
# - use on major version upgrades (use `npm update` for minor)
###
set -e
git_stuff() {
diff --git a/packages/shared/compile-template.js b/packages/shared/compile-template.js
index f505702..8ace3db 100644
--- a/packages/shared/compile-template.js
+++ b/packages/shared/compile-template.js
@@ -17,6 +17,18 @@ export function compileFromString(str: string) {
export function compileTemplate(component: Component): void {
if (component.template) {
+ if (component.template.charAt('#') === '#') {
+ var el = document.querySelector(component.template);
@earnubs
earnubs / cheatsheet.md
Last active May 29, 2019 10:17
jq notes

Find minimum in array of things:

$ cat gitlab.json | jq '.locationFactors | min_by(.locationFactor)'

Sort by value, reverse:

$ cat gitlab.json | jq '.locationFactors | sort_by(.locationFactor) | reverse

//(0b001 << 0b010).toString(2)
const isBuilding = 0b001;
const hasFinished = 0b010;
const hasFailed = 0b100;
let combinedBuildState = 0b000;
combinedBuildState = combinedBuildState | isBuilding;
const callApi = () => {
const response = fetch(...);
// do stuff with response
return response;
}
try {
yarn list --json | jq '.data.trees[] | select(.name | contains("caniuse-lite"))'
cat charts.json | jq -r '.data[].attributes | [.name, .home, .description] | @csv' | sed 's/"//g' | awk -F, '{ printf "\n%s (%s)\n%s\n",$1,$2,$3}'
@earnubs
earnubs / index.js
Created March 29, 2019 20:31
date-fns, days of month
const df = require('date-fns');
const today = Date.now();
const tomorrow = df.addDays(today, 1);
function getWorkDaysInMonth(day) {
return df.eachDay(df.startOfMonth(day), df.endOfMonth(day))
.filter(date => !df.isWeekend(date))
.map(date => df.format(date, 'ddd Do'));
}
@earnubs
earnubs / docker-ip.js
Created February 5, 2019 10:18
use dockerode to get container ip address
const Docker = require('dockerode');
const fs = require('fs');
const socket = process.env.DOCKER_SOCKET || '/var/run/docker.sock';
const stats = fs.statSync(socket);
if (!stats.isSocket()) {
throw new Error('Are you sure the docker is running?');
}
@earnubs
earnubs / Brewfile
Last active May 20, 2019 11:29
Bitnami setup
tap "bazelbuild/tap"
tap "codekitchen/dinghy"
tap "datawire/blackbird"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
cask "osxfuse"
brew "automake"