Skip to content

Instantly share code, notes, and snippets.

View madssj's full-sized avatar

Mads Sülau Valstorp Jørgensen madssj

  • San Jose, United States
View GitHub Profile
@madssj
madssj / get_ips.sh
Created October 5, 2015 11:17
Returns the ip ranges of a given AWS service.
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json|grep -B 2 CLOUDFRONT|grep -oE "\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}\b"
#include <openssl/ssl.h>
int main(int argc, char **argv) {
return 0;
}

Keybase proof

I hereby claim:

  • I am madssj on github.
  • I am madssj (https://keybase.io/madssj) on keybase.
  • I have a public key whose fingerprint is A8FF F2C5 7038 93A4 1435 C4B1 E12B 4C53 E051 13A1

To claim this, I am signing this object:

The new mirror selector doesn't work without the traling slash.
➜ ~ curl -iH 'Host: httpredir.debian.org' 5.153.231.35/debian/
HTTP/1.1 302 Found
Date: Wed, 22 Jul 2015 14:22:21 GMT
Location: http://mirror.easyspeedy.com/debian/
Content-Type: text/plain
X-Clacks-Overhead: GNU Terry Pratchett
@madssj
madssj / .vimrc
Last active August 29, 2015 14:17
Current .vimrc file
if has('vim_starting')
if &compatible
set nocompatible
endif
set runtimepath+=/Users/mads/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand('/Users/mads/.vim/bundle'))
@madssj
madssj / gist:142e5bcb714f9e162ae0
Created February 27, 2015 13:57
A fix for running a wordpress with a new url, setting WP_HOME and WP_SITEURL to whatever is in $_SERVER['HTTP_HOST']
/** Automaticly set the correct WP_HOME and WP_SITEURL based on HTTP_HOST */
$absolute_url = "http" . ($_SERVER['HTTPS'] ? 's' : '') . "://{$_SERVER['HTTP_HOST']}";
if ($_SERVER['HTTP_PORT'] != 80 || $_SERVER['HTTP_PORT'] != 443) {
$absolute_url .= "{$_SERVER['HTTP_PORT']}";
}
define('WP_HOME', $absolute_url);
define('WP_SITEURL', $absolute_url);
# Because the package manager really should *not* be the
# judge over if you should install a package or not - I actually
# need to use sshpass because of things outside of my control.
#
# Of course I'll use a long and secure encrypted ssh key when
# possible.
#
# Sometimes this is not possible. Deal with it.
#
# Note: If you in any way can, use public/private key authentication.
@madssj
madssj / compressors.py
Last active August 29, 2015 13:56
Ngmin compressor mixin for django-pipeline
# edit: i put this in a project called django-pipeline-ngmin-mixin-compressor
# which you should use
from pipeline.conf import settings
from pipeline.compressors.yuglify import YuglifyCompressor
from pipeline.compressors.uglifyjs import UglifyJSCompressor
class NgminMixIn(object):
"""
@madssj
madssj / s3_restore.py
Last active December 26, 2015 08:08
Restores keys from Amazon Glaicer based on a given bucket and prefix. Uses multiprocessing to speed up marking keys as restored.
import sys
import boto
import multiprocessing
NUM_PROCS = 16
bucket_name = sys.argv[1]
prefix = sys.argv[2]
try:
@madssj
madssj / debian_upgrade_postgresql.sh
Last active December 25, 2015 04:49
A shell script to upgrade between versions of PostgreSQL on Debian. Use at your own risk.
#!/bin/sh
if [ $# -ne 2 ]
then
echo "Usage: $0 <from> <to>"
exit 1
fi
from=$1
to=$2