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 sys | |
from suds import client | |
from suds.wsse import Security, UsernameToken | |
from suds.sax.text import Raw | |
from suds.sudsobject import asdict | |
from suds import WebFault | |
''' | |
Given a Workday Employee_ID, returns the last name of that employee. |
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/python | |
''' | |
Python-based gift exchange randomizer. | |
Step through a list of people and, for each member of that list, | |
select someone else to be a recipient of their gift. That recipient: | |
A) Must not be themselves (no self-gifting) | |
B) Must not already have been assigned as a recipient | |
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 datetime import datetime | |
import json | |
import requests | |
import sys | |
from bs4 import BeautifulSoup | |
from django.core.management.base import BaseCommand | |
from django.contrib.auth.models import User |
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
# General pattern for a data "chunking" process to prevent a server from hitting memory limits | |
# when calling .update() or .delete() on large amounts of data. In this example, we enter an | |
# infinite loop, then keep deleting 1000 records at a time until the records are exhausted, | |
# then exit the loop. You can't call .update() or .delete() after taking a slice, hence the need | |
# for two queries rather than one. | |
t = Territory.objects.get(name="some-territory") | |
while True: | |
loc_ids = Location.objects.filter(territory=t)[:1000].values_list("id", flat=True) |
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
[alias] | |
alias = config --get-regexp ^alias\\. | |
br = branch | |
bra = branch -a -v -v | |
cm = commit -a | |
co = checkout | |
cp = cherry-pick | |
dev = checkout develop | |
find = "!f() { git ls-files |grep $@; }; f" | |
last = log -1 HEAD |
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 re | |
from django.core.management import call_command | |
from test_plus.test import TestCase | |
class SmokeTestAllViews(BaseUserTestCase): | |
def test_all_view_respones(self): | |
""" |
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
# For just python: | |
pip install libgravatar | |
# libravatar documentation/options at: | |
# http://libgravatar.readthedocs.io/ | |
# Then: | |
from libgravatar import Gravatar |
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
@register.simple_tag | |
def git_ver(): | |
''' | |
Retrieve and return the latest git commit hash ID and tag as a dict. | |
''' | |
git_dir = os.path.dirname(settings.BASE_DIR) | |
try: | |
# Date and hash ID |
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 dirapp.models import Log | |
from django.contrib import admin | |
class LogAdmin(admin.ModelAdmin): | |
search_fields = ['user__username', 'action'] | |
list_display = ('user', 'anon_username', 'action', 'target', 'status', 'ip_addr', 'timestamp',) | |
list_filter = ['target', 'status'] | |
admin.site.register(Log, LogAdmin) |
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 django import forms | |
from django.utils.encoding import force_text | |
from django.utils.html import format_html | |
from wagtail.wagtailcore.blocks import FieldBlock | |
class BlockQuoteBlock(FieldBlock): | |
def __init__(self, required=True, help_text=None, max_length=None, min_length=None, **kwargs): | |
self.field = forms.CharField( |
NewerOlder