[Solved] What could be the regular expression for the text “192.168.71.1 GET HTTP/1.0 /test/abc”?

Using https://regex101.com/ the following works: 192\.168\.71\.1\sGET\sHTTP\/1\.0\s\/test\/abc Remember to escape special characters like . and \ if you want to use them as literals. If you want to use any of these characters as a literal in a regex, you need to escape them with a backslash Take a look at http://www.regular-expressions.info/characters.html to see more about … Read more

[Solved] Print a list with names and ages and show their average age

This also works: pairs = dict([tuple(namn[i:i+2]) for i in range(0, len(namn), 2)]) for name, age in sorted(pairs.items()): print(“%s: %d” % (name, age)) avg_age = sum(pairs.values())/ len(pairs) print(“Average Age: %f” % (avg_age)) Output: Anna: 27 Emelie: 32 Erik: 30 Johanna: 29 Jonas: 26 Josefine: 20 Kalle: 23 Lena: 22 Peter: 19 Average Age: 25.333333 You could … Read more

[Solved] Python – Swap a value for a dictionary item

First make from your string a list. list_name = string_name.split(‘ ‘) Then switch the keys and the values from your dict (if using python 3.x use iter instead of iteritems) my_dict = {y:x for x,y in my_dict.iteritems()} Then you can iter tro your code for numbers in list_name: print(my_dict[int(numbers)]) 6 solved Python – Swap a … Read more

[Solved] Sort row in array as easily as possible (Javascript)

You can use this function: function sortCol(desc) { const tbl = document.querySelector(“table>tbody”); const rows = Array.from(tbl.rows).slice(1).sort((a, b) => a.querySelector(“img”).src.localeCompare(b.querySelector(“img”).src) ); if (desc) rows.reverse(); rows.forEach(row => tbl.appendChild(row)); } Call it with argument true when you want to have a descending sort order. If you have more than one table on your page, you need to qualify … Read more

[Solved] Save an Object into User Defaults [duplicate]

The UserDefaults class provides convenience methods for accessing common types such as floats, doubles, integers, Boolean values, and URLs. A default object must be a property list—that is, an instance of (or for collections, a combination of instances of) NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary. If you want to store any other type of … Read more

[Solved] NodeJs function wait until callback return value

make your function async and then await xyz() var http = require(‘http’); var foo = async function(req, res){ var a = await xyz(‘5’); res.end(a); console.log(a); } function xyz(arg){ var aa = 55; return aa; } http.createServer(foo).listen(8000); console.log(‘start server’); 2 solved NodeJs function wait until callback return value

[Solved] C++ program does nothing when executed

Vectors in c++ are dynamically sized. You can create a vector without a size argument in the constructor then push size number of elements like so: vector<int> makeGaps (int size){ vector<int> vectorOfGaps; for(int i = 0; i < size;i++){ vectorOfGaps.push_back(i); } return vectorOfGaps; } Edit: Also, as someone already pointed out in your comments, it … Read more

[Solved] PHP PDO, request users name

please reference the user properties that you want to select the SQL queries using their post variables. something like: $username =$_POST[‘username’]; $password = password=$_POST[‘password’]; $stmt = $db->query(“SELECT * FROM users where username=”$username” and password= ‘$password'”); While this might solve your problem but Please do not use this code in production for fear of sql inject,html … Read more

[Solved] How do I programmatically pull up a different storyboard when a button is clicked in Swift 4? [duplicate]

You can do it programatically this way: Swift 3+ let storyboard = UIStoryboard(name: “StoryboardName”, bundle: nil) let vc = storyboard.instantiateViewController(withIdentifier: “ViewControllerID”) as UIViewController present(vc, animated: true, completion: nil) 2 solved How do I programmatically pull up a different storyboard when a button is clicked in Swift 4? [duplicate]