Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

View GitHub Profile
@daaru00
daaru00 / template.yml
Created July 8, 2021 14:44
A SAM template that describe an Amazon CloudFront distribution that serve a static website from an S3 Bucket.
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Personal Website"
# Template Parameters
@rietta
rietta / batch-convert-heic.rb
Created July 6, 2021 22:47
Shell script to batch convert HEIC files to jpeg, leaving the original and its converted side by side. Requires Mac OS or Linux, the find command line tool, and ImageMagick
#!/usr/bin/env ruby
require 'shellwords'
files = `find . -iname '*.heic'`.split("\n")
files.each do |original_file|
output_file = original_file.gsub(/\.heic\z/i, ' Converted.jpg')
if File.exist?(output_file)
STDERR.puts "Skipping output #{output_file} exists."
else
@leegilmorecode
leegilmorecode / serverless.yml
Created June 27, 2021 14:26
Example of AWS AppConfig alongside the Serverless Framework for the use of Feature Flags
service: serverless-feature-flag
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: 20201221
memorySize: 128
stage: ${opt:stage, 'develop'}
region: eu-west-1
apiGateway:
shouldStartNameWithService: true
@luhn
luhn / mount.sh
Created April 5, 2021 21:21
Mount NVMe EBS volume
# Mount the data disk
# Adapted from https://gist.github.com/ctompkinson/30f570882af38879b36fc7bffe3d1a60
device=/dev/sdh
mount_point=/monitor-config
apt-get install -y nvme-cli
while [ true ]; do
for blkdev in $(nvme list | awk '/^\/dev/ { print $1 }'); do
mapping=$(nvme id-ctrl --raw-binary "${blkdev}" | cut -c3073-3104 | tr -s ' ' | sed 's/ $//g')
if [ ${mapping} = ${device} ]; then
echo "Found $device on $blkdev"
@t-kigi
t-kigi / template.yaml
Last active November 13, 2024 13:56
cloudformation for CloudFront +Private S3 hosting plus Signed Cookie Behavior
AWSTemplateFormatVersion: '2010-09-09'
Description: Hosting resource stack creation using Amplify CLI
Parameters:
env:
Type: String
Default: gist
bucketName:
Type: String
Default: cfn-sample-bucketname-20210209000412
pubkeyCallerReference:
import axios, { AxiosResponse } from 'axios';
import dotenv from 'dotenv';
import newman from 'newman';
import { Collection, Variable } from 'postman-collection';
import { Logger } from './logger.js';
interface PostmanMetadata {
id: string;
name: string;
@atheiman
atheiman / Cfn-Stack.yml
Last active November 6, 2024 11:46
Run command across accounts and regions with SSM
AWSTemplateFormatVersion: '2010-09-09'
Description: >
SSM Automation Document run a custom SSM Command Document
against a fleet of target instances.
Parameters:
AutomationDocumentName:
Type: String
Description: Name of created SSM Automation Document
Default: MyAutomation
@atheiman
atheiman / ssm_offline_instances.py
Created September 8, 2020 22:59
Dump EC2 instances that do not have SSM PingStatus of 'Online'
import boto3
import json
region = "us-gov-west-1"
all_instance_ids = [
i.id for i in boto3.resource("ec2", region_name=region).instances.all()
]
ssm_inst_paginator = boto3.client("ssm", region_name=region).get_paginator(
@dabit3
dabit3 / cdk-chat-stack.ts
Last active October 11, 2024 12:52
Creating DynamoDB tables with a GSI with CDK
const messageTable = new Table(this, 'CDKMessageTable', {
billingMode: BillingMode.PAY_PER_REQUEST,
partitionKey: {
name: 'id',
type: AttributeType.STRING,
},
});
const roomTable = new Table(this, 'CDKRoomTable', {
billingMode: BillingMode.PAY_PER_REQUEST,