Skip to content

Instantly share code, notes, and snippets.

View 1st's full-sized avatar
🎯
Work smarter, not harder

Anton Danilchenko 1st

🎯
Work smarter, not harder
View GitHub Profile
@1st
1st / 2015.py
Last active August 29, 2015 14:12
2015-binary.py
"""
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'
@1st
1st / brew_config.sh
Last active December 10, 2015 13:30
HomeBrew and PostgreSQL. Illegal instruction: 4
$ 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
@1st
1st / get_prime_number.py
Last active December 15, 2015 02:19
Solution for task: http://projecteuler.net/problem=7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number?
#!/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:
@1st
1st / singleton.py
Created March 30, 2013 23:26
Singleton implantation on Python
#!/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
@1st
1st / function_decorator.py
Last active December 17, 2015 13:49
My implementation of Python decorators based on functions (not class-based decorator).
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):
@1st
1st / django_project_code_sample.py
Created June 3, 2013 14:38
My example of code for Django project
'''
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
@1st
1st / PTHPHX.sh
Created August 6, 2014 16:14
Shell script that generates Welcome message to Putin
echo @У-И. *УЙЛO | tr '@-.:%*' ПTHTHX
@1st
1st / inheritance.py
Created September 28, 2014 18:02
Inheritance in Python
class A(object):
def aa(self):
print 'in A'
return self.__class__.__name__
class B(A):
def bb(self):
print 'in B'
return super(B, self).aa()
@1st
1st / sublimetext_jedi.md
Last active April 4, 2016 20:26
SublimeJEDI traceback

What I need to do

I opened .py file to edit in SublimeText project. Inported library (from django import db) and wrote db. to show autocompletion. But nothing happens.

Step-by-step guide

SublimeText running without JEDI plugin installed