Skip to content

Instantly share code, notes, and snippets.

View thiagoavadore's full-sized avatar

Thiago de Faria thiagoavadore

View GitHub Profile
def check_demo(intent_request):
caller_id = get_call_id(intent_request['sessionAttributes'])
output_session_attributes = intent_request['sessionAttributes'] if intent_request[
'sessionAttributes'] is not None else {}
content = "Sorry, we couldn't find your Darius MLOps platform demo."
if caller_id is not '':
response = table.query(
KeyConditionExpression=Key('phoneNumber').eq(caller_id)
)
def build_response_card(title, subtitle, options):
buttons = None
if options is not None:
buttons = []
for i in range(min(5, len(options))):
buttons.append(options[i])
return {
'contentType': 'application/vnd.amazonaws.card.generic',
'version': 1,
def schedule_demo(intent_request):
date = intent_request['currentIntent']['slots']['Date']
appointment_time = intent_request['currentIntent']['slots']['Time']
source = intent_request['invocationSource']
caller_id = get_call_id(intent_request['sessionAttributes'])
output_session_attributes = intent_request['sessionAttributes'] if intent_request['sessionAttributes'] is not None else {}
timeslot_map = json.loads(try_except_key_error(lambda: output_session_attributes['timeslotMap']) or '{}')
if source == 'DialogCodeHook':
def dispatch(intent_request):
logger.debug(
'dispatch userId={}, intentName={}'.format(intent_request['userId'], intent_request['currentIntent']['name']))
intent_name = intent_request['currentIntent']['name']
if intent_name == 'ScheduleDemo':
return schedule_demo(intent_request)
elif intent_name == 'CheckDemo':
return check_demo(intent_request)
def lambda_handler(event, context):
os.environ['TZ'] = 'Europe/Amsterdam'
time.tzset()
logger.debug('event.bot.name={}'.format(event['bot']['name']))
logger.debug('event={}'.format(event))
return dispatch(event)
mappings:
- match: '*.*.jvm.*.*'
name: jvm_memory_usage
labels:
application: $1
executor_id: $2
mem_type: $3
qty: $4
- match: '*.*.jvm.pools.*.*'
*.sink.graphite.class=org.apache.spark.metrics.sink.GraphiteSink
*.sink.graphite.host=$GRAPHITE_EXPORTER_HOSTNAME
*.sink.graphite.port=$GRAPHITE_EXPORTE_PORT
*.sink.graphite.period=10
*.sink.graphite.unit=seconds
master.source.jvm.class=org.apache.spark.metrics.source.JvmSource
worker.source.jvm.class=org.apache.spark.metrics.source.JvmSource
driver.source.jvm.class=org.apache.spark.metrics.source.JvmSource
executor.source.jvm.class=org.apache.spark.metrics.source.JvmSource
graphite_exporter:
image: prom/graphite-exporter
command: "--graphite.mapping-config=/tmp/graphite_mapping_spark.conf"
container_name: graphite_exporter
volumes:
- $GRAPHITE_MAPPING_PATH/graphite_mapping_spark.conf:/tmp/graphite_mapping_spark.conf
@thiagoavadore
thiagoavadore / HugoCloudfrontRoute53.json
Last active June 15, 2020 10:10
Route53 configuration file to update a Domain and its www version to a cloudfront distribution
{
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"AliasTarget": {
"HostedZoneId": "Z2FDTNDATAQYW2",
"EvaluateTargetHealth": false,
"DNSName": "<CLOUDFRONT_URI>"
},
{
"Comment": "My Hugo Static Hosting on S3",
"Logging": {
"Bucket": "<LOGGING-BUCKET>.s3.amazonaws.com",
"Prefix": "cdn-cf/",
"Enabled": true,
"IncludeCookies": false
},
"Origins": {
"Quantity": 1,