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
import requests | |
class RemoteFile: | |
""" | |
Context manager for handling remote OR local files | |
Can be used like so: | |
>>> with RemoteFile("/path/to/local/file.txt") as f: |
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
/* | |
Copy and paste into your browser console window after loading | |
your archives page, e.g. with a selected long date range. | |
Original: https://www.reddit.com/r/javascript/comments/5my92r/console_script_to_click_all_download_links_on_a/dc7cktr/ | |
The problem I had with my first attempt was that there was no delay, | |
so I was only downloading the last entry on the page. The linked | |
solution above pointed to the problem (each subsequent request was | |
killing the preceding request) which was including a delay. Here |
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
import functools | |
import stripe | |
from typing import Any, Optional | |
def stripe_subscriptions(limit: Optional[int] = 100, **params: Any): | |
""" | |
Returns an iterator of all matching subscriptions |
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
# List the domains you want to block, one per line, in your ~/.blocked_sites file, | |
# then ensure this script is included or sourced in your terminal configuration. | |
function worktime { | |
while read -r line; do | |
echo "127.0.0.1 ${line} # WORKTIME" | |
echo "fe80::1%lo0 ${line} # WORKTIME" | |
echo "127.0.0.1 www.${line} # WORKTIME" | |
echo "fe80::1%lo0 www.${line} # WORKTIME" | |
done < $HOME/.blocked_sites | sudo tee -a /etc/hosts > /dev/null |
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
from organizations.backends.defaults import RegistrationBackend, InvitationBackend | |
class SendMailMixin(object): | |
def _send_email(self, user, subject_template, body_template, | |
sender=None, connection=None, **kwargs): | |
"""Utility method for sending emails to new users""" | |
if sender: | |
from_email = "%s %s <%s>" % (sender.first_name, sender.last_name, |
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
### MODEL | |
# -*- coding: utf-8 -*- | |
""" | |
Models for the "flatpages" project | |
""" | |
import time | |
import socket | |
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 bash | |
PACKAGES=(pagecolor titling sourcecodepro mweights ly1 sourcesanspro needspace mdframed csquotes) | |
for item in ${PACKAGES[*]} | |
do | |
tlmgr install $item | |
done |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def annotated(attr_name): | |
""" | |
Decorator for returning pre-calculated, annotated values | |
This should be used with model instance methods that fetch some | |
kind of related or calculated data. If the method is called on | |
a single instance in isolation, we should expect the method to | |
execute and return its value. However if the method is called | |
on a member of a queryset where the `attr_name` was added as an |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.