C++ Indent existing xml file Posted: 07 Dec 2021 11:33 AM PST I want to write a c++ program that indents existing (offline) xml file, and i am supposed not to use any existing libraries and should implement the code from scratch, so my question is how to indent that file? |
Retrieving Part of a URL (Regex) Posted: 07 Dec 2021 11:33 AM PST How can I extract the "wp-*" portion of the URL in regex? facebook.com/wp-content/uploads/xyz facebook.com/wp-uploads/uploads/xyz |
open url in external browser instead of in-app mobile browser using php for ios Posted: 07 Dec 2021 11:33 AM PST I am using below code which is working perfectly for android mobile but its not working on iphone. What will be the perfect way to achieve this on iPhone? $userAgent = $_SERVER['HTTP_USER_AGENT']; if (strpos($userAgent, 'Instagram')) { header('Content-type: application/pdf'); header('Content-Disposition: inline; filename= test'); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); @readfile($file); } else{ header('Location: index.php'); } I want to open index.php on external browser of mobile app |
How can I structure a Django REST API for a lot of similar online games? Posted: 07 Dec 2021 11:32 AM PST I am very new to Django and the Django REST Framework and I want to implement an API for 4 relatively similar games. The most basic game consists of a player labelling an image and receiving points for this if they enter the same labels as their co-player for the same image. One game session consists of 3 rounds. What I have done so far is create a view for the game type, game session, game round, image to be shown and the labels, which will be divided into Taggings (a user has used this label as input) and Tags (more than one user has entered this very same label for the same picture). All of those views look similar to the Gametype and Tagging views below. """ API View that handles retrieving the correct type of a game """ serializer_class = GametypeSerializer def get_queryset(self): gametypes = Gametype.objects.all().order_by("name") return gametypes def get(self, request, *args, **kwargs): gametype = self.get_queryset() serializer = GametypeSerializer(gametype, many=True) return Response(serializer.data) class Tagging(APIView): """ API View to do everything to do with taggings """ serializer_class = TaggingSerializer def get_queryset(self): taggings = Tagging.objects.all().filter(resource=8225) return taggings def get(self, request, *args, **kwargs): tagging = self.get_queryset() serializer = TaggingSerializer(tagging, many=True) return Response(serializer.data) def post(self, request, *args, **kwargs): tagging = request.data.get_queryset() serializer = TaggingSerializer(data=tagging) if serializer.is_valid(raise_exception=True): saved_tagging = serializer.save() return Response(saved_tagging) The Tag Tagging and Gamesession views will also need POST requests on top of this (I am still working on those). I am also only doing the backend for this web app so I can only test all of this with a GUI I have written in Python (with tkinter) so far. What I am struggling with is: how do I connect the views with each other, such that the game logic works properly? Or do I have to write one view per game and write a separate serialised for this? Better said - how do I make the backend of the game functional with those views? What am I missing? |
Pass php value of a selected Submit image Posted: 07 Dec 2021 11:32 AM PST I have an image swiper, that changes between 3 images accoording to the below code. When I select image 1 or 2, I want that value to be sent to next page (submit form page). As for now only Image3 is always sent to the next page. <form method="get" action="order.php"> <div class="col-lg-8"> <div class="portfolio-details-slider swiper"> <div class="swiper-wrapper align-items-center"> <div class="swiper-slide"> <input type="submit" value='<?php $var = "Image1";?>' style="background-image: url('img/portfolio/img4.jpg');"> </div> <div class="swiper-slide"> <input type="submit" value='<?php $var = "Image2";?>' style="background-image: url('img/portfolio/img7.jpg');"> </div> <div class="swiper-slide"> <input type="submit" value='<?php $var = "Scooter3";?>' style="background-image: url('img/portfolio/img8.jpg');"> </div> <div class="swiper-pagination"></div> </div> </div> </div> <input type='hidden' name='var' value='<?php echo "$var";?>'/> <input type='hidden' name='fail' value='<?php echo "$fail";?>'/> </form> How can I get the correct image value to be sent to the next page? |
Display array elements in angular template Posted: 07 Dec 2021 11:31 AM PST I'm trying to display values of an array from a *ngFor const blockData = [ {text: sampleText1, array: [val1]}, {text: sampleText2, array: [val2, dat2]}, {text: sampleText3, array: [val3, dat3]} ] <div *ngFor="let data of blockData">{{data.text}} <span>{{data.array}}</span></div> How to display my both data.array values in my span |
Save workspace Gitpod Posted: 07 Dec 2021 11:31 AM PST I have been doing some exercises in python through Gitpod. I am a newbie in this platform. I tried to save a workspace that I have been working on but I failed to do it. Where it is what appears |
how to change the color of Alert box button? [duplicate] Posted: 07 Dec 2021 11:33 AM PST function notification() { let isConfirm = window.confirm("any"); if (isConfirm) { console.log("any"); } else { console.log("any"); } } notification(); |
How to get months out of alphabetical order using facet_grid in ggplot? [duplicate] Posted: 07 Dec 2021 11:32 AM PST I am using the facet_grid(~month) function in ggplot to separate time-step results of plant growth over 5 months. I have mostly gotten the stacked bar figure as I want it, except I want the months in chronological, rather than alphabetical order and the labels on the x-axis separated so they are readable. ggplot() + geom_bar(data=count, aes(y = count, x = treatment, fill = part), stat="summary", position='stack') + facet_grid( ~month) + labs(x='', y='Count', title='') + theme(plot.title = element_text(hjust=0.5, size=20, face='bold')) + scale_fill_manual('part', values=c('darkorchid4', 'chartreuse3','tan3')) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"))  I've searched SO and other resources trying to fix this, including using the "factor", "levels", and "mutate" commands with no success. |
How to make a new column with conditions on another column? Posted: 07 Dec 2021 11:31 AM PST I would like to create a 'cat_month' column in my 'expeditions' dataframe. This column would contain the mountain category (small, medium or large) and I would like to assign a category according to the height contained in the "height_metres" column (with quartiles: small = height lower than the first quartile) but I can't manage to do it, I'm writing down what I tried. Would you have an idea? Code : import pandas as pd expeditions = pd.read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-09-22/expeditions.csv") What I've tried : peaks[cat_monts] = for peak_id in expeditions : if "height_metres" < 6226.5 : #1er quartile return "petite montagne" elif 6226.5<"height_metres" <7031.25: return "moyenne montagne" else : return "grande montagne" |
How to sum values in a column based on values in a different column SQL Posted: 07 Dec 2021 11:31 AM PST For example, lets say I have id | values | 1 | 10 | 1 | 12 | 1 | 10 | 2 | 2 | 2 | 5 | 2 | 4 | then i would want sql to return |
Writing trigger in MySQL regarding two tables, with logic Posted: 07 Dec 2021 11:33 AM PST When I write trigger mentioned below I get error "INSERT not expected here" Tables movies, Lightning is many to many relation with associative table. My aim is to get Lumens_power in 'Lightning' table set as 5300 when Movies table 'genre' attribute is equal to 'action' . CREATE DEFINER = CURRENT_USER TRIGGER `Film_industry`.`Movies_AFTER_INSERT` AFTER INSERT ON `Movies` FOR EACH ROW BEGIN SELECT genre, CASE WHEN genre = 'action' THEN INSERT INTO Lightning(id, type, Lumens_power) values('NEW.Movies_id', 'directed', '5300'); END; FROM Movies; END; -- ----------------------------------------------------- -- Table `Film_industry`.`Movies` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `Film_industry`.`Movies` ( `id` INT NOT NULL AUTO_INCREMENT, `title` VARCHAR(100) NOT NULL, `released_on` DATE NOT NULL, `genre` VARCHAR(40) NOT NULL, `rating` DECIMAL(2,1) NOT NULL, `finansial_stake` DECIMAL(11,2) NOT NULL, `Supporting_object_id` INT NOT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE, UNIQUE INDEX `title_UNIQUE` (`title` ASC) VISIBLE, INDEX `fk_Movies_Supporting_object1_idx` (`Supporting_object_id` ASC) VISIBLE, CONSTRAINT `fk_Movies_Supporting_object1` FOREIGN KEY (`Supporting_object_id`) REFERENCES `Film_industry`.`Supporting_object` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `Film_industry`.`Lightning` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `Film_industry`.`Lightning` ( `id` INT NOT NULL AUTO_INCREMENT, `type` VARCHAR(45) NOT NULL, `Lumens_power` INT NOT NULL, `Scene_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_Lightning_Scene1_idx` (`Scene_id` ASC) VISIBLE, CONSTRAINT `fk_Lightning_Scene1` FOREIGN KEY (`Scene_id`) REFERENCES `Film_industry`.`Scene` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; |
Understanding meaning of syntax of git push Posted: 07 Dec 2021 11:31 AM PST Situation - I have 2 local branches A and B.
- I have 2 remote branches C and D.
- The name of my remote is origin.
- If I want to push changes from my branch B to remote branch D, what should be the git push syntax? I am confused among the following options
- git push origin B:D
- git push origin B/D
- git push origin B
- git push origin D
Please help me in understanding the correct git push syntax as well as its meaning |
Is there a way in which I can return multiple data from sql not individually Posted: 07 Dec 2021 11:31 AM PST I'm building a mock REST API in php which extracts papers from a database at the moment I'm currently extracting a list of papers which is fine. the problem arises when I try to extract the papers authors as there can be multiple, I want to show each paper individually and if there is more than one author show them also. at the moment its outputting like this duplicating the papers and showing with each author, I don't want that I want one paper to show and show ALL the authors associated with the paper is there a way around this?: See image find all function which returns all the papers and relevant metadata public function findAll() { $sql = "SELECT paper.paper_id, paper.title, paper.abstract, award_type.name AS award, author.author_id, author.first_name AS author_first_name, author.last_name AS author_last_name FROM paper LEFT JOIN award on (paper.paper_id = award.paper_id) LEFT JOIN award_type on (award.award_type_id = award_type.award_type_id) LEFT JOIN paper_author on (paper.paper_id = paper_author.paper_id) LEFT JOIN author on (paper_author.author_id = author.author_id)"; $result = $this->getDatabase()->executeSQL($sql); $this->setResult($result); } Current output: 0 paper_id "60071" title "Laina: Dynamic Data Phys…low Exercising Feedback" abstract "The increased popularity…sicalization artefact. " award null author_id "59687" author_first_name "Daphne" author_last_name "Menheere" 1 paper_id "60071" title "Laina: Dynamic Data Phys…low Exercising Feedback" abstract "The increased popularity…sicalization artefact. " award null author_id "59839" author_first_name "Steven" author_last_name "Vos" 2 paper_id "60071" title "Laina: Dynamic Data Phys…low Exercising Feedback" abstract "The increased popularity…sicalization artefact. " award null author_id "59868" author_first_name "Carine" author_last_name "Lallemand" the output I want: 0 paper_id "60071" title "Laina: Dynamic Data Phys…low Exercising Feedback" abstract "The increased popularity…sicalization artefact. " award null author_id "59687" author_first_name "Daphne" author_last_name "Menheere" author_id "59839" author_first_name "Steven" author_last_name "Vos" author_id "59868" author_first_name "Carine" author_last_name "Lallemand" |
Need to merge together certain values within extracted list into sublists Posted: 07 Dec 2021 11:34 AM PST I am extracting this block of text from a file to convert into a dictionary: ACC210: Luther, Martin Spurgeon, Charles CS121P: Bunyan, John Henry, Matthew Luther, Martin CS132S: Calvin, John Knox, John Owen, John and this is the code I used to open it and create two lists so I can use them to create the dictionary: with open("classes.txt") as file: data = [line.strip() for line in file] a = [] b = [] for x in data: if ':' in x: a.append(x) else: b.append(x) The lists come out as ['ACC210:', 'CS121P:', 'CS132S:'] ['Luther, Martin', 'Spurgeon, Charles', '', 'Bunyan, John', 'Henry, Matthew', 'Luther, Martin', '', 'Calvin, John', 'Knox, John', 'Owen, John', ''] However i need the second list to look like this: [['Luther, Martin', 'Spurgeon, Charles'],['Bunyan, John', 'Henry, Matthew','Luther, Martin'], ['Calvin, John', 'Knox, John', 'Owen, John']] How would I go about that? |
search value in multi array Posted: 07 Dec 2021 11:31 AM PST I have two arrays (array_1 and array_2). This is the structure: array_1 Array ( [0] => Array ( [email] => Array ( [0] => mail@domain.de ) [ID] => 489 ) ) array_2 Array ( [0] => Array ( [email] => Array ( [0] => test@domain.de ) [ID] => 13 ) [1] => Array ( [email] => Array ( [0] => mail@domain.de [1] => yourmail@domain.de ) [ID] => 48 ) ) Now I would like to check, if the mail address "mail@domain.de" (array_1[0]['email'][0] ) exist in array_2. And If yes: I need to know the key of array_2, where the mail address was found. I tried array_search() but this seems not work with multi arrays. Can you help me please? Thanks !! array_1 var_export() array ( 0 => array ( 'email' => array ( 0 => 'mail@domain.de', ), 'customerID' => '489', ), ) array_2 var_export() array ( 0 => array ( 'email' => array ( 0 => 'test@domain.de', ), 'customerID' => '13', ), 1 => array ( 'email' => array ( 0 => 'mail@domain.de', 1 => 'yourmail@domain.de', ), 'customerID' => '48', ), ) |
C ++ using multiple cores breakes output , code for a math problem Posted: 07 Dec 2021 11:33 AM PST So, for start im just starting to learn c++, and i had to resolve this problem: Find the numbers with the propriety : 5 * 5 = 25 , 25 * 25 =625(25squared), 6*6 =36(6squared) ( 25 is the ending of 625, 5 is the the ending of 25 ). So i've got my code to find all the numbers lower than 30k , but then i wanted to push it to it's limit ,so up to lluint_max, but it was really slow, i saw that my 12 core cpu is not utilised so i thought i'd add more cpu cores. I wanted to find the easiest fix and i found openmp, read a little and foun that if i add omp for it should divide the load to multiple cores, but the console doesn't display my numbers anymore.(PS i enabled omp in vs) Here's my code: #include <iostream> #include <cmath> #include <climits> #include <omp.h> using namespace std; int main() { long long int x, i, nc = 0, z = 1, p; #pragma omp for for (x = 1; x <= ULLONG_MAX; x++) { //numarul de cifre a lui x while (x / z != 0) { z = z * 10; nc = nc + 1; } //patratul p = x * x; i = pow(10, nc); if (p % i == x) cout << x << endl; } } And heres my output: C:\Users\Mihai Cazac\source\repos\ConsoleAPP2\Debug\ConsoleAPP2.exe (process 8736) exited with code 0. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . . Expected output: 1 5 6 25 76 376 625 9376 90625 109376 890625 2890625 7109376 12890625 //and so on Thanks in advance!! |
Can anyone tell me what I'm dong wrong here? [duplicate] Posted: 07 Dec 2021 11:33 AM PST I am newer to coding so please forgive me if there is a simple mistake that I missed but I'm trying to get just the dollar amount and then the exact change it would take for the value entered. Just not sure where my mistake is and what is needed to fix it. If anyone could help that would be greatly appreciated! fun main(args: Array<String>) { val change = 10.88 Dollar(change); Quarter(change); Dime(change); Nickel(change); Penny(change); } fun Dollar(myChange: Double): Double{ val dollar = myChange/(1.00).toFloat(); val change1 = myChange - (dollar * 1.00); print((dollar * 1)/1); if(dollar<2) println("_Dollar"); else if (dollar>=2) println("_Dollars"); return change1 } fun Quarter(myChange: Double): Double{ val quarter = myChange/(0.25).toFloat(); val change2 = myChange - (quarter * 0.25); println((quarter*4)/4); if(quarter<2) println("_Quarter"); else if (quarter>=2) println("_Quarters"); return change2 } fun Dime(myChange: Double): Double{ val dime = myChange/(0.10).toFloat(); val change3 = myChange - (dime * 0.10); println((dime * 10)/10); if(dime<2) println("_Dime"); else if(dime>=2) println("_Dimes"); return change3 } fun Nickel(myChange: Double): Double{ val nickel = myChange/(0.05).toFloat(); val change4 = myChange - (nickel * 0.05); println((nickel*20)/20); if(nickel<2) println("_Nickel"); else if (nickel>=2) println("_Nickels"); return change4 } fun Penny(myChange: Double){ val penny = myChange/100); print((penny * 100)/ 100); if(penny<2) println("_Penny"); else if (penny>=2) println("_Pennies"); return Unit } Output:10.88_Dollars 43.52 _Quarters 108.79999837875371 _Dimes 217.59999675750743 _Nickels 0.10880000000000001_Penny |
Create object from JSON string and access propertys [closed] Posted: 07 Dec 2021 11:32 AM PST I have this sting: var flightplan = {"Descr":"AceXML Document","FlightPlanFlightPlan":{"Title":"LSZH to LSZA","FPType":"VFR","RouteType":"Direct","CruisingAlt":8500,"DepartureID":"LSZH","DepartureLLA":"N47° 27' 52.05\",E8° 32' 57.78\",+001398.00","DestinationID":"LSZA","DestinationLLA":"N46° 0' 13.01\",E8° 54' 37.00\",+000907.00","Descr":"LSZH, LSZA","DeparturePosition":"GATE P 37","DepartureName":"Zürich","DestinationName":"Lugano","AppVersion":{"AppVersionMajor":11,"AppVersionBuild":282174},"ATCWaypoint":[{"ATCWaypointType":"Airport","WorldPosition":"N47° 27' 28.99\",E8° 32' 53.00\",+001398.00","ICAO":{"ICAORegion":null,"ICAOIdent":"LSZH","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N47° 21' 39.39\",E8° 36' 53.77\",+003821.33","ICAO":{"ICAORegion":"LS","ICAOIdent":"IZS06","ICAOAirport":"LSZH"},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N47° 3' 31.99\",E8° 24' 49.00\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"URIGI","ICAOAirport":null},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 58' 39.21\",E8° 20' 1.02\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 57' 45.24\",E8° 21' 29.39\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"Airport","WorldPosition":"N46° 58' 28.00\",E8° 23' 49.00\",+008500.00","ICAO":{"ICAORegion":null,"ICAOIdent":"LSZC","ICAOAirport":null},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 59' 22.21\",E8° 36' 1.32\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 56' 0.80\",E8° 36' 23.10\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS202","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 49' 40.60\",E8° 38' 37.50\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS204","ICAOAirport":null},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 46' 13.58\",E8° 40' 21.39\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 41' 51.50\",E8° 36' 5.30\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS206","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 38' 59.90\",E8° 35' 25.10\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS207","ICAOAirport":null},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 36' 41.32\",E8° 34' 3.81\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 33' 56.96\",E8° 33' 27.96\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 32' 52.60\",E8° 34' 3.60\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS209","ICAOAirport":null},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 31' 35.00\",E8° 35' 37.12\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 31' 37.90\",E8° 38' 10.80\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS210","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 28' 33.80\",E8° 48' 17.40\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS211","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 21' 39.20\",E8° 56' 39.30\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS212","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Airport","WorldPosition":"N46° 17' 39.22\",E8° 59' 34.29\",+008500.00","ICAO":{"ICAORegion":null,"ICAOIdent":"LSML","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 13' 22.80\",E9° 2' 21.20\",+008500.00","ICAO":{"ICAORegion":"LS","ICAOIdent":"LS213","ICAOAirport":null},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 10' 7.16\",E8° 58' 55.18\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 10' 0.00\",E8° 52' 52.00\",+008500.00","ICAO":{"ICAORegion":"LI","ICAOIdent":"CANNE","ICAOAirport":null},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N46° 7' 26.18\",E8° 43' 47.28\",+008500.00","ICAO":null,"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N46° 0' 36.82\",E8° 42' 11.93\",+008500.00","ICAO":{"ICAORegion":"LI","ICAOIdent":"MC418","ICAOAirport":"LIMC"},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N45° 55' 1.68\",E8° 33' 41.47\",+008500.00","ICAO":{"ICAORegion":"LI","ICAOIdent":"MC414","ICAOAirport":"LIMC"},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N45° 53' 51.00\",E8° 36' 35.00\",+008500.00","ICAO":{"ICAORegion":"LI","ICAOIdent":"RIXUV","ICAOAirport":null},"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N45° 47' 34.40\",E8° 44' 5.40\",+006086.66","ICAO":{"ICAORegion":"LI","ICAOIdent":"R359","ICAOAirport":"LIMC"},"Id":null},{"ATCWaypointType":"User","WorldPosition":"N45° 52' 51.77\",E8° 53' 19.57\",+003355.79","ICAO":null,"Id":null},{"ATCWaypointType":"Intersection","WorldPosition":"N45° 58' 19.16\",E8° 53' 40.37\",+001565.16","ICAO":{"ICAORegion":"LS","ICAOIdent":"25ILU","ICAOAirport":"LSZA"},"Id":null},{"ATCWaypointType":"Airport","WorldPosition":"N46° 0' 13.01\",E8° 54' 37.00\",+000907.00","ICAO":{"ICAORegion":null,"ICAOIdent":"LSZA","ICAOAirport":null},"Id":null}]},"Type":"AceXML","Version":null} I parse this string with var flightplanParsed = JSON.Parse(flightplan); Now i like to get an object with all WorldPositions and it's propertys. |
Azure Web App HTTP ERROR 414 - Url too long request Posted: 07 Dec 2021 11:32 AM PST Our Dot Net Core 5 is hosted on Linux Azure Web App, which contains angular 12 web apps. this.router.navigate([]).then((result) => { window.open('/flight/flight-book?flightdata=' + encodeURIComponent(this.encryptData(hiddenvalue)), '_blank'); }); Now the above code is running on the browser getting an error - HTTP ERROR 414 - URL Too Long but running in localhost it is working fine. We think that the azure web app is stopping this URL to render on the browser. Even on web.config we mention the below code but still not working. <system.webServer> <!-- Here you have other settings related to handlers.--> <security> <requestFiltering> <requestLimits maxAllowedContentLength="10485760" maxUrl="1000241" maxQueryString="3002768" /> </requestFiltering> </security> </system.webServer> |
ion-select selected value in loop Posted: 07 Dec 2021 11:31 AM PST So Im making an app with IONIC. Im using the tag ion-select & ion-select-option to make it possible to select one or multiple options and send these to typescript (works so far). Now I want that someone is able to edit their options. This means some of the ion-select-option should be [selected] (checked true). Does anyone know if that is possible? I am using 2 different arrays for this. user.companies (all the companies a user has added to the application) blocked.companies (all the blocked companies an used has added to their blocked contact) I am using user.companies to display all the ion-select-option choices (the companies to select) If the ion-select-option value exists in the blocked.companies array is should be selected This is my code. If more clarification is needed please tell me and I will provide it. Thanks HTML <ion-select multiple="true" [(ngModel)]="selectedCompanies" class="selectModal" placeholder="Add one or more companies" text="Hello" okText="Ok" cancelText="Dismiss"> <ion-select-option selected="{{isSelected}}" *ngFor="let company of user.company; let i=index" value="{{company.company_name}}">{{company.company_name}}</ion-select-option> </ion-select> Typescript import { Component, OnInit, Input } from '@angular/core'; import { ModalController} from '@ionic/angular'; import { LoginService } from 'src/app/login.service'; @Component({ selector: 'edit-blocked', templateUrl: './edit-blocked.page.html', styleUrls: ['./edit-blocked.page.scss'], }) export class EditBlockedPage implements OnInit { user = this.loginSrvc.user; blocked = this.loginSrvc.editNumber; blockedToggle: any; minDate = new Date().toISOString(); selectedCompanies = []; isSelected = false; constructor(private modalController: ModalController, private loginSrvc: LoginService) {} } } JSON "blocked": [ { "id":20, "name":"X X", "number":"06-12345678", "address":"Address", "alwaysBlocked":true, "companies": [ "Company1","Company2","Company3" ] } ] "user": [ { "id": 1, "gender": "0", "fullname": "X X", "number": "06-12345678", "mail": "user@company.com", "password": "admin1", "company": [ { "company_id": 1, "company_name": "Company1", }, { "company_id": 2, "company_name": "Company2", }, { "company_id": 3, "company_name": "Company3", }, { "company_id": 4, "company_name": "Company4", } |
how do resources talk to each other from different namespaces Posted: 07 Dec 2021 11:32 AM PST Conditions: I have a 3 tier application to deploy using Kubernetes. I have created two namespaces for backend and frontend respectively. Problem: I want to know how would my backend talk to the frontend or vice versa. In simple words, how do backend and frontend communicate if they are in different namespaces? Kindly help. |
Why is segmentation fault not recoverable? Posted: 07 Dec 2021 11:31 AM PST Following a previous question of mine, most comments say "just don't, you are in a limbo state, you have to kill everything and start over". There is also a "safeish" workaround. What I fail to understand is WHY is segmentation fault inherently non recoverable. The moment in which writing to protected memory is caught - otherwise, the SIGSEGV would not be sent. If the moment of writing to protected memory can be caught, I don't see why - in theory - it can't be reverted, at some low level, and have the SIGSEGV converted to a standard software exception. Please explain why after a segmentation fault the program is in an undetermined state, as very obviously, the fault is thrown BEFORE memory was actually changed (I am probably wrong and don't see why). Had it been thrown after, one could create a program that changes protected memory, one byte at a time, getting segmentation faults, and eventually re-programming the kernel - A security risk that is not present, as we can see the world still stands. - When exactly does segmentation fault happen (=when is
SIGSEGV sent)? - Why is the process in undefined behavior state after that point?
- Why is it not recoverable?
- Why does this solution avoid that unrecoverable state? Does it even?
|
Flask Modal Confirm Dialog Posted: 07 Dec 2021 11:33 AM PST I am trying to add a modal dialog to confirm the user's comment. After user finishes editing title and comment then clicks submit button, a modal dialog will pop up for user to confirm. How can I get the data from html after user clicks confirm button on modal? Thanks in advance form.py class PostForm(FlaskForm): title_field = StringField('Title') comment_field = TextAreaField('Comment') submit = SubmitField('Update') routes.py @posts.route('/update_post/<post_id>', methods=['GET', 'POST']) def post(post_id): form = PostForm() post= Post.query.get_or_404(post_id) if request.method == 'POST': print(form.title_field.data) print(form.comment_field.data) return redirect(url_for('posts.post')) return render_template('post.html', title='Post', form=form, post=post) post.html <!-- form--> <form action= "" method="POST", enctype="multipart/form-data"> {{ form.hidden_tag() }} <p></p> <h4>New Post</h4> <div class="form-group"> {{ form.title_field.label(class="form-control-label") }} {{ form.title_field(class="form-control form-control-lg") }} <!-- Pass this data> --> </div> <div class="form-group"> {{ form.comment_field.label(class="form-control-label") }} {{ form.comment_field(class="form-control form-control-lg") }} <!-- Pass this data> --> </div> {{ form.submit( class="btn btn-outline-info", data_toggle="modal", data_target="#updateModal") }} </form> <!-- Modal --> <div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="updateModalLabel">New Post?</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <form action="{{ url_for('post.post', post_id=post.id) }}" method="POST"> <input class="btn btn-success" type="submit" value="Confirm"> </form> </div> </div> </div> </div> |
Exporting Room database to another folder or directory inst working Posted: 07 Dec 2021 11:32 AM PST I'm trying to export Database file from root directory to download directory. The database is created using Room, everything is working perfectly, i can add data, delete and update data , but when i try to export database it gives exception java.io.FileNotFoundException: /storage/emulated/0/storage/emulated/0/Download: open failed: ENOENT (No such file or directory) Screen shot while debugging i am using following lines of code to export db. private void exportDB() { try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); boolean ans = sd.canWrite(); //if (ans) { String currentDBPath ="/data/" + getPackageName() + "/databases/" + SAMPLE_DB_NAME + ""; String backupDBPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/"; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB).getChannel(); FileChannel dst = new FileOutputStream(backupDB).getChannel(); dst.transferFrom(src, 1, src.size()); src.close(); dst.close(); } } catch (Exception e) { Log.e("MYAPP", "exception", e); Toast.makeText(MainActivity.this, "" + e, Toast.LENGTH_SHORT).show(); } Please have a look at this and guide me, Thank you in advance |
set type unordered - error in python - pandas Posted: 07 Dec 2021 11:32 AM PST I know I have to take this step, but I don't know how to do it: By using the NASA Space Science Data Coordinated Archive, we gathered information about each module used in each mission. As you did when you created the samples tables, create six new columns, three for the lunar modules and three for the command modules: - Module name
- Module mass
- Module mass diff
Fill in any NaN values with 0: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_8184/2992438938.py in <module> ----> 1 missions['Lunar module (LM)'] = {'Eagle (LM-5)', 'Intrepid (LM-6)', 'Antares (LM-8)', 'Falcon (LM-10)', 'Orion (LM-11)', 'Challenger (LM-12)'} 2 missions['LM mass (kg)'] = {15103, 15235, 15264, 16430, 16445, 16456} 3 missions['LM mass diff'] = missions['LM mass (kg)'].diff() 4 missions['LM mass diff'] = missions['LM mass diff'].fillna(value=0) 5 C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\frame.py in __setitem__(self, key, value) 3610 else: 3611 # set column -> 3612 self._set_item(key, value) 3613 3614 def _setitem_slice(self, key: slice, value): C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\frame.py in _set_item(self, key, value) 3782 ensure homogeneity. 3783 """ -> 3784 value = self._sanitize_column(value) 3785 3786 if ( C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\frame.py in _sanitize_column(self, value) 4508 if is_list_like(value): 4509 com.require_length_match(value, self.index) -> 4510 return sanitize_array(value, self.index, copy=True, allow_2d=True) 4511 4512 @property C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure, allow_2d) 557 if isinstance(data, (set, frozenset)): 558 # Raise only for unordered sets, e.g., not for dict_keys --> 559 raise TypeError(f"'{type(data).__name__}' type is unordered") 560 561 # materialize e.g. generators, convert e.g. tuples, abc.ValueView TypeError: 'set' type is unordered Code used: missions['Lunar module (LM)'] = ['Eagle (LM-5)', 'Intrepid (LM-6)', 'Antares (LM-8)', 'Falcon (LM-10)', 'Orion (LM-11)', 'Challenger (LM-12)'] missions['LM mass (kg)'] = {15103, 15235, 15264, 16430, 16445, 16456} missions['LM mass diff'] = missions['LM mass (kg)'].diff() missions['LM mass diff'] = missions['LM mass diff'].fillna(value=0) missions['Command module (CM)'] = ['Columbia (CSM-107)', 'Yankee Clipper (CM-108)', 'Kitty Hawk (CM-110)', 'Endeavor (CM-112)', 'Casper (CM-113)', 'America (CM-114)'] missions['CM mass (kg)'] = {5560, 5609, 5758, 5875, 5840, 5960} missions['CM mass diff'] = missions['CM mass (kg)'].diff() missions['CM mass diff'] = missions['CM mass diff'].fillna(value=0) missions Pedido do user: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_8184/3771249595.py in <module> 1 missions['Lunar module (LM)'] = ['Eagle (LM-5)', 'Intrepid (LM-6)', 'Antares (LM-8)', 'Falcon (LM-10)', 'Orion (LM-11)', 'Challenger (LM-12)'] ----> 2 missions['LM mass (kg)'] = {15103, 15235, 15264, 16430, 16445, 16456} 3 missions['LM mass diff'] = missions['LM mass (kg)'].diff() 4 missions['LM mass diff'] = missions['LM mass diff'].fillna(value=0) 5 C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\frame.py in __setitem__(self, key, value) 3610 else: 3611 # set column -> 3612 self._set_item(key, value) 3613 3614 def _setitem_slice(self, key: slice, value): C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\frame.py in _set_item(self, key, value) 3782 ensure homogeneity. 3783 """ -> 3784 value = self._sanitize_column(value) 3785 3786 if ( C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\frame.py in _sanitize_column(self, value) 4508 if is_list_like(value): 4509 com.require_length_match(value, self.index) -> 4510 return sanitize_array(value, self.index, copy=True, allow_2d=True) 4511 4512 @property C:\ProgramData\Miniconda3\lib\site-packages\pandas\core\construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure, allow_2d) 557 if isinstance(data, (set, frozenset)): 558 # Raise only for unordered sets, e.g., not for dict_keys --> 559 raise TypeError(f"'{type(data).__name__}' type is unordered") 560 561 # materialize e.g. generators, convert e.g. tuples, abc.ValueView TypeError: 'set' type is unordered |
How to use Ziggy with Vuex Posted: 07 Dec 2021 11:33 AM PST Is anyone using Ziggy with Vuex? I recently installed Ziggy (https://github.com/tighten/ziggy) so I can use Laravel's named routes in my Vue (2) files. It's working just fine my my Vue components, but it's a different story with Vuex files, where I have a number of axios calls in Vuex actions. The documentation says nothing about vuex modules, and all of my attempts to import the route method from the Ziggy vendor package result in either compilation errors or console errors on page load (e.g., route is not defined ). I've tried: import route from '../...relative-path-to.../vendor/tightenco/ziggy/dist/index.js'; import route, { ZiggyVue } from 'ziggy'; and methods suggested elsewhere (https://highlandsolutions.com/blog/how-i-like-to-simplify-ziggys-route-helper) |
R how to speed up pattern matching using vectors Posted: 07 Dec 2021 11:32 AM PST I have a column in one dataframe with city and state names in it: ac <- c("san francisco ca", "pittsburgh pa", "philadelphia pa", "washington dc", "new york ny", "aliquippa pa", "gainesville fl", "manhattan ks") ac <- as.data.frame(ac) I would like to search for the values in ac$ac in another data frame column, d$description and return the value of column id if there is a match. dput(df) structure(list(month = c(202110L, 201910L, 202005L, 201703L, 201208L, 201502L), id = c(100559687L, 100558763L, 100558934L, 100558946L, 100543422L, 100547618L), description = c("residential local telephone service local with more san francisco ca flat rate with eas package plan includes voicemail call forwarding call waiting caller id call restriction three way calling id block speed dialing call return call screening modem rental voip transmission telephone access line 34 95 modem rental 7 00 total 41 95", "digital video programming service multilatino ultra bensalem pa service includes digital economy multilatino digital preferred tier and certain additonal digital channels coaxial cable transmission", "residential all distance telephone service unlimited voice only harrisburg pa flat rate with eas only features call waiting caller id caller id with call waiting call screening call forwarding call forwarding selective call return 69 3 way calling anonymous call rejection repeat dialing speed dial caller id blocking coaxial cable transmission", "residential all distance telephone service unlimited voice only pittsburgh pa flat rate with eas only features call waiting caller id caller id with call waiting call screening call forwarding call forwarding selective call return 69 3 way calling anonymous call rejection repeat dialing speed dial caller id blocking", "local spot advertising 30 second advertisement austin tx weekday 6 am 6 pm other audience demographic w18 49 number of rating points for daypart 0 29 average cpp 125", "residential public switched toll interstate manhattan ks ks plan area residence switched toll base period average revenue per minute 0 18 minute online" )), row.names = c(1L, 1245L, 3800L, 10538L, 20362L, 50000L), class = "data.frame") I have tried to do this via accessing the row indexes of the matches via the following methods: which(ac$ac %in% df$description) --this returns integer(0) . grep(ac$ac, df$description, value = FALSE) --this returns the first index, 1. But this isn't vectorized. str_detect(string = ac$ac, pattern = df$description) -- but this returns all FALSE which is incorrect. My question: how do I search for ac$ac in df$description and return the corresponding value of df$id in the event of a match? Note that the vectors are not of the same length. I am looking for ALL matches, not just the first. I would prefer something simple and fast, because the actual datasets that I will be using have over 100k rows each but any suggestions or ideas are welcome. Thanks. Edit. Due to Andre's initial answer below, the name of the question was changed to account for the change in the scope of the question. Edit (12/7): bounty added to generate additional interest and a fast, efficient scalable solution. |
Incorrect casting between tf and keras when trying to view layer activity? Posted: 07 Dec 2021 11:33 AM PST I am trying to run the routine to see activations in various layers. However for some reason it doesnt seem to work for a model instantiated this way, and I cannot figure out how to do it. The error I get is: ValueError: Input tensors to a Functional must come from tf.keras.Input . Received: 0 (missing previous layer metadata). The code: import tensorflow as tf IMG_SHAPE = (160, 160) + (3,) base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE, include_top=False, weights='imagenet') K=tf.keras.backend func = K.function([base_model.input, K.learning_phase()],[layer.output for layer in base_model.layers if layer.output is not base_model.input]) #[layer.output for layer in base_model.layers]) Thank you for suggestions! |
Hide console variables in Pycharm debugger variables panel Posted: 07 Dec 2021 11:34 AM PST |
No comments:
Post a Comment