Skip to content

Instantly share code, notes, and snippets.

@kll
kll / TypeMemberLayout.xaml
Last active May 25, 2024 05:46
ReSharper/Rider StyleCop file layout
<?xml version="1.0" encoding="utf-16"?>
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern DisplayName="Non-reorderable types">
<TypePattern.Match>
<Or>
<And>
<Kind Is="Interface" />
<Or>
<HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" />
<HasAttribute Name="System.Runtime.InteropServices.ComImport" />
@kll
kll / iam-store-credentials.sh
Last active May 15, 2018 02:18
Fetches the IAM instance profile provided credentials inside of an EC2 instance and stores them in environment variables. usage: source iam-store-credentials.sh
#!/bin/bash
IAM_INFO=$(GET http://169.254.169.254/latest/meta-data/iam/info)
IAM_INSTANCE_PROFILE=$(echo "${IAM_INFO}" | sed -n 's_^[^/]*/\([^"]*\)".*_\1_p')
IAM_CREDENTIALS_URL="http://169.254.169.254/latest/meta-data/iam/security-credentials/$IAM_INSTANCE_PROFILE"
IAM_CREDENTIALS=$(GET $IAM_CREDENTIALS_URL)
export AWS_ACCESS_KEY=$(echo "${IAM_CREDENTIALS}" | sed -n 's_.*"AccessKeyId" : "\([^"]*\)".*_\1_p')
export AWS_SECRET_KEY=$(echo "${IAM_CREDENTIALS}" | sed -n 's_.*"SecretAccessKey" : "\([^"]*\)".*_\1_p')
export AWS_DELEGATION_TOKEN=$(echo "${IAM_CREDENTIALS}" | sed -n 's_.*"Token" : "\([^"]*\)".*_\1_p')