This file contains 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
import cPickle | |
import numpy as np | |
import tensorflow as tf | |
from data_utils_ubuntu import CustomRunner | |
def position_encoding(sentence_size, embedding_size): | |
""" | |
Position Encoding described in section 4.1 [1] |
This file contains 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 lasagne import nonlinearities, init | |
from lasagne.layers.normalization import BatchNormLayer | |
from lasagne.layers.recurrent import Gate, Layer, MergeLayer, LSTMLayer | |
from lasagne.utils import unroll_scan | |
import numpy as np | |
import theano | |
import theano.tensor as T |
This file contains 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
import os | |
from django.core.files.storage import FileSystemStorage | |
from django.db.models import signals | |
class MyFileSystemStorage(FileSystemStorage): | |
def rename(self, src, dest): | |
return os.rename(self.path(src), self.path(dest)) | |
class MyFileField(models.FileField): |
This file contains 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
sizes = new Array({{ product_sizes|safe }}); | |
function filterSizeSelectField() | |
{ | |
product_type = $("#id_product_type").val(); | |
fields = $("select[id*='-size']").serializeArray(); | |
size_options = '<option value="">---------</option>'; | |
$.each(sizes, | |
function(i, size) | |
{ |
This file contains 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
$(document).ready(function() { | |
$("select[id*='id_products-']").css("width", "145px"); | |
function getSizeSelectField() | |
{ | |
product_type = $("#id_product_type").val(); | |
fields = $("select[id*='-size']").serializeArray(); | |
$("select[id*='-size']").load('{% url shop.views.getSelectField %}' + '?type=size&object_id=' + product_type, | |
function() { | |
$.each(fields, function(i, field) { |
This file contains 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
# Самое элегантное решение (доступно с версии Python 2.6) | |
class Requisite(models.Model): | |
requisite = models.CharField(max_length=100, verbose_name=u'реквизиты') | |
@property | |
def requisite_dict(self): | |
return json.loads(self.requisite) | |
@requisite_dict.setter | |
def requisite_dict(self, value=None): | |
self.requisite = json.dumps(value) |
This file contains 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 MultiTextInputWidget(forms.TextInput): | |
""" | |
A widget that is composed of multiple TextInput widgets. | |
Its render() display multiple TextInput widgets. | |
The ``value`` argument supposes to be a dictionary in json format or string | |
This widget can be used together with MultiTextInputField. | |
""" | |
def __init__(self, attrs=None): |