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 random | |
import string | |
import datetime | |
def resample(lst, n): | |
''' return a list of length n of randomly chosen elements | |
from an input list''' | |
inp = list(lst) | |
if n <= 0: |
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 logging | |
import logging.handlers | |
LOG_FILE = 'test.log' | |
#logging.basicConfig(filename=LOG_FILE, | |
#level=logging.DEBUG, | |
#) | |
#logging.debug('this should be in the log file') |
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 | |
now = datetime.now() | |
codes = [ | |
r'%Y-%m-%d %H:%M:%S', | |
r'%a %b %d %H:%M:%S', | |
r'%A %B %d', | |
r'%c', | |
r'%x %X %z %Z', # locale's date & time, UTC offset and timezone |
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 pathlib import Path | |
# add local (unpiped) PyPDF2 | |
p = Path(str(__file__)).absolute().parent(level=2) | |
sys.path.append(p.join('dld', 'PyPDF2').as_posix()) | |
from PyPDF2 import PdfFileReader | |
from PyPDF2 import PdfFileWriter |
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 yaml | |
document = """ | |
a: 1 | |
b: | |
- 0.5 | |
- one | |
- True | |
c: | |
key: 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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
# poor man crypto | |
import base64 | |
def _shiftchars(s): | |
lens = len(s) | |
if lens == 1: | |
return s | |
elif lens == 2: | |
return s[1]+s[0] | |
else: |
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
#!/bin/sh | |
# source: https://github.com/tinfoil/openvpn_autoconfig/blob/master/bin/openvpn.sh | |
set -e | |
apt-get update -q | |
apt-get install -qy openvpn curl | |
cd /etc/openvpn | |
[ -f dh.pem ] || openssl dhparam -out dh.pem 2048 |
OlderNewer