Skip to content

Instantly share code, notes, and snippets.

View elpaso's full-sized avatar

Alessandro Pasotti elpaso

View GitHub Profile
@elpaso
elpaso / gist:9227318
Created February 26, 2014 10:35
Django truncate HTML with smart insert
# Set up regular expressions
re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U | re.S)
re_chars = re.compile(r'<.*?>|(.)', re.U | re.S)
re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S)
re_newlines = re.compile(r'\r\n|\r') # Used in normalize_newlines
re_camel_case = re.compile(r'(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))')
def add_truncation_text(text, truncate=None):
if truncate is None:
@elpaso
elpaso / gist:7600176
Created November 22, 2013 13:52
AsyncImage glitches
# -*- coding: utf-8 -*-
"""
Test
"""
import kivy
kivy.require('1.0.7')