Skip to content

Instantly share code, notes, and snippets.

View pije76's full-sized avatar

panjianom pije76

View GitHub Profile
@pije76
pije76 / models.py
Created August 15, 2017 09:19 — forked from mhulse/models.py
Django basic/simple category/sub-category model.
# ...
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'
@pije76
pije76 / zip2tz.csv
Created August 13, 2017 18:42 — forked from benjiwheeler/zip2tz.csv
Zip to Time Zone csv
We can't make this file beautiful and searchable because it's too large.
'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'
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']
@pije76
pije76 / maps_url.py
Created August 9, 2017 05:31 — forked from willcharlton/maps_url.py
Python (3) snippet to generate google maps url and timezone for a given address.
#!/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
@pije76
pije76 / utcisoformat.py
Created July 30, 2017 08:51 — forked from bryanchow/utcisoformat.py
Convert Django DateTimeField values to ISO format in UTC
# 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
@pije76
pije76 / geonames.py
Created July 30, 2017 01:52 — forked from pamelafox/geonames.py
Geonames Python wrapper
import sys
import urllib
import urllib2
import json
import logging
class GeonamesError(Exception):
def __init__(self, status):
@pije76
pije76 / zodiac_tag.py
Created July 29, 2017 21:10 — forked from amiroff/zodiac_tag.py
Django template filter that returns appropriate zodiac for a given date (in Turkish)
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)),
@pije76
pije76 / Preferences.sublime-settings
Created July 29, 2017 21:09 — forked from amiroff/Preferences.sublime-settings
My Sublime Text User Preferences File
{
"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,
@pije76
pije76 / git_toturial
Created July 29, 2017 21:00 — forked from guweigang/git_toturial
git命令大全
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远程仓库
@pije76
pije76 / gist:eff79746215c8e5f5e9eb5d4c1d75f7e
Created July 29, 2017 01:09 — forked from zgohr/gist:3399170
SVG vector data to PNG
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