Skip to content

Instantly share code, notes, and snippets.

View adamghill's full-sized avatar

Adam Hill adamghill

View GitHub Profile
@jakelazaroff
jakelazaroff / i-frame.js
Last active December 4, 2023 10:16
simple web component that sandboxes its slotted elements inside an iframe
customElements.define(
"i-frame",
class extends HTMLElement {
#shadow = this.attachShadow({ mode: "closed" });
constructor() {
super();
this.#shadow.innerHTML = `
<slot></slot>
<iframe part="frame" srcdoc=""></iframe>
@adamghill
adamghill / deploy-to-caprover.yml
Last active November 26, 2023 19:36
GitHub Action to build and deploy Docker image to CapRover
# Might be outdated! Check https://github.com/marketplace/actions/build-docker-and-deploy-to-caprover for the latest version.
name: Create and publish Docker image to CapRover
# Requires the following Action secrets to be set in your GitHub repo:
# - CAPROVER_APP_TOKEN
# - CAPROVER_SERVER_URL
on:
push:
@carltongibson
carltongibson / middleware.py
Last active December 3, 2023 02:47
Django Middleware to have `request.is_secure()` always return `True`. Maybe preferred to a WSGI middleware. Refs: https://noumenal.es/notes/til/django/csrf-trusted-origins/
class HTTPSOnlyMiddleware:
"""
Override request.is_secure() to always return True.
Only use if you're **always** serving with HTTPS
**and** SECURE_PROXY_SSL_HEADER is not suitable for your setup.
"""
def __init__(self, get_response):
self.get_response = get_response
import { reactive } from '@vue/reactivity'
function switchboard(value) {
let lookup = {}
let current
let get = () => current
let set = (newValue) => {

Untitled CSS Library RFP

Untitled CSS Library is a CSS library that, so far as I can tell, does not exist.

It offers the following features:

  • It renders well out of the box with Vanilla HTML, like a classless CSS library such as pico
  • It takes advantage of semantic, lesser used tags such as nav, main and section to allow for more elaborate layouts in pure HTML
  • It offers "High Power" classes that capture high level components in, as much as is possible, a single CSS class
@tonybaloney
tonybaloney / main.py
Last active August 18, 2021 17:21
PyInstrument with FastAPI
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from profiler import FastApiProfiler
app = FastAPI()
import .routes # NOQA
PROFILING = True # Put this in Settings when you're ready
@claudiodekker
claudiodekker / github-sponsors-graphql.graphql
Last active May 14, 2023 22:15
Retrieve a list of sponsors from the Github Graph API
query ($owner: String!, $after: String) {
user (login: $owner) {
sponsorshipsAsMaintainer(first: 100, after: $after, includePrivate: true) {
totalCount
nodes {
sponsorEntity {
... on User {
login
}
}
@0atman
0atman / Makefile
Last active February 27, 2023 19:41
Full-stack, pure Nim. Backend and JS using the same staticly-typed model.
app:
nim c app.nim
clean:
rm app
run:
./app
@adamghill
adamghill / clean_osx.md
Last active May 9, 2024 02:52
Things to setup on a clean OSX install

An opinionated list of things that I tend to do on a clean install of OSX.

OSX applications

  • Rectange: Resize and move around windows with the keyboard
  • Postgres.app: Easiest way to run a local Postgres server
  • VS Code: For when an IDE might actually be useful
  • 1Password7: Better than a Post-It note stuck to your monitor
  • iTerm2: Terminal replacement
  • GitUp: A clean git UI
  • DevUtils: Offline toolbox for developers
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active May 15, 2024 20:11
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}