Skip to content

Instantly share code, notes, and snippets.

from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.properties import ListProperty
from kivy.animation import Animation
KV = '''
#:import RGBA kivy.utils.rgba
<ImageButton@ButtonBehavior+Image>:
@Guest007
Guest007 / connected.kv
Last active July 31, 2019 16:30 — forked from Cheaterman/.gitignore
Kivy Login example
<Connected>:
BoxLayout:
orientation: 'vertical'
Label:
text: "You are now connected"
font_size: 32
Button:
text: "Disconnect"
font_size: 24
@Guest007
Guest007 / github.png
Created May 2, 2019 20:59 — forked from sorenvonsarvort/a-infinality-w10-config.sh
Windows 10 font rendering for Linux. The answer on how to make Linux fonts look like Windows ones with ClearType.
github.png
@Guest007
Guest007 / metrials-go.md
Created April 25, 2019 15:00 — forked from shr3000/metrials-go.md
Материалы по Go (golang): мануалы, статьи, книги и ссылки на сообщества

Материалы по Go (golang)

На русском языке

Мануалы и туториалы

  • [Введение в программирование на Go][1]
  • [Маленькая книга о Go][3]
  • [Эффективный Go][2]
  • Есть еще [Краткий пересказ Effective Go на русском языке][4], но 2009 года
@Guest007
Guest007 / foursquare_leaflet_layer.js
Created March 12, 2019 09:54 — forked from avilaj/foursquare_leaflet_layer.js
This is an attempt to make the foursquare layer implementation for leafletjs
/**
* @author Jorge Avila <[email protected]>
* @license Mit
* @description Adds a padding to one side of the layer, like foursquare does.
*/
// i use the nwtjs library to get the element and height
// you can modify it to use jquery or whatever... instead
updateExtended = function () {
@Guest007
Guest007 / LimitedImageField.py
Created December 20, 2018 08:46
Check dimensions of loading image (https://toster.ru/q/588674)
class LimitedImageField(ImageField):
def __init__(self, *args, **kwargs):
self.max_upload_size = kwargs.pop('max_upload_size', None)
self.min_dim = kwargs.pop('min_dim', None)
self.max_dim = kwargs.pop('max_dim', None)
if not self.max_upload_size:
self.max_upload_size = settings.FILE_UPLOAD_MAX_MEMORY_SIZE
super(LimitedImageField, self).__init__(*args, **kwargs)
def clean(self, *args, **kwargs):
@Guest007
Guest007 / models.py
Created July 16, 2018 14:10
Prefetch id for Postgresql backend
# from https://djangosnippets.org/snippets/2731/
import os
from django.db import connection, models
def prefetch_id(instance):
""" Fetch the next value in a django id autofield postgresql sequence """
cursor = connection.cursor()
cursor.execute(
"SELECT nextval('{0}_{1}_id_seq'::regclass)".format(
instance._meta.app_label.lower(),
@Guest007
Guest007 / models.py
Created July 16, 2018 13:35
Dynamic File Path in Django
#from https://stackoverflow.com/questions/5135556/dynamic-file-path-in-django
"""MEDIA_ROOT/
/company_Company1/company.png
/shop_Shop1/shop.png
/bikes/bike.png
"""
def photo_path_company(instance, filename):
# file will be uploaded to MEDIA_ROOT/company_<name>/
return 'company_{0}/{1}'.format(instance.name, filename)
@Guest007
Guest007 / save_image_from_url.py
Created April 11, 2018 20:43
save image from url to django ImageField
# -*- coding: utf-8 -*-
from django.core.files import File
from django.core.files.temp import NamedTemporaryFile
import requests
import urlparse
def save_image_from_url(field, url):
@Guest007
Guest007 / wildcard-ssl-cert-for-testing-nginx-conf.md
Created March 2, 2018 10:08 — forked from dasgoll/wildcard-ssl-cert-for-testing-nginx-conf.md
create a self signed wildcard ssl cert for testing with nginx.conf example
openssl genrsa 2048 > edgenode1.key

openssl req -new -x509 -nodes -sha1 -days 3650 -key edgenode1.key -subj "/C=JO/CN=*.goll.com"> edgenode1-wildcard.cert

Common Name (eg, your name or your server's hostname) []:*.goll.com