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
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'formatters': { | |
'simple': { | |
'format': '%(levelname)s %(asctime)s %(name)s: %(message)s' | |
}, | |
}, | |
'handlers': { | |
'console': { |
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 xml.etree import ElementTree as ET | |
for prefix, uri in NAMESPACES.items(): | |
ET.register_namespace(prefix, uri) | |
root_xml_element = ET.fromstring(xml) | |
token_xml_element = root_xml_element.find( | |
'soap:Body', namespaces=NAMESPACES | |
).find( | |
'wst:RequestSecurityTokenResponseCollection', namespaces=NAMESPACES | |
).find( | |
'wst:RequestSecurityTokenResponse', namespaces=NAMESPACES |
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
HTTP/1.1 200 OK | |
Date: 21 Jan 2004 07:00:49 GMT | |
Content-Type: text/html; charset=iso-8859-1 | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<body onload="document.forms[0].submit()"> | |
<noscript> | |
<p> |
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
_functions = {} | |
def register(f): | |
global _functions | |
_functions[f.__name__] = f | |
return f | |
@register | |
def foo(): | |
return 'bar' |
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 contextlib import contextmanager | |
@contextmanager | |
def temporarily(obj, **kwargs): | |
original_values = {k: getattr(obj, k) for k in kwargs} | |
for k, v in kwargs.items(): | |
setattr(obj, k, v) | |
obj.save(update_fields=kwargs.keys()) | |
try: | |
yield |
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
eval(function(p, a, c, k, e, d) { | |
e = function(c) { | |
return (c < a ? "" : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) | |
} | |
; | |
if (!''.replace(/^/, String)) { | |
while (c--) | |
d[e(c)] = k[c] || e(c); | |
k = [function(e) { | |
return d[e] |
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 validate_email(email): | |
from django.core.validators import EmailValidator | |
from django.core.exceptions import ValidateError | |
try: | |
EmailValidator()(email) | |
except ValidateError: | |
return False | |
return 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
- name: restart server if ulimit changed | |
become: yes | |
shell: sleep 2 && reboot | |
async: 1 | |
poll: 0 | |
ignore_errors: yes | |
- name: wait for server to come back | |
local_action: | |
module: wait_for |
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 python | |
# coding=utf8 | |
""" | |
Send email with SMTP | |
Add env vars in your ~/.bashrc and source it: | |
export EMAIL_HOST=smtp.example.com | |
export EMAIL_PORT=587 | |
export EMAIL_USERNAME=sender@example.com |
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
# -*- mode: ruby -*- | |
Vagrant.configure("2") do |config| | |
config.ssh.insert_key = false | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 4096 | |
v.cpus = 4 | |
end | |
config.vm.define "dc0" do |dc| | |
dc.vm.box = "samba-ubuntu1604" |
OlderNewer