Skip to content

Instantly share code, notes, and snippets.

@niklasvincent
niklasvincent / README.md
Last active May 1, 2020 07:04
Most played songs by year on last.fm

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):

@niklasvincent
niklasvincent / README.md
Created May 18, 2017 20:10
Migrating from Github to Gitlab

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

@niklasvincent
niklasvincent / README.md
Last active September 16, 2016 15:31
Github SSH Key Check

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:

@niklasvincent
niklasvincent / keybase.md
Created September 11, 2016 11:27
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:

@niklasvincent
niklasvincent / 07-djikstra.py
Created September 2, 2016 20:28
Grokking Algorithms
#!/usr/bin/env python
graph = {
"start": {
"a" : 6,
"b" : 2
},
"a" : {
"fin" : 1
},
"b" : {
@niklasvincent
niklasvincent / README.md
Last active July 10, 2020 14:18
ACM Migration Summary

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

@niklasvincent
niklasvincent / lets-encrypt-sha256.sh
Last active September 9, 2023 09:04
Let's Encrypt Certificates SHA256 fingerprint
#!/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
@niklasvincent
niklasvincent / config.py
Created June 16, 2016 20:57
Download and parse configuration file from AWS S3
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 = {
@niklasvincent
niklasvincent / elb-connection-draining-status.sh
Created April 25, 2016 13:14
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
@niklasvincent
niklasvincent / nginx-build.sh
Last active March 18, 2016 12:25
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"