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
| parser = argparse.ArgumentParser() | |
| group = parser.add_mutually_exclusive_group(required=True) | |
| group.add_argument('--foo', action='store_true') | |
| group.add_argument('--bar', action='store_false') | |
| settings = parser.parse_args() |
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 kafka import SimpleProducer, KafkaClient | |
| kafka = KafkaClient('localhost:9092') | |
| producer = SimpleProducer(kafka) | |
| producer.send_messages(b'my-topic', b'some message') | |
| producer.send_messages(b'my-topic', b'this method', b'is variadic') | |
| producer.send_messages(b'my-topic', u'안녕?'.encode('utf-8')) |
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 kafka import KafkaConsumer | |
| # To consume messages | |
| consumer = KafkaConsumer('my-topic', | |
| group_id='my_group', | |
| bootstrap_servers=['localhost:9092']) | |
| for message in consumer: | |
| # message value is raw byte string -- decode if necessary! | |
| # e.g., for unicode: `message.value.decode('utf-8')` |
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 apt-get update | |
| sudo apt-get install -y python-software-properties debconf-utils | |
| sudo add-apt-repository -y ppa:webupd8team/java | |
| sudo apt-get update | |
| echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections | |
| sudo apt-get install -y oracle-java8-installer |
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 human_format(num): | |
| magnitude = 0 | |
| while abs(num) >= 1000: | |
| magnitude += 1 | |
| num /= 1000.0 | |
| # add more suffixes if you need them | |
| return '%.2f%s' % (num, ['', 'K', 'M', 'G', 'T', 'P'][magnitude]) | |
| print('the answer is %s' % human_format(7436313)) # prints 'the answer is 7.44M' |
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
| nohup node server.js > server.log 2>&1& | |
| echo $! > server_pid.txt |
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 | |
| scriptname &>/dev/null |
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 convert_to_mib { | |
| local mib=$1 | |
| if [ $2 = "KB" ] | |
| then | |
| # if less than 1 MiB, just return 1 MiB | |
| mib=1 | |
| 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
| echo "hello" | python -c "import sys; sys.stdout.write( sys.stdin.read() )" |
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 docker inspect bwa | python -c "import json; import sys; j=json.loads(sys.stdin.read()); print j[0]['Config']['Labels']" |
OlderNewer