Skip to content

Instantly share code, notes, and snippets.

In [90]: str(r0.answer[0])
Out[90]: 'pinterest.com. 60 IN A 54.243.129.204\npinterest.com. 60 IN A 50.16.219.149\npinterest.com. 60 IN A 54.225.186.27\npinterest.com. 60 IN A 54.235.105.67\npinterest.com. 60 IN A 50.16.231.144\npinterest.com. 60 IN A 23.21.210.110\npinterest.com. 60 IN A 50.17.251.14\npinterest.com. 60 IN A 54.243.162.10'
In [91]: str(r1.answer[0])
Out[91]: 'pinterest.com. 60 IN A 54.197.238.4\npinterest.com. 60 IN A 174.129.10.138\npinterest.com. 60 IN A 50.16.211.7\npinterest.com. 60 IN A 54.225.188.149\npinterest.com. 60 IN A 174.129.209.56\npinterest.com. 60 IN A 54.225.139.43\npinterest.com. 60 IN A 54.225.169.36\npinterest.com. 60 IN A 50.17.208.61'
In [92]: if str(r0.answer[0]) == str(r1.answer[0]):
print('No problem')
....:
(dnsdiff)jenders@collaris/pts/0: dnsdiff $ ./dnsdiff.py --help
usage: dnsdiff.py [-h] -f FILENAME --from-ns NAMESERVER1 --to-ns NAMESERVER2
optional arguments:
-h, --help Show this help message and exit
-f FILENAME, --filename FILENAME
File containing resource records to verify. File is
expected to be a valid zone master file as described
here: https://tools.ietf.org/html/rfc1035#section-5
--from-ns NAMESERVER1
@joshenders
joshenders / function.sh
Last active August 29, 2015 14:20
rvm/extras/bash_zsh_support/chpwd/function.sh
__zsh_like_cd()
{
# Called as:
# cd() { __zsh_like_cd cd "$@" ; }
# popd() { __zsh_like_cd popd "$@" ; }
# pushd() { __zsh_like_cd pushd "$@" ; }
# So, "$@" in __zsh_like_cd contains the __zsh_like_cd "personality" as well as passed arguments
\typeset __zsh_like_cd_hook # define local variable in __zsh_like_cd scope, may be POSIXly correct but lol- #! is /bin/bash, use "local __zsh_like_cd_hook". Also, hilarious that they prepend \ to typeset because who knows if you can trust that it's not hooked!
if
builtin "$@" # builtin returns true if command is a built-in
jenders@jenders-mba tmp :) $ cat ./foo.sh
#!/bin/bash
echo "\$@: $@"
flags=()
for flag in "$@"; do
if [[ "${flag}" =~ ^- ]]; then
flags=("${flags[@]}" "${flag}")
fi
@joshenders
joshenders / stats-by-country.py
Created March 30, 2015 06:58
stats-by-country.py
#!/usr/bin/python3.4
import math
import statistics as stats
import signal
import sys
from os.path import basename
# Hide stack trace from KeyboardInterrupt
[root@dev-aje:~]# apt-cache --help | grep -- depends
depends - Show raw dependency information for a package
rdepends - Show reverse dependency information for a package
[root@dev-aje:~]# apt-cache depends libpng12-0
libpng12-0
Depends: libc6
Depends: zlib1g
PreDepends: multiarch-support
Conflicts: libpng12-dev
Conflicts: <mzscheme>
#!/bin/bash
# for each list of nodes in ISP metadata list
for country in metadata/by-isp/*; do
ccode="$(basename ${country})"
echo "${ccode}"
mkdir "by-isp/${ccode}"
# from node list for each country, create file with only tests from said country
pattern=$(awk '{ print $2 }' "${country}" \
>>> a = "1.0"
>>> int(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.0'
>>> int(float(a))
1
>>> foo = "1.0"
>>> int(foo)
Traceback (most recent call last):
@joshenders
joshenders / sshrc
Created March 13, 2015 12:47
/etc/ssh/sshrc to fix X11 Forwarding on Debian
if read proto cookie && [ -n "$DISPLAY" ]; then
if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
# X11UseLocalhost=yes
echo add unix:`echo $DISPLAY |
cut -c11-` $proto $cookie
else
# X11UseLocalhost=no
echo add $DISPLAY $proto $cookie
fi | xauth -q -
fi
def params_to_dict(param_str):
splits = param_str.split(" ")
data = {}
prev_key = None
prev_val = None
for s in splits:
if "=" in s:
key, val = s.split("=")
if prev_key: