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
| ``` | |
| $ kubectl run --image nginx nginx ; while kubectl get pod --no-headers | grep -v Running ; do sleep 2; done | |
| deployment "nginx" created | |
| nginx-701339712-wpg0v 0/1 ContainerCreating 0 0s | |
| nginx-701339712-wpg0v 0/1 ContainerCreating 0 2s | |
| nginx-701339712-wpg0v 0/1 ContainerCreating 0 4s | |
| nginx-701339712-wpg0v 0/1 ContainerCreating 0 6s | |
| nginx-701339712-wpg0v 0/1 ContainerCreating 0 8s | |
| nginx-701339712-wpg0v 0/1 ContainerCreating 0 10s | |
| ``` |
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 | |
| test -z "$1" && { | |
| cat >/dev/stderr <<-HELP | |
| Usage: $0 mod-name | |
| Use this script from top level of Cataclysm checkout, with your changes to data/json not added to git. | |
| It will try to make a mod out of those changes instead. | |
| The script needs: | |
| - python (2?) | |
| - jsondiff from jsonpatch python package (https://python-json-patch.readthedocs.io) |
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 process_dict_item(k, v): | |
| try: | |
| return k, int(v) | |
| except (TypeError, ValueError): | |
| if k == 'EbsOptimized' and v == 'true': | |
| return 'EbsOptimized', 1 | |
| if k == 'NoEcho' and v == 'true': | |
| return 'NoEcho', 1 | |
| return k, replace_quoted_ints_in_values(v) |
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 prepend_with_path(j, path=''): | |
| """ | |
| >>> prepend_with_path({}) | |
| [('', {})] | |
| >>> prepend_with_path([]) | |
| [('', [])] | |
| >>> prepend_with_path({1:2}) | |
| [('', {1: 2}), ('[1]', 2)] | |
| >>> prepend_with_path({'a':'b'}) | |
| [('', {'a': 'b'}), ("['a']", 'b')] |
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 collections import defaultdict | |
| def _maj(counts_to_items, items_to_counts, max_count, sequence): | |
| if not sequence: | |
| return counts_to_items, items_to_counts, max_count, sequence | |
| item, new_sequence = sequence[0], sequence[1:] | |
| count = items_to_counts[item] | |
| counts_to_items[count].discard(item) | |
| count += 1 | |
| counts_to_items[count].add(item) |
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 tornado.web import asynchronous, RequestHandler, Application | |
| from tornado import gen | |
| from tornado.testing import AsyncHTTPTestCase, gen_test | |
| from tornado.httpclient import AsyncHTTPClient, HTTPRequest, HTTPResponse | |
| from mock import patch, Mock | |
| from tornado.concurrent import Future | |
| import StringIO | |
| class FooHandler(RequestHandler): |
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 | |
| eval "function $1() { $(cat $1); }"; | |
| type $1 2>&1 | sed -n 's#^ ##p' > "$1" |
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
| for i in `seq 2 10`; do | |
| dots=`printf '% *s' $i '' | tr ' ' .` | |
| alias $dots=cd\ `printf '../%.0s' $(seq $((i-1)))` | |
| done |
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
| function retry { | |
| local retry_max=$1 | |
| shift | |
| local count=$retry_max | |
| while [ $count -gt 0 ]; do | |
| "$@" && break | |
| count=$(($count - 1)) | |
| sleep 1 | |
| done |