Dmitry Belaventsev

1

votes
2

answer
1.5k

views

Long to Double in Jexl

I use Jexl lib from apache and have some problems with using the evaluate() method of Expression class. Here is the code of NelderMead class: import org.apache.commons.jexl2.*; public class NelderMead { // контсанты private static int M = 3; private static double E = 0.005; private s...
Dmitry Belaventsev
1

votes
1

answer
1.1k

views

Can't create JexlEngine object

I write the following class: import org.apache.commons.jexl2.*; public class NelderMead { // контсанты private static int M = 3; private static double E = 0.005; private static double A = 1.000; private static double B = 0.500; private static double Y = 2.000; // перемен...
Dmitry Belaventsev
1

votes
1

answer
1k

views

How delete JPanel from JFrame before adding new one

I have JPanel has already added to JFrame. And I have dynamically added JPanel. After adding JPanel on the fly it stay near the JPanel added before. How can I delete previous JPanel? PS I also think about using cardlayout - is it a good way?
Dmitry Belaventsev
1

votes
1

answer
727

views

Make LiveServerTestCase not to call setUp() before each test

I have one problem with testing django app by using LiveServerTestCase. LiveServerTestCase execute setUp() function before executing each test. But I'm using factory-boy's factories to create objects for testing (users, items, etc...). And the same objects are created before executing each test. How...
Dmitry Belaventsev
1

votes
1

answer
236

views

simplejson - encoding regexp \d+

I have some missunderstanding with encoding regexp: >>> simplejson.dumps({'title':r'\d+'}) '{'title': '\\\\d+'}' >>> simplejson.loads('{'title': '\\\\d+'}') {u'title': u'\\d+'} >>> print simplejson.loads('{'title': '\\\\d+'}')['title'] \d+ So, without using print I see \\, with using print I see \....
Dmitry Belaventsev
1

votes
2

answer
0

views

DRF: Serializer for heterogneous list of related models

Roughly said, I have the following schema in ORM: class Page(models.Model): title = models.CharField(max_length=255, null=False, blank=False) @property def content(self): return [Video.objects.all()[0], Text.objects.all()[0], Video.objects.all()[1]] and I have the following set of classes to support...
Dmitry Belaventsev
1

votes
2

answer
0

views

CSS3 inner lighting for input

I need to make rounded inputs with inner lighting like on this picture: I can make the rounding like this: .loginRounded{ -moz-border-radius: 14px; -webkit-border-radius: 14px; border-radius: 14px; outline: 0; -webkit-appearance: none; } But I can't imagine how to make inner lighting with css3. PS I...
Dmitry Belaventsev
1

votes
1

answer
379

views

Django: changing model's schema (replace CharField with ImageField)

I modify project based on Django framework. I have form to add an item. Item has the cover (an image). Current version of model for this item store cover's url like this: class Item(models.Model): title = models.CharField(max_length = 255, db_index = True) slug = models.CharField(max_length = 80, db...
1

votes
1

answer
747

views

Periodically download file from my dropbox account

I have the django application, which needs refresh some data. This data should be downloaded from my dropbox account (file name and path is the same each time). How can I implement this? I start with using dropbox api, create application, etc - but this method has one big defect - it needs user go t...
1

votes
1

answer
230

views

How to get remote ip from `twisted.web._newclient.Response` instance

I have a code, which make request to web-site (request by hostname, for example - www.google.com). Remote host send a response. How can I get IP of the host, which sent a response? PS I'm using twisted web client PS2 Feature request
Dmitry Belaventsev
1

votes
1

answer
173

views

Flask-SQLAlchemy using STI: how to automatically substitute type field

I'm using Flask-SQLAlchemy==2.2 and have STI (Single Table Inheritance) configuration like this: from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Item(db.Model): __tablename__ = 'item' id = db.Column(db.Integer, primary_key=True) info = db.Column(db.String(255)) type = db.Column(db.St...
1

votes
4

answer
1.1k

views

Horizontal scroll of elements (100% width) inside parent element with percentage width value [duplicate]

This question already has an answer here: horizontal scroll of inline-block element 2 answers I'm using Bootstrap3 for creating pages in my application. Somewhere deep in a page I have the column (col-md-6), which width is calculated by percentage. My current goal is to fill that element with a set...
1

votes
2

answer
2.3k

views

GetMem for one PChar variable change content of other PChar variable

So, I have the folowing problem. I have 2 PChar variables. I allocate memory for first, do some operations, allocate memory for the second variable - and on this step the first variable contains bad value (i saw it while debugging). Here is the code: procedure TReadThread.Execute; Var iRead, temp, i...
1

votes
1

answer
64

views

Select string which matches following regexp

I have the following regexp /^\+[0-9]{1,3}\s[0-9]{1,6}\s[0-9\s]{5,8}$/u in my PHP code. And I can't understand which strings will be matched by this expression. I tried the following +7 777 777777 and it does not match... could you help me to understand - what string will match this regexp?
Dmitry Belaventsev
1

votes
1

answer
1.4k

views

Call method in collection, when View's method called

I have a view and collection like this: window.DmnView = Backbone.View.extend({ template: _.template($('#tmpl_dmnListItem').html()), events: { 'click .getWhois': 'showWhois', 'click .getDomain': 'toBasket' }, initialize: function() { this.model.bind('change', this.render, this); this.model.bind('des...
Dmitry Belaventsev
1

votes
3

answer
85

views

Absolute positioned ul stratch parent div

I look at example of dropdown menu here. Here is simplified jsfiddle example. I want to build my own styled HTML element base on it. All it's ok. But in my implementation I need to wrap ... with div styled with the CSS like this: border: 2px solid green; overflow: auto; And in this case the ul with...
1

votes
1

answer
2.2k

views

Django: store InMemoryUploadedFile on the disk

I have the HTML form which do prior upload of files via AJAX. So in django backend I have the following code of View, which process this AJAX calls: @csrf_exempt def book_upload(request): if request.method == 'POST': log.info('received POST to main book_upload view') if request.FILES is None: return...
Dmitry Belaventsev
1

votes
1

answer
1.1k

views

Django: control time of TemporaryUploadedFile life

I have form in my django app. User can do prior upload of files before submitting the form. In handler for uploaded files I use TemporaryUploadedFile. So - files are stored in /tmp directory. This handler send the response to the form - JSON object, which contains file path and file extension. This...
Dmitry Belaventsev