Skip to content

Instantly share code, notes, and snippets.

View ducksoupdev's full-sized avatar

Matt Levy ducksoupdev

View GitHub Profile
@ducksoupdev
ducksoupdev / delete_old_branches.sh
Created March 22, 2023 14:42
Delete old branches
#!/bin/bash
# Set the age threshold in seconds (7 days)
age=$((7 * 24 * 60 * 60))
# Loop through all local branches
for branch in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
# Get the timestamp of the last commit on the branch
timestamp=$(git log -1 --format="%ct" "$branch")
@ducksoupdev
ducksoupdev / .bashrc
Last active August 17, 2022 12:18
Advanced Artefacts Bash Commands
alias alogin="aws sso login --profile advanced-artefacts"
alias aauth='eval $(adv-do-artefacts auth --profile advanced-artefacts)'
import { h } from '@ficusjs/renderers/jsx-dom'
import { createCustomElement } from 'ficusjs/custom-element'
createCustomElement('hello-world', {
render () {
return html`
<p>Hello world!</p>
`
}
})
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ducksoupdev
ducksoupdev / service-worker.js
Created February 19, 2021 09:53 — forked from revsmoke/service-worker.js
An example of a service worker for serving network first, cache second
// the cache version gets updated every time there is a new deployment
const CACHE_VERSION = 10;
const CURRENT_CACHE = `main-${CACHE_VERSION}`;
// these are the routes we are going to cache for offline support
const cacheFiles = ['/', '/about-me/', '/projects/', '/offline/'];
// on activation we clean up the previously registered service workers
self.addEventListener('activate', evt =>
evt.waitUntil(
import cryptoEs from 'https://cdn.skypack.dev/crypto-es'
const hash = cryptoEs.MD5("matt.levy@oneadvanced.com")
const img = document.querySelector('img')
img.src = `https://www.gravatar.com/avatar/${hash.toString()}`
@ducksoupdev
ducksoupdev / dom-tree-depth-level.js
Created December 18, 2019 06:20 — forked from JasonRammoray/dom-tree-depth-level.js
Get depth of a DOM tree with a list of nodes included into longest path
function getDomDepthLevel(root = document.documentElement) {
let pathInfo = {
route: [],
level: 0
};
for (let i = 0, j = root.children.length; i < j; i++) {
const curNodePathInfo = getDomDepthLevel(root.children[i]);
if (curNodePathInfo.level > pathInfo.level) {
pathInfo = curNodePathInfo;
}
#Delete local tags.
git tag -d $(git tag -l)
#Fetch remote tags.
git fetch
#Delete remote tags.
git push origin --delete $(git tag -l) # Pushing once should be faster than multiple times
#Delete local tags.
git tag -d $(git tag -l)
@ducksoupdev
ducksoupdev / service-worker-ghost-cms.js
Created July 25, 2019 09:04 — forked from mordka/service-worker-ghost-cms.js
Service Worker for Ghost CMS - ignore Ghost admin
const cacheName = 'blogCache';
const offlineUrl = '/offline/';
const adminPageSlug = '/ghost';
/**
* The event listener for the service worker installation
*/
self.addEventListener('install', event => {
event.waitUntil(
caches.open(cacheName)
FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" echo "%d" && rimraf "%d"