This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
nouns = [ | |
"sten", | |
"et glashus", | |
"perler", | |
"svin", | |
"hunden", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# | |
# If you are using Thunderbird and other todo clients that do not support | |
# creation of new calendars on a CalDav backend (such as Fastmail), you'll | |
# need to tell Fastmail directly via CalDav. | |
# | |
# Dependencies: On Debian/Ubuntu, install python3-caldav: | |
# | |
# sudo apt install python3-caldav | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
This script adds on_delete to Django migrations. It works on multi-line | |
definitions of ForeignKey/OneToOneField which may be in your codebase if you | |
have black'ened the migration files. | |
It's not perfect, but it doesn't create syntax errors and you can run black on | |
the code again afterwards. | |
First version: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Fixes a downloaded apt mirror | |
# See: https://github.com/apt-mirror/apt-mirror/issues/113#issuecomment-464932493 | |
## first parameter is optional mirror list file | |
if [ "$1" != "" ] | |
then | |
mirrorlist=$1 | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# get the upstream repository username | |
upstream_repo=$(git config remote.upstream.url | sed 's/^.*://' | sed 's/\/.*$//') | |
# open the PR against develop, or another branch specified as the first command-line argument | |
upstream_branch=${1:-develop} | |
# branch | |
branch=$(git symbolic-ref HEAD | sed 's/refs\/heads\///') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Ever got tired of having loads of migrations that have no effect on | |
the actual database? | |
This little mockup presents how we can move properties of fields into | |
a scope where they can easily be ignored by the migration system | |
Would it work? | |
""" | |
from django.db import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
try: | |
import kolibri | |
except ImportError: | |
print( | |
"Could not find Kolibri in the system path, if you are using a PEX " | |
"file, please run `./file.pex manage shell` and then copy-paste all " | |
"contents of this script into the command line of Kolibri." | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This command exports blog posts, categories and tags from django-blog-zinnia | |
to wagtail_blog. | |
Usage: | |
0. Carefully consider if you want custom models for wagtail_blog before | |
starting the import. You may for instance want to retain an FK relation in | |
the database between old Zinnia Entry objects and new BlogPage objects. | |
1. Copy this script to yourapp/management/commands/zinnia_to_wagtail.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Automatically suspend computer when the user has fallen asleep. But using your | |
own custom timing. | |
Add to your crontab with `crontab -e` | |
# m h dom mon dow command | |
0 2 * * * python3 /path/to/awake_or_suspend.py | |
This command either needs that your user can invoke `sudo` without a password or that it's launched with sude permissions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExceptionUserInfoMiddleware(object): | |
""" | |
Adds user details to request context on receiving an exception, so that they show up in the error emails. | |
Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on top if possible). This allows | |
it to catch exceptions in other middlewares as well. | |
Origin: https://gist.github.com/646372 | |
""" | |
NewerOlder