This file contains hidden or 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
# ... | |
class Category(Base): | |
slug = models.SlugField(_(u'slug'), max_length=100, unique=True) | |
title = models.CharField(_(u'title'), max_length=250) | |
parent = models.ForeignKey('self', blank=True, null=True, related_name='child') | |
class Meta: | |
verbose_name_plural = 'Categories' |
We can't make this file beautiful and searchable because it's too large.
This file contains hidden or 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
'00501','Holtsville','NY','America/New_York' | |
'00544','Holtsville','NY','America/New_York' | |
'01001','Agawam','MA','America/New_York' | |
'01002','Amherst','MA','America/New_York' | |
'01003','Amherst','MA','America/New_York' | |
'01004','Amherst','MA','America/New_York' | |
'01005','Barre','MA','America/New_York' | |
'01007','Belchertown','MA','America/New_York' | |
'01008','Blandford','MA','America/New_York' | |
'01009','Bondsville','MA','America/New_York' |
This file contains hidden or 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 forms | |
from django.contrib.auth.models import User | |
class UserProfileForm(forms.ModelForm): | |
class Meta: | |
model = User | |
fields = ['first_name', 'last_name', 'email'] | |
This file contains hidden or 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 python3 | |
""" | |
So far only tested on python3 interpreter. | |
Given an address, this script outputs a google maps url to the address. | |
""" | |
import requests, sys, time | |
from urllib.parse import quote_plus |
This file contains hidden or 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
# Convert Django DateTimeField values to ISO format in UTC | |
# Useful for making Django DateTimeField values compatible with the | |
# jquery.localtime plugin. | |
# | |
# https://gist.github.com/1195854 | |
from pytz import timezone, utc | |
from django.conf import settings | |
This file contains hidden or 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 urllib | |
import urllib2 | |
import json | |
import logging | |
class GeonamesError(Exception): | |
def __init__(self, status): |
This file contains hidden or 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
register = template.Library() | |
@register.filter(name='zodiac') | |
def zodiac(value): | |
""" Return appropriate zodiac for a given date | |
Usage in templates: {{ your_object.date_of_birth|zodiac }} """ | |
signs = ( | |
(u"Oğlak", range(356, 365)), | |
(u"Oğlak", range(1, 20)), | |
(u"Kova", range(21, 52)), | |
(u"Balık", range(52, 79)), |
This file contains hidden or 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
Show hidden characters
{ | |
"always_prompt_for_file_reload": false, | |
"auto_complete": false, | |
"auto_complete_commit_on_tab": true, | |
"auto_find_in_selection": false, | |
"caret_style": "phase", | |
"color_scheme": "Packages/User/Themes/Mac CLassic.tmTheme", | |
"copy_with_empty_selection": false, | |
"default_line_ending": "unix", | |
"diff_changes_to_buffer": true, |
This file contains hidden or 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
git init # 初始化本地git仓库(创建新仓库) | |
git config --global user.name "xxx" # 配置用户名 | |
git config --global user.email "[email protected]" # 配置邮件 | |
git config --global color.ui true # git status等命令自动着色 | |
git config --global color.status auto | |
git config --global color.diff auto | |
git config --global color.branch auto | |
git config --global color.interactive auto | |
git config --global --unset http.proxy # remove proxy configuration on git | |
git clone git+ssh://[email protected]/VT.git # clone远程仓库 |
This file contains hidden or 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
brew upgrade | |
brew update | |
brew install cairo | |
brew install py2cairo | |
ln -s ~/Developer/lib/python2.7/site-packages/cairo ~/.virtualenvs/wpd/lib/python2.7/site-packages/cairo | |
# I needed to specify that my virtual environment uses python 2.7.3 because by default it used 2.7.2 | |
# but brew compiled py2cairo with 2.7.3 | |
mkvirtualenv --no-site-packages -p ~/Developer/bin/python wpd |