Skip to content

Instantly share code, notes, and snippets.

@arahaya
arahaya / feedfinder.py
Created April 21, 2012 06:52
Extract feed urls from HTML document
"""
required: Python 2.7+
required: beautifulsoup4
required: lxml
"""
from urlparse import urldefrag, urljoin
from lxml import etree
from bs4.dammit import UnicodeDammit
@arahaya
arahaya / feedfinder.js
Created April 30, 2012 22:22
[JavaScript] Extract feed urls from HTML document
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
};
@arahaya
arahaya / FeedFinder.java
Created May 1, 2012 19:22
[Java][Jsoup] Extract feed urls from HTML document
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;
@arahaya
arahaya / bootstrap-fluidmodal.js
Created July 23, 2012 08:18
Twitter Bootstrap Fluid Modal
(function ($) {
$(function () {
function update() {
var width = $(window).width();
var height = $(window).height();
$('.modal-fluid').css({
width: width * 0.8,
marginLeft: -(width * 0.4)
});
@arahaya
arahaya / url_add_query.py
Last active December 12, 2015 08:39
[django, jinja2, coffin] Add query string parameters to current URL
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.
@arahaya
arahaya / since_filter.py
Created February 9, 2013 17:34
Django since filter
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").
@arahaya
arahaya / 0_reuse_code.js
Created February 3, 2014 15:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@arahaya
arahaya / gist:765d0dff8bec2ef96880
Created May 5, 2015 14:58
jQuery.create(element, attrs)
jQuery.create = function (element, attrs) {
return $('<' + element + ' />', attrs);
};
$.create('a', {href: 'http://google.com'});