Skip to content

Instantly share code, notes, and snippets.

View adamghill's full-sized avatar

Adam Hill adamghill

View GitHub Profile
<!--
Just playing around with https://github.com/hawkticehurst/stellar/blob/vnext/signal-element.js from https://hawkticehurst.com/2024/12/declarative-signals/.
There are also some silly utility functions here to clean up the examples below.
How-to:
1. Grab my fork at https://github.com/adamghill/stellar/blob/remove-custom-renderer/signal-element.js
2. Grab this HTML
3. `python -m http.server 8000`
4. Go to http://localhost:8000/signal-element-example.html
@adamghill
adamghill / bluesky-convert-starter-pack-to-list.py
Last active November 8, 2024 13:06
Convert a starter pack to a list for Bluesky
# Python port of https://github.com/sbm12/bsky-Pack2List/blob/main/bskyList2StarterPack.php with some fixes / features
# Handle is username or email address
# Password is the regular login password or a specific app password
import json
from datetime import datetime
import requests
@adamghill
adamghill / justfile
Created July 6, 2024 20:20
Example justfile for Python projects
# https://just.systems
set quiet
set dotenv-load
set export
# List commands
_default:
just --list --unsorted --justfile {{justfile()}} --list-heading $'Available commands:\n'
@adamghill
adamghill / docker.md
Created May 25, 2024 17:44
Useful docker CLI commands that I always forget

Note: IMAGE_NAME should be replaced with some unique name.

  • Build the Dockerfile in the current directory: docker build -t IMAGE_NAME .
  • Get the size of the resulting Docker image: docker image save IMAGE_NAME | wc -c | numfmt --to=si
  • Run the resulting Docker image for web apps: docker run -p 127.0.0.1:80:3000 IMAGE_NAME
  • Open a shell in a Docker image: docker run -it --rm IMAGE_NAME /bin/bash
@adamghill
adamghill / Dockerfile
Last active June 1, 2024 03:30
Multi-stage Dockerfile with Python and `uv`
# Layer with Python and some shared environment variables
FROM python:3.10-slim-bullseye as python
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Layer for installing Python dependencies
FROM python as dependencies
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
// This was an initial prototype, but https://github.com/adamghill/conjure has the latest version
@adamghill
adamghill / helpers.py
Created December 2, 2023 20:51
Helper method to verify two dictionaries are the same with helpful error messages
from typing import Union
def assert_dictionaries(dictionary_one: Union[dict, list], dictionary_two: dict) -> None:
"""Helper method to verify two dictionaries are the same. Display helpful error messages
when the two dictionaries are different.
Args:
dictionary_one: The first dictionary.
dictionary_two: The second dictionary.
@adamghill
adamghill / timeit.py
Created November 10, 2023 17:34
timeit decorator
from contextlib import contextmanager
import time
@contextmanager
def timeit():
"""
Decorator that prints out how long a function took to run.
"""
now = time.monotonic()
@adamghill
adamghill / dork.js
Last active April 6, 2024 15:06
The most important JavaScript framework ever created. https://github.com/adamghill/dorkjs
/*
Moved to https://github.com/adamghill/dorkjs.
*/
@adamghill
adamghill / stargazers.gql
Last active November 16, 2023 00:05
Get last stargazers for repos
# Query GitHub for all new stargazers for a particular user's repositories
query($login: String!) {
user(login: $login) {
login
repositories(last: 5, orderBy: {field: STARGAZERS, direction: ASC}) {
edges {
node {
name
url