This file contains hidden or 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
<script> | |
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful | |
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it. | |
// The following will allow remote autocompletes *without* modifying any officially released core code. | |
// If others find ways to improve this, please share. | |
var autocomplete = $('#searchinput').typeahead() | |
.on('keyup', function(ev){ | |
ev.stopPropagation(); |
This file contains hidden or 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
def email_user(user, email, template): | |
""" | |
""" | |
if 'domain' not in email: | |
email['domain'] = SITE_DOMAIN | |
c = Context({'user': user, 'email' : email}) | |
html_content = template.render(c) | |
text_content = strip_tags(html_content) | |
print 'Sending Email to {0}'.format(user) |
This file contains hidden or 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
# pip install django-orm-extensions | |
from django.contrib.gis.db.models import GeoManager | |
from django.contrib.gis.db.models.query import GeoQuerySet | |
from django.contrib.gis.db.models.sql.where import GeoWhereNode | |
from django.contrib.gis.db.models.sql import GeoQuery | |
from django_hstore.query import HStoreQuerySet, HStoreWhereNode | |
from django_hstore.managers import HStoreManager | |
class GeoHStoreWhereNode(GeoWhereNode, HStoreWhereNode): |
This file contains hidden or 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
function processSiteRequest( data ) { | |
var sites = data.response.sites; | |
// loop through each site given back for the paginated result set | |
$.each( sites || [], function(index, site) { | |
debugPrint("Site: " + site.name); | |
$.each( site.content_categories || [], function( index, category ) { | |
// build up category to publisher map | |
debugPrint(" Category: " + category.name); | |
if ( category.id in category_publisher_map ) { |
This file contains hidden or 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
[alias] | |
lg = log --graph --oneline --decorate --all | |
today = log --since=midnight --pretty='format:%an @ %ad%n%Cblue%s%n' | |
add this to ~/.gitconfig | |
then go | |
$ git today |
This file contains hidden or 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
from django import template | |
register = template.Library() | |
class UpdateQuerystringNode(template.Node): | |
def __init__(self, **kwargs): | |
self.kwargs = kwargs | |
def render(self, context): |
This file contains hidden or 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
# gunicorn.conf.py: getting gevent and gevent-psycopg2 running | |
bind = '127.0.0.1:1437' | |
accesslog = "<some-path>/logs/gunicorn-access.log" | |
errorlog = "<some-path>/logs/gunicorn-error.log" | |
workers = 5 | |
try: | |
# fail 'successfully' if either of these modules aren't installed | |
from gevent import monkey | |
import gevent_psycopg2 |
This file contains hidden or 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
#/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# _______ _______ _ _________ _ _______ | |
# |\ /|( ___ )( ____ )( ( /|\__ __/( ( /|( ____ \ | |
# | ) ( || ( ) || ( )|| \ ( | ) ( | \ ( || ( \/ | |
# | | _ | || (___) || (____)|| \ | | | | | \ | || | | |
# | |( )| || ___ || __)| (\ \) | | | | (\ \) || | ____ | |
# | || || || ( ) || (\ ( | | \ | | | | | \ || | \_ ) | |
# | () () || ) ( || ) \ \__| ) \ |___) (___| ) \ || (___) | |
This file contains hidden or 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 requests | |
import json | |
import datetime | |
from .hooks import auth_check | |
class Service: | |
""" Base Service Class """ | |
def __init__(self, username=None, password=None): |
This file contains hidden or 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
""" | |
usage: python broken_links.py somedomain.com > broken_links.list | |
somedomain.com/sitemap.xml will be grabbed and parsed | |
for each location entry, the page is fetched and all links on that page | |
make a HEAD request. The output is a summary of broken links and what entries or locations | |
contained them from sitemap.xml | |
this offeres a crude but effective way to spot essential pages across a domain. | |
""" |