Skip to content

Instantly share code, notes, and snippets.

View benbridts's full-sized avatar

Ben Bridts benbridts

View GitHub Profile
@benbridts
benbridts / lambda-with-loggroup.yaml
Last active October 19, 2023 08:52
AWS Lambda Function with a generated name, using a CloudFormation-managed LogGroup
Resources:
Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal: {Service: lambda.amazonaws.com}
@benbridts
benbridts / cloudformation-select-split-trick.md
Created March 5, 2021 21:19
How to select a value out of the !GetAtt Firewall.EndpointIds

Remarks:

  • I decided to use the Fn::Function form in most cases, as I didn't want to deal with when you're allowed or not allowed to nest them. If you want them all in the short format, you can flip it twice with cfn_flip
  • When writing, I think about it from the bottom the the top / from the inside to the outside
  • There is a summary at the end, with the steps instead of the values as comments

The trick

The trick is that splitting on a token, or seeking to the first / second / ... token in a string is very similar.

Example

If we split on something unique, we get everything before token and everything after token

@benbridts
benbridts / template.yaml
Created June 16, 2020 08:55
CloudFormation template only outputting the not empty parameters
---
Parameters:
Parameter01:
Type: String
Default: ''
Parameter02:
Type: String
Default: ''
Parameter03:
Type: String
@benbridts
benbridts / send_message.py
Created May 13, 2017 15:00
Script to send messages to alexa
import requests
import sys
# Configuration, you need to capture this from a request made by the Amazon Alexa App
# Host, conversation_id and sender appear to be static
host = ''
conversation_id = ''
sender = ''
# ubid_main and at_main change over time, so you will need to recapture them from time to time
ubid_main = ''
@benbridts
benbridts / data.json
Created March 18, 2017 15:50
S3 status history
{
"us-west-1": {
"apigateway": {
"launch_time": "2016-12-01 00:00:00",
"number_of_events": 0,
"events": []
},
"cloudsearch": {
"launch_time": null,
"number_of_events": 0,

Keybase proof

I hereby claim:

  • I am bandb42 on github.
  • I am ikben (https://keybase.io/ikben) on keybase.
  • I have a public key whose fingerprint is B057 B555 E86C 257E A3FA 5CEE 9C38 D937 DCB1 26FB

To claim this, I am signing this object:

#!/bin/bash
# This script will switch all textual columns in your db to a new encoding
# without switching the actual bytes in those columns. If you had a dumb
# programming language like Ruby 1.8 that dumped a bunch of utf8-encoded
# strings into your latin1 database columns, then switching to a better
# programming language (like Ruby 1.9) may get you some weird results. MySQL
# will try to be helpful, and convert the stored bytes from latin1 to utf8. But
# since they're already in utf8, you get gobblidigook.
#
# Find more detail and a more complete description of the strategy used here at
@benbridts
benbridts / examentool.sh
Created May 11, 2014 12:55
Examentool on fedora
##############
# xprintidle #
##############
# install xprintidle dependencies
sudo yum -y install libXScrnSaver-devel libx11-devel
# download xprintidle source
wget https://launchpad.net/ubuntu/+archive/primary/+files/xprintidle_0.2.orig.tar.gz
# extract
tar -xf xprintidle_0.2.orig.tar.gz
cd xprintidle-0.2/
@benbridts
benbridts / dfcolor.sh
Last active December 15, 2015 02:49
Oplossingen examen computersystemen 2 (praktijk Linux)
#! /bin/bash
#
# Ben Bridts - 2013-03-18
#
reset='\e[0m'
red='\e[0;31m'
yellow='\e[1;33m'
blue='\e[0;34m'
regex="([[:digit:]]{1,3})[%]"