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 / 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 / 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);
@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'))
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

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:

@madssj
madssj / gist:1319151
Created October 27, 2011 09:25
Get a random name from /usr/share/dict/propernames
def get_random_name():
"""
Return a random proper name in a somewhat efficient way.
"""
fp = open("/usr/share/dict/propernames")
fp.seek(0, 2)
size = fp.tell()
fp.seek(0)
fp.seek(int(random.random() * size * 0.95))
#include <openssl/ssl.h>
int main(int argc, char **argv) {
return 0;
}
@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"
var a:XML = <request command="run-command" />;
var r:URLRequest = new URLRequest("http://localhost/service.php");
r.data = a;
r.method = URLRequestMethod.POST;
r.contentType = "text/xml";
var l:URLLoader = new URLLoader();
l.addEventListener(Event.COMPLETE, function(e:Event) {
trace("success", l.data);
#!/bin/sh
if [ $# -ne 2 ]
then
echo "Usage: $0 <postgresql sql dump> <db_name>" >&2
exit 1
fi
db_file=$1
db_name=$2