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
jQuery.create = function (element, attrs) { | |
return $('<' + element + ' />', attrs); | |
}; | |
$.create('a', {href: 'http://google.com'}); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 datetime | |
from django import template | |
from django.utils.timezone import is_aware, utc | |
from django.utils.translation import ungettext, ugettext | |
register = template.Library() | |
@register.filter(is_safe=False) | |
def since(date, stop_at_month=False): | |
"""Formats a date as the time since that date (i.e. "4 days ago"). |
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 jinja2 import nodes | |
from jinja2.ext import Extension | |
class UrlAddQueryExtension(Extension): | |
"""Add query string parameters to the current URL | |
This is a Jinja2 version of http://djangosnippets.org/snippets/2882/ | |
targeted to work for django+coffin. | |
The django request object must be included in the 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
(function ($) { | |
$(function () { | |
function update() { | |
var width = $(window).width(); | |
var height = $(window).height(); | |
$('.modal-fluid').css({ | |
width: width * 0.8, | |
marginLeft: -(width * 0.4) | |
}); |
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 org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
import org.jsoup.select.Elements; | |
import java.io.File; | |
import java.io.IOException; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.HashSet; |
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 findFeeds() { | |
var FEED_CONTENT_TYPES = { | |
"application/rss+xml": 1, | |
"application/atom+xml": 1, | |
"application/rdf+xml": 1, | |
"text/xml": 1, | |
"application/x.atom+xml": 1, | |
"application/x-atom+xml": 1 | |
}; | |
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
""" | |
required: Python 2.7+ | |
required: beautifulsoup4 | |
required: lxml | |
""" | |
from urlparse import urldefrag, urljoin | |
from lxml import etree | |
from bs4.dammit import UnicodeDammit |