Skip to content

Instantly share code, notes, and snippets.

View djnorrisdev's full-sized avatar

2dz160c1-3c4bz-105t0imj41cu58 djnorrisdev

View GitHub Profile
@monkut
monkut / argparse_date_datetime_custom_types.py
Last active April 11, 2025 21:27
Custom date/datetime type validators for python's argparse module
def valid_date_type(arg_date_str):
"""custom argparse *date* type for user dates values given from the command line"""
try:
return datetime.datetime.strptime(arg_date_str, "%Y-%m-%d")
except ValueError:
msg = "Given Date ({0}) not valid! Expected format, YYYY-MM-DD!".format(arg_date_str)
raise argparse.ArgumentTypeError(msg)
def valid_datetime_type(arg_datetime_str):
"""custom argparse type for user datetime values given from the command line"""
@dannycallaghan
dannycallaghan / Memoization Pattern.js
Created October 9, 2013 08:08
Memoization Pattern From 'JavaScript Patterns' (O'Reilly) by Stoyan Stefanov.
/* Memoization Pattern */
// a single parameter example
var myFunc = function ( param ) {
if ( !myFunc.cache[ param ] ) {
var result = {};
// ... expensive operation ...
myFunc.cache[ param ] = result;
}
return myFunc.cache[ param ];
@mrwweb
mrwweb / reset-rems
Created May 22, 2013 13:22
"Sanity-ize" REMs by setting them to 10px-baseline aka "Tiny Happy Pixels Dancing."
/* this is the "root" in "root em." */
html {
font-size: 62.5%; /* Now 10px = 1rem! */
}
body {
font-size: 16px; /* px fallback */
font-size: 1.6rem; /* default font-size for document */
line-height: 1.5; /* a nice line-height */
}