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
"""Floored Relative Delta(frdelta) | |
This module contains ready-made relativedeltas. The kwargs class contains | |
all the key word arguments used to create the relativedeltas | |
All relativedeltas are floored, ie. all lesser absolute information is set | |
to zero. | |
If you need more than one forward(FWD) or backward(BWD), use multiplication: | |
This: |
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
Copyright (c) 2012, Michael A. Jackson | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without modification, | |
are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright notice, this | |
list of conditions and the following disclaimer. | |
* Redistributions in binary form must reproduce the above copyright notice, |
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
expire_deltas = { | |
'minutes': frdelta.FWD_MIN, | |
'hours' : frdelta.FWD_HR, | |
'days': frdelta.FWD_DAY, | |
'months': frdelta.FWD_MO, | |
'years': frdelta.FWD_YR, | |
} | |
def GetExpireDate(expire_date='months', now=None): | |
"""Convert expire_date arguments to date |
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
""" Inherit SafeReadOnly for safe access to mutable objects on classes | |
* Deep copy of mutable attributes on accessing uninstantiated class | |
* No assignment to class attributes on uninstantiated class | |
* Deep copy of mutable attributes when class is instantiated | |
""" | |
from collections import Hashable |
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.db import models | |
class QuerySetManager(models.Manager): | |
"""Add new QuerySet methods using a Model inner class | |
Reference: | |
http://djangosnippets.org/snippets/734/ | |
""" |
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
""" Interview question | |
Write a method that takes a string, and returns the string in reverse. | |
For instance, if passed abc123 it should return 321cba | |
""" | |
class StringUtil(object): | |
""" Utility for strings |
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
""" Additional collections to augment Python's collections module. | |
""" | |
from collections import namedtuple | |
def defaultnamedtuple( | |
typename, | |
field_names, | |
verbose=False, | |
rename=False, |
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
const storedTemplate = (a,b,c) => `a:${a}, b:${b}, c:${c}` | |
storedTemplate(1,2,3) |
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
// var depPairs = [ | |
// "KittenService: ", | |
// "Leetmeme: Cyberportal", | |
// "Cyberportal: Ice", | |
// "CamelCaser: KittenService", | |
// "Fraudstream: Leetmeme", | |
// "Ice: " | |
// ]; | |
// | |
// Turn that into: `'KittenService, Ice, Cyberportal, Leetmeme, CamelCaser, Fraudstream'` |
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
# Execute docker run with --rm --network shared | |
# The shared network will be created if it dosn't already exist | |
dr () { | |
docker network inspect shared > /dev/null 2>&1 | |
if [ $? -ne 0 ] | |
then | |
docker network create shared > /dev/null 2>&1 | |
fi | |
local DOCKER_CMD="docker run --rm --network shared $@" | |
echo |