235
Points
Questions
45
Answers
44
-
Asked on July 17, 2020 in XML.
Consider using the
saxon:parse-dateTime()
extension function:https://www.saxonica.com/documentation/index.html#!functions/saxon/parse-dateTime
Requires Saxon-PE or higher, Saxon 10 onwards.
- 411 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
URL rewrite get executed in the begin request event in IIS pipeline. There’s no apparent difference in security level when you redirect http to https.
When you enable SSL in IIS manager, http and https side-by-side is not supported because schannel will break it. So you may need to create another site to handle the http binding and implement https redirection. In this case, both of them should be safe.
- 471 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
The text in English is clearer:
A non-flags−attributed enumeration should define a member that has the value of zero so that the default value is a valid value of the enumeration.
They key difference is that English is clearer that the requirement is for a value of zero (not
null
, since enum members can’t have anull
value).DayOfWeek
meets this requirement, because it hasSunday
:Sunday 0 Indicates Sunday.
The intent here is that if you do code like https://dotnetfiddle.net/H4Eq1k (whereby you declare a variable of the enum type but don’t assign anything to it, so it has the default 0 value) then you get meaningful results (i.e. 0 represents a valid value of the enum).
If what you are trying to do is allow some optional notion of
DayOfWeek
then you likely want a nullable parameter:private List<Class> GetData(DayOfWeek? Day = null) { }
This will allow you to pass a day of the week if you want (with the value of
null
being used if you don’t pass a value).- 406 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
^[+-]?\d{1,18}(\.\d{1,2})?$
accepts positive or negative decimal values.
- 649 views
- 14 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
You could also check the query written if there are fully optimized, and connection are closed when not used.
Also you can reduce the load on the mysql server by balancing some work to php.
Also take a look at your query_cache_size, innodb_io_capacity, innodb_buffer_pool_size and max_connection setting in your my.cnf.
Also sometimes upgrading php and doing some caching on your apache can help reduce of ram uses.
https://phoenixnap.com/kb/improve-mysql-performance-tuning-optimization
- 431 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
Try using {} instead of %s in your str.format() command. Using %s is for the alternate/older way to input variables.
sqlCommand = str.format("UPDATE PowerTable set Power = '{}' ", PowerValue)
alternate way
sqlCommand2 = "UPDATE PowerTable set Power = '%s' " % PowerValue
Reference: https://realpython.com/python-string-formatting/#2-new-style-string-formatting-strformat
- 451 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
MySQL will run queries in parallel to the best of its ability without any special intervention.
The message about being blocked is because your web socket is generating so many connection errors in a short timeframe that MySQL is interpreting it as an attack. You should be monitoring the error feedback being received by your process and resolving whatever issues are occurring. (It’s very likely you will need to raise the server’s max_connections.)
- 398 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
You can Sum the transactions grouped by CustomerID and then join to the customers table on the CustomerID like this:
SELECT c.Customer_name, c.Customer_mobile, t.Transaction_sum FROM Customer c JOIN ( SELECT t.CustomerID, SUM(t.Sum) as Transaction_sum FROM transactions t GROUP BY t.CustomerID ) t on t.CustomerID = c.CustomerID
- 375 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in Linux.
I recently discovered that using
strtolower()
can cause issues where the data is truncated after a special character.The solution was to use
mb_strtolower($string, 'UTF-8');
mb_ uses MultiByte. It supports more characters but in general is a little slower.
- 726 views
- 15 answers
- 0 votes
-
Asked on July 16, 2020 in Python.
print(df)
reason count 0 location 35 1 recommendation 23 2 recommedation 8 3 confort 7 4 availability 4 5 reconmmendation 3 6 facilities 3
.groupby()
, partial string..transform()
while finding thesum
df['groupcount']=df.groupby(df.reason.str[0:4])['count'].transform('sum') reason count groupcount 0 location 35 35 1 recommendation 23 34 2 recommedation 8 34 3 confort 7 7 4 availability 4 4 5 reconmmendation 3 34 6 facilities 3 3
If needed to see string and partial string side by side. Try
df=df.assign(groupname=df.reason.str[0:4]) df['groupcount']=df.groupby(df.reason.str[0:4])['count'].transform('sum') print(df) reason count groupname groupcount 0 location 35 loca 35 1 recommendation 23 reco 34 2 recommedation 8 reco 34 3 confort 7 conf 7 4 availability 4 avai 4 5 reconmmendation 3 reco 34 6 facilities 3 faci 3
Incase you have multiple items in a row like you have in the csv; then
#Read csv df=pd.read_csv(r'path') #Create another column which is a list of values 'Why you choose us' in each row df['Why you choose us']=(df['Why you choose us'].str.lower().fillna('no comment given')).str.split(',') #Explode group to ensure each unique reason is int its own row but with all the otehr attrutes intact df=df.explode('Why you choose us') #remove any white spaces before values in the column group and value_counts df['Why you choose us'].str.strip().value_counts() print(df['Why you choose us'].str.strip().value_counts()) location 48 no comment given 34 recommendation 25 confort 8 facilities 8 recommedation 8 price 7 availability 6 reputation 5 reconmmendation 3 internet 3 ac 3 breakfast 3 tranquility 2 cleanliness 2 aveilable 1 costumer service 1 pool 1 comfort 1 search engine 1 Name: group, dtype: int64
- 415 views
- 1 answers
- 0 votes