Skip to content

Instantly share code, notes, and snippets.

View dangayle's full-sized avatar

Dan Gayle dangayle

View GitHub Profile
@dangayle
dangayle / Addthisbookmarks.html
Created December 15, 2012 21:50
Uses Addthis to create a cross-browser compatible bookmarks/favorites link. Yeah, I know it's heavy for this sort of thing, but what are you going to do?
<!-- AddThis Button BEGIN -->
<div class="addthis_default_style addthis_32x32_style">
<a class="addthis_button_favorites" style="text-decoration:none;font-size:32px;">&nbsp;bookmark this page</a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js"></script>
<!-- AddThis Button END -->
@dangayle
dangayle / gist:4302849
Created December 16, 2012 03:11
Provision new NGINX server using Fabric
from fabric.api import cd, sudo, run, put
def www(domain):
'''
Create new www file directory
'''
with cd("/var/www/"):
run("mkdir " + domain)
sudo('chown -R www-data:www-data ' + domain)
@dangayle
dangayle / gist:5855580
Last active February 1, 2016 20:06
Easy python batch file rename one-liner
"""
In the terminal, go to the directory of the files you want to rename
Open yer python CLI, import os, then one-liner. I guess technically 2-liner
"""
import os
[os.rename(f, f.replace('_','-')) for f in os.listdir('.')]
return {"category": category,
"category_url": category_url,
"winner": winner,
"runners_up": runners_up}
from StringIO import StringIO
import requests
from xmlutils.xml2csv import xml2csv
"""Grab xml schedules from gsl.tandemcal.com and convert to csv"""
varsity_sports_ids = {
"boys_baseball": 26,
"boys_basketball": 19,
"girls_basketball": 20,
"boys_cross_country": 7,
import sys
from django.conf import settings
from django.core.cache import cache
from twython import Twython, TwythonError
from ttp.ttp import Parser
from pprint import pprint
def parse_tweet(x):
"""
@dangayle
dangayle / gist:6385843
Last active December 21, 2015 23:59
Responsive Double Click for Publishers ads with Modernizr's media query .mq() method
<script type='text/javascript'>
googletag.cmd.push(function() { Modernizr.mq('(min-width: 1200px)') && googletag.display('div-gpt-ad-1377815593640-3') });
</script>
@dangayle
dangayle / gist:6787345
Last active December 24, 2015 10:59
Google Web Designer writes 1337 codez http://i.imgur.com/9M8B4Ot.png
<!DOCTYPE html>
<html><head data-gwd-animation-mode="quickMode">
<meta name="generator" content="Google Web Designer 1.0.0.924">
<meta name="template" content="Banner 1.0.5">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">html, body {
width: 100%;
height: 100%;
margin: 0px;
import argparse
'''Hide a zipfile in an image or unpack an image with a hidden archive in it'''
import argparse
from zipfile import ZipFile
def hide(image_file, archive_file):
'''Append an archive onto the end of an image'''
# open the image file in "append binary" mode