Skip to content

Instantly share code, notes, and snippets.

View adamghill's full-sized avatar

Adam Hill adamghill

View GitHub Profile
// 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
@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:
@adamghill
adamghill / !steps.md
Created December 19, 2022 01:48
Steps to create a new Django project
@adamghill
adamghill / leveling-up.md
Created December 5, 2022 15:16
Reading material on how to be a better software engineer?

Responses from https://news.ycombinator.com/item?id=33854815, but sans the drama and only containing books not about coding.

  • The Goal by Eli Goldratt: It is a novel about optimizing a factory, but it is immensely valuable in thinking through what are the actual constraints on your team's ability to deliver software and how do you fix it without making other things worse. The Phoenix Project is kind of a modern retelling, but I'd start with The Goal.
  • The Principles of Product Development Flow by Reinersten: Great for thinking deeply about how you deliver value through your system and the tradeoffs you are making in what you choose to focus on next. Once again it isn't specific to software, but very relevant.
  • The 5 Dysfunctions of Teams by Lencioni: Common team problems and what to do instead.
  • Influence: Science and Practice by Cialdini - How to get people into agreement so you can move forward--a skill that can be used for both good and evil.
@adamghill
adamghill / backup-restore-postgres
Created December 3, 2022 21:15
Backup and restore postgres database
PGPASSWORD=PASSWORD pg_dump -h HOST_URL -p PORT -U USER --format=custom --no-acl --no-owner DATABASE_NAME > sql.dump
PGPASSWORD=PASSWORD pg_restore --verbose --clean --no-acl --no-owner -h HOST_URL -p PORT -U USER -d DATABASE_NAME sql.dump
@adamghill
adamghill / !render-checklist.md
Last active September 6, 2023 03:40
Settings, files, and a checklist to deploy a Django app to Render with gunicorn + redis and using `poetry` for dependencies.
  • GitHub for code
  • Render blueprint specified by render.yaml
    • Postgres
    • Redis
    • Linked to GitHub repo
    • Add environment variables for PYTHON_VERISON=3.9.7, ENVIRONMENT=live, and SECRET_KEY
  • Cloudflare for SSL and CNAME pointing to Render app domain
    • Force SSL with a Cloudflare rule
  • Namecheap for the domain
  • Point nameservers to Cloudflare