Skip to content

Instantly share code, notes, and snippets.

View sloria's full-sized avatar

Steven Loria sloria

View GitHub Profile
huytd /
Last active May 16, 2024 20:39
Wordle in less than 50 lines of Bash


How to use:


Or try the unlimit mode:

AndrewIngram /
Created December 10, 2021 11:43
Django on_save callback
import logging
from django.db import models, transaction
from django.db.models.signals import post_save
logger = logging.getLogger(__name__)
def on_save(obj: models.Model, callback):
Attaches a one-off callback that's triggered after a Django model instance is
AndrewIngram /
Last active December 10, 2021 23:47
Strawberry Generic Connections (Python 3.10 syntax)
from typing import Generic, TypeVar
import strawberry
ConnectionNode = TypeVar("ConnectionNode")
class Edge(Generic[ConnectionNode]):
node: ConnectionNode
jacobian /
Created March 15, 2021 13:00
How to deploy Datasette to Heroku using Docker
heroku create {app} --stack container
datasette package --tag{app}/web
docker push{app}/web
heroku container:release -a {app} web
m-radzikowski /
Last active July 13, 2024 13:20
Minimal safe Bash script template - see the article with full description:
#!/usr/bin/env bash
set -Eeuo pipefail
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
var timer=100;document.querySelectorAll("div > input[type='checkbox']:checked").forEach((interest) => {setTimeout(function(){},timer);timer+=2000;});
zzzeek /
Last active August 15, 2023 10:00
The SQL is just as easy as an ORM challenge
""" "Writing SQL is just as fast as using an ORM" proof of concept
Below is a simple Python object model, where we represent a database that
stores the names of employees at a company, some of whom are "engineers",
and a list of the jobs they do and the programming languages they use.
We'd like to persist the state represented by this Python object model
in a relational database, using our Python objects as a start. Then we'd
like to write SQL queries for rows in this database, and we get back instances
of Python objects exactly as they were created.
import sys
from django.conf import settings
rkrzr /
Last active April 10, 2024 11:14
Automatically generate ansible tags of the same name for each role in a playbook
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin:
geoffreydhuyvetters /
Last active January 13, 2023 06:49
What is React Fiber? And how can I try it out today?