Skip to content

Instantly share code, notes, and snippets.

View thiagoavadore's full-sized avatar

Thiago de Faria thiagoavadore

View GitHub Profile

Keybase proof

I hereby claim:

  • I am thiagoavadore on github.
  • I am thiagoavadore (https://keybase.io/thiagoavadore) on keybase.
  • I have a public key whose fingerprint is 1901 6927 5B2E 6279 FA25 707F 5D1B D2F2 52F4 F8B1

To claim this, I am signing this object:

@thiagoavadore
thiagoavadore / HugoS3BucketRedirect.json
Created June 15, 2020 09:19
S3 configuration file for Hugo static sites redirect
{
"IndexDocument": {
"Suffix": "index.html"
},
"ErrorDocument": {
"Key": "404.html"
},
"RoutingRules": [
{
"Redirect": {
{
"Comment": "My Hugo Static Hosting on S3",
"Logging": {
"Bucket": "<LOGGING-BUCKET>.s3.amazonaws.com",
"Prefix": "cdn-cf/",
"Enabled": true,
"IncludeCookies": false
},
"Origins": {
"Quantity": 1,
@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>"
},
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
*.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
mappings:
- match: '*.*.jvm.*.*'
name: jvm_memory_usage
labels:
application: $1
executor_id: $2
mem_type: $3
qty: $4
- match: '*.*.jvm.pools.*.*'
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)
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 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':