[Solved] How to remove part of a data string? [closed]

It’s unclear what ResultSet is and its format from your question, however the following example code might be helpful: import csv csv_filename=”result_set.csv” ResultSet = {“(u’maxbotix_depth’, None)”: [{u’time’: u’2017-07-12T12:15:54.107488923Z’, u’value’: 7681}, {u’time’: u’2017-07-12T12:26:01.295268409Z’, u’value’: 7672}]} with open(csv_filename, mode=”wb”) as csv_file: writer = csv.writer(csv_file) for obj in ResultSet[“(u’maxbotix_depth’, None)”]: time, value = obj[u’time’], obj[u’value’] print(‘time: {}, value: … Read more

[Solved] Initializing singleton in class instead of instance? [closed]

This is the non-lazy method of implementing the Singleton pattern for languages that support it. It’s perfectly acceptable to do this, especially since it’s one of the ways of implementing a thread-safe Singleton. However, if your Singleton object is expensive (see lazy initialization) to create, then it might not be appropriate to create it in … Read more

[Solved] generate random password [C++]

You’re getting only numbers because there’s no specialization of std::to_string() for char. So when you do to_string(alphabet[random])), it converts the char to int (which returns the letter’s character code) and then converts that to a string. So to_string(‘a’) is “97”, not “a”. Instead of an array, you could use a string containing the alphabet. std::string::append() … Read more

[Solved] Have Excel VBA wait for PowerQuery data refresh to continue

Public Sub DataRefresh() DisplayAlerts = False For Each objConnection In ThisWorkbook.Connections ‘Get current background-refresh value bBackground = objConnection.OLEDBConnection.BackgroundQuery ‘Temporarily disable background-refresh objConnection.OLEDBConnection.BackgroundQuery = False ‘Refresh this connection objConnection.Refresh ‘Set background-refresh value back to original value objConnection.OLEDBConnection.BackgroundQuery = bBackground Next Workbooks(“DA List.xlsm”).Model.Refresh DoEvents For i = 1 To 100000 Worksheets(“DA List”).Range(“G1”) = i Next i DoEvents … Read more

[Solved] Rules for using ‘define’ [closed]

#define P1(x) x+x #define P2(x) 2*P1(x) int a=P1(1)?1:0; int b=P2(a)&a; after code substitution it will look like this: int a=1+1?1:0; int b=2*a+a&a; Since 1+1 is not false, a will be 1, so: int b=2*1+1&1 for clearness, I will write it with parenthesis (see operator precedence): int b=((2*1)+1)&1 which is equivalent to: int b=3&1 which is … Read more

[Solved] Unable to insert mutiple values to database [closed]

You can’t do 2 sets of values like your trying to do with an INSERT statement. Your effectively doing: INSERT INTO Controller_Forecast(C1,C2…) VALUES(…loads of values…) VALUES(…Loads of more values…) This isn’t valid. To insert 2 sets of data, which is what it looks like you’re trying to do you can do 2 INSERT INTO statements … Read more

[Solved] In SSRS 2008, how are parameters passed down to the DatSet Query… or can they?

In the query designer drag a dimension on top of your report. Chose an Operator and a Filter and check the checkbox by Parameters and BOOOM you have your parameter. If you go now into your report designer you find the parameter you just checked in the folder Parameters on the left navigation pane (on … Read more

[Solved] declaring and assigning variable [closed]

Instead of writing the following which id not valid Java, Paraula tipo1; tipo1 = { Paraula.lletres[0] = ‘t’; Paraula.lletres[1]=’1′; Paraula.llargaria = 2; perhaps you intended to write Paraula tipo1 = new Paraula(); tipo1.lletres[0] = ‘t’; tipo1.lletres[1]=’1′; tipo1.llargaria = 2; However a much cleaner way to do this is to pass a String to the constructor … Read more

[Solved] Simple Bubble sort program. It works flawlessly about 85% of times but in some cases it doesn’t sort the list

You are not using bubble sort. this is a selection sort algorithm and your code is not correct. I have updated the code for the bubble sort algorithm. #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int ctr, inner, outer, didSwap, temp; int nums[10]; time_t t; srand(time(&t)); for (ctr = 0; ctr < 10; … Read more

[Solved] How do I complete this C (assembly) character to hexadecimal and binary conversion code? [closed]

Three problems: No header files. You need stdio.h for printf and fileno, and io.h for read and setmode (setmode is a Windows only function; on Linux, you would include unistd.h for read). This: int main(void); Is a function declaration, not a definition. Get rid of the ;: int main(void); Finally: while(read(STDIN_FILENO, &c, ‘) > 0){ … Read more

[Solved] Regexp – Delete the one word before XXX, remove XXX too [closed]

Do a single regex replacement: string input = @”Hello World XXX Goodbye XXX Rabbit!”; Regex rgx = new Regex(@”\s*\w+\s+(?:XXX|xxx)”); // or maybe [Xx]{3} string result = rgx.Replace(input, “”, 1); Console.WriteLine(result); Hello Goodbye XXX Rabbit! Demo This replacement only would target XXX for removal if it be preceded by a word (one character or more). Explore … Read more