Skip to content

Instantly share code, notes, and snippets.

@borgstrom
borgstrom / 00_test_assertions.py
Last active June 14, 2018 03:20
Pytest assertion for unittest assertions (assertEquals, assertAlmostEqual, etc...)
import time
import pytest
from unittest import TestCase
IPSUM1 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ut semper quam.'
IPSUM2 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec congue sagittis eros ac aliquet.'
@borgstrom
borgstrom / human_time_duration.py
Created May 9, 2018 04:00
Python: Convert seconds (duration) to human readable string
TIME_DURATION_UNITS = (
('week', 60*60*24*7),
('day', 60*60*24),
('hour', 60*60),
('min', 60),
('sec', 1)
)
def human_time_duration(seconds):
@borgstrom
borgstrom / pyobjects_map_example.py
Created March 4, 2014 00:14
Example of the SaltStack pyobjects Map object usage
#!pyobjects
class Samba(Map):
__merge__ = 'samba:lookup'
class Debian:
server = 'samba'
client = 'samba-client'
service = 'samba'
import logging
try:
from nacl.auto import *
from nacl.state import default_registry
HAS_NACL = True
except ImportError:
HAS_NACL = False
__virtualname__ = 'nacl'
//
// This is a userscript for activecollab that allows for you to press the 's'
// key on any page and have it focus the search input box allowing for quick
// searching.
//
// author: Evan Borgstrom (@borgstrom)
// license: MIT
//
window.onkeydown = function(event) {
@borgstrom
borgstrom / 2013.03.09-bootstrap-datepicker-setOnHide.diff
Created March 9, 2013 06:28
Patch to the bootstrap datepicker (http://www.eyecon.ro/bootstrap-datepicker/) to allow a new option: setOnHide It defaults to true, but if set to false then the input field will not get a value simply from clicking off of it without actually selecting a date. We have text boxes that need to show a date picker but are optional so we don't want t…
--- js/bootstrap-datepicker.js.orig 2013-03-09 00:59:04.000000000 -0500
+++ js/bootstrap-datepicker.js 2013-03-09 01:23:06.000000000 -0500
@@ -77,6 +77,7 @@
this.startViewMode = this.viewMode;
this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
+ this.setOnHide = options.setOnHide === false ? false : true;
this.fillDow();
this.fillMonths();
this.update();