Skip to content

Instantly share code, notes, and snippets.

View jeremystretch's full-sized avatar

Jeremy Stretch jeremystretch

View GitHub Profile
from django.db.models import OuterRef, Subquery
from dcim import models
# Map each denormalized field to its "source" field on the parent device
device_component_fields = {
'_site': 'site',
'_location': 'location',
'_rack': 'rack',
}
@jeremystretch
jeremystretch / copy_repo_labels
Created June 30, 2025 17:43
Copy GitHub issue labels from one repository to another
gh api repos/$ORGANIZATION/$SOURCE_REPO/labels --paginate > labels.json
jq -c '.[]' labels.json | while read -r label; do
name=$(echo "$label" | jq -r '.name')
color=$(echo "$label" | jq -r '.color')
description=$(echo "$label" | jq -r '.description')
gh api repos$ORGANIZATION/$TARGET_REPO/labels -f name="$name" -f color="$color" -f description="$description"
done
@jeremystretch
jeremystretch / github_notifications_fix.md
Created June 12, 2024 14:11
Mark GitHub notifications as read

I've needed to do this several times to combat "ghost" notifications. These occur when a discussion is created and then deleted (e.g. for spam) before the notofication is read. You may see something like "1-0 of 4" at the bottom of the notifications page.

You can use the GitHub API client to show these notifications:

gh api notifications

To mark all notifications as read, send the API request below with curl. (Update the last_read date as needed.)

@jeremystretch
jeremystretch / firefox_colors.md
Last active December 16, 2022 18:24
Custom Firefox colors

A quick guide on color-coding multiple Firefox profiles.

  1. Open about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to True.
  2. Within the Firefox profile directory, create a new directory named chrome.
  3. Within the chrome directory, create userChrome.css with the following content:
#tabbrowser-tabs {
    background-color: $COLOR !important;
}