Skip to content

Instantly share code, notes, and snippets.

View elidickinson's full-sized avatar

Eli Dickinson elidickinson

View GitHub Profile
@elidickinson
elidickinson / media-queries.css
Created July 12, 2012 20:20
Tisa theme bugfix for single column 3.4.1
@media screen and (max-width: 980px) {
/************************************************************************************
STRUCTURE
*************************************************************************************/
.pagewidth {
max-width: 94%;
}
/* content */
@elidickinson
elidickinson / emailchecker.py
Created October 23, 2012 12:59
Script to check that a list of email address have valid domains (i.e. they have an MX record)
# pip install pydns
import DNS, smtplib
import csv, re
in_filename = 'input.csv'
skip_to = None
# DNS.DiscoverNameServers()
DNS.defaults['server'].append('208.67.222.222')
@elidickinson
elidickinson / _gradients.css.scss
Created November 21, 2012 17:52 — forked from thbar/_gradients.css.scss
SCSS mixing for CSS3 gradients
@mixin gradient($from, $to) {
background-color: $from; /* fallback/image non-cover color */
background-image: -moz-linear-gradient($from, $to); /* Firefox 3.6+ */
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to)); /* Safari 4+, Chrome 1+ */
background-image: -webkit-linear-gradient($from, $to); /* Safari 5.1+, Chrome 10+ */
background-image: -o-linear-gradient($from, $to); /* Opera 11.10+ */
// extras from http://www.colorzilla.com/gradient-editor/
background: -ms-linear-gradient(top, $from 0%,$to 100%); /* IE10+ */
background: linear-gradient(to bottom, $from 0%,$to 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to',GradientType=0 ); /* IE6-9 */
@elidickinson
elidickinson / real_ip_address.py
Created November 29, 2012 03:33
ProxiedRequest class for flask that gets correct remote_addr
from flask import Request
class ProxiedRequest(Request):
"""
`Request` subclass that overrides `remote_addr` with Frontend Server's
HTTP_X_FORWARDED_FOR when available.
"""
@property
def remote_addr(self):
@elidickinson
elidickinson / gist:4173065
Created November 30, 2012 01:09
Edudemic Signup Form Snippet
<!-- ======================= begin newsletter signup code ======================= -->
<style>
#ed_signup_box {
background: #E8E8E8;
margin: 10px 0;
padding: 10px;
border: 1px solid #D62828;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
<table cellspacing="0" cellpadding="0">
<tr>
<td align="center" width="300" height="40" bgcolor="#a10000" style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #fff; font-weight: bold; font-family: Helvetica, Arial, sans-serif; display: block;">
<a href="http://www.EXAMPLE.com/" style="color: #fff; text-decoration: none; line-height:40px; width:100%; display:inline-block">
Button Text Goes Here
</a>
</td>
</tr>
</table>
#!/bin/bash
# Get the directory that this script is running from and cd to there
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
echo "Deploying $DIR"
# tell hyde to rebuild whole site to production_deploy and note the
# script will bail out if hyde returns an error
hyde gen -c production.yaml -r -d production_deploy/ || exit $?
# copy only changed files to the server
rsync -cvraz --delete production_deploy/* [email protected]:/var/www/
@elidickinson
elidickinson / mysql backup oneliner
Last active December 16, 2015 11:59
mysql backup oneliner (assumes proper permissions set in .my.cnf)
mysql -e 'show databases' | while read dbname; do mysqldump --complete-insert --single-transaction "$dbname" | gzip > "$dbname".sql.gz; done
@elidickinson
elidickinson / max_width_email.html
Created May 6, 2013 15:10
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
class SaferProxyFix(object):
"""This middleware can be applied to add HTTP proxy support to an
application that was not designed with HTTP proxies in mind. It
sets `REMOTE_ADDR`, `HTTP_HOST` from `X-Forwarded` headers.
If you have more than one proxy server in front of your app, set
num_proxy_servers accordingly
Do not use this middleware in non-proxy setups for security reasons.