- [Введение в программирование на Go][1]
- [Маленькая книга о Go][3]
- [Эффективный Go][2]
- Есть еще [Краткий пересказ Effective Go на русском языке][4], но 2009 года
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Connected>: | |
BoxLayout: | |
orientation: 'vertical' | |
Label: | |
text: "You are now connected" | |
font_size: 32 | |
Button: | |
text: "Disconnect" | |
font_size: 24 |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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 () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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): |