Skip to content

Instantly share code, notes, and snippets.

@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')
@mswietlicki
mswietlicki / AsyncExtensions.cs
Created July 30, 2013 12:52
InCompletionOrder allows you to do foreach on collection of Tasks that will process them as fast as they complete.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Asyncfun
{
public static class AsyncExtensions
{
@willb
willb / backup-db.rb
Created August 29, 2012 21:00
Backup script for SQLite databases
#!/usr/lib/env ruby
# Acquires a shared lock on a SQLite database file and copies it to a backup
# usage: backup-db.rb DBFILE.db BACKUPFILE.db
# author: William Benton (willb@redhat.com)
# Public domain.
require 'sqlite3'
require 'fileutils'
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@scottb
scottb / app-assets-javascripts-application.js
Created September 7, 2011 15:48
Getting Dojo to work with Rails 3.1 and Sprockets
//= require_directory .
dojo.require('dojox.rails');