Skip to content

Instantly share code, notes, and snippets.

View elidickinson's full-sized avatar

Eli Dickinson elidickinson

View GitHub Profile
@elidickinson
elidickinson / update_profile.py
Created August 15, 2013 02:04
Update twitter profile background image
import tweepy
import tempfile
import urllib
from time import sleep
import os
url = 'http://wwc.instacam.com/instacamimg/KDCA/KDCA_l.jpg'
# The consumer keys can be found on your application's Details
# page located at https://dev.twitter.com/apps (under "OAuth settings")
@elidickinson
elidickinson / UglifyJS API.sublime-build
Created May 22, 2013 15:03
Minify your JS using the UglifyJS online API generously provided at http://marijnhaverbeke.nl/uglifyjs
{
"cmd": ["curl","-s","-S","--write-out", "Response code: %{http_code}; Total time: %{time_total}\n","-o","$file_base_name.min.js","--data-urlencode","js_code@$file","http://marijnhaverbeke.nl/uglifyjs"],
"selector": "source.js"
}
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.
@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]>
@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
#!/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/* user@example.com:/var/www/
<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>
@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;
@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 / _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 */