Skip to content

Instantly share code, notes, and snippets.

@Guest007
Guest007 / Material Login Form.markdown
Created December 27, 2015 10:07
Material Login Form

Material Login Form

Interactive Material Design Login Form.

This could be a lot more smoother, which is why I'll be updating it sometime this week when I have free time. However, here's the first version of it.

Close button should function properly now.

Design by Boris Borisov @ MaterialUp http://www.materialup.com/posts/compact-login

@Guest007
Guest007 / gist:9e82e7d5edc6fcc8ca79
Last active February 4, 2016 14:28
HyperlinkedNestedRelatedField
from rest_framework.relations import HyperlinkedRelatedField, PKOnlyObject
class HyperlinkedNestedRelatedField(HyperlinkedRelatedField):
def __init__(self, view_name, parent_fields_by_kwargs, **kwargs):
super(HyperlinkedNestedRelatedField, self).__init__(
view_name,
read_only=True,
source='*',
# the old MS starfield screensaver
# https://www.reddit.com/r/Python/comments/495pum/remember_the_old_ms_starfield_screensaver_its/
import cv2
import math
import numpy as np
import random
stars = []
w,h = 1920, 1080
center = w/2,h/2
while True:
@Guest007
Guest007 / rename_table_migration.py
Created March 10, 2016 14:22 — forked from jamesmfriedman/rename_table_migration.py
Renaming a Django app that has migrations already sucks. This Is a way I found to do it that preserves your old migration history and keeps your contenttypes in order. The trick is, this migration cannot be in the app you are migrating, so stick it in your "core" app or another app you have installed. Just plug in your own old and new app names.
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
from django.db.models import get_app, get_models
class Migration(SchemaMigration):
@Guest007
Guest007 / comprehensions.md
Created March 30, 2016 09:06 — forked from bearfrieze/comprehensions.md
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain

^(.+)@(.+)\.(.+)$
^.+@.+\..+$
@Guest007
Guest007 / set_ff.md
Last active March 19, 2026 01:02
Настройка Firefox

I. СОЗДАНИЕ НОВОГО ПРОФИЛЯ

Используйте менеджер профилей, чтобы создать новый профиль Firefox.

LINUX:

В терминале (консоли) Linux исполните команду от обычного пользователя:

firefox -P
@Guest007
Guest007 / paginator.py
Created July 22, 2016 03:43 — forked from vaad2/paginator.py
paginator
class VTPaginator(dict):
def __init__(self, num_rows, **kwargs):
defaults = {
'offset': 0,
'limit': 10,
'view_num': 11,
'splitter': '...',
'view_one_page': False,
'min_limit': 10,
'max_limit': 50,
[defaults]
hash_behaviour=merge
roles_path=../common/roles:./roles
host_key_checking=False
pipelining=True
@Guest007
Guest007 / views.py
Created October 7, 2016 04:28
"OR" type of filter
# got from https://github.com/carltongibson/django-filter/issues/137 (closed issue)
# I used variant from https://github.com/ddevlin - https://github.com/carltongibson/django-filter/issues/137#issuecomment-38158832
# like this: /?categ_in=3,4
from django_filters import Filter
from django_filters.fields import Lookup
from waypoints.models import WayPoint
class ListFilter(Filter):
def filter(self, qs, value):