This file contains 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
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; } |
This file contains 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
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) |
This file contains 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 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() |
This file contains 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 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() |
This file contains 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
filetype plugin on | |
set omnifunc=syntaxcomplete#Complete | |
set wrap | |
set autoindent | |
set smartindent | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set smarttab | |
set expandtab |
This file contains 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
# pip install django-debug-toolbar | |
# /api/creatives/?format=json&debug | |
from django.http import HttpResponse | |
import json | |
INSTALLED_APPS += ('debug_toolbar',) | |
MIDDLEWARE_CLASSES += ( | |
'debug_toolbar.middleware.DebugToolbarMiddleware', |
This file contains 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
#!/usr/bin/env node | |
var program = require('commander'), | |
read = require('node-readability'), | |
format = require('distro-mic').format; | |
program | |
.version('1.0.0') | |
.option('-u, --url [type]', 'Input article URL') | |
.option('-h, --html [type]', 'Input HTML code') | |
.parse(process.argv); |
This file contains 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
def get_mentions(text): | |
limits = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' | |
words = text.split() | |
mentions = [] | |
for word in words: | |
if word.endswith(('.', ',', '!', '?', ':', ';')): | |
word = word[:-1] | |
if word.endswith(')'): | |
word = word[:-1] | |
if word.startswith('('): |
This file contains 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 django.utils.safestring import mark_safe | |
def parser(text): | |
''' Convert plain text to HTML ''' | |
limits = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' | |
digits = '0123456789' | |
# unicode xml safe | |
text = text.replace('&', '&').replace('<', '<').replace('>', '>') | |
# replace (160) with space (32) | |
text = text.replace(chr(160), chr(32)) |
This file contains 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
def qsort(list): | |
if list == []: | |
return [] | |
pivot = list[0] | |
l = qsort([x for x in list[1:] if x < pivot]) | |
u = qsort([x for x in list[1:] if x >= pivot]) | |
return l + [pivot] + u |
OlderNewer