mastodon

0

votes
0

answer
6

views

How to count non-zeroes values using binned_statistic

I need to efficiently process very large 1D arrays extracting some statistics per bin and I have found very useful the function binned_statistic from scipy.stats as it includes a 'statistic' argument that works quite efficiently. I would like to perform a 'count' function but without considering zer...
Mastodon
2

votes
5

answer
1.2k

views

Collection for storing objects with date

I have some objects with Date parameters. What collection will be best for storing them and later querying for object/objects with particular date ? (like given as a String or java.util.Date format) ? EDIT: I was trying to use TofuBear's solution, but cannot make it work. let's say I am calling my f...
mastodon
2

votes
5

answer
37.9k

views

Style facebook 'like' button

I'm struggling with this for a while now and without any success. Setting the style with jquery doesn't work, the same with after the facebook iframe. Is there a way to perform this task ? .connect_widget_not_connected_text, .connect_widget_connected_text { color:white; } .connect_widget_connected_...
mastodon
2

votes
4

answer
1.8k

views

Sending GET to server gives no response (but status returned)

I'm sending an ajax request to my server that updates some data there. Request is sent with jquery's get function. On success I'd like te perform some action, but unfortunately whole operation fails since server gives no response, even though firebug clearly shows 200 status: What more, when I enter...
mastodon
2

votes
3

answer
118

views

Strange python's comparison behaviour

I have a sample code looking like this, values (position = 2, object.position = 3) : new_position = position old_position = object.position logging.debug("1. new_position: %s, old_position: %s" % (new_position, old_position)) if old_position != new_position: logging.debug("old position other tha...
mastodon
6

votes
5

answer
2.5k

views

Pause form submission for validation

I have some form, which uploads file in an iframe. I'd like to hold it's submission until I'll check if it's valid with ajax. How can I do this ? My code pauses the submission and returns validation result (currently just a dummy function which returns 'result': 'true') but then the 'submit' action...
mastodon
4

votes
2

answer
22.7k

views

Encode keys of dictionaries inside a list from unicode to ascii

I have sample response with friends list from facebook: [{u'uid': 513351886, u'name': u'Mohammed Hossein', u'pic_small': u'http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs643.snc3/27383_513351886_4933_t.jpg'}, {u'uid': 516583220, u'name': u'Sim Salabim', u'pic_small': u'http://profile.ak.fbcdn.net/hp...
mastodon
1

votes
1

answer
105

views

Filtering blast results by evalue but only if unique

I am working on a pipeline that at some point generates hundred of different files in the following format (I write X in the fields that I don't care about): id1 X X X X X X X X X evalue1 X id2 X X X X X X X X X evalue2 X ... I have to filter this file...
Mastodon
4

votes
5

answer
46.4k

views

Read multiline text with values separated by whitespaces

I have a following test file : Jon Smith 1980-01-01 Matt Walker 1990-05-12 What is the best way to parse through each line of this file, creating object with (name, surname, birthdate) ? Of course this is just a sample, the real file has many records.
mastodon
4

votes
3

answer
2.6k

views

Casting Objects to <T>-type

I'm implementing List interface to a class which stores data in a type array. This raises problems with methods that take Collection as parameters, since collection stores it's objects as Object. How can I transform Object to T ? Simple casting doesn't work. class MyCollection implements List{ T[]...
mastodon
1

votes
3

answer
333

views

Replacing whitespaces within list elements

I have a list of tags: >>> tags_list ['tag1', 'second tag', 'third longer tag'] How can I replace whitespaces within each element of the list with "+" ? I was trying to do this with regular expressions but each string remains unchanged: for tag in tags_list: re.sub("\s+" , " ", tag) What is wrong wi...
mastodon
6

votes
5

answer
3.4k

views

Retrieving response from remote server after uploading a file in iframe

I have a form that uploads a file in an firame to a remote server. As a result at the submission url server returns json data with the result of operation, which my iframe catches. {'result': 'true' or 'false'} Now I'd like to retrieve this json as the callback of my iframe. I know that I need jsonp...
mastodon
1

votes
1

answer
219

views

Form doesn't accept additional parameters

I was trying to pass an additional parameter to my form, which is anObject to ForeignKey relation. But dunno why form returns __init__() got an unexpected keyword argument 'parent' when I'm pretty sure that it is possible to send additional parameters to form's __init__ (ie here : Simple form not va...
mastodon
3

votes
3

answer
13.6k

views

Workaround for adding ActionListener to JTextArea

I have a program that get's input string with file path in one JTextArea and then loads it's content to a second JTextArea. Problem is that when using JTextArea I cannot add an actionListener that will load content in the second JTextArea when leaving this field. How to get around this problem ? pro...
mastodon