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
@lig
lig / gist:08eef53e3fc6fb387498
Created September 30, 2014 14:44
flexbox autoscroll
vertical layout > flex layout > flex autoscrolly
@lig
lig / views.py
Created May 20, 2014 09:41
Retrieve file from GridFS
from django.http.response import (Http404, HttpResponseNotModified,
CompatibleStreamingHttpResponse)
from django.utils.http import http_date
from django.views.static import was_modified_since
from gridfs import GridFS
from mongoengine.connection import get_db
from bson.objectid import ObjectId
def file(request, collection_name, grid_id):
@lig
lig / gist:6756865
Last active December 24, 2015 06:29
$PS1
PS1="« \[\e[1;32m\]\u@\h \[\e[1;34m\]\w\[\e[0m\] »\n\[\e[0;37m\]$\[\e[0m\] "
@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,
fs.inotify.max_user_watches=100000
class CharacterName(EmbeddedDocument):
first = StringField()
last = StringField()
class Character(Document):
name = EmbeddedDocumentField(CharacterName)
rating = IntField()
@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()
# Use uswsusp
SLEEP_MODULE="uswsusp"
# Always use suspend_hybrid instead of suspend
if [ "$METHOD" = "suspend" ]; then
METHOD=suspend_hybrid
fi
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)
filename = os.path.join(root, name)
try:
os.remove(filename)
except OSError:
log.error('Error removing file %s' % filename)