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
# -*- coding: utf-8 -*- | |
def transliterate(string): | |
capital_letters = {u'А': u'A', | |
u'Б': u'B', | |
u'В': u'V', | |
u'Г': u'G', | |
u'Д': u'D', | |
u'Е': u'E', |
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
# -*- coding: utf-8 -*- | |
import re | |
def transliterate(string): | |
capital_letters = {u'А': u'A', | |
u'Б': u'B', | |
u'В': u'V', | |
u'Г': u'G', |
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
# -*- coding: utf-8 -*- | |
def transliterate(string): | |
capital_letters = {u'А': u'A', | |
u'Б': u'B', | |
u'В': u'V', | |
u'Г': u'G', | |
u'Д': u'D', | |
u'Е': u'E', |
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
These strings are not present in any other template or Python file, so you just put them here in order to make the makemessages management command keep them in the translation file. | |
{% load i18n %} | |
{% trans "Some string you want to keep in the django.po translation file" %} | |
{% trans "So makemessages won't comment it out each time you run it" %} | |
{% trans "This template does not have to be used anywhere, putting it in your templates directory is enough" %} |
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 deep_get(dictionary, keys, default=None): | |
""" | |
Gets a value following the specified path, if it exists. | |
The keys are dot-separated. | |
Example: | |
deep_get({'most_visited': {'url': 'https://test.com/'}}, 'most_visited.url') | |
""" |
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
import argparse | |
parser = argparse.ArgumentParser(description='Replace text nodes') | |
parser.add_argument('file', type=str) | |
args = parser.parse_args() | |
html = open(args.file).read() | |
def replace(content): |
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
# No need to redisplay it on sudo su and in screen sessions | |
if [ "$(id -u)" != "0" ] && [[ ! $TERMCAP =~ screen ]]; then | |
/etc/motd.tcl | |
fi |
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.contrib import admin | |
from django.contrib.auth.admin import UserAdmin | |
from django.utils.translation import ugettext_lazy as _ | |
from .forms import UserChangeForm, UserCreationForm | |
from .models import User |
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
import sys | |
import httplib2 | |
import urllib | |
import hashlib | |
import re | |
import itertools | |
from BeautifulSoup import BeautifulSoup | |
import progressbar |
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.db import models | |
from django import forms | |
class TextInputTextField(models.TextField): | |
def formfield(self, **kwargs): | |
kwargs.update({ | |
"widget": forms.TextInput | |
}) |
NewerOlder