Skip to content

Instantly share code, notes, and snippets.

@nlindblad
nlindblad / README.md
Last active May 1, 2020
Most played songs by year on last.fm
View README.md

Most played songs by year from last.fm

How to use

Download last_fm_to_csv.py from this Gist (you might have to click "Raw" and then right-click and select "Save as").

You'll need an API key from last.fm, which you can get here. You can leave every field apart from Contact email and Application name blank.

Once you've got the API key, run the following in a terminal (assuming last_fm_to_csv.py got downloaded to your Downloads folder):

@nlindblad
nlindblad / README.md
Created May 18, 2017
Migrating from Github to Gitlab
View README.md

After setting up the repository with the exact same name (username/repository) with Gitlab and importing it directly in Gitlab.

git remote set-url origin $(git remote get-url origin|sed -e 's/github/gitlab/')
git push --all origin
@nlindblad
nlindblad / README.md
Last active Sep 16, 2016
Github SSH Key Check
View README.md

Github SSH Key Check

Checks ~/.ssh/authorized_keys against a list of Github users and checks who has access.

Usage:

$ python github-ssh-check.py -u nlindblad

Example output:

View keybase.md

Keybase proof

I hereby claim:

  • I am nlindblad on github.
  • I am nlindblad (https://keybase.io/nlindblad) on keybase.
  • I have a public key ASBEnrWN6BHDWT9Pgi8kcHD5HWmr7SqESagcNfB36iLfjQo

To claim this, I am signing this object:

@nlindblad
nlindblad / 07-djikstra.py
Created Sep 2, 2016
Grokking Algorithms
View 07-djikstra.py
#!/usr/bin/env python
graph = {
"start": {
"a" : 6,
"b" : 2
},
"a" : {
"fin" : 1
},
"b" : {
@nlindblad
nlindblad / README.md
Last active Jul 10, 2020
ACM Migration Summary
View README.md

ACM Migration Summary

This script iterates all ELBs in an account and lists whether they use Amazon Certificate Manager for SSL or not.

If your SSL certificate name ends with -expYYYY-MM-DD, the expiry date will also be listed and the final list is sorted by days until expiry.

## Install dependencies

Make sure you have virtualenv installed

@nlindblad
nlindblad / lets-encrypt-sha256.sh
Last active Jan 17, 2020
Let's Encrypt Certificates SHA256 fingerprint
View lets-encrypt-sha256.sh
#!/bin/bash
BASE_URL="https://letsencrypt.org/certs/"
CERTIFICATES="lets-encrypt-x3-cross-signed.pem lets-encrypt-x4-cross-signed.pem lets-encrypt-x1-cross-signed.pem lets-encrypt-x2-cross-signed.pem"
for CERTIFICATE in $CERTIFICATES; do
echo "# $CERTIFICATE "
curl --silent "${BASE_URL}${CERTIFICATE}" | openssl x509 -noout -fingerprint -sha256 -inform pem | cut -d'=' -f2 | tr '[:upper:]' '[:lower:]' | sed -e 's/://g' |
done
@nlindblad
nlindblad / config.py
Created Jun 16, 2016
Download and parse configuration file from AWS S3
View config.py
import boto3
import ConfigParser
import tempfile
class ConfigFromS3(object):
def __init__(self, bucket_name, key, region_name):
"""Read configuration file from S3 and parse it"""
defaults = {
@nlindblad
nlindblad / elb-connection-draining-status.sh
Created Apr 25, 2016
elb-connection-draining-status.sh
View elb-connection-draining-status.sh
#!/bin/bash
PROFILE="${1}"
ELBS=$(aws --profile ${PROFILE} elb describe-load-balancers --page-size 100 | jq -r '.LoadBalancerDescriptions[].LoadBalancerName')
for ELB in ${ELBS}; do
CONNECTION_DRAINING=$(aws --profile ${PROFILE} elb describe-load-balancer-attributes --load-balancer-name ${ELB} | jq ".LoadBalancerAttributes.ConnectionDraining.Enabled")
printf "%-32s %s\n" $ELB $CONNECTION_DRAINING
done
@nlindblad
nlindblad / nginx-build.sh
Last active Mar 18, 2016
nginx-build.sh
View nginx-build.sh
#!/bin/bash
set -e
NGINX_VERSION="1.9.12"
NGINX_TARBALL="nginx-${NGINX_VERSION}.tar.gz"
PCRE_VERSION="8.38"
PCRE_TARBALL="pcre-${PCRE_VERSION}.tar.gz"
OPENSSL_VERSION="1.0.1s"
OPENSSL_TARBALL="openssl-${OPENSSL_VERSION}.tar.gz"