Skip to content

Instantly share code, notes, and snippets.

View nfelger's full-sized avatar

Niko Felger nfelger

View GitHub Profile
@nfelger
nfelger / obs.py
Last active April 28, 2022 10:10
OBS request signing
import binascii
from datetime import datetime
import hashlib
import hmac
import os
import requests
access_key_id = os.getenv('AWS_ACCESS_KEY_ID')
secret_access_key = os.getenv('AWS_SECRET_ACCESS_KEY')
@nfelger
nfelger / tf.log
Created March 13, 2017 09:33
Terraform debug log
2017/03/13 10:10:55 [INFO] Terraform version: 0.8.8
2017/03/13 10:10:55 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.8.8/bin/terraform", "import", "aws_route53_record.domainkey", "Z0000000000000_some._domainkey.mydomain.com_TXT"}
2017/03/13 10:10:55 [DEBUG] Detected home directory from env var: /Users/nfelger
2017/03/13 10:10:55 [DEBUG] Detected home directory from env var: /Users/nfelger
2017/03/13 10:10:55 [DEBUG] Attempting to open CLI config file: /Users/nfelger/.terraformrc
2017/03/13 10:10:55 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/03/13 10:10:55 [DEBUG] Detected home directory from env var: /Users/nfelger
2017/03/13 10:10:55 [DEBUG] New state was assigned lineage "16e415ff-cd53-4f95-970a-3fdec824d014"
2017/03/13 10:10:55 [TRACE] ConfigTransformer: Starting for path: []
2017/03/13 10:10:55 [TRACE] Graph after step *terraform.ConfigTransformer:
@nfelger
nfelger / s3_down.sh
Created April 15, 2015 10:27
Quick and dirty s3 speed tests with temporary STS credentials
#!/bin/bash
# Inspired by http://dl.getipaddr.net/ and http://curl.haxx.se/mail/archive-2014-10/0006.html
file=path/to/file
bucket=your-bucket
contentType="application/octet-stream"
dateValue=`date -R`
resource="/${bucket}/${file}"
s3Key=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/ec2-app-role | grep 'AccessKeyId' | sed 's/.* "\([^"]*\).*/\1/'`
s3Secret=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/ec2-app-role | grep 'SecretAccessKey' | sed 's/.* "\([^"]*\).*/\1/'`
token=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/ec2-app-role | grep 'Token' | sed 's/.* "\([^"]*\).*/\1/'`
@nfelger
nfelger / get_from_domains.py
Created February 4, 2015 12:08
Get all domains an mbox has received email from
import mailbox
from collections import defaultdict
from flanker import mime
from flanker.addresslib import address
mbox_path = '...'
mbox = mailbox.mbox(mbox_path)
domains = defaultdict(int)
@nfelger
nfelger / com.whatever.dailylinks.plist
Created November 1, 2013 08:11
Using AppleScript and launchd to open a bunch of URLs every morning when I get into work. (Why not just a shell script in cron? If your Mac is asleep when the run is scheduled, launchd will run it when you next wake it from sleep.)
var myModule = angular.module('myModule', []);
myModule.run(function() {
jQuery.ajax({
method: 'GET',
url: '/foo',
dataType: 'json',
async: false,
success: function (data) {
...
@nfelger
nfelger / gist:5221574
Created March 22, 2013 14:14
get commit messages
require 'grit'
root_dir = "/some/path"
terms = ['niko', 'nfelger']
Dir[root_dir + "/*/.git"].each do |dir|
repo = Grit::Repo.new(dir)
File.open("/where/ever/commit_messages/#{dir.split('/')[-2]}", 'w') do |file|
step = 100
@nfelger
nfelger / movietize.sh
Created January 26, 2013 19:45
Script to make a movie from some 480x640 pixel JPGs, and imprint the images with their creation date (OSX only).
#!/bin/bash
# Image sequence counter. Makes the ffmpeg command simpler.
imgNr=0
# Clear any previously generated intermediate files.
rm -rf dated rotated
mkdir dated
mkdir rotated
@nfelger
nfelger / gist:4329505
Created December 18, 2012 16:35
Download all your Instagram snaps.
#!/bin/sh
# Take the command to execute from the command line.
command=$@
# Default to updating the project if no command given.
[ -z "$command" ] && command='git pull --rebase ; git submodule init && git submodule update'
# Colors.
boldgreen=$(tput bold)$(tput setaf 2)
colorreset=$(tput sgr0)