Skip to content

Instantly share code, notes, and snippets.

View judy2k's full-sized avatar

Mark Smith judy2k

View GitHub Profile
@judy2k
judy2k / build_run_test.fish
Last active July 28, 2025 14:04
Fish abbreviations to build, run, and test
# Configure the abbreviations b, build, r, run, t, test.
#
# Written and placed in the public domain, by Mark Smith <[email protected]>
function project_file \
-d "Find a file in parent directories"
# Find a file in the specified directory (or PWD), or any parent directory.
#
# Usage:
# project_file [-p START_DIRECTORY] [-v] FILENAME
@judy2k
judy2k / brew_installed.sh
Created July 23, 2025 10:25
List installed homebrew packages.
#!/bin/sh
# This script prints out the packages that have been installed by homebrew,
# along with a description of each package.
#
# This doesn't include packages that were installed as dependencies,
# only packages requested explicitly by the user.
#
# This script requires the following packages: jq, qsv
@judy2k
judy2k / sometimes.py
Last active April 28, 2025 23:11
A descriptor that wraps a method that can be called on a class or an instance.
from functools import wraps
class SometimesClassmethod:
def __init__(self, wrapped_function):
self._wrapped = wrapped_function
def __get__(self, instance, owner=None):
if instance is None:
return self._class_call(owner)
@judy2k
judy2k / run.fish
Created September 14, 2024 10:31
Fish Shell: Expand 'run' to an appropriate 'run' command, depending on the files in the current directory.
function _expand_run
-d "Expand the 'run' abbreviation into a project-specific run command.";
if test -e Justfile;
echo just run
else if test -e Makefile;
echo make run
else if test -e Cargo.toml
echo cargo run
else if test -e package.json
echo npm run dev
@judy2k
judy2k / atlas-uri
Last active June 27, 2024 11:38
A script to generate a user for a MongoDB Atlas project.
#!/bin/bash
# Create a database user with a random password, and print out a MongoDB connection string for that database.
#
# Requires: python >= 3.6, jq, and atlas-cli
set -e
CLUSTER='Sandbox'
@judy2k
judy2k / the_importance_of_what_we_do.md
Created November 15, 2019 10:26
The Importance of What We Do
We couldn’t find that file to show.
@judy2k
judy2k / trim
Created March 26, 2019 11:13
trim - a useful (but tiny) script to trim surrounding whitespace from some output.
#!/usr/bin/env python3
import sys
def main():
i = sys.stdin.read()
sys.stdout.write(i.strip())
@judy2k
judy2k / dbag.py
Last active February 19, 2019 11:49
An Infinite Bag of Dice
import random
import re
import sys
def _roll_func(count, sides):
def _roll():
return sum(random.randint(1, sides) for _ in range(count))
return _roll
@judy2k
judy2k / phony.py
Created January 23, 2019 16:32
Phony! Fake phone number generator.
#!/usr/bin/env python3
import argparse
from random import randint, choice
def uk():
return randint(447700900000, 447700900999+1)
def us_area_code():
@judy2k
judy2k / post.md
Last active July 3, 2018 16:57
EuroPython 2018: Women's Django Workshop

EuroPython 2018: Women's Django Workshop

EuroPython 2018 is pleased to host and sponsor a free Women's Django Workshop on Monday 23rd July, from 9am-6pm.

Would you like to learn about how to build websites, but don’t know where to start? A group of volunteers will lead you through HTML, CSS, Python & Django to build a blog in a one day workshop. No prior programming knowledge is needed to participate! If you would like to take part, apply for a spot by filling in our application form

EuroPython 2018 sponsors this event, providing space and catering, together with other facilities.

EuroPython ticket sales are picking up