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
| def _warn(cls, func, *args, **kwargs): | |
| warn("blah_class is deprecated - use BlahClass instead", DeprecationWarning) | |
| return func(*args, **kwargs) | |
| class blah_class(BlahClass): | |
| @classmethod | |
| def add_warnings(cls): | |
| for attr_name, attr_value in BlahClass.__dict__.items(): |
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
| env HTTPS_PROXY=aproxy:3128 GIT_SSL_NO_VERIFY=true go get -v github.com/jessevdk/go-flags |
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
| Set-Service tabletinputservice -StartupType Disabled | |
| stop-service tabletinputservice |
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
| Set-Service tabletinputservice -Status Running -StartupType Manual |
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
| # from stack overflow http://stackoverflow.com/questions/8230315/python-sets-are-not-json-serializable and others | |
| class SerialiseThis(json.JSONEncoder): | |
| def default(self, obj): | |
| if isinstance(obj, set): | |
| return list(obj) | |
| if isinstance(obj, datetime.datetime): | |
| return obj.isoformat() |
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
| script_path = os.path.realpath(__file__) | |
| script_path_no_ext = os.path.splitext(os.path.realpath(__file__))[0] | |
| script_dir = os.path.dirname(script_path) | |
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
| sudo mkdir /mnt/tmpfs | |
| sudo mount -t tmpfs -o size=16g /dev/shm /mnt/tmpfs | |
| dd if=/dev/zero bs=1024k count=4096 of=/mnt/tmpfs/bigfile |
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
| # This will work even with spaces in the directory name or the script name | |
| # or even if the script is sourced | |
| script_basename=${BASH_SOURCE[0]##*/} | |
| # on osx you need to brew install coreutils - then you get greadlink not readlink as in linux | |
| script_fullpath=$( (greadlink -f "${BASH_SOURCE[0]}" || readlink -f "${BASH_SOURCE[0]}" ) 2> /dev/null) | |
| script_dirname=${script_fullpath%/*} | |
| echo basename \'${script_basename}\' | |
| echo fullpath \'${script_fullpath}\' |
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
| from distutils.version import LooseVersion | |
| if LooseVersion(thing.__version__) < LooseVersion('1.11.1'): | |
| exit("Use the right version dude") | |
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
| On the slave (python string) | |
| "select pg_last_xlog_receive_location(), pg_last_xlog_replay_location(), " | |
| "EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp()) AS seconds_since_last_replay, " | |
| "pg_xlog_location_diff(pg_last_xlog_receive_location(), pg_last_xlog_replay_location()) " | |
| "AS replay_receive_xlog_pos_delta; | |
| On the master | |
| use pg_xlog_location_diff with the extracted positions from the slave to do something similar |