Skip to content

Instantly share code, notes, and snippets.

View lig's full-sized avatar
🛴
kicking it

Serge Matveenko lig

🛴
kicking it
View GitHub Profile
description = models.TextField(validators=[MaxLengthValidator(128)], max_length=128, verbose_name='Краткая аннотация', help_text='Максимум 128 символов')
description = models.TextField(
validators=[MaxLengthValidator(128)],
max_length=128,
verbose_name='Краткая аннотация',
help_text='Максимум 128 символов')
def another_profile(request, id):
user2 = CustomUser.objects.get(id = id)
if request.user.is_authenticated():
if request.user == user2:
viewable = False
else:
viewable = True
userlist = request.user.friends.all()
try:
Friendship.objects.get(user=request.user)
from dist import *
try:
from local import *
except ImportError:
from local_sample import *
from warnings import warn
warn(
'Local settings not found (settings/local.py).'
'Using local_sample.py instead.')
filename = os.path.join(root, name)
try:
os.remove(filename)
except OSError:
log.error('Error removing file %s' % filename)
a = ['123', '1234', None, '12']
## 1
from operator import methodcaller
b = [methodcaller('__len__')(x) for x in a if x]
print(b)
## 2
b = [len(x) for x in a if x]
print(b)
# Use uswsusp
SLEEP_MODULE="uswsusp"
# Always use suspend_hybrid instead of suspend
if [ "$METHOD" = "suspend" ]; then
METHOD=suspend_hybrid
fi
@lig
lig / list_as_default_func_arg.py
Last active December 13, 2015 23:18
"def foo(bar=[])" explained
lst = []
def foo1(bar=lst):
bar.append(1)
print(bar)
foo1()
foo1()
foo1()
class CharacterName(EmbeddedDocument):
first = StringField()
last = StringField()
class Character(Document):
name = EmbeddedDocumentField(CharacterName)
rating = IntField()
fs.inotify.max_user_watches=100000
@lig
lig / .conkyrc
Last active January 19, 2018 06:45
Conky config. Gnome 3 compatible.
conky.config = {
alignment = 'tl',
background = true,
border_width = 1,
default_bar_width = 256, default_bar_height = 4,
default_color = 'white',
default_outline_color = 'white',
default_shade_color = 'black',
double_buffer = true,
draw_borders = false,