Skip to content

Instantly share code, notes, and snippets.

View judy2k's full-sized avatar

Mark Smith judy2k

View GitHub Profile
@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@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 / know_thyself.py
Last active July 5, 2022 06:35
__qualname__ implementation in Python 2
from inspect import isclass
import __builtin__
# We're going to overwrite object, so we need to squirrel away the old one:
obj = object
# Metaclass, overriding the class' __getattribute__,
# so that __qualname__ can be generated and cached on access:
class QualnameMeta(type):
@judy2k
judy2k / gitignore
Last active February 1, 2022 11:14
A script to manage a .gitignore file
#!/bin/bash
# To add two items to the current .gitignore file:
# gitignore '*.swp' bin
#
# To sort and de-dupe the current .gitignore file:
# gitignore
# Append each argument to its own line:
for item in "$@"; do
echo "$item" >> .gitignore;
@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.
module ActsAsCsv
class Row < Array
def initialize(ary, headings)
super(ary)
@headings = headings
end
def method_missing(name, *args)
idx = @headings.index name.to_s
self[idx] if idx != nil
@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 / 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

@judy2k
judy2k / may_the_4th.json
Last active June 7, 2017 17:26
May the 4th be with you!
[{
"action": "talk",
"voiceName": "Brian",
"text": "May the fourth be with you!"
}]