Skip to content

Instantly share code, notes, and snippets.

View elidickinson's full-sized avatar

Eli Dickinson elidickinson

View GitHub Profile
@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 / html_email_buttons_1.html
Last active November 27, 2023 14:55
HTML email buttons that work
<div>
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://www.EXAMPLE.com/" style="height:40px;v-text-anchor:middle;width:300px;" arcsize="10%" stroke="f" fillcolor="#d62828">
<w:anchorlock/>
<center style="color:#ffffff;font-family:sans-serif;font-size:16px;font-weight:bold;">
Button Text Here!
</center>
</v:roundrect>
<![endif]-->
<![if !mso]>
@elidickinson
elidickinson / admin.py
Created November 20, 2011 01:16
Using CKEditor with Flatpages
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
# Note: we are renaming the original Admin and Form as we import them!
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld
from django.contrib.flatpages.admin import FlatpageForm as FlatpageFormOld
from django import forms
from ckeditor.widgets import CKEditorWidget
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.
# What 8 letter word can have a letter taken away, and each time still make another word, until only one letter (and one word) are left?
words_by_length = [set(), set(), set(), set(), set(), set(), set(), set(), set()]
with open('scrabble2019.txt') as f:
for w in f:
word = w.strip()
word_len = len(word)
if word_len <= 8:
words_by_length[word_len].add(word)
answers = set()
var x = $(".gb-domain-name").each(function(i,x) { console.log($(x,"span").text())}); window.scrollBy(0,600)

Keybase proof

I hereby claim:

  • I am elidickinson on github.
  • I am esd (https://keybase.io/esd) on keybase.
  • I have a public key whose fingerprint is 6884 A79C 69EC C924 961C 95B9 2CEB 89F6 30BC 7837

To claim this, I am signing this object:

@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 / mobile-detect.vcl
Last active June 14, 2018 11:52
Varnish config for user agent sniffing
# This file has been modified by Eli Dickinson to update detection rules and to
# send a Vary header downstream. It has also been updated to
# work with newer versions of Varnish.
#
# A simple mobile device detection implementation in VCL
# http://fangel.github.com/mobile-detection-varnish-drupal
#
# The file is based upon initial work done by Audun Ytterdal, which can be
@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')