[Solved] Python List of Dictionaries by Loops

If you want only print the resulting dictionaries, uncomment the print statement (and comment the following 2). d1 = [ {‘index’:’1′,’color’:’red’}, {‘index’:’2′,’color’:’blue’}, {‘index’:’3′,’color’:’green’} ] d2 = [ {‘device’:’1′,’name’:’x’}, {‘device’:’2′,’name’:’y’}, {‘device’:’3′,’name’:’z’} ] result_list = [] for dict1 in d1: merged_dict = dict1.copy() for dict2 in d2: merged_dict.update(dict2) # print(merged_dict) result_list.append(merged_dict.copy()) print(result_list) The result: [{‘name’: ‘x’, ‘device’: … Read more

[Solved] Convert decimal to integer without losing monetary value

decimal firstDecimal = 120.01M; double firstDouble = 120.01; float firstFloat = 120.01F; Console.WriteLine ((int)(firstDecimal * 100)); // 12001 Console.WriteLine ((int)(firstDouble * 100)); // 12001 Console.WriteLine ((int)(firstFloat * 100)); // 12001 Console.WriteLine (Convert.ToInt32(firstDecimal * 100)); // 12001 Console.WriteLine (Convert.ToInt32(firstDouble * 100)); // 12001 Console.WriteLine (Convert.ToInt32(firstFloat * 100)); // 12001 This means one thing…. you have something … Read more

[Solved] Want to get drop down value on php sql query without page refresh

Use ajax $.ajax({ url: “fetchlist.php”, dataType: ‘json’, success: function(response){ // Here, you may bind response with your select HTML } }); You may either return json from your php file and create DOM elements in response. Or, you may create HTML version and return as response. Suggestion will be to use JSON for better flexibility. … Read more

[Solved] Dialogflow and C#. How do I get a response from an agent?

I’ve written simple bots for Dialogflow / Google Home in C# using the following Nuget package. https://www.nuget.org/packages/Google.Cloud.Dialogflow.V2 Docs: https://developers.google.com/resources/api-libraries/documentation/dialogflow/v2/csharp/latest/ You can use the webhookrequest and webhookresponse classes to send and recieve information from Dialogflow. It can be a bit more trouble than the NodeJs version, but with some work it is possible. 1 solved Dialogflow … Read more

[Solved] Some fake data coming automatically in webserver databse

Quick workaround: Add a validation on Laravel side (server side validation) with a regex allowing only non-russian characters. Then Post your code with implementation of Google reCAPTCHA, there we’ll find the answer. Which version of Google reCAPTCHA you are using..? 1 solved Some fake data coming automatically in webserver databse

[Solved] Write a program that uses Bubble Sort to sort integers in a 2 dimensional array in ascending order

You can cast pointer to the first row of a two-dimensional array to pointer to int and sort the array as a one-dimensional array. Here you are #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> void bubble_sort( int *a, size_t n ) { for ( size_t last /* = n */; not ( n < … Read more

[Solved] Remove duplicates from a Java List [duplicate]

There are two possbile solutions. The first one is to override the equals method. Simply add: public class DataRecord { […..] private String TUN; @Override public boolean equals(Object o) { if (o instanceof DataRecord) { DataRecord that = (DataRecord) o; return Objects.equals(this.TUN, that.TUN); } return false; } @Override public int hashCode() { return Objects.hashCode(TUN); } … Read more

[Solved] How to delete part of a string in C++

#include <string> #include <iostream> // std::cout & std::cin using namespace std; int main () { string str (“This is an example phrase.”); string::iterator it; str.erase (10,8); cout << str << endl; // “This is an phrase.” it=str.begin()+9; str.erase (it); cout << str << endl; // “This is a phrase.” str.erase (str.begin()+5, str.end()-7); cout << str … Read more

[Solved] C# read value from .txt file? [closed]

The format you’re describing for your text file is a CSV – Comma Separated Value. It’s a very common storage format, and there are many helpful tools and examples out there to work with it. So now that you know how it’s called, you can run more specific searches for things like “CSV C#” and … Read more

[Solved] Incorrect syntax near ‘=’ … Error in .ashx file [closed]

Do something like this: if(imageid != null) { SqlCommand command = new SqlCommand(” select Image from ImageStore where ImageID=” + imageid, connection); SqlDataReader dr = command.ExecuteReader(); dr.Read(); context.Response.BinaryWrite((Byte[])dr[0]); } else { SqlCommand command = new SqlCommand(” select Image from ImageStore where ImageID=0″, connection); SqlDataReader dr = command.ExecuteReader(); dr.Read(); context.Response.BinaryWrite((Byte[])dr[0]); } 1 solved Incorrect syntax near … Read more