Skip to content

Instantly share code, notes, and snippets.

View lucianmarin's full-sized avatar
🐞

Lucian Marin lucianmarin

🐞
View GitHub Profile
@lucianmarin
lucianmarin / tohtml.py
Created June 18, 2015 14:40
tohtml.py
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
# Converts line breaks to paragraphs
@register.filter
def tohtml(manylinesstr):
return mark_safe(''.join("<p>%s</p>" % line
for line in manylinesstr.splitlines()
@lucianmarin
lucianmarin / md5.py
Created April 25, 2015 18:28
MD5 Django Template Tag
from django import template
import hashlib
register = template.Library()
# {{ "some identifier"|md5 }} -> g87g98ht02497hg349ugh3409h34
@register.filter(name='md5')
def md5_string(value):
return hashlib.md5(value).hexdigest()
@lucianmarin
lucianmarin / views.py
Last active August 29, 2015 14:12
Timeline View — sublevel.net/timeline
def timeline(request):
index_list = User.objects.order_by('-id').select_related('userprofile').prefetch_related('comment_set')[:120]
paginator = Paginator(index_list, 24)
page = request.GET.get('page')
try:
index = paginator.page(page)
except PageNotAnInteger:
index = paginator.page(1)
@lucianmarin
lucianmarin / sublevel-dark
Created October 18, 2014 00:32
Sublevel (dark mode)
body, .menu, .footer { background-color: #000; color: #eee; }
.main { background-color: #222; color: #eee; }
.menu li a { color: #eee; }
.entry a, .profile a, .footer a { color: #30c0c0; }
.page a, .dock a { background-color: #000; color: silver; }
.page a:hover, .dock a:hover { background-color: #333; }
.page a.selected { background-color: #30c0c0; }
.page sup { color: gray }
.list li { border-color: #444; }
.list .small a { color: #bbb; }