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 dateutil.relativedelta import relativedelta | |
| from datetime import datetime, timedelta | |
| first_date = datetime(1970, 1, 1) | |
| date_list = [first_date + timedelta(days=x) for x in xrange(0, 1000000)] | |
| forty_weeks = 40 * 7 | |
| for date in date_list: | |
| if ((date + relativedelta(months=10)) - date).days == forty_weeks: | |
| print('40 weeks equals 10 months! Starting at {}'.format(date)) |
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
| === command mode === | |
| h - moves left 1 char | |
| j - moves down 1 line | |
| k - moves up 1 line | |
| l - moves right 1 char | |
| w - moves right 1 word | |
| b - mover left 1 word | |
| $ - moves to the end of the line | |
| ^ - moves right before the first non-blank character in the line | |
| 0 - moves to the beginning of the line |
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
| # kill processes by name | |
| pkill <process name> | |
| # if the above doesn't work, drop an atomic bomb! | |
| ps auxww | grep '<process name>' | awk '{print $2}' | xargs kill -9 |
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
| # listar bancos de dados | |
| \list | |
| # passa a usar o banco | |
| \c <banco> | |
| # sair do prompt | |
| \q | |
| # mostrar todas as tabelas |
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
| mysqldump -u <user> -p --host=<host> --port=<port> <database> > <filename>.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
| # Teste em ambiente Windows | |
| cls | |
| python manage.py test %* --settings=app.settings.test | |
| rd /S /q %~dp0\media_tests | |
| # Teste em ambiente Unix | |
| clear | |
| python manage.py test $* --settings=app.settings.test | |
| rm -rf $(dirname $0)/media_test |
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
| <script src="/js/dojo.js" | |
| data-dojo-config="'selectorEngine': 'sizzle/sizzle', 'packages': [{'name': 'sizzle', 'location': 'https://rawgithub.com/jquery/sizzle/master/dist/'}]" ></script> | |
| <script src="my.js"></script> |
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 math import floor | |
| BASE62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| def base_convert(src, from_base=10, to_base=16, alphabet=BASE62): | |
| src = str(src) | |
| from_alphabet = alphabet[:from_base] | |
| to_alphabet = alphabet[:to_base] |
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
| # coding: utf-8 | |
| from django.db import models | |
| from django.utils.crypto import get_random_string | |
| from django.utils.translation import ugettext_lazy as _ | |
| class Discount(models.Model): | |
| discount = models.FloatField(_('Discount Value')) | |
| code = models.CharField(_("Discount code"), max_length=255, unique=True, default=get_random_string) |
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.contrib import admin | |
| from django.contrib.auth.admin import UserAdmin | |
| from django.contrib.auth.models import User | |
| class UserAdmin(admin.ModelAdmin): | |
| list_display = ('email', 'first_name', 'last_name') | |
| list_filter = ('is_staff', 'is_superuser') | |
| search_fields = ('email',) |