Skip to content

Instantly share code, notes, and snippets.

View GoodMirek's full-sized avatar

Mirek Svoboda GoodMirek

  • Brno, Czech Republic
View GitHub Profile
@GoodMirek
GoodMirek / AWS_EC2_user_data.txt
Last active October 5, 2021 05:43
AWS EC2 user data execution upon every boot
# Running user data on EC2 instance during every boot (default is that it runs only on first boot during instance launch):
# Add the following tag to user data:
# <persist>true</persist>
# Example:
<script>net start codedeployagent</script>
<persist>true</persist>
@GoodMirek
GoodMirek / Fastfile
Created September 7, 2017 20:52
Fastfile for Apple iOS build, resilient against Apple Developer Portal outages. Works with Xcode8.
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# If you want to automatically update fastlane if a new version is available:
# update_fastlane
@GoodMirek
GoodMirek / disable_troublesom_scaling_processes.py
Created August 23, 2017 08:59 — forked from simon-weber/disable_troublesom_scaling_processes.py
disable ASG scaling processes during CodeDeploy deploys
"""
Suspend an auto scaling group's scaling processes that can interfere with CodeDeploy deploys.
It assumes a single ASG per deployment group.
To use this:
* create a lambda function with this code, then hook up it up to an SNS topic that receives all deployment events (but not host events).
* attach that topic as a trigger in your deployment groups.
Unlike AWS's in-appspec approach, this supports arbitrary deploy concurrency.
@GoodMirek
GoodMirek / rabbitmq2cloudwatch
Last active January 28, 2020 09:03
Bash script sending RabbitMQ metrics to AWS CloudWatch
#! /bin/bash
# This script reads rabbitmq statistics and report them as CloudWatch metrics.
# Author: Mirek Svoboda
# Version: 0.3
# TABSTOP=4
#
# Changelog:
# 0.3
# -- increasing number of AWS CLI calls from 3 to 5. We have added RabbitMQ queues and then hit a limit of 20 datapoints.
#
@GoodMirek
GoodMirek / calculate_read_only_routing_url.sql
Created January 10, 2017 13:22
T-SQL script for calculating read_only_routing_url for AlwaysOn
-- Original URL of this script and related article: https://blogs.msdn.microsoft.com/mattn/2012/04/25/calculating-read_only_routing_url-for-alwayson/
-- Script formatting is seriously broken at original location
--
-- Read-only routing url generation script.
-- Connect to each replica in your AlwaysOn cluster and run this script to get the read_only_routing_url for the replica.
-- Then set this to the read_only_routing_url for the availability group replica =>
-- alter availability group MyAvailabilityGroup modify replica on N’ThisReplica’ with (secondary_role(read_only_routing_url=N'<url>’))
print 'Read-only-routing url script v.2012.1.24.1'
print 'This SQL Server instance version is [' + cast(serverproperty('ProductVersion') as varchar(256)) + ']'
@GoodMirek
GoodMirek / userdata
Last active August 3, 2017 18:20
AWS EC2 Windows instance userdata for automated installation of Datadog agent
<powershell>
# Comment: EC2config service executes user data upon boot, if configured to do so.
# EC2config log is available at: C:\Program Files\Amazon\Ec2ConfigService\Logs\Ec2ConfigLog.txt
mkdir "c:\datadog\download"
Set-Location "c:\datadog\download"
Read-S3Object -BucketName ddagent-windows-stable -Key ddagent-cli.msi -File c:\datadog\download\ddagent-cli.msi
& msiexec --% /qn /i c:\datadog\download\ddagent-cli.msi APIKEY="abcdefghijklmnopqrstuvwxyz123456" TAGS="environment:production"
</powershell>