surface 3D plotting using matplotlib Posted: 19 Apr 2021 08:00 AM PDT I want to plot a 3D surface plot. Luckily a lot of help is available. but I need to import my file for plotting. I have a file with 3 columns as x, y, and z with a long list of values and I want to import those values for as x y and z values. I have the following code. from mpl_toolkits import mplot3d %matplotlib inline import numPy as np import matplotlib.pyplot as plt import csv fig = plt.figure() ax = plt.axes(projection='3d') x = import first column y = import second column z = import third column surf = ax.plot_surface(x, y, z, rstride = 8, cstride = 8, alpha = 0.8, ) fig.colorbar(surf, ax = ax, shrink = 0.5, aspect = 5) ax.set_xlabel('X-axis') ax.set_xlim(-5, 5) ax.set_ylabel('Y-axis') ax.set_ylim(-5, 5) ax.set_zlabel('Z-axis') ax.set_zlim(np.min(z), np.max(z)) ax.set_title('3D Energy plot') ax.plot_surface(x, y, z) # for surface plotting plt.show() Kindly give me suggestions. |
javascript: Get JSON to classify the website Posted: 19 Apr 2021 08:00 AM PDT I've got a set of URL data (their order is disordered). I want to sort them, create corresponding node classification, and let the commonly used URLs be classified as the front. The expected generated node should be the following HTML structure a { text-decoration: none; } .item-wrap+.item-wrap { border-top: 2px solid #6d28d9; margin-top: 30px; } <div class="container"> <div class="item-wrap"> <h3>commonly-used</h3> <div class="items"> <a href="">stackoverflow</a> </div> <div class="items"> <a href="">github</a> </div> </div> <div class="item-wrap"> <h3>search-type</h3> <div class="items"> <a href="">google</a> </div> <div class="items"> <a href="">wikipedia</a> </div> </div> <div class="item-wrap"> <h3>study-type</h3> <div class="items"> <a href="">w3c</a> </div> <div class="items"> <a href="">vue</a> </div> <div class="items"> <a href="">react</a> </div> </div> <div class="item-wrap"> <h3>tool-type</h3> <div class="items"> <a href="">remove bg</a> </div> </div> <div class="item-wrap"> <h3>movie-type</h3> <div class="items"> <a href="">movie site</a> </div> <div class="items"> <a href="">movie site2</a> </div> </div> </div> JSON structure What are the ways to classify type into items ? let ary = [{ "type": "search-type", "content": { "title": "google", "link": "https://", } }, { "type": "study-type", "content": { "title": "w3c", "link": "https://", } }, { "type": "movie-type", "content": { "title": "movie site", "link": "https://", } }, { "type": "commonly-used", "content": { "title": "stackoverflow", "link": "https://", } }, { "type": "tool-type", "content": { "title": "remove bg", "link": "https://www//", } }, { "type": "movie-type", "content": { "title": "movie site2", "link": "https://", } }, { "type": "commonly-used", "content": { "title": "github", "link": "https://", } }, { "type": "search-type", "content": { "title": "wikipedia", "link": "https://", } }, { "type": "study-type", "content": { "title": "vue", "link": "https://", } }, { "type": "study-type", "content": { "title": "react", "link": "https://", } }]; |
Verification with IvalidatableObject Posted: 19 Apr 2021 08:00 AM PDT I applied the IvalidatableObject Interface to the student class coming from the database. However, I do not know how to do this verification on the Form1 side. How can I verify the student class in Form1 and show the error messages to the user? Thanks. public partial class students:IValidatableObject { public int StudentId { get; set; } public short StudentMemberNum { get; set; } public string StudentName { get; set; } public string StudentSurname { get; set; } public System.DateTime StudentBirthDate { get; set; } public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { if (string.IsNullOrEmpty(StudentName)) { yield return new ValidationResult("The student's name is required.", new string[] { "StudentName" }); } } } |
R caption contains "&" Misplaced Alignment tabs Posted: 19 Apr 2021 08:00 AM PDT I have a kable table that works normally, but as the amount of tables I need per 'user' is more than a page, I need to add a caption in order for the tables to be comprehensible. I have the following code. name <- "This & That" kable(head(mtcars), format = "latex", row.names = FALSE, caption = paste(as.character(sub("&", "\\&",name)), "Car Score Input")) %>% kable_styling(full_width = FALSE, font_size = 10,latex_options = "HOLD_position", position = "left") %>% row_spec(row = 0, bold = TRUE, underline = F, background = "orange", color = "white", italic = FALSE, monospace = FALSE, strikeout = FALSE) %>% print(floating = FALSE, row.names = FALSE) as an example. the name variable is sometimes something like "This & That" originally, i just had 'name ' in the paste function but I get the following error: ! Misplaced alignment tab character &. <argument> ...ab:unnamed-chunk-6} This & That Car Score Input} name changes and goes through a bunch of other names, some with ampersand and some without As you can see, I've found some forums that advise for adding \\ to the front of the character to avoid it thinking it is an escape code, but it seems no matter what I try I cannot get it to be thought of as a character. the as.character(sub("&", "\\&", name)) has been nested, I tried sub alone, before pairing it with as.character I'm just running out of ideas. the kable eventually loops through a variety of names, I even tried assigning the sub function output to name prior to adding it to the caption, it does appear as This \\& That however, I get the same error in the captio. |
Spring rspec not speeding up tests Posted: 19 Apr 2021 08:00 AM PDT Running a single test in our test suite takes anywhere from 20 - 30 seconds. Prior to adding spring and spring-commands-rspec , the output from running a test would look like this. Finished in 21.99 seconds (files took 21.64 seconds to load) 1 example, 0 failures Randomized with seed 52406 The 22 second file load time suggested that adding the aforementioned gems would help, but after doing so the test is still just as slow. The new output (see below) suggests the file time has in fact been drastically improved (down from 21.64 seconds to 1.25 seconds), but the overall speed of the test is basically the same. This seems very odd and unexpected based on what I have read about the expected effects of adding these gems. Finished in 21.86 seconds (files took 1.25 seconds to load) 1 example, 0 failures Randomized with seed 7594 Any thoughts on why the test is still just as slow, and does anyone have tips on how to fix this/speed up the test? Thanks. |
Does DO-178C requires qualified complier? Posted: 19 Apr 2021 08:00 AM PDT In the DO 178C text, the "development tools" and "verification tools" are required to be qualified. A complier is certainly a development tool. But when searching "DO 178C qualified C compilers" I did not really find a compiler for C language. Instead, some articles said "DO 178C does not require to qualify compliers". Could someone help to explain why? |
Keep alive component data ? Angular and dynamic component? Posted: 19 Apr 2021 08:00 AM PDT All code is here: https://stackblitz.com/edit/angular-keep-alive-component?file=src/app/app.component.ts is it possible to keep the state entered and when the component changes? I am using dynamic component - component factory resolver for rendering component but i want to keep entered values and when change component..... ? In Vue.js for that exist keep-alive directive but is it possible and using Angular 9 ? Example what I need: Rendering first component -> type in input whatever example TEST DATA -> Change component second -> Return on first component and see previous entered 'TEST DATA' public createComponent(component: number): void { const currentComponent = this.components[component]; let componentFactory = this.componentFactoryResolver.resolveComponentFactory( currentComponent as any ); let viewContainerRef = this.adHost.viewContainerRef; viewContainerRef.clear(); let componentRef: any = viewContainerRef.createComponent(componentFactory); componentRef.instance.outputEventData.subscribe((val: Object | any) => { if (val) { this.sendFilter.emit(val); } }); setTimeout(() => { componentRef.instance.destroyComponent.subscribe((val: any) => { if (val) { viewContainerRef.clear(); } }); }, 0); } } |
Insert or Update Documents in MongoDB from a CSV using Python Posted: 19 Apr 2021 08:00 AM PDT I'm trying to insert/update documents in MongoDB based on information that I have in a CSV. Where if the first header of the CSV customer_id doesn't exist then it should create a new document but, if it does exist then it should just update all the values in the document. I have the script built that will look for the customer_id and if it doesn't exist then it will create the new document but, having trouble getting the update part working. Do you have to specify each header that needs to be updated or is there a more efficient way of updating by utilizing the headers from the CSV in the event new headers are added later on so that the script wouldn't have to be updated to specify the new headers: import csv from pymongo import MongoClient conn = MongoClient('localhost', 27017) db = conn.shipping collection = db.sales file = csv.reader(open("shipping_list.csv"), delimiter=',') header = ["customer_id", "customer_name", "sales_rep", "purchase_date", "region", "purchase_price", "shipping_status", "products_purchased"] for each in file: if collection.count_documents({ 'customer_id': each[0] }) == 0: row={} for n in range(0,len(header)): row[header[n]] = each[n] collection.insert_one(row) else: row={} for n in range(0,len(header)): row[header[n]] = each[n] collection.update({'customer_id': each[0]}, row) |
mysql container won't start - Failed to initialize DD Storage Engine Posted: 19 Apr 2021 08:00 AM PDT My container suddenly crashed and now it won't start: This is the log of the start and error/shutdown: Starting dev-laradock_mysql_1 ... done Attaching to dev-laradock_mysql_1 mysql_1 | 2021-04-19T14:40:37.622458Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. mysql_1 | 2021-04-19T14:40:37.622522Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.16) starting as process 1 mysql_1 | 2021-04-19T14:40:37.624025Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. mysql_1 | 2021-04-19T14:40:41.405115Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 12 for {space: 14398, page_no:37} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405123Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 13 for {space: 14398, page_no:1} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405129Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 21 for {space: 14398, page_no:31} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405139Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 23 for {space: 14398, page_no:36} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405144Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 53 for {space: 14398, page_no:26} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405151Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 54 for {space: 14398, page_no:25} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405157Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 55 for {space: 14398, page_no:23} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405168Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 57 for {space: 14398, page_no:1} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405173Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 58 for {space: 14398, page_no:4} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405179Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 59 for {space: 14398, page_no:27} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405185Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 60 for {space: 14398, page_no:0} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405195Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 61 for {space: 14398, page_no:2} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405201Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 62 for {space: 14398, page_no:24} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405206Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 63 for {space: 14398, page_no:5} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405212Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 64 for {space: 14398, page_no:28} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405232Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 65 for {space: 14398, page_no:22} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405237Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 66 for {space: 14398, page_no:29} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405242Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 67 for {space: 14398, page_no:30} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405248Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 68 for {space: 14398, page_no:6} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405260Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 69 for {space: 14398, page_no:21} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405265Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 70 for {space: 14398, page_no:31} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405271Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 71 for {space: 14398, page_no:17} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405277Z 1 [Warning] [MY-013088] [InnoDB] Doublewrite page 72 for {space: 14398, page_no:32} could not be restored. File name unknown for tablespace ID 14398 mysql_1 | 2021-04-19T14:40:41.405291Z 1 [ERROR] [MY-012179] [InnoDB] Could not find any file associated with the tablespace ID: 14398 mysql_1 | 2021-04-19T14:40:41.405301Z 1 [ERROR] [MY-012964] [InnoDB] Use --innodb-directories to find the tablespace files. If that fails then use --innodb-force-recovery=1 to ignore this and to permanently lose all changes to the missing tablespace(s) mysql_1 | 2021-04-19T14:40:41.505537Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error. mysql_1 | 2021-04-19T14:40:42.006337Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine mysql_1 | 2021-04-19T14:40:42.006486Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. mysql_1 | 2021-04-19T14:40:42.006905Z 0 [ERROR] [MY-010119] [Server] Aborting mysql_1 | 2021-04-19T14:40:42.009937Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.16) MySQL Community Server - GPL. The only thing I did recently was create a new docker container / project which had mysql involved, but I don't know how that would corrupt this one. Initially when I started up, everything worked fine. I was in my app which interacts with the database, but then it crashed |
Flex does not wrap two divs in same line Posted: 19 Apr 2021 08:00 AM PDT I am trying to make a form where the first name and last name are on the same line/column. I've tried putting the main group into flex and then putting the group I want with flex-wrap but it doesn't seem to move. Am I missing something? I've tried a couple things that didn't work (like setting the wrapped children to flex 1 1. Didn't work. Anyways here's the HTML <form> <div class="sd-form-group"></div> <div className="sd-form-wrap"> <div class="form-name form-first-name"> <label>First Name</label> <br> <input type="text"> </div> <div class="form-name form-last-name"> <label>Last Name</label> <br> <input type="text"> </div> </div> <div class="form-email"> <label>Email</label> <br> <input type="text"> </div> <div class="form-message"> <label>Message</label> <br> <textarea placeholder="Enter your comments, questions and feedback here." rows="4"></textarea> </div> <div class="form-checkbox"> <input type="checkbox"> <label> Communications box. </label> </div> <input type="submit" value="Submit"> </div> </form> CSS: .sd-form-group{ display: flex; flex-flow: column nowrap; justify-content: center; align-items: flex-start; } .sd-form-wrap { flex-wrap: wrap; } |
Determine if open and close time has passed using timezone in android java Posted: 19 Apr 2021 08:00 AM PDT I have a javascript code that check if store has closed open using timezone , opening time and closing time . I will like to write the same function in android java , I have no idea how I can archive that. I have included my javascript example. /* @param {string} location: IANA representative location ** @param {Date} date: date instance to get time from, default is now ** @returns {string} time in location in h:mm ap format */ global.getTime = function(location, date ) { date = (typeof date == "undefined" ? new Date() : date); return date.toLocaleString('en', { timeZone: location, hour : 'numeric', minute: '2-digit', dayPeriod: 'short' }); }; /* @param {string} time: h:mm A ** @returns {number} time converted to minutes */ global.timeToMin = function(time) { var [hour, minute] = time.match(/\d\d?/g); hour = hour%12; if (/pm$/i.test(time)){ hour +=12; } return hour * 60 + parseInt(minute); }; /* @param {string} openTime: opening time in h:mm ap format ** @param {string} closeTime: closing time in h:mm ap format ** @param {string} timeZone: IANA/Timezone representative location ** @return {string} open if current time is within openTime and closeTime in location, ** closed otherwise */ global.isOpen = function(openTime, closeTime, timeZone) { var self = global; if (openTime == '24HR'){ return 'open'; } timeZone = self.getTime(timeZone); var nowMin = self.timeToMin(timeZone); var openMin = self.timeToMin(openTime); var closeMin = self.timeToMin(closeTime) || 1440; if (openMin < closeMin) { return nowMin < openMin || nowMin >= closeMin ? 'closed' : 'open'; } else { return nowMin >= openMin && nowMin < closeMin ? 'open' : 'closed'; } }; Usage const status = global.isOpen("12:00PM", "12:00AM", "Asia/Kuala_Lumpur"); const status = global.isOpen("10:00AM", "11:00PM", "Asia/Kuala_Lumpur"); |
Traefik with nip.io Posted: 19 Apr 2021 07:59 AM PDT I'm trying to expose some applications using traefik and nip.io My docker-compose file looks as the following version: '3.3' services: traefik: image: traefik:1.7-alpine command: --web --docker --docker.domain=app.test --logLevel=DEBUG ports: - 80:80 - 8080:8080 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro whoami: image: tons/whoami-go labels: - "traefik.port=8080" - "traefik.frontend.rule=Host:whoami.127.0.0.1.nip.io" But I can't reach my service $ curl -vvv whoami.127.0.0.1.nip.io The above returns 404 and the complete verbose output is $ curl -vvv whoami.127.0.0.1.nip.io * Trying 127.0.0.1:80... * Connected to whoami.127.0.0.1.nip.io (127.0.0.1) port 80 (#0) > GET / HTTP/1.1 > Host: whoami.127.0.0.1.nip.io > User-Agent: curl/7.71.1 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 404 Not Found < Content-Type: text/plain; charset=utf-8 < Vary: Accept-Encoding < X-Content-Type-Options: nosniff < Date: Mon, 19 Apr 2021 12:07:29 GMT < Content-Length: 19 < 404 page not found * Connection #0 to host whoami.127.0.0.1.nip.io left intact It works just fine when I do $ curl -vvv -H "Host: whoami.127.0.0.1.nip.io" localhost And the complete output is very similar $ curl -vvv -H "Host: whoami.127.0.0.1.nip.io" localhost * Trying ::1:80... * Connected to localhost (::1) port 80 (#0) > GET / HTTP/1.1 > Host: whoami.127.0.0.1.nip.io > User-Agent: curl/7.71.1 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Content-Length: 12 < Content-Type: text/plain; charset=utf-8 < Date: Mon, 19 Apr 2021 12:12:13 GMT < * Connection #0 to host localhost left intact 49d197f2d4ae⏎ Notably the host header is sent correctly with both requests. I have the same issue using jwilder/nginx-proxy but I have no problem when I'm using nip.io with Kubernetes ingress regardless of using Traefik or Nginx. Anyone got a clue about what's wrong? |
How to organize parsed data into tables using command prompt? Posted: 19 Apr 2021 07:59 AM PDT I am attempting to create a table in excel that reads folder directories as field headers and lists contents as row data. I am trying to parse through existing work section folders that contain training certificates of staff and compile a list of them into a table. REM cd /This is my workspace directory to organize into a table dir /s *cert1 /b /o:gn >query.csv & dir /s *cert2 /b /o:gn >>query.csv This creates an output, but its still messy and hard to sort. I would like to delineate the tables by folder but I cant find a simple way of doing it in command prompt. |
Flexbox is not wrapping contents Posted: 19 Apr 2021 07:59 AM PDT I'm using ordered lists (ol) as the basis for this flexbox layout. But the wrapping is not cooperating all of a sudden. Maybe squarespace has messed with the default properties for ordered lists. Either way, the text refuses to wrap within the ol li ol li element and it looks like this: This is the CSS I'm using: `.ProductItem-details-excerpt ol {list-style:none; padding-left:0vw; padding-right:0vw; padding-bottom:0vw !important; background-color:white; text-align-last:center; margin-left:1.85vw !important; margin-right:1.85vw !important; display: flex; flex-wrap: wrap; justify-content: space-between; border-radius:15px;} .ProductItem-details-excerpt ol li { flex-grow: 1; white-space: nowrap; font-size:.8em; display:inline-block; position:relative !important; margin:1px; border:0px solid #dedede; padding:.3vw; padding-right:.6vw; padding-left:.6vw; text-align:center; background-color:#f0f0f0;} .ProductItem-details-excerpt ol li ol{ margin-top:.2vw !important; margin-right:-.6vw !important; margin-left:-.6vw !important; margin-bottom:-.3vw !important; border-radius:0px !important; display: flex; flex-wrap: wrap !important; } .ProductItem-details-excerpt ol li ol li{font-size:.9em !important; max-width:100%;}` How can I get the text and the flexbox children to wrap properly? |
How select images from downloads in an emulator? Posted: 19 Apr 2021 07:59 AM PDT So I've been trying test my app with appium, using Genymotion and python . Tried pushing images through driver.push_file("/sdcard/Download/image.jpeg","/home/image.jpeg") But I don't know how can I select them when I open this environment: I can't use TouchAction(driver).tap(x=999, y=777).perform() because none of the elements of iamages are clickable!!!! Any advice? Is it possible any other ways? Thanks in advance. |
Exclude weekdays from passed DateTime Posted: 19 Apr 2021 08:00 AM PDT Currently, i have 2 options: @from = DateTime.now.tomorrow.beginning_of_day @to = (@from + 3.days).end_of_day The question is how to exclude weekdays? So literally if @to value falls into weekday, then it should be moved to Monday. |
How to call a function in a structure like that : Posted: 19 Apr 2021 07:59 AM PDT this is a simpliest version of what I want to accomplish(to make it more understandable) function x() { function x2() { /*in this function I will call y2()*/ } } function y() { function y2() { /*called function */ } } How to call y2() from x2() ? Thanks |
ClassCastException with IWorkbenchPage.hideActionSet("org.eclipse.ui.WorkingSetActionSet") Posted: 19 Apr 2021 08:00 AM PDT The eclipse bundled with RCP thick client has recently upgraded from Eclise 4.2.2 to Eclipse Neon 4.6.3 . With this upgrade, switching perspective gives ClassCastException with below code at line page.hideActionSet("org.eclipse.ui.WorkingSetActionSet") : private IPerspectiveListener perspectiveListener = new IPerspectiveListener() { public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { // do not show the WorkingSetsactionSet toolbar buttons page.hideActionSet("org.eclipse.ui.WorkingSetActionSet"); } }; The exception I get is: !ENTRY org.eclipse.ui.workbench 4 2 2021-04-19 17:54:30.409 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench". !STACK 0 java.lang.ClassCastException: org.eclipse.e4.ui.model.application.ui.menu.impl.DirectToolItemImpl incompatible with org.eclipse.e4.ui.model.application.ui.menu.MToolBar at org.eclipse.ui.internal.CoolBarToTrimManager.add(CoolBarToTrimManager.java:147) at org.eclipse.ui.internal.CoolBarToTrimManager.insertAfter(CoolBarToTrimManager.java:418) at org.eclipse.ui.internal.ActionSetActionBars.getToolBarManager(ActionSetActionBars.java:259) at org.eclipse.ui.internal.PluginActionSetBuilder$ActionSetContribution.contributeAdjunctCoolbarAction(PluginActionSetBuilder.java:402) at org.eclipse.ui.internal.PluginActionSetBuilder.processAdjunctContributions(PluginActionSetBuilder.java:243) at org.eclipse.ui.internal.PluginActionSetBuilder.processActionSets(PluginActionSetBuilder.java:227) at org.eclipse.ui.internal.ActionPresentation.setActionSets(ActionPresentation.java:184) at org.eclipse.ui.internal.WorkbenchWindow.updateActionSets(WorkbenchWindow.java:2409) at org.eclipse.ui.internal.WorkbenchPage.hideActionSet(WorkbenchPage.java:2603) at org.eclipse.epf.rcp.ui.MainWorkbenchWindowAdvisor$1.perspectiveActivated(MainWorkbenchWindowAdvisor.java:75) at org.eclipse.ui.internal.PerspectiveListenerList$1.run(PerspectiveListenerList.java:75) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.PerspectiveListenerList.fireEvent(PerspectiveListenerList.java:58) at org.eclipse.ui.internal.PerspectiveListenerList.firePerspectiveActivated(PerspectiveListenerList.java:72) at org.eclipse.ui.internal.WorkbenchWindow.firePerspectiveActivated(WorkbenchWindow.java:1717) at org.eclipse.ui.internal.WorkbenchPage$4.handleEvent(WorkbenchPage.java:3009) at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40) at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233) at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:145) at org.eclipse.swt.widgets.Display.syncExec(Display.java:4821) From the above stack trace it looks like there is problem with code from plug-in: "org.eclipse.ui.workbench" which looks like out of control. Is there any way to address this issue? |
Is it safe to use function references to register and unregister a listener? Posted: 19 Apr 2021 08:00 AM PDT I recently found myself writing the following code: fun listener() { // Do some stuff adapter.removeLoadStateListener(::listener) } adapter.addLoadStateListener(::listener) A colleague remarked on the fact that val x1 = ::listener val x2 = ::listener x1 == x2 //true x1 === x2 //false However, var mySet = mutableSetOf<() -> Unit>() fun a() { } fun b() { } mySet.add(::a) mySet.add(::b) mySet.remove(::a) mySet.contains(::a) // false mySet.contains(::b) // true Based on this I get the impression I do not understand ::myFun properly and I start to question if my original code is safe to use. TL;DR - Is it safe to use
::listener to reference a method to be used as a listener and that will need to be referenced multiple times (e.g. add + remove)? - What is actually going on behind the scenes regarding anonymous classes etc.?
|
Stripe - when I cancel subscription, no money refunded? Posted: 19 Apr 2021 08:00 AM PDT I am using Stripe Checkout to process the checkout form. I've made an "Cancel Subscription" Button on front (using React.js) and I'm sending api call to cancel the subscription by id. Subscription is being canceled successfully, but money are not refunded to the customer? For example: I have subscribed today (per month), and I want to cancel my subscription tomorrow? The money for 29 days or 30 should refunded to me, right? Node JS code: const deleted = await stripe.subscriptions.del(id, { prorate: true, invoice_now: true }); I'm seeing on Stripe dashboard when I delete the subscription, the money value are not changing. Thanks. |
Issue combining inner and outer joins in Oracle Posted: 19 Apr 2021 07:59 AM PDT I'm trying to simplify a query against an Oracle database that uses multiple inner joins against the same table. I know the multiple joins against the same table can be cleaned up with outer joins, but I'm failing to elicit the same results. Below are the tables listing only the columns needed for the query. The "link" column in table X maps to the ID, ID2, and ID3 columns in tables A, B, and C respectively. **Table A** id **Table B** id id2 nm **Table C** id3 nm **Table X** cfgnum link Existing (working query): SELECT COUNT(*) FROM A, X, X X1, X X2, B, C WHERE X.cfgnum = 9999 AND A.id = X.link AND X.cfgnum = X1.cfgnum AND X.cfgnum = X2.cfgnum AND B.id2 = X1.link AND B.id = A.id AND C.id3 = X2.link AND C.nm = B.nm; The below was my attempt to rewrite, but it returns substantially different results. With the comments in place it does return the right number of rows against the linking X table. SELECT COUNT(*) FROM X LEFT JOIN A ON X.link = A.id LEFT JOIN B on X.link = B.id2 --AND A.id = B.id LEFT JOIN C on X.link = C.id3 --AND B.nm = C.nm WHERE cfgnum = 9999 AND COALESCE (A.id, B.id2, C.id3) IS NOT NULL; Any help is appreciated! |
WooCommerce Select2 Dropdown default sorting filter colors CSS Posted: 19 Apr 2021 08:00 AM PDT I have been trying to change the colours for the hovered default sorting filter on the woocommerce shop page but I cannot seem to find the selector in Google Chrome developer tools, I can't seem to find the CSS that is controlling the colour of this hover element. The solution below works for the country selector dropdown only it seems, but it does not change the default sorting hover colour. Does anyone know the correct selector for the default sorting filter selector, please? .select2-container--default .select2-results__option[aria-selected=true]{ background-color: #FF0000;} .select2-container--default .select2-results__option[data-selected=true]{ background-color: #0000FF;} Thanks |
Import-Export Call Order in NodeJS Posted: 19 Apr 2021 08:00 AM PDT This is a "code theory" question. So imagine this scenario, I am using the global namespace in a package. I have a main entrypoint file, some class files that I export, and some utility files the classes use. Here's a theoretical file structure: /index.js (main entrypoint) /src |_/source.js (exporting function for src folder) |_/utils |_/headers.js |_/constants.js |_/classes |_/class1.js |_/class2.js In constants.js I define some global variables and then export an object that uses some global variables. /src/utils/constants.js const foobar = 'foo'; global.foobar = foobar; export default { foo: global.foobar, } In some class file I import constants.js. /src/classes/class1.js import constants from '../utils/constants.js' export default class Xyzzy { function baz() { return constants.foo + 'baz' } } And finally in the entrypoint file I import source.js which imports /src/classes/class1 and /src/classes/class2 and exports both of them, then define some global variables. /index.js import source from '/src/source.js' export default function index() { global.foobar = 'bar' return { class1: source.class1, class2: source.class2, } } What would be the assignment order of global.foobar, what is the final result, and most importantly why does this happen? Thanks! |
How would I be able to detect when a collision shape polygon has made a circle with collision Posted: 19 Apr 2021 08:00 AM PDT This is a hard idea to put into a question, I have made a system where the player draws circles on screen, I want the player has either touched another line of its self start a new circle from that position, the issue I am having is having no clue on how would I make it collide, I have an idea but not sure if it will work, my idea is too simply use a different collision shape that creates its self on points that connect each other and when the mouse collides with that specific collision shape start again, is this the best option I have or is there another way of detecting when a circle is made. heres a video of what I want: https://youtu.be/wSolVcaIszE?t=998 and heres my video of what I have: https://www.youtube.com/watch?v=BDnd-n3PEdQ code: extends Node2D var points_array = PoolVector2Array() var index : int = 0 onready var collision = $Area2D/CollisionPolygon2D func _physics_process(delta): collision.polygon = points_array if Input.is_action_just_pressed("Left_click"): #This sets a position so that the next line can work together points_array.append(get_global_mouse_position()) # This makes a empty vector and the mouse cords is assigned too it points_array.append(Vector2()) if Input.is_action_pressed("Left_click"): #This checks the distance between last vector and the mouse vector points_array[-1] = get_global_mouse_position() # Gets the last position of the array and sets the mouse cords if points_array[index].distance_to(get_global_mouse_position()) > 20: points_array.append(get_global_mouse_position()) index += 1 if points_array.size() > 25: # This adds a length to the circle/line so it wont pass 18 mini lines index -= 1 points_array.remove(0) #Removes the first array to make it look like it has a length if Input.is_action_just_released("Left_click"): # This just clears the screen when the player releases the button points_array = PoolVector2Array() index = 0 |
How to add data to a json file while making use of multiproccesing? Posted: 19 Apr 2021 08:00 AM PDT I'm using a user-friendly json based document oriented database named TinyDB. But I'm unable to add multiple pieces of data to my database because I'm making use of multiproccesing. After a while I get the error that id x already exists in the database (this because 2 or more processes are trying to add data at the same time). Is there any way to solve this? Every run I insert new unique params. Example params: params = {'id' = 1, 'name': 'poop', 'age': 99} Code: resultsDb = TinyDB('db/resultsDb.json') def run(params): resultsDb.insert({'id': params['id'], 'name': params['name'], 'age': params['age']}) maxProcesses = 12 # Cores in my pc for i in range(maxProcesses): processes.append(Process(target=run, args=(params,))) for p in processes: p.start() for p in processes: p.join() |
Access to TelemetryConfiguration object from C# script (csx) in Azure Function Posted: 19 Apr 2021 08:00 AM PDT I need to inject a TelemetryProcessor into existing TelemetryConfiguration (Application Insights) to modify default Azure Function behavior. There are examples how to do it through Dependency Injection for c# projects. I wonder whether there is a way to access it from C# script (csx). It looks like it is possible to access through TelemetryConfiguration.Active but compiler gives a warning that it is obsolete: 2021-04-17T01:38:35.988 [Warning] run.csx(28,15): warning CS0618: 'TelemetryConfiguration.Active' is obsolete: 'We do not recommend using TelemetryConfiguration.Active on .NET Core. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/1152 for more details' |
issue SeqHmm data format Posted: 19 Apr 2021 08:00 AM PDT I have the data which is biofam3c in package SeqHMM in list format. I wanted to see it in matrix form. I used this command matrix_biofam3c= matrix(unlist(biofam3c), ncol=16, byrow= TRUE) But its results was confusing . Then I also tried to change matrix_biofam3c into list using a command U= as.list(as.data.frame(matrix_biofam3c)) it gives not similar results like given form in package (List of length 4). I request please, suggest the right way to make biofam3c in matrix data (like biofam in package TraMineR). And also how to convert it again so it becomes like list as it is given there. |
LAB: Sorting TV Shows (dictionaries and lists) Posted: 19 Apr 2021 07:59 AM PDT I have used Pycharm to help me correct this issue. I have tried to put a specific range. I was considering user count +=1 every time something was print but couldn't get it into the code without getting an error. my output 07: Rules of Engagement; Medium; Lux Video Theatre 08: Mama; Barney Miller; Castle 10: Will & Grace; Smallville; Modern Family; Friends 11: Cheers; The Jeffersons 12: Murder, She Wrote; NYPD Blue 14: Dallas; Bonanza 15: ER 20: Gunsmoke; Law & Order; Law & Order: Special Victims Unit 30: The Simpsons '''' expected output 7: Rules of Engagement; Medium; Lux Video Theatre 8: Mama; Barney Miller; Castle 10: Will & Grace; Smallville; Modern Family; Friends 11: Cheers; The Jeffersons 12: Murder, She Wrote; NYPD Blue 14: Dallas; Bonanza 15: ER 20: Gunsmoke; Law & Order; Law & Order: Special Victims Unit 30: The Simpsons ''' '''' file = input() #user file input with open(file) as f: #open file data = f.readlines() dict_info = {} for i in range(0, len(data)-1, 2): season = data[i].strip() name = data[i+1].strip() if(season in dict_info): dict_info[season].append(name) else: dict_info[season] = [name] #OUTPUT KEYS keys = list(dict_info.keys()) #will list the dictionary keys keys.sort() #will sort the keys from min to max with open('output_keys.txt', 'w') as f: for key in keys: names = '; '.join(name for name in dict_info[key]) #will print the name with number f.write(str(key)+': '+names+"\n") names = [] #Dictionary value for item in dict_info: #will add name to dict for name in dict_info[item]: names.append(name) #OUTPUT TITTLE names.sort() #sort names from min to max with open('output_titles.txt', 'w') as f: #open the file for name in names: #will write name plus a new line f.write(name+'\n') |
Kotlin MPP expect / actual with different signatures Posted: 19 Apr 2021 07:59 AM PDT I have a manager class that has an Android and iOS impl (from a 3rd party lib). "ex. MyManagerImpl()". To construct the 3rd party manager, iOS does not require a Context but Android does. I created a common class "MyManager" which pulls out all the common methods needed to be called within commonMain. //commonMain expect class MyManager { fun method1() companion object Factory { makeManager(): MyManager } } val manager = MyManager.Factory.makeManager() // ex intended usage //androidMain MyManagerImpl(context: Context) { fun method1() } actual class MyManager private constructor(manager: MyManagerImpl) { .. actual companion object Factory { override fun makeManager(): MyManager { return MyManager(MyManagerImpl(?how to get context?)) } } } //iosMain MyManagerImpl() { fun method1() } actual class MyManager private constructor(manager: MyManagerImpl) { .. actual companion object Factory { override fun makeManager(): MyManager { return MyManager(MyManagerImpl()) } } } What is the cleanest way to merge the two implementations? Is it possible to do so even tho they have different constructor dependencies? We would like to be able to construct the classes lazily within commonMain. Is this possible? |
Define a list of optional keys for Typescript Record Posted: 19 Apr 2021 08:00 AM PDT I want to type an object which can only have keys 'a', 'b' or 'c'. So I can do it as follows: Interface IList { a?: string; b?: string; c?: string; } They are all optional! Now I was wondering if this can be written with Record in just one line type List = Record<'a' | 'b' | 'c', string>; The only issue is that all keys need to be defined. So I ended up with type List = Partial<Record<'a' | 'b' | 'c', string>>; This works, but I can imagine there is a better way to do this without Partial. Is there an other way to make the keys optional inside Record ? |
No comments:
Post a Comment