Skip to content

Instantly share code, notes, and snippets.

@jsoa
jsoa / nospaces.html
Created March 26, 2013 16:22
web-mode highlighting issue
{% block body %}
{% block body_full_upper %}{% endblock %}
<div class="width-1000 body-title-outer">
<div class="body-title">{% block body_title %}{% endblock %}</div>
{% block body_content %}{% endblock %}
</div>
{% block body_full_lower %}{% endblock %}
{% endblock %}
{% block footer %}
@jsoa
jsoa / tweetify.coffee
Created February 22, 2013 17:47
Tweetify angular filter. linkifies links, mentions and hashtags REF: https://gist.github.com/furf/2415595 Slightly changed tag regex so - (dashes) are not matched and changed the tag link to use ?q=%23
app = angular.module 'myApp', []
tweetify = (->
linkToUrl = (url) ->
url.link url
linkToUser = (match, atUser, user) ->
atUser.link twitterUrl + "/#!/" + user
linkToTag = (match, hashTag, tag) ->
hashTag.link twitterUrl + "/search/?q=%23" + tag
twitterUrl = "https://twitter.com"
@jsoa
jsoa / hts.py
Created November 5, 2012 13:09
Django humanized time since filter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
from django.template.defaultfilters import date, timesince
from django.template import Library
from django.utils.translation import ugettext
register = Library()
@jsoa
jsoa / redirects.py
Created August 17, 2012 14:52
django redirects fallback middleware so it only matches the old path resource and not query strings.
import urlparse
from django import http
from django.conf import settings
from django.contrib.redirects.models import Redirect
@jsoa
jsoa / gist:959372
Created May 6, 2011 17:24
Elegant way to parse arguments, keyword arguments and/or return variable for a django template tag
def do_sometag(parser, token):
"""
{% tagname arg1 arg2 arg3 ... with kwg1=v kwg2=v kwg3=v ... as varname %}
"""
argv = token.contents.split()
# get the index of 'as' or the total length of the arguments
a = 'as' in argv and argv.index('as') or len(argv)
# get the index from 'with' to 'as' or the total length of arguments
@jsoa
jsoa / purge_files.py
Created April 8, 2011 18:55
django management command to purge files in limelight
from django.core.management.base import BaseCommand, CommandError
from suds.client import Client
from optparse import make_option
WSDL = "https://soap.llnw.net/PurgeFiles/PurgeService.asmx?WSDL"
class Command(BaseCommand):
help = '''Purge a files from limelight\nUsage: purge_file url [url..] [-r] [-d]'''
option_list = BaseCommand.option_list + (
make_option('-d',
@jsoa
jsoa / fabfile.py
Created March 29, 2011 13:38
Fabric script used to push updates to an activity topic on convore.com
def update():
"""
Cause the site to pull in the latest changes to its code and touch the
wsgi file so it reloads
"""
global site_path
with cd(site_path):
extra_msg = run('git pull --all')
reload()
send_convore_update(msg="Push Live", extra=extra_msg)