220
Points
Questions
42
Answers
40
-
Asked on July 17, 2020 in XML.
That is just what I needed now I can load my xml and display in a text field for now with the code below. THANK YOU soooo much I had spent many hours on this and was getting nowhere, your help has got me over this hurdle, I really appreciate the help.
<!DOCTYPE html> <html> <input type="file" onchange="readfile(this)" > <output id="list"></output> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script> <script> function readfile(fileinputobj){ var reader = new FileReader(); reader.onload = function(e) { //Using DOMParser to get XMLDocument var parser = new DOMParser(), xmlDoc = parser.parseFromString(reader.result, "text/xml"); var xmlWrapper = $(xmlDoc) var title = xmlWrapper.find("title").text(); var textInput = $('<input/>'); textInput.attr("type", 'text'); textInput.appendTo('body'); textInput.val(title); } reader.readAsText(fileinputobj.files[0]); } </script> </body>
- 486 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in XML.
In recent versions of the free and open source Eclipse IDE you can generate XML documents from DTD and XSD files. Right-click on a given *.dtd or *.xsd file and select “Generate -> XML File…”. You can choose which root element to generate and whether optional attributes and elements should be generated.
Of course you can use Eclipse to create and edit your DTD and XSD schema files, too. And you don’t need to install any plugins. It is included in the standard distribution.
- 838 views
- 19 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
You should add an optional hyphen at the beginning by adding
-?
(?
is a quantifier meaning one or zero occurrences):^-?[0-9]\d*(\.\d+)?$
I verified it in Rubular with these values:
10.00 -10.00
and both matched as expected.
- 648 views
- 14 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
Interestingly, none of the answers on this page mention the two edge cases, hope no one minds if I add them:
Edge case #1: concurrent access to a Dictionary
Generic dictionaries in .NET are not thread-safe and they sometimes might throw a
NullReference
or even (more frequent) aKeyNotFoundException
when you try to access a key from two concurrent threads. The exception is quite misleading in this case.Edge case #2: unsafe code
If a
NullReferenceException
is thrown byunsafe
code, you might look at your pointer variables, and check them forIntPtr.Zero
or something. Which is the same thing (“null pointer exception”), but in unsafe code, variables are often cast to value-types/arrays, etc., and you bang your head against the wall, wondering how a value-type can throw this exception.(Another reason for non-using unsafe code unless you need it, by the way)
- 1189 views
- 28 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
Sample method to do the cross-product using MathNet.Numerics.LinearAlgebra.Generic.Vector of a 2 element vector.
Vector<float> v1 = new DenseVector(new float[] { 1, 2, 3 }); Vector<float> v2 = new DenseVector(new float[] { 3, 2, 1 }); Vector<float> result = v1.CrossProduct(v2); Vector<float> result = Vector.CrossProduct(v1,v2);
- 370 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
Run this query:
select 1 or 1 and 0
If it comes out as
1
, then that means the precedence is:select 1 or (1 and 0)
if it comes out
0
, then the precedence is:select (1 or 1) and 0
Spoiler: it comes out
1
That is to say,
AND
s are evaluated beforeOR
s, or as I like to say, ANDs are stickier.- 391 views
- 4 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
I do not think you can combine two queries in the same statement (create + insert). Try splitting them up.
- 355 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
After editting the "right" files (all php.ini’s). i had still the issue. My solution was:
-
Adding a System variable: OPENSSL_CONF
the value of OPENSSL_CONF should be the openssl.cnf file of your current php version.
for me it was:
- C:\wamp\bin\php\php5.6.12\extras\ssl\openssl.cnf
-> Restart WAMP -> should work now
- 687 views
- 18 answers
- 0 votes
-
-
Asked on July 16, 2020 in Python.
Creating a
multi_index
then usingstack
df = df.set_index(['ID1','ID2']) df.columns = df.columns.str.split('_',expand=True) df1 = df.stack(1).reset_index().rename(columns={'level_2' : 'Ch'}) ID1 ID2 Ch Foc Sat 0 r 1 A 10 100 1 r 1 B 15 105 2 r 1 C 17 107 3 r 2 A 20 110 4 r 2 B 25 115 5 r 2 C 27 117 6 s 1 A 30 120 7 s 1 B 35 125 8 s 1 C 37 127 9 s 2 A 40 130 10 s 2 B 45 135 11 s 2 C 47 137
- 471 views
- 5 answers
- 0 votes
-
Asked on July 16, 2020 in Python.
Try putting the
return
out of the loop like this:def abc(df_189): dfObj = pd.DataFrame(columns=['my_product_id', 'Cost']) my_products = df_189.my_product_id.unique() for i in my_products: df_test = df_189[df_189.my_product_id == i] Grouped=df_test.groupby('date') GetWeightAvg=lambda g: np.average(g['cost'], weights=g['quantity']) pr=Grouped.apply(GetWeightAvg).sort_index(ascending=False).head(3).mean() dfObj = dfObj.append({'my_product_id': i, 'Cost': pr}, ignore_index=True) return dfObj
- 0 views
- 1 answers
- 0 votes