This file contains 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/env python | |
""" | |
Broker API log parser | |
https://help.datadoghq.com/hc/en-us/articles/209064386-How-to-collect-metrics-or-events-with-a-Custom-Log-Parser | |
""" | |
import datetime | |
import re |
This file contains 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 restart_elasticsearch(): | |
""" | |
Restart es from one place using this command | |
Restart one node at a time, starting with master | |
Wait till cluster is in yellow state before doing the next one | |
Usage: | |
fab restart_elasticsearch -H rad@search1.int.fanxchange.com | |
""" | |
first_host = env.hosts[0] | |
if '@' in first_host: |
This file contains 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
(metadata like "%Camp Nou%" or | |
metadata like "%Wembley%" or | |
metadata like "%Croke Park%" or | |
metadata like "%Twickenham%" or | |
metadata like "%Signal Iduna Park%" or | |
metadata like "%Stade de France%" or | |
metadata like "%Santiago Bernabéu%" or | |
metadata like "%Luzhniki%" or | |
metadata like "%San Siro%" or | |
metadata like "%Atatürk Olympic%" or |
This file contains 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
and | |
(metadata like "%Camp Nou%" or | |
metadata like "%Wembley%" or | |
metadata like "%Croke Park%" or | |
metadata like "%Twickenham%" or | |
metadata like "%Signal Iduna Park%" or | |
metadata like "%Stade de France%" or | |
metadata like "%Santiago Bernabéu%" or | |
metadata like "%Luzhniki%" or |
This file contains 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
class TicketMachine(object): | |
def __init__(self, route1_name, route1_child, route1_adult, route2_name, route2_child, route2_adult): | |
self.routes = [ | |
{'name': route1_name, 'child_fare': route1_child, 'adult_fare': route1_adult}, | |
{'name': route2_name, 'child_fare': route2_child, 'adult_fare': route2_adult} | |
] | |
self.selected_route = None |
This file contains 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
AWSTemplateFormatVersion: '2010-09-09' | |
Description: > | |
AWS CloudFormation template to create a new VPC | |
or use an existing VPC for ECS deployment | |
in Create Cluster Wizard. Requires exactly 1 | |
Instance Types for a Spot Request. | |
Parameters: | |
EcsClusterName: | |
Type: String | |
Description: > |
This file contains 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_file='/path/to/env/file' | |
env_vars = [] | |
with open(env_file) as f: | |
for line in f: | |
if line.startswith('#'): | |
continue | |
# if 'export' not in line: | |
# continue | |
# Remove leading `export ` | |
# then, split name / value pair |
This file contains 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
# -*- coding: utf-8 -*- | |
# #!/usr/bin/env python | |
""" | |
Deploy docker image to ecs, upload repo to ecr | |
Pass the repository url, the tag and the service family | |
Also checks cluster is there or creates it | |
Sets up necessary ELB and TG | |
""" | |
import os | |
import sys |
This file contains 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
""" | |
Pub/sub is a pattern used in scaling software its important to understand what sort of | |
scaling it helps with. An important distinction is between pub/sub and message queueing. | |
In the queueing pattern, a queue (or list in Redis) buffers the messages to be processed while | |
a pool of workers pops items off the list and handles them. In this model, scaling the size of | |
your pool of workers scales the speed with which you process your queue, because each message | |
is passed to only one worker. All of the workers handle any given message in the exact same way. | |
In pub/sub on the other hand, the system attempts to deliver all of a channels messages to all |
This file contains 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 __future__ import unicode_literals | |
""" | |
S3 bucket CRUD operations core module | |
""" | |
import logging | |
import time | |
import boto3 | |
import botocore | |
from botocore.client import Config |