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
''' | |
My example of code for Django project | |
See also my Open Source project here: https://github.com/1st/django-startup | |
@author Anton Danilchenko <anton.danilchenko@me.com> | |
''' | |
# app_name/urls.py |
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 login_required(function=None, message=None): | |
""" | |
Decorator for views that checks that the user is logged in, | |
or show error page with message. | |
>>> We can use any of this forms of decorator: | |
>>> | |
>>> # 1. without parameters | |
>>> @login_required | |
>>> def my_function(request): |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
class Singleton(type): | |
def __call__(self, *args, **kwargs): | |
if 'instance' not in self.__dict__: | |
self.instance = super(Singleton, self).__call__(*args, **kwargs) | |
return self.instance | |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
def get_prime_number(index): | |
''' | |
Return prime number by given index. | |
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. | |
Args: |
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
$ brew config | |
HOMEBREW_VERSION: 0.9.5 | |
ORIGIN: https://github.com/Homebrew/homebrew | |
HEAD: dcb3cf09cba68f891bb8eda4b1735b50996a85b9 | |
Last commit: 6 hours ago | |
HOMEBREW_PREFIX: /usr/local | |
HOMEBREW_REPOSITORY: /usr/local | |
HOMEBREW_CELLAR: /usr/local/Cellar | |
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com | |
CPU: quad-core 64-bit ivybridge |
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
""" | |
2015 year calculations. | |
>>> # we missing 32 in this year pow(2,5) | |
>>> pow(2,5) | |
32 | |
>>> 1024+512+256+128+64+0+16+8+4+2+1 | |
2015 | |
>>> bin(2015) | |
'0b11111011111' |
NewerOlder