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
| >>> Airport.objects.filter( | |
| iata_code='DME', | |
| ).values_list( | |
| 'iata_code', | |
| 'city__name', | |
| 'city__country__name', | |
| ) | |
| [(u'DME', u'Moscow', u'Russia')] |
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.db import models | |
| class Project(models.Model): | |
| name = models.CharField(max_length=140) | |
| parent = models.ForeignKey('self', blank=True, null=True) | |
| class ProjectForm(ModelForm): | |
| def __init__(self, *args, **kwargs): | |
| super(ProjectForm, self).__init__(*args, **kwargs) | |
| ordered = [] |
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 datetime | |
| duration = datetime.timedelta(seconds=1823723) # 21 days, 2:35:23 | |
| days, seconds = duration.days, duration.seconds # (21, 9323) | |
| hours = seconds // 3600 # 2 | |
| minutes = (seconds % 3600) // 60 # 35 | |
| seconds = (seconds % 60) # 23 |
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
| # Installation: https://help.ubuntu.com/community/PostgreSQL | |
| # Creating a user: http://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist | |
| # Set password: http://stackoverflow.com/a/7696398/914332 | |
| # make dump of existing database | |
| $ pg_dump -O -U postgres database_name | gzip > /tmp/dump.sql.gz | |
| # create dump without data | |
| $ pg_dump test_db_development -s > /tmp/createdb.sql |
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
| def update_user_social_data(strategy, *args, **kwargs): | |
| """Set the name and avatar for a user only if is new. | |
| """ | |
| print 'update_user_social_data ::', strategy | |
| if not kwargs['is_new']: | |
| return | |
| full_name = '' | |
| backend = kwargs['backend'] |
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
| SOCIAL_AUTH_FACEBOOK_SCOPE = [ | |
| 'email', | |
| 'user_friends', | |
| 'friends_location', | |
| ] |
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
| export CPPFLAGS=-Qunused-arguments | |
| export CFLAGS=-Qunused-arguments | |
| brew install libjpeg | |
| #pip install Pillow | |
| #pip install pyOpenSSL |
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
| [user] | |
| name = Vera | |
| email = vera@example.com | |
| [color] | |
| ui = true | |
| [alias] | |
| st = status | |
| ci = commit | |
| last = log -1 HEAD | |
| co = checkout |
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
| find . -name "*.pyc" -exec rm '{}' ';' |
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
| export CFLAGS=-Qunused-arguments | |
| export CPPFLAGS=-Qunused-arguments | |
| pip install lxml |
OlderNewer