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
# Works on Py3 | |
def parse_version_failsafe(version_string): | |
try: | |
return Version( | |
unicodedata.normalize('NFKD', six.text_type(version_string)) | |
) | |
except (UnicodeError, InvalidVersion): | |
return None | |
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 numpy as np | |
import pandas as pd | |
from geopy.distance import EARTH_RADIUS | |
def numpy_distance(src_lats, src_longs, dest_lats, dest_longs): | |
"""Calculate distance between (effectively) two Series of points.""" | |
# Convert from degrees to radians. | |
src_lats = src_lats.apply(np.deg2rad) | |
src_longs = src_longs.apply(np.deg2rad) | |
dest_lats = dest_lats.apply(np.deg2rad) | |
dest_longs = dest_longs.apply(np.deg2rad) |
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 datetime | |
def get_date(x): | |
"""Extract date from the provided timestamp. | |
Useful because the Pandas data model makes it hard to invoke | |
instance methods of values directly.""" | |
return x['Occurred Date or Date Range Start'].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
⇒ pip install jupyter [ruby-2.2.1] | |
Collecting jupyter | |
Downloading https://dev-infrastructure.rescuetime.com/root/pypi/+f/f81/d039e084c2c0c/jupyter-1.0.0-py2.py3-none-any.whl | |
Collecting qtconsole (from jupyter) | |
Downloading https://dev-infrastructure.rescuetime.com/root/pypi/+f/046/29b6bfeaa40fd/qtconsole-4.2.1-py2.py3-none-any.whl (104kB) | |
100% |████████████████████████████████| 112kB 1.4MB/s | |
Collecting ipykernel (from jupyter) | |
Downloading https://dev-infrastructure.rescuetime.com/root/pypi/+f/8dc/3c636084d2471/ipykernel-4.3.1-py2.py3-none-any.whl (93kB) | |
100% |████████████████████████████████| 102kB 1.8MB/s | |
Collecting nbconvert (from jupyter) |
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 org.python.core.io import FileIO, FileUtil | |
path = "/tmp/hello_world.txt" | |
python_fio = FileIO(path, "r") | |
java_is = python_fio.asInputStream() | |
python_file = FileUtil.wrap(java_is) | |
workbook = jxl.Workbook.getWorkbook(java_is) | |
# Do stuff with your Pythonic file interface here. |
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
2014-11-14T16:29:58.065531+00:00 ip-172-18-1-52 charon: 14[IKE] authentication of 'C=US, O=RescueTime, CN=client' with RSA successful | |
2014-11-14T16:29:58.065570+00:00 ip-172-18-1-52 charon: 14[IKE] no RSA private key found for 'C=US, O=RescueTime, CN=clientvpn.rescuetime.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
conn ios | |
keyexchange=ikev1 | |
# This was working, but required the local ipsec.secrets file | |
# authby=xauthrsasig | |
# xauth=server | |
left=%defaultroute | |
leftsubnet=0.0.0.0/0 | |
leftfirewall=yes | |
leftcert=serverCert.pem | |
right=%any |
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
$ ip route show table all | |
default via 172.18.1.1 dev eth0 | |
172.18.1.0/24 dev eth0 proto kernel scope link src 172.18.1.154 | |
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1 | |
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1 | |
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1 | |
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1 | |
broadcast 172.18.1.0 dev eth0 table local proto kernel scope link src 172.18.1.154 | |
local 172.18.1.154 dev eth0 table local proto kernel scope host src 172.18.1.154 | |
broadcast 172.18.1.255 dev eth0 table local proto kernel scope link src 172.18.1.154 |
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
$ sudo ipsec statusall | |
Status of IKE charon daemon (strongSwan 5.1.2, Linux 3.13.0-29-generic, x86_64): | |
uptime: 89 minutes, since Oct 02 18:38:37 2014 | |
malloc: sbrk 1486848, mmap 0, used 435536, free 1051312 | |
worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 11 | |
loaded plugins: charon test-vectors ldap aes rc2 sha1 sha2 md4 md5 random nonce x509 revocation constraints pkcs1 pkcs7 pkcs8 pkcs12 pem openssl xcbc cmac hmac ctr ccm gcm attr kernel-netlink resolve socket-default stroke updown eap-identity eap-radius xauth-generic xauth-eap radattr addrblock | |
Virtual IP pools (size/online/offline): | |
10.0.0.0/24: 254/1/0 | |
Listening IP addresses: | |
10.230.25.28 |
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
$ sudo iptables-save | |
# Generated by iptables-save v1.4.21 on Thu Oct 2 19:59:57 2014 | |
*filter | |
:INPUT ACCEPT [407:42791] | |
:FORWARD ACCEPT [0:0] | |
:OUTPUT ACCEPT [121:24299] | |
-A FORWARD -s 10.0.0.1/32 -i eth0 -m policy --dir in --pol ipsec --reqid 4 --proto esp -j ACCEPT | |
-A FORWARD -d 10.0.0.1/32 -o eth0 -m policy --dir out --pol ipsec --reqid 4 --proto esp -j ACCEPT | |
COMMIT | |
# Completed on Thu Oct 2 19:59:57 2014 |
NewerOlder