2018-10-22         Rod

python can't append a string to each element of a tuple using join

I tried to append a string to each element string in a tuple using join,str_tup = ('country', 'town')fields = ('_outlier'.join(key) for key in str_tup)for key in fields: print(key)I gotc_outliero_outlieru_outliern_outliert_outlierr_outlieryt_outliero_outlierw_outlierninstead of country_outliertown_outlierI am wondering how to resolve the issue, using a generator here trying to save memory. The join(x) function concatenates an iterable(e.g. a list) of items, placing x in between every item. What you are looking for is simple concatenation:str_tup = ('country', 'town')f...

 python                     2 answers                     53 view
 2018-10-22         Rod

How to Append to a file (FTP Python)

This question already has an answer here: Python, add data to file on server how? 1 answer import ftplib ftp = ftplib.FTP('some ip') ftp.login ('username','password') fin = open ('foo.txt', 'r') ftp.storbinary ('APPE foo2.txt', fin, 1) ftp.close()Please make sure the file on the server is writable. [XXX]

 python                     1 answers                     84 view
 2018-10-22         Rod

ASP.NET AJAX Page Methods Are Inconsistent

Given the following javascript code: function ValidateFlagAsUrgent() { selectedValuesList = document.getElementById('<%= _searchResultsUserControlUserControl.SelectedValuesHiddenFieldClientID %>').value; $.ajax({ type: 'POST', url: window.location.href + '/' + 'AreAnyOfTheSelectedTasksInMyProjects', data: '{"selectedTasks":"' + selectedValuesList + '"}', contentType: 'application/json; charset=utf-8', dataType: 'json', success: AjaxProjectManagerSucceeded, error: AjaxFailed, ...

 jquery                     1 answers                     55 view
 2018-10-22         Rod

Django having trouble linking a UserProfile to User

So im wanting to extend the django auth.User model to add extra fields. Ive read a few articles here and there, and am almost there.Im just trying to make the signup form at the moment. So a new user can sign up. I can get the new User created but when I come to save the UserProfile object to the database it fails citingCannot assign "u'clare'": "Customer.user" must be a "User" instance.where "clare" is the username ive put in. This user is created in Auth.User, but the UserProfile, in this case called Customer is not created. So I think im doing something wrong when creati...

 django                     1 answers                     57 view
 2018-10-22         Rod

Remove Double Encoding in Java Lambda Response

Getting Lambda Response as follows, which is double encoded. "{\"id\":\"6EE1DDABDC5C5EB271289A057DDA82B1\",\"name\":\"Test\",\"stateName\":\"INITIAL\",\"description\":\"Test Description\",\"type\":\"Download\",\"createTime\":\"Aug 10, 2018 2:02:02 PM\",\"updateTime\":\"Aug 10, 2018 2:02:02 PM\"}"However it shows fine when I print it under the handleRequest(Object input, Context context) method.{"id":"6EE1DDABDC5C5EB271289A057DDA82B1","name":"Test","stateName":"INITIAL","description":"Test Description","type":"Test","createTime":"Aug 10, 2018 2:02:02 PM","updateTime":"Aug 10...

 json                     1 answers                     8 view
 2018-10-22         Rod

Get Text From DOM object. Chrome Extension

I have page https://somepage in internet. Here is part of it's code from chrome code: ..............<div class="wr"><div class="auth_username">tesеDom@mail.com</div><div class="auth_stars"><i class="fa fa-star-o fa-fw">...........................I have seen many answers and examples, but my code still not working. Seems I am missing something. My manifest:{ "manifest_version": 2, "name": "Bot_copy", "version": "1.0", "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", "icons": {"48": "48x48.png","128": ...

 google-chrome                     1 answers                     83 view
 2018-10-22         Rod

avoid Negative Array Size Exception with try, catch and throw

The following Java code: public class SomeClass { int[] table; int size; public SomeClass(int size) { this.size = size; table = new int[size]; } public static void main(String[] args) { int[] sizes = {5, 3, -2, 2, 6, -4}; SomeClass testInst; for (int i = 0; i < 6; i++) { testInst = new SomeClass(sizes[i]); System.out.println("New example size " + testInst.size); } }}The first two instances of SomeClass, which have size 5 and 3, will be created without a problem. However, when the constructor SomeClass is called...

 arrays                     1 answers                     98 view
 2018-10-22         Rod

onclick event of google app script not working

some days before my code working fine with "onclick='google.script.run.processForm(this.parentNode)" but suddenly its stop working without any changes in code. mycode:html file:-<form id='addnewForm' action='myurl' method="post"> <input name='name' type="text" > <input name='age' type='text'> <input type='submit' value="submit" name="submit" onclick='google.script.run.processForm(this.parentNode)' > </form>code.js file: function processForm(value) { var name= value.name; var age= value.age; Logger.log('name is: ' + name...

 google-apps-script                     1 answers                     25 view
 2018-10-22         Rod

Deducing Multiple Parameter Packs

BackgroundI'm trying to write some template functions for a template-only unit test library, specifically for Qt.ProblemIn this library, I have a variadic template that receives a variable amount of objects and functors (Qt5 Signals actually), always paired next to each other, as in QObject, signal, etc... then desirably followed by a variable amount of signal arguments. Desired Solution// implementation.htemplate <typename T, typename U, typename... Sargs, typename... Fargs>void test_signal_daisy_chain(T* t, void(T::*t_signal)(Fargs...), ...

 c++                     2 answers                     72 view
 2018-10-22         Rod

extract delimited substring from field from arbitrary positions in the field using SQL

I'm trying to extract the following substring from the following field that contains strings delimited by underscores, where the substring may not be in the same location in every cella_bsdf_cat123_adsd_esdfa_cat345_zasd_weaqcat123213_sdfa_sadfas_23dsafaz_cat987_cat123_sdfaefI would like the extract the first underscore delimited substring starting with the letters "cat". So in the above example, I would like to extracta_bsdf_cat123_adsd_esdf -> cat123a_cat345_zasd_weaq -> cat345cat123213_sdfa_sadfas_23dsafa -> cat123213z_cat987_...

 mysql                     1 answers                     78 view
 2018-10-22         Rod

How to sum any credits before debits SQL Server?

I'm trying to sum the all credits that occur before a debit, then sum all the debits after credit within a 4 day time period.Table ACCT |Date | Amount | Credit or debit-----+----------+---------+---------------- 152 |8/14/2017 | 48 | C 152 |8/12/2017 | 22.5 | D 152 |8/12/2017 | 40 | D 152 |8/11/2017 | 226.03 | C 152 |8/10/2017 | 143 | D 152 |8/10/2017 | 107.23 | C 152 |8/10/2017 | 20 | D 152 |8/10/2017 | 49.41 | CMy query should only sum if there is credit before the debit. the results will have 3 rows with the data above. Out...

 sql-server                     1 answers                     39 view
 2018-10-22         Rod

Datetime need the date only

I have a column in SQL Server that is datetime this is a typical value 10/6/2016 8:40:00PMI want to process just according to the date.I want to group a report by date only. What must I do for this? On SQL Server 2008 and higher:SELECT CONVERT(date, getdate()) [XXX]

 sql                     1 answers                     50 view
 2018-10-22         Rod

Iterating when using OptimizeForPointLookup

I have a requirement where I only do point lookups but I also need to iterate but don't have to be in any specific order. I used OptimizeForPointLookup and used the iterator API and everything seems to work fine. However, the rocksdb code is documented with the following in options.h against the OptimizeForPointLookup api.// Use this if you don't need to keep the data sorted, i.e. you'll never use// an iterator, only Put() and Get() API callsIs there something I am missing? Interestingly the iteration also seems to be happening in a sorted order. OptimizeForPointLookup()...

 rocksdb                     1 answers                     13 view
 2018-10-22         Rod

An impasse with hooking calls to HeapAlloc for a memory tracking application

I am writing a memory tracking application that hooks all the calls to HeapAlloc using IAT patching mechanism. The idea is to capture all the calls to HeapAlloc and get a callstack. However I am currently facing a problem with getting the callstack using DBGHELP Apis. I found that the dbghelp dll itself is linking to MSVCRT dll and this dependancy results in a recursive call. When I try to get a callstack for any of the calls from the target application, dbghelp internally calls some method from MSVCRT that again calls HeapAlloc. And since I have already patched MSVCRT it r...

 windows                     3 answers                     85 view
 2018-10-22         Rod

Listing required Azure container files/file types using PowerShell

I have two azure containers. One filled with lot of files and other is new container. With Azure storage explorer, the container with lot files does not work as it hangs due to large data in it. I would like to see the files of my interest using Powershell and move them to new container.Get-AzureStorageBlob -Container $container -Context $destContext lists all the blobs which is not practically good option as it is difficult to search all blobs as data is huge.I want to search say for example only .csv files or .txt files or search with part of name using "Powershell". Ho...

 powershell                     1 answers                     58 view
 2018-10-22         Rod

Stray characters seen at output of snprintf

I have a string creating function in C which accepts an array of structs as it's argument and outputs a string based on a predefined format (like a list of list in python).Here's the functiontypedef struct{ PacketInfo_t PacketInfo; char Gnss60[1900]; //and other stuff...} Track_json_t;typedef struct { double latitude; double longitude;} GPSPoint_t;typedef struct{ UInt16 GPS_StatusCode; UInt32 fixtime; GPSPoint_t point; double altitude; unsigned char GPS_Satilite_Num;} GPS_periodic_t;unsigned short SendTrack(){ ...

 c                     2 answers                     69 view

Page 1 of 146  |  Show More Pages:  Top Prev Next Last