Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

  • 07:51 (UTC +01:00)
View GitHub Profile
AWSTemplateFormatVersion: '2010-09-09'
Description: Template to connect DynamoDB Stream to EventBridge
Resources:
OrdersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName:
Fn::Sub: ${AWS::StackName}-orders
AttributeDefinitions:
- AttributeName: id
@filipeandre
filipeandre / get-ec2.yaml
Created October 11, 2022 18:08 — forked from JAMSUPREME/get-ec2.yaml
SSM Automation
description: |-
### EC2 stopper by tag
Stop EC2 instances by tag
schemaVersion: '0.3'
mainSteps:
- name: getInstancesByTag
action: 'aws:executeAwsApi'
outputs:
- Name: InstanceIds
@filipeandre
filipeandre / check_tag_exists.py
Created August 5, 2022 12:47 — forked from nathanieltalbot/check_tag_exists.py
A simple Python function to check if an image tag exists in an ECR repo using boto3
# Checks if an image tag exists in the repo
def check_tag_exists(tag, repo):
ecr_client = boto3.client('ecr', region_name='us-east-1')
response = ecr_client.describe_images(repositoryName=repo, filter={'tagStatus': 'TAGGED'})
for i in response['imageDetails']:
if tag in i['imageTags']:
return True
return False
@SerhatTeker
SerhatTeker / ve
Created May 10, 2022 16:02
Automate Python Virtual Environment with a Script - https://tech.serhatteker.com/post/2022-04/automate-python-virtualenv
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# vim: set ft=sh et ts=4 sw=4 sts=4:
# =================================================================================================
#
# Copyright 2022 Serhat Teker <me@serhatteker.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
import { BatchExecuteStatementCommand, BatchExecuteStatementCommandInput, BatchGetCommand, BatchGetCommandInput, DeleteCommand, DeleteCommandInput, ExecuteStatementCommand, ExecuteStatementCommandInput, ExecuteTransactionCommand, ExecuteTransactionCommandInput, GetCommand, GetCommandInput, PutCommand, PutCommandInput, QueryCommand, QueryCommandInput, ScanCommand, ScanCommandInput, UpdateCommand, UpdateCommandInput } from "@aws-sdk/lib-dynamodb";
import { Logger } from "@nestjs/common";
import { DbClientsInstance } from "./db.clients";
class DbDataOps {
private static instance: DbDataOps;
private constructor() {
console.log('DbDataOps init');
if(DbDataOps.instance) {
@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
@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"
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 May 21, 2024 12:05
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