Skip to content

Instantly share code, notes, and snippets.

View jemerick's full-sized avatar

Jason Emerick jemerick

View GitHub Profile
@jemerick
jemerick / README.md
Last active January 15, 2016 23:02 — forked from StefanWallin/README.md
nginx ssl config with multiple SNI vhosts and A+ SSL Labs score as of 2014-11-05

Configuring nginx for SSL SNI vhosts

Gotchas

Remarks

  • My version of konklones SSL config does not have SPDY support(my nginx+openssl does not support it)
  • You need a default ssl server (example.org-default.conf).
  • Some SSL-options have to be unique across your instance, so it's easier to have them in a common file(ssl.conf).
@jemerick
jemerick / gist:9536094
Created March 13, 2014 20:17 — forked from kevingessner/gist:9509148
Responsive email template
<html>
<head>
<style type="text/css">
table table {
width: 600px !important;
}
table div + div { /* main content */
width: 65%;
float: left;
}
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {
private final Context context;
private final LayoutInflater inflater;
#!/bin/bash
# note: this won't work too well with filenames/directories with spaces in them
compressresource() {
gzip -c9 "$1" > "$1.gz"
touch -c --reference="$1" "$1.gz"
echo "Compressed: $1 > $1.gz"
}
@jemerick
jemerick / json-response.py
Created October 6, 2011 18:11 — forked from leah/json-response.py
JSONResponse classes
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
@jemerick
jemerick / Folder Preferences
Created October 2, 2011 20:07 — forked from chrisyour/Folder Preferences
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
// Provides a device_scale class on iOS devices for scaling user
// interface elements relative to the current zoom factor.
//
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari
// Copyright (c) 2010 37signals.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
import os, sys
sys.path.append('/var/django/ihome')
# redirect print statements to the apache log
sys.stdout = sys.stderr
os.environ['DJANGO_SETTINGS_MODULE'] = 'ihome.settings'
import django.core.handlers.wsgi
"""
Simple timer class. Example usage:
t = Timer()
for url in ('http://www.google.com/', 'http://www.yahoo.com/'):
t.start('fetch url')
content = urllib.urlopen(url).read()
t.stop('fetch url')
t.start('reorder bytes')
bytes = list(content)
"""
Some simple utilities to read the magic bytes from the beginning of a
file and determine whether the file meets certain criteria (e.g., contains
JPEG image data).
"""
import array
from operator import eq
IMAGE_MAGIC_DATA = (