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/awk -f | |
# | |
# analyzes ping output on Linux and looks for missed returns | |
# based on icmp_seq | |
# | |
# ping output is expected on stdin | |
# | |
BEGIN { num = 0 } | |
$5 ~ /icmp_seq=/ { |
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
{"us-east-1": {"m1.large": {"Windows": [[190, 210], [214, 217], [220], [241], [250], [257], [280], [350], [450], [500], [700]], "Linux/UNIX": [[114, 126], [140], [145], [150], [180], [200], [220], [300], [320], [330], [340], [350], [500], [680]], "SUSE/Linux": [[126, 140]]}, "m2.2xlarge": {"Windows": [[523, 577], [1500]], "Linux/UNIX": [[399, 441], [1000]], "SUSE/Linux": [[335, 371]]}, "m1.small": {"Windows": [[48, 52], [70], [125]], "Linux/UNIX": [[29, 31], [40], [45], [50], [85]], "SUSE/Linux": [[41, 45]]}, "c1.medium": {"Windows": [[119, 131], [151], [170], [200], [290], [450]], "Linux/UNIX": [[57, 63], [65], [67, 68], [70], [75], [80], [85], [90], [100], [110], [120]], "SUSE/Linux": [[69, 77]]}, "m1.xlarge": {"Windows": [[380, 420], [960]], "Linux/UNIX": [[228, 252]], "SUSE/Linux": [[240, 266]]}, "m2.xlarge": {"Windows": [[228, 252], [450], [620], [650]], "Linux/UNIX": [[162, 178], [184], [200], [220], [250], [300], [350], [500], [550], [560], [600], [750]], "SUSE/Linux": [[174, 192]]}, "t1.micro": {"Wind |
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 revenue_maximizing_spot_price(n, bids): | |
assert len(bids) <= n, "does not work when the number of bids exceeds n" | |
revenue, spot_price = max( | |
[ (sum([p for x in bids if x >= p]), p) for p in bids ]) | |
return spot_price, revenue | |
if __name__ == '__main__': | |
print revenue_maximizing_spot_price(10, [ 1, 2, 5, 50 ]) | |
# -> (50, 50) | |
print revenue_maximizing_spot_price(10, [ 1, 2, 5, 45, 50 ]) |
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
module Jekyll | |
Page.class_eval { | |
def clone | |
Page.new(@site, @base, @dir, @name) | |
end | |
} |
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
#!/opt/sensu/embedded/bin/ruby | |
# | |
# Check num_occurrences_filter logic | |
# | |
# Reads sensu-server log on stdin, looks for messages that are | |
# marked with 'event was filtered' and runs them through this tester handler | |
# to make sure it would filter them as well | |
# | |
# http://github.com/yelp/sensu_handlers | |
# |
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
$ diff -u f.py f1.py | |
--- f.py 2016-10-19 18:31:41.000000000 -0500 | |
+++ f1.py 2016-10-19 18:32:25.000000000 -0500 | |
@@ -53,7 +53,7 @@ | |
class DiscoveryServiceCached(DiscoveryService): | |
def __init__(self, *args, **kwargs): | |
- super(DiscoveryService.__class__, self).__init__(*args, **kwargs) | |
+ super(self.__class__, self).__init__(*args, **kwargs) | |
self.hit_cache = {} |
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
require 'aws-xray-sdk' | |
def random_sleep_under_1s | |
r = Random.rand | |
sleep r | |
r | |
end | |
def xray(segment_name, method_name, with_subsegments: true) | |
parent_id = ENV['_X_AMZN_TRACE_ID'].gsub(/.*Parent=/, '').split(';').first |
OlderNewer