This file contains hidden or 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
| $ var=$(echo ' ab') | |
| $ echo $var | |
| ab | |
| $ echo $var | xxd | |
| 0000000: 6162 0a ab. | |
| $ if [[ "$var" =~ ^a ]]; then echo match; else echo not match; fi | |
| not match | |
| $ var=$(echo 'ab') | |
| $ echo $var | xxd |
This file contains hidden or 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/bash | |
| function exit_with_usage() { | |
| # usage: exit_with_usage | |
| echo "Usage: ${0##*/} <src> <dest>" >&2 | |
| exit 1 | |
| } | |
| function prompt() { |
This file contains hidden or 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
| 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') | |
| ....: |
This file contains hidden or 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
| (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 |
This file contains hidden or 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
| __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 |
This file contains hidden or 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
| jenders@jenders-mba tmp :) $ cat ./foo.sh | |
| #!/bin/bash | |
| echo "\$@: $@" | |
| flags=() | |
| for flag in "$@"; do | |
| if [[ "${flag}" =~ ^- ]]; then | |
| flags=("${flags[@]}" "${flag}") | |
| fi |
This file contains hidden or 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/python3.4 | |
| import math | |
| import statistics as stats | |
| import signal | |
| import sys | |
| from os.path import basename | |
| # Hide stack trace from KeyboardInterrupt |
This file contains hidden or 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
| [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> |
This file contains hidden or 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/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}" \ |
This file contains hidden or 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
| >>> 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): |