This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import os, fnmatch, sys | |
def findReplace(directory, find, rep, filePattern): | |
for path, dirs, files in os.walk(os.path.abspath(directory)): | |
for filename in fnmatch.filter(files, filePattern): | |
filepath = os.path.join(path, filename) | |
with open(filepath) as f: | |
s = f.read() | |
new = s.replace(find, rep) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlalchemy | |
from sqlalchemy import Column, Integer, ForeignKey, String, MetaData | |
from sqlalchemy.ext.declarative import declarative_base | |
engine_url = 'postgresql://postgres@localhost/joins' | |
Base = declarative_base() | |
class User(Base): | |
__tablename__ = 'users' | |
id = Column(Integer, primary_key=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pinurl = window.location.href; // link to the page that the pin was found on | |
var pinimage = 'http://your-image.png'; // link to the pin's image | |
var pindescription = document.title; // description of the pin | |
// button - The full HTML needed for the embedded pin it button. Place this where you'd like the button to be: $('#placeholder').append(button) | |
var button = '<a class="pinbutton" href="//pinterest.com/pin/create/button/?url='+escape(pinurl)+'&media=' + escape(pinimage) + '&description=' + escape(pindescription) + '" data-pin-do="bu\ | |
ttonPin" data-pin-config="above"><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /></a>'; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var youtubelink = $('object param[name="movie"]').val(); // grabs the video link from an embedded video | |
// OLD EMBED STYLE CODE var youtubecode = youtubelink.match(/\/v\/(.*)\?/)[1]; | |
var youtubecode = youtubelink.match(/\/embed\/(.*)/)[1]; | |
var pinimage = 'http://img.youtube.com/vi/' + youtubecode + '/0.jpg'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT strftime('%Y-W%W', "ch0"."Date") AS "Week of Date", | |
"ch0"."Winner" AS "Winner", | |
COUNT(DISTINCT "ch0"."_row_id") AS "Count of Chess - Sheet1" | |
FROM "Chess - Sheet1" AS "ch0" | |
GROUP BY "Week of Date", "Winner" | |
ORDER BY "Week of Date" ASC, "Winner" ASC LIMIT 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dns.resolver # requires pip install dnspython | |
def uses_google_apps(email): | |
domain = email.lower().split('@')[1] | |
if domain.lower() not in ('gmail.com', 'googlemail.com'): | |
try: | |
answers = dns.resolver.query(domain, 'MX') | |
for rdata in answers: | |
if 'google' in rdata.exchange.to_text().lower(): | |
return True |