instruction
stringlengths
0
30k
|php|html|sql|database|
I'm trying to implement basic socket program in C which parses HTTP GET requests for now, in `parse_http_req` function I've declared `char* line;` and after `strncpy` call `line` contains 1st line of HTTP request data. My doubt is I didn't allocate any memory for `line` before I called `strncpy`, how is this code working correctly ? Here is my full `server.c` code (still under development) ``` #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/ip.h> #include <netinet/in.h> #include <unistd.h> #include <asm-generic/socket.h> #include <string.h> #define DEFAULT_PORT 8080 #define MAX_REQ_QUEUE_SIZE 10 #define MAX_REQ_SIZE 1024 #define DEFAULT_PROTOCOL "http" enum Methods { GET, POST, PUT, OPTIONS, DELETE, INVALID_METHOD }; typedef struct Request { enum Methods method; char *path; char *protocol; char *body; size_t content_length; } Request; enum Methods get_req_method(char *req) { if (strcmp(req, "GET")) { return GET; } if (strcmp(req, "POST")) { return POST; } if(strcmp(req, "OPTONS")){ return OPTIONS; } if (strcmp(req, "PUT")) { return PUT; } if (strcmp(req, "DELETE")) { return DELETE; } return INVALID_METHOD; } void parse_http_req(char *req, size_t req_size) { int size = 0; while ((*(req + size) != '\n') && (size < req_size)) { size++; } printf("size: %d\n", size); char *line; line = strncpy(line, req, size); line[size] = '\0'; printf("First line: %s\n", line); } void accept_incoming_request(int socket, struct sockaddr_in *address, socklen_t len) { int accept_fd; socklen_t socklen = len; while ((accept_fd = accept(socket, (struct sockaddr *)address, &len)) > 0) { char *buffer = (char *)malloc(sizeof(char) * MAX_REQ_SIZE); int recvd_bytes = read(accept_fd, buffer, MAX_REQ_SIZE); printf("%s\n%ld\n%d\n\n\n", buffer, strlen(buffer), recvd_bytes); parse_http_req(buffer, strlen(buffer)); free(buffer); send(accept_fd, "hello", 5, 0); close(accept_fd); } shutdown(socket, SHUT_RDWR); } int create_socket(struct sockaddr_in *address, socklen_t len) { int fd, opt = 1; if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("socket creation failed\n"); return -1; } if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt))) { perror("setsockopt"); return -1; } if (bind(fd, (struct sockaddr*)address, len) < 0) { perror("Socket bind failed\n"); return -1; } return fd; } int main(int argc, char *argv[]) { short PORT = DEFAULT_PORT; char *PROTOCOL = DEFAULT_PROTOCOL; if (argc > 1) { PORT = (short)atoi(argv[1]); } if (argc > 2) { PROTOCOL = argv[2]; } printf("%d %s\n", PORT, PROTOCOL); struct sockaddr_in address = { sin_family: AF_INET, sin_addr: { s_addr: INADDR_ANY }, sin_port: htons(PORT) }; int socket; if ((socket = create_socket(&address, sizeof(address))) < 0) { exit(1); } if (listen(socket, MAX_REQ_QUEUE_SIZE) < 0) { perror("Listen failed\n"); exit(1); } accept_incoming_request(socket, &address, sizeof(address)); return 0; } ``` If you compile and run server starts at port: `8080` or you can pass desired port as 1st arg like `./server 9000` To test: `wget http://localhost:8080/dummy/path` I tried to see if that line `strncpy` piece of code is valid. Here is my `test.c` ``` #include <stdio.h> #include <string.h> #include <stdlib.h> void f1(char *l2, int size) { char *l1; l1 = strncpy(l1, l2, size); printf("%s\n", l1); } void main() { char *l1 = malloc(10); char *l2 = "test"; strncpy(l1, l2, 5); printf("%s\n", l1); free(l1); f1(l2, 5); } ``` As I expected if I allocate some memory for `l1` before calling `strncpy` like in main it's all good. But, getting `Segmentation fault (core dumped)` while executing `function f1`. How is similar piece of code working in my **server.c** but not in this **test.c** program
Select all lines after last occurence of a certain character
Remove the `bin` from MAVEN_HOME. When the path is building you add `bin` again, then the path the machine is looking for is ```none C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%MAVEN_HOME%\bin\bin; ``` which is wrong.
This is more a hint than a question: The goal is to parse a command line **AND** create a useful *usage* message code: for arg ; do case "$arg" in --edit) # edit file cd "$(dirname $0)" && vim "$0" ;; --noN) # do NOT create 'NHI1/../tags' let noN=1 ;; --noS) # do NOT create 'HOME/src/*-latest/tags' let noS=1 ;; --help) # write this help message ;& *) echo "usage: $(basename $0) options..." 1>&2 awk '/--?\w+\)/' "$0" 1>&2 exit ;; esac done this create the *usage* message: > build_tags.bash -x usage: build_tags.bash options... --edit) # edit file --noN) # do NOT create 'NHI1/../tags' --noS) # do NOT create 'HOME/src/*-latest/tags' --help) # write this help message the clue is that the *definition* of the *case* target is also the *documentation* of the *case* target.
I have started using Jenkins. I am totally new to this. I am executing my Seleium automation script using Jenkins but encountered into the below error. I am using Java 17 in my system as well as in my project. I tried many times but it is getting failed. Even I tried to change java version in pom.xml file. That also didn't worked. Here is my pom.xml file ```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>FreeCRMTestAutomation</groupId> <artifactId>FreeCRMTest</artifactId> <version>0.0.1-SNAPSHOT</version> <name>FreeCRMTest</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.8.3</version> </dependency> <dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>5.3.2</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-devtools-v108</artifactId> <version>4.7.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>5.2.2</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>5.2.2</version> </dependency> <!-- https://mvnrepository.com/artifact/org.testng/testng --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.8.0</version> <scope>compile</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports --> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports</artifactId> <version>5.0.9</version> </dependency> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports-testng-adapter</artifactId> <version>1.0.7</version> </dependency> </dependencies> <build> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> <plugin> <artifactId>maven-site-plugin</artifactId> <version>3.7.1</version> </plugin> <plugin> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.0.0</version> </plugin> </plugins> </pluginManagement> </build> </project> ```
I have an array of points formatted like this: `[point(0,0), point(0,0), point(0,0)]`, where `0,0` is replaced with the location of the point. I would like to interconnect them all by distance, for example: [connecting.png](https://i.stack.imgur.com/CWs57.png). This would be done by looping over each point (loop 1), and then nesting another loop of all the points except for the current one (loop 2), then calculating the distance between the value from loop 1 and loop 2, then if it is less than the threshold, that is a neighbour and return in in an array. The problem happens when I get doubled up values, for example it has found that point 1 is a neighbour of point 2, but also that point 2 is a neighbour of point 1, so when I connect them, they will be doubled up. I know of the nearest neighbour algorithm, but that only selects the closest, and won't it also just do the duplicate thing again??
I have modal dialog window in images block on OPENCART site that has folder-looking elements with elements, and clicking one folder-element, I go inside this folder-element and there is another folder-element in it, which I need to click too. I'm trying to write code in selenium/python to go through all those folder-elements, but html-path of inner folder-element is the same as previous folder-element's html-path. The elems' tree look like this: modal_dialog = id="filemanager" inside of modal dialog theres elements: [folder1, folder2, folder3, folder4, folder5, folder6, *images] Inside folder3 there's another level - [folder3-1, folder3-2] and inside folder3-2 there's elements i need. Can someone help me? I spent many days, resolving this, but still find resolution. I used find_elements(By.XPATH...) and index to make selenium click the third folder-element of outerlevel like this: ```python modal_dialog = driver.find_elements(By.XPATH, '//div[@class="text-center"]//a[@class="directory"]//i[@class="fa fa-folder fa-5x"]') folder3 = modal_dialog[2] folder3.click() ``` Folder3-2 has the same htmlpath as outer folders and inner folders. I used fullXPATH: `/html/body/div[5]/div/div/div[2]/div[2]/div[2]/div/a/i` but the same fullXPATH has folder2.
I am building a face-id detection program on my raspberry pi, for which I need to use OpenCV along with my RaspberryPi camera. However, when I run my code, I keep on getting an error which I am guessing is because the cv2.VideoCapture() function is not able to take input from my RaspberryPi camera. Whenever I run the following code, I get the following error: **Code** ``` import cv2 cap = cv2.VideoCapture("dev/video12") print(cap) while True: ret, frame = cap.read() cv2.imshow("frame", frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows() ``` **Error** [ WARN:0@0.572] global ./modules/videoio/src/cap_gstreamer.cpp (1127) open OpenCV | GStreamer warning: Error opening bin: no element "dev" [ WARN:0@0.572] global ./modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created < cv2.VideoCapture 0x7f80b53750> Traceback (most recent call last): File "/home/pi/Desktop/test.py", line 9, in <module> cv2.imshow("frame", frame) cv2.error: OpenCV(4.6.0) ./modules/highgui/src/window.cpp:967: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow' I am guessing this has something to do with the cv2.VideoCapture() function not taking input from my camera. I am using a RaspberryPi 3B with Bookworm. Please help. Thank you.
How to use a RaspberryPi camera with the cv2.videoCapture() function?
|opencv|raspberry-pi3|
null
If you're trying to get a fixed top section, and then, a scrollable one, you could simply use a Column() into your Scaffold, and wrap a Container() followed by an Expanded() into it. For example : Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(widget.title), backgroundColor: Colors.green), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( // will be fixed top child: Column(children: [ TextField( decoration: const InputDecoration( labelText: 'Search...', suffixIcon: Icon(Icons.search), ), ), Wrap( spacing: 5.0, children: List<Widget>.generate( 3, (int index) { return ChoiceChip( label: Text('Item $index'), selected: false, onSelected: (bool selected) { /*setState(() { _value = selected ? index : null; });*/ }, ); }, ).toList(), ), ])), Expanded( // will be scrollable child: ListView.builder( scrollDirection: Axis.vertical, itemCount: 15, itemBuilder: (BuildContext context, int ind) { return Container( margin: const EdgeInsets.all(5), height: 450, decoration: BoxDecoration( color: Colors.pink[600], borderRadius: BorderRadius.circular(10), ), ); })) ], ), )); }
{"OriginalQuestionIds":[72238175,60618844],"Voters":[{"Id":9504406,"DisplayName":"emeraldsanto"},{"Id":8690857,"DisplayName":"Drew Reese","BindingReason":{"GoldTagBadge":"react-hooks"}}]}
I have 2 lists that I wanted to merge together (witch contained 'class' objects), so I tried using the \__str_\_() method but it didn't work I made this class that would give each card a color and number and then tried to use the \__str_\_() function ``` #create class class card: def __init__(self, color, number): self.color = color self.number = number def __str__(self): return (self.color, self.number) ``` then I made a list of 'class' objects using loops ``` red_cards = [(card("red",i) for i in range(1,10))] blue_cards = [(card("blue",i) for i in range(1,10))] ``` then I merged the list ``` cards_in_deck = red_cards + blue_cards ``` and then I tried to print it using the \__str_\_() method ``` print(cards_in_deck.__str__) ``` and it returned this ``` <method-wrapper '__str__' of list object at 0x7f5d7d992a00> ```
How do I print a list with the __str__() method
|python|
null
I am working with a school project where I need to obtain the analyst price targets estimates of certain stocks from the Yahoo Finance Website (this is mandatory). When I tried to use it by beatiful soup I couldn't scrape it (I believe JS is adjusting the page as it laods), so I turned to selenium to obtain such data. However when I'm trying to obtain the elements through the XPATH, it returns error as if it doesn't exist. I am using EC in case it needs to load, but its not working. I've tried modifying the wait times up until 2 minutes, so that is not the issue Code below: ```from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--no-sandbox') chrome_options.add_argument("--headless") chrome_options.add_argument(f'user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36') chrome_options.add_argument("window-size=1920,1080") driver = webdriver.Chrome(options=chrome_options) driver.get("https://finance.yahoo.com/quote/BBAJIOO.MX?.tsrc=fin-srch") driver.delete_all_cookies() WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="Col2-11-QuoteModule-Proxy"]/div/section/div'))) ``` Anyone has an idea as to why this is happening? and how can I obtain such ratings? Image below of desired ratings [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/mBp3Q.png This is the XPATH I'm using: //*[@id="Col2-11-QuoteModule-Proxy"]/div/section/div This is the example of the HTML Code: <div aria-label=***"Low 60 Current 64.59 Average 69.25 High 76.8"*** class="Px(10px)"><div class="Pos(r) Pb(30px) H(1em)"><div class="Start(75%) W(25%) Pos(a) H(1em) Bdbc($seperatorColor) Bdbw(2px) Bdbs(d) T(30px)"></div><div class="Pos(a) H(1em) Bdbc($seperatorColor) Bdbw(2px) Bdbs(s) T(30px) W(100%)"></div><div class="Pos(a) D(ib) T(35px)" data-test="analyst-cur-tg" style="left: 27.3214%;"><div class="W(7px) H(7px) Bgc($linkActiveColor) Bdrs(50%) Z(1) B(-5px) Translate3d($half3dTranslate) Pos(r)"></div><div class="Bgc($linkActiveColor) Start(0) T(5px) W(1px) H(17px) Z(0) Pos(r)"></div><div class="Miw(100px) T(6px) C($linkActiveColor) Pos(r) Fz(s) Fw(500) D(ib) Ta(c) Translate3d($half3dTranslate)"><span>Current</span>&nbsp;<span>64.59</span></div></div><div class="Pos(a) D(ib) T(-1px)" data-test="analyst-avg-tg" style="left: 55.0595%;"><div class="Pos(r) T(5px) Miw(100px) Fz(s) Fw(500) D(ib) C($primaryColor)Ta(c) Translate3d($half3dTranslate)"><span>Average</span>&nbsp;<span>69.25</span></div><div class="Pos(r) Bgc($tertiaryColor) W(1px) H(17px) Z(0) T(6px) Start(-1px)"></div><div class="W(8px) H(8px) Bgc(t) Bd Bdc($seperatorColor) Bdrs(50%) Z(1) B(-6px) Pos(r) Translate3d($half3dTranslate)"></div></div><span class="W(6px) H(6px) Bgc($tertiaryColor) Bdrs(50%) Z(0) B(-5px) Start(0) Pos(a) Translate3d($half153dTranslate)"></span><span class="W(6px) H(6px) Bgc($tertiaryColor) Bdrs(50%) Z(0) B(-5px) Pos(a) Translate3d($zero153dTranslate) Start(100%)"></span></div><div class="Ov(a) Fz(xs) Mt(10px) C($tertiaryColor)"><div class="Pos(r) Fl(start) Fz(xs) C($tertiaryColor) "><span>Low</span>&nbsp;<span>60.00</span></div><div class="Pos(r) Fl(end) Fz(xs) C($tertiaryColor) "><span>High</span>&nbsp;<span>76.80</span></div></div></div>
{"Voters":[{"Id":2943403,"DisplayName":"mickmackusa"},{"Id":354577,"DisplayName":"Chris"},{"Id":16217248,"DisplayName":"CPlus"}]}
{"Voters":[{"Id":14853083,"DisplayName":"Tangentially Perpendicular"},{"Id":354577,"DisplayName":"Chris"},{"Id":16217248,"DisplayName":"CPlus"}],"SiteSpecificCloseReasonIds":[18]}
{"Voters":[{"Id":14732669,"DisplayName":"ray"},{"Id":354577,"DisplayName":"Chris"},{"Id":16217248,"DisplayName":"CPlus"}],"SiteSpecificCloseReasonIds":[18]}
I'm programming a simple 'game' that is just a block that can jump around. I placed a wall, but now the character phases through when moving to the right, but the collision works when going to the right. simple working code for this example: ``` <!DOCTYPE html> <html> <head><title>Simple Game</title></head> <body> <div id="bg" class="bg"></div> <div id="cube" class="cube"></div> <div id="ground1" class="ground1"></div> <div id="ground2" class="ground2"></div> <script> var verticalVelocity = 0; var maxVertVelo = 100; var runSpeed = 5; var CUBE = document.getElementById("cube"); var playerTop = CUBE.offsetTop; var immovables = ["ground1", "ground2"]; //Key was created by another student who allowed me to use it. let Key = { pressed: {}, up: "ArrowUp", left: "ArrowLeft", right: "ArrowRight", isDown: function (key){ return this.pressed[key]; }, keydown: function (event){ this.pressed[event.key] = true; }, keyup: function (event){ delete this.pressed[event.key]; } } window.addEventListener("keyup", function(event) { Key.keyup(event); }); window.addEventListener("keydown", function(event) { Key.keydown(event); }); setInterval(()=>{ //move left if (Key.isDown(Key.left)){ if(willImpactMovingLeft("cube", immovables)!=false){ cube.style.left = willImpactMovingLeft("cube", immovables)+"px"; }else{ cube.style.left = CUBE.offsetLeft - runSpeed +"px"; } } //move right if (Key.isDown(Key.right)){ if(willImpactMovingRight("cube", immovables)!=false){ cube.style.left = willImpactMovingRight("cube", immovables)+"px"; }else{ cube.style.left = CUBE.offsetLeft + runSpeed +"px"; } } //this moves the character vertically based on the velocity (negative velocity moves it up, positve moves it down). playerTop = CUBE.offsetTop; playerTop = playerTop+verticalVelocity; CUBE.style.top = playerTop+"px"; }, 10); function willImpactMovingLeft(a, b){ var docA = document.getElementById(a); var docB = document.getElementById(b[0]); for(var i=0;i<b.length;i++){ docB = document.getElementById(b[i]); if((docA.offsetTop>docB.offsetTop&&docA.offsetTop<docB.offsetTop+docB.offsetHeight)||(docA.offsetTop+docA.offsetHeight>docB.offsetTop&&docA.offsetTop+docA.offsetHeight<docB.offsetTop+docB.offsetHeight)){//vertical check if(docA.offsetLeft+docA.offsetWidth>docB.offsetLeft+runSpeed){ if(docA.offsetLeft-runSpeed<docB.offsetLeft+docB.offsetWidth){ return docB.offsetLeft+docB.offsetWidth; } } } } return false; } function willImpactMovingRight(a, b){ var docA = document.getElementById(a); var docB = document.getElementById(b[0]); for(var i=0;i<b.length;i++){ docB = document.getElementById(b[i]); if((docA.offsetTop>docB.offsetTop&&docA.offsetTop<docB.offsetTop+docB.offsetHeight)||(docA.offsetTop+docA.offsetHeight>docB.offsetTop&&docA.offsetTop+docA.offsetHeight<docB.offsetTop+docB.offsetHeight)){//vertical check if(docA.offsetLeft>docB.offsetWidth+docB.offsetLeft-runSpeed){ if(docA.offsetLeft+docA.offsetWidth+runSpeed<=docB.offsetLeft){ CUBE.textContent = "WIMR"; return docB.offsetLeft-docA.offsetWidth; } } } } return false; } </script><style> .cube{height:50px;width:50px;background-color:red;position:absolute;top:500px;left:500px;} .ground1{height:10px;width:100%;background-color:black;position:absolute;top:600px;left:0;} .ground2{height:150px;width:10px;background-color:black;position:absolute;top:450px;left:700px;} </style></body></html> ``` it looks like a lot, but the only problem is the last if statement. Even when the condition is true, it still skips the return number and returns false. Any idea why? P.S. **I CANNOT USE THE CONSOLE, I AM ON A MANAGED COMPUTER** I'm also locked out of my github account and have a link to a code.org page (just copy the code) https://studio.code.org/projects/applab/iFUpHIl-Vq3nQ4PYxY8Y1tMkIIgh9tAl95RexkDQUh8
{"Voters":[{"Id":794749,"DisplayName":"gre_gor"},{"Id":354577,"DisplayName":"Chris"},{"Id":16217248,"DisplayName":"CPlus"}],"SiteSpecificCloseReasonIds":[18]}
{"Voters":[{"Id":2943403,"DisplayName":"mickmackusa"},{"Id":354577,"DisplayName":"Chris"},{"Id":16217248,"DisplayName":"CPlus"}]}
{"Voters":[{"Id":9473764,"DisplayName":"Nick"},{"Id":9214357,"DisplayName":"Zephyr"},{"Id":16217248,"DisplayName":"CPlus"}]}
**Promise resolution** The technical explanation is that pairs of `resolve`/`reject` functions are "one shots" in that once you call one of them, further calls to either function of the pair are ignored without error. If you resolve a promise with a promise or thenable object, Promise code internally creates a new, second pair of resolve/reject functions for the promise being resolved and adds a `then` clause to the resolving promise to resolve or reject the promise being resolved, according to the settled state of the resolving promise. Namely, in ```js const test = new Promise((resolve, reject) => { resolve(Promise.resolve(78)) }) ``` `resolve(Promise.resolve(78))` conceptually becomes ```js Promise.resolve(78).then(resolve2,reject2) ``` where `resolve2`/`reject2` are a new pair of resolve/reject functions created for the promise `test`. If and when executed, one of the `then` clause's handlers (namely `reject2` in this case) will be called by a Promise Reaction Job placed in the microtask queue. Jobs in the microtask queue are executed asynchonously to calling code, where `test` will remain pending at least until after the synchronous code returns. **Promise Rejection** Promise rejection is certain if a promise's `reject` function is called. Hence you can reject a promise with any JavaScript value, including a Promise object in any state. Namely in ```js const test2 = new Promise((resolve, reject) => { reject(Promise.resolve(78)) }) ``` the rejection can be performed synchronously, and the the rejection reason of `test2` is the _promise object_ `Promise.resolve(78)`, not the number 78. Demo: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> const test2 = new Promise((resolve, reject) => { reject(Promise.resolve(78)) }) test2.catch(reason => console.log("reason is a promise: ", reason instanceof Promise) ); <!-- end snippet -->
That error seems odd, because imports should be allowed, but it's possible that it's just an inaccurate message. What you're looking for in this case isn't an import, it's a directive that Tailwind itself supplies: ```css @tailwind base; @tailwind components; @tailwind utilities; ```
`while` is a looping construct. It is not that the thread revisits the code before - it just loops again: while (mode.get() != 1) { lock.wait(); } After the `wait()` call finishes the loop condition is evaluated again in the same way that while (counter.get() < n) { // some code here that might modify the value of the counter } loops for as long as `counter.get()` returns a value less than `n`. The other approach (using if): if (mode.get() != 3) { lock.wait(); } only calls `lock.wait();` once if `mode.get()` returns something else then `3`. After `lock.wait();` returns it just continues with the code after the `if` statement, no matter what `mode.get()` would return.
I am currently experimenting a bit with the Qt DataVisualization. The goal is that I have a `QLineEdit` and when I exit it, I use the `QLineEdit::editingFinished` signal. And then I set the value that was entered to the selected `Bar`. I get an error on line 46 when I start the second `for` loop when I try to access the `QBarDataItem`. I am getting a Read Access Violation there and I get the error on this line of the `qarraydatapointer.h` file from Qt: ``` bool needsDetach() const noexcept { return !d || d->needsDetach(); } ``` Here my code : Main file: ```cpp #include <QApplication> #include <QFile> #include "Window.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); // creates a window Window window; QFile file(app.applicationDirPath() + "/Test.txt"); // Writes the x and y position of the selected Bar QObject::connect(window.getSeries(), &QBar3DSeries::selectedBarChanged, [&]() { if (!file.open(QIODevice::ReadWrite)) { QTextStream stream(&file); stream << window.getSeries()->selectedBar().x() << ", " << window.getSeries()->selectedBar().y() << ", " << window.getSeries()->dataProxy()->rowAt(window.getSeries()->selectedBar().x())->data()->value() << "\n"; } }); QFile file1(app.applicationDirPath() + "/Data.txt"); if (file1.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file1); QBarDataRow *data = new QBarDataRow; while (!in.atEnd()) { QString line = in.readLine(); *data << line.toFloat(); } window.getSeries()->dataProxy()->addRow(data); } window.show(); file.close(); file1.close(); return app.exec(); } ``` Window.h: ```cpp #ifndef WINDOW_H #define WINDOW_H #include <QMainWindow> #include <QtDataVisualization> #define WIDTH 1400 #define HEIGHT 800 struct Data { Data() { data1 = new QBarDataRow; data2 = new QBarDataRow; data3 = new QBarDataRow; data4 = new QBarDataRow; data5 = new QBarDataRow; } ~Data() { delete data1; delete data2; delete data3; delete data4; delete data5; } public: QList<QBarDataRow *> data{ data1, data2, data3, data4, data5 }; QBarDataRow *data1; QBarDataRow *data2; QBarDataRow *data3; QBarDataRow *data4; QBarDataRow *data5; }; class Window : public QMainWindow { Q_OBJECT public: Window(QWidget *parent = nullptr); ~Window(); QBar3DSeries *getSeries(); protected: void resizeEvent(QResizeEvent *event) override; private: Q3DBars *m_bars; QBar3DSeries *m_series; Data *m_data; QWidget *m_graph; }; #endif // WINDOW_H ``` Window.cpp: ```cpp #include "Window.h" #include <QLineEdit> static void setData(Data *data, QBar3DSeries *series) { *data->data1 << 1.0f << 3.0f << 6.5f << 5.0f << 2.2f; *data->data2 << 2.0f << 1.5f << 5.0f << 2.0f << 2.4f; *data->data3 << 3.0f << 2.5f << 4.0f << 1.0f << 3.4f; *data->data4 << 2.9f << 2.5f << 2.3f << 3.1f << 1.7f; //*data->data5 << 1.6f << 1.1f << 1.8f << 4.8f << 3.4f; series->dataProxy()->addRow(data->data1); series->dataProxy()->addRow(data->data2); series->dataProxy()->addRow(data->data3); series->dataProxy()->addRow(data->data4); //series->dataProxy()->addRow(data->data5); } Window::Window(QWidget *parent) : QMainWindow(parent) { // Initialising variables m_bars = new Q3DBars; m_series = new QBar3DSeries; m_data = new Data; setWindowTitle("Physik"); resize(WIDTH, HEIGHT); m_bars->rowAxis()->setRange(0, 4); m_bars->columnAxis()->setRange(0, 4); m_bars->scene()->activeCamera()->setCameraPosition(30, 30); // set values which can then be seen setData(m_data, m_series); m_bars->addSeries(m_series); // Creates a QWidget, which is a child of the QMainWindow (this) m_graph = QWidget::createWindowContainer(m_bars, this); m_graph->setGeometry(0, 0, WIDTH * 0.7, HEIGHT); //-------------------------------------------------------------- QLineEdit *lineEdit = new QLineEdit(this); lineEdit->setGeometry(WIDTH * 0.75, HEIGHT * 0.1, WIDTH * 0.85, HEIGHT * 0.15); connect(lineEdit, &QLineEdit::editingFinished, [&]() { QPoint position = m_series->selectedBar(); for (size_t i{}; i < m_data->data.size(); ++i) { if (i == position.x()) { size_t j{}; for (auto &value : *m_data->data[i]) { if (j == position.y()) { value.setValue(lineEdit->text().toFloat()); } ++j; } break; } } }); } Window::~Window() {} QBar3DSeries *Window::getSeries() { return m_series; } void Window::resizeEvent(QResizeEvent *event) { QMainWindow::resizeEvent(event); if (m_graph) { m_graph->resize(event->size().width() * 0.7, event->size().height()); } } ``` I tried to write my own `QBarDataItem` and `QBarDataRow` who inherit public both classes and tried to rewrite the functions, but it didn't work, and I really tried a lot of different stuff. But nothing worked, so I hope you can help me. I know it's better to make this problem not too specific so that many people can help. In the end, I am only trying that I have a selected `Bar` and when I get out of the `QLineEdit` the value is then being set to the selected `Bar`.`enter code here`
Read Access Violation when accessing a QBarDataItem in a loop in QLineEdit::editingFinished
I have a DJI Mavic 3M drone where I shoot images of the ground. For further processing, I need to obtain the world-to-camera transformation matrix. The drone saves the yaw, pitch and roll angles for both the drone and the gimbal. Since the camera is attached to the gimbal, I only use the euler angles of the gimbal. However, using scipy's `Rotation` object, I obtain an incorrect rotation. The way how I checked that the rotation is incorrect is by feeding all the drone images to `OpenDroneMap` and obtain the world-to-camera rotation from the `reconstruction.json` file. In `scipy` then I just call `Rotation.from_euler("zyx", [yaw, pitch, roll])` to obtain the `Rotation` object. The euler angles I obtained from `OpenDroneMap` are: **z: -2.25155729 y: -0.30835846 x: -179.96534315**. The euler angles of the gimbal that the image data shows me are: **z: 0.70 y: -89.90 x: 0.00**. What is the usual way of constructing the world-to-camera matrix when I have the origin point of the camera in world coordinates and the yaw, pitch and roll angles?
Incorrect world-to-camera matrix with euler angles (yaw, pitch, roll)
|scipy|computer-vision|coordinate-systems|coordinate-transformation|photogrammetry|
null
|sql|sqlite|group-by|ranking|group-concat|
I need to create a Query that will re-organize a table. It has been over 5 years since I was heavily using Query and Arrayformula's in Google Sheets and am not getting the results needed. Google Sheet example Data: https://docs.google.com/spreadsheets/d/1YI1mPJqL8x0GfxMSE9K2xCNzwiUvo0RLhd5DQ0O1mC4/edit?usp=sharing Example Google Sheet: https://docs.google.com/spreadsheets/d/1YI1mPJqL8x0GfxMSE9K2xCNzwiUvo0RLhd5DQ0O1mC4/edit?usp=sharing Original format: ![Original Format](https://i.stack.imgur.com/V2eOa.png) Format needed: ![Format Needed](https://i.stack.imgur.com/hLIHt.png)
Google Sheet - Transpose with Query or ArrayFormula?
In modern JavaScript (ES5+), evaluating a RegExp literal is specified to return a new instance each time a regular expression literal is evaluated. In ES3, a JavaScript literal creates a distinct `RegExp` object for each literal (including literals with the same content) **at parse time** and each “physical” literal always evaluates to the same instance. So, in both ES5 and ES3, the following code will assign distinct `RegExp` instances to `re`: re = /cat/; re = /cat/; However, if these lines are executed multiple times, ES3 will assign the same `RegExp` object on each line. In ES3, there will be exactly two instances of RegExp. The latter instance will always be assigned to `re` after executing those two lines. If you copied `re` to another variable in the meantime, you will see that `re === savedCopy`. In ES5, each execution will produce new instances. So each time those lines run, a new `RegExp` object will be created for the first line and then another new `RegExp` object will be created and saved to the `re` variable for the second line. If you copied `re` to another variable in the meantime, you will see that `re !== savedCopy`. # Specs [ECMAScript 3rd Edition (ECMA-262)](https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf) ­­­§ 7.8.5 (p. 20) states the following (emphasis added on pertinent text): > ### 7.8.5 Regular Expression Literals > > A regular expression literal is an input element that is *converted to a RegExp object (section 15.10) when it is scanned*. The object is created before evaluation of the containing program or function begins. Evaluation of the literal produces a reference to that object; it does not create a new object. Two regular expression literals in a program evaluate to regular expression objects that never compare as `===` to each other even if the two literals' contents are identical. A RegExp object may also be created at runtime by `new RegExp` (section 15.10.4) or calling the `RegExp` constructor as a function (section 15.10.3). [ECMAScript 5.1 (ECMA-262) § 7.8.5](https://www.ecma-international.org/ecma-262/5.1/#sec-7.8.5) states the following (emphasis added on pertinent text): > 7.8.5 Regular Expression Literals > > A regular expression literal is an input element that is *converted to a RegExp object ([see 15.10](https://www.ecma-international.org/ecma-262/5.1/#sec-15.10)) each time the literal is evaluated*. Two regular expression literals in a program evaluate to regular expression objects that never compare as `===` to each other even if the two literals' contents are identical. A RegExp object may also be created at runtime by `new RegExp` (see [15.10.4](https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.4)) or calling the `RegExp` constructor as a function ([15.10.3](https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.3)). This means that the behavior is specified differently between ES3 and ES5.1. Consider this code: function getRegExp() { return /a/; } console.log(getRegExp() === getRegExp()); In ES3, that particular `/a/` will always refer to the same `RegExp` instance and the log will output `true` because the `RegExp` is instantiated once **“when it is scanned”**. In ES5.1, every evaluation of `/a/` will result in a new `RegExp` instance, meaning that creation of a new `RegExp` happens each time the code refers to it because the spec says that it is **“converted to a RegExp object (see 15.10) each time the literal is evaluated”**. Now consider this expression: `/a/ !== /a/`. In both ES3 and ES5, this expression will always evaluate to `true` because each distinct literal gets a distinct `RegExp` object. In ES5 this happens because each evaluation of a literal always results in a new object instance. In ES3.1 this happens because the spec says “Two regular expression literals in a program evaluate to regular expression objects that never compare as === to each other even if the two literals' contents are identical.”. This change in behavior is documented as an incompatibility with ECMAScript 3rd Edition in [ECMAScript 5.1 (ECMA-262) Annex E](https://www.ecma-international.org/ecma-262/5.1/#sec-E): > Regular expression literals now return a unique object each time the literal is evaluated. This change is detectable by any programs that test the object identity of such literal values or that are sensitive to the shared side effects. Old code may have been written to rely on the ES3 behavior. This would allow a function to be called multiple times to incrementally walk through matches in a string when the expression was compiled with the `g` flag. This is similar to how, in C, the non-reentrant [`strtok()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html) method works. If you want the same effect with ES5, you must manually store the `RegExp` instance in a variable and ensure that the variable has a long enough lifetime since ES5 effectively gives you behavior like the reentrant [`strtok_r()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html) method instead. # Optimization Bugs Supposedly there are bugs in JavaScript implementations which result in `RegExp` object caching resulting in observable side effects which should be impossible. The observed behavior does not necessarily adhere to either the ES3 or ES5 specification. An example for Mozilla is given at the end of [this post](http://web.archive.org/web/20170731115123/https://siderite.blogspot.com/2011/11/careful-when-reusing-javascript-regexp.html#at833673626) with the spoiler text and explanation that the bug is not observable when debugging but is observable when the JavaScript is running in non-debug optimized mode. The blog author wrote a comment saying the bug was still reproducible in stable Firefox as of 2017-03-08, though the comments do not load in Wayback Machine.
I have written a SQL query to find prev year sales one using `lag` and with nested CTE, and another just without nested CTE. I am seeing difference in output in SQL Server environment. Without nested CTE (correct output): WITH cte AS ( SELECT * FROM (SELECT category, product_id, DATEPART(YEAR, order_date) AS order_year, SUM(sales) AS sales FROM namastesql.dbo.orders GROUP BY category, product_id, DATEPART(YEAR, order_date)) a ) SELECT *, LAG(sales) OVER (PARTITION BY category ORDER BY order_year) AS prev_year_sales FROM cte WHERE product_id = 'FUR-FU-10000576' With nested CTE (wrong output): with cte as ( select category, product_id, DATEPART(YEAR, order_date) as order_year, sum(sales) as t_sales from namastesql.dbo.orders GROUP BY category, product_id, DATEPART(YEAR, order_date) ), cte2 as ( select *, lag(t_sales) over (partition by category order by order_year) as prev_year_sales from cte ) select * from cte2 where product_id = 'FUR-FU-10000576'; Correct output: [![enter image description here][1]][1] Wrong output from nested CTE: [![enter image description here][2]][2] [1]: https://i.stack.imgur.com/kVcTr.png [2]: https://i.stack.imgur.com/X0wMG.png Any help on this will be appreciated .
Writing query in CTE returning the wrong output
In your vs code press keys `ctrl`+`shift`+`p` then search `settings.json` and write the following code { "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[javascriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.formatOnSave": true, "files.autoSave": "afterDelay", "files.autoSaveWhenNoErrors": true, "files.autoSaveDelay": 1000, "notebook.formatOnSave.enabled": true }
I have written a SQL query to find prev year sales one using `lag` and with nested CTE, and another just without nested CTE. I am seeing difference in output in SQL Server environment. Without nested CTE (correct output): WITH cte AS ( SELECT * FROM (SELECT category, product_id, DATEPART(YEAR, order_date) AS order_year, SUM(sales) AS sales FROM namastesql.dbo.orders GROUP BY category, product_id, DATEPART(YEAR, order_date)) a ) SELECT *, LAG(sales) OVER (PARTITION BY category ORDER BY order_year) AS prev_year_sales FROM cte WHERE product_id = 'FUR-FU-10000576' With nested CTE (wrong output): with cte as ( select category, product_id, DATEPART(YEAR, order_date) as order_year, sum(sales) as t_sales from namastesql.dbo.orders GROUP BY category, product_id, DATEPART(YEAR, order_date) ), cte2 as ( select *, lag(t_sales) over (partition by category order by order_year) as prev_year_sales from cte ) select * from cte2 where product_id = 'FUR-FU-10000576'; Correct output: [![enter image description here][1]][1] Wrong output from nested CTE: [![enter image description here][2]][2] [1]: https://i.stack.imgur.com/kVcTr.png [2]: https://i.stack.imgur.com/X0wMG.png Any help on this will be appreciated.
Selected answer didn't work for me in 2024. But such POST request did the thing: curl --location --request POST 'https://***' `--request` defines 'POST' method. `--location` follows redirect if 3XX HTTP status and "location" header are returned in response.
I want to upload a large file (public accessable over the internet) to an Azure blob using the PUT REST API with the x-ms-copy-source header. The PUT uri includes a SAS token and I use these headers: ``` x-ms-version: 2023-11-03 x-ms-blob-type: BlockBlob x-ms-copy-source: https://mypublicfile/filename.csv ``` That works fine. But the [documentation](https://learn.microsoft.com/en-us/rest/api/storageservices/copy-blob-from-url) states that also the x-ms-requires-sync:true headers should be added and is required. But when I add this, I get this error: ``` <?xml version="1.0" encoding="utf-8"?> <Error> <Code>InvalidHeaderValue</Code> <Message>The value for one of the HTTP headers is not in the correct format. RequestId:935f1ff5-a01e-0065-6f34-80e89b000000 Time:2024-03-27T10:51:11.7886167Z</Message> <HeaderName>x-ms-requires-sync</HeaderName> <HeaderValue>true</HeaderValue> </Error> ``` Any idea what I am doing wrong? Beside this, is there any size limit (beside the obvious max blob sizes stated [here](https://learn.microsoft.com/en-us/azure/storage/blobs/scalability-targets#scale-targets-for-blob-storage)). Up to 5GiB seems to work fine, but large files give an error.
Azure Storage Copy Blob From Url (REST API) error on x-ms-requires-sync header
|azure|azure-blob-storage|
|c++|qt|qt-creator|
I have recently migrated to vmware geode 9.15.9 from Gemfire 8.2.0. After this migration, our application became terribly slow. The small queries are taking almost twice of more time than the previous version. Also, when a big data is queried to the geode cache, it fails with socket timeout. Any clue on what could have gone wrong?
VMWare Geode (Gemfire) is terribly slow after migrating to 9.15.9
|gemfire|geode|geode9.15.9|
How to model such that a drill through for Order suppliers having M:1 relation with Order fact table can be configured?
|powerbi|data-modeling|star-schema|
When fetching a users stats for a game from the steam API using: ``` url = f"http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/" params = { 'appid': self.appid, 'key': apikey, 'steamid': steamid } response = requests.get(url, params=params) ``` If the game isn't owned it returns None. However whether or not the game is owned I would like to be able to view the available stat names as I would like to display them. Is there any way to do this? Do I need to find an account with all games on? Thanks.
Steam API - Available stats when I don't own a game?
|python-requests|steam|steam-web-api|
After following instructions for installing MacOS on VirtualBox, I kept running into errors. This is the one that stumped me. The exact error message is as follows: ```VM Name: BigSur Failed to query SMC value from the host (VERR_INVALID_HANDLE). Result Code: E_FAIL (0X80004005) Component: ConsoleWrap Interface: IConsole {6ac83d89-6ee7-4e33-8ae6-b257b2e81be8} ``` I've followed all the recommended steps online (reinstalling, turning Virtualization on/off etc.) and nothing seems to work. After reinstalling it did go from showing the error in the Virtual Machine window to showing it on the sidebar of the menu (as shown in the image: (https://i.stack.imgur.com/kfDZj.png). Can someone tell me what I did wrong? -Edit: It appears that the 'BigSur.xml-prev' and 'BigSur.xml-tmp' files don't exist at all, and seeing as the troubleshooting steps require renaming one of those files I still can't do anything.
I'm a noob to shopware 6 and I have been struggling for a week to add a field to product entity just like admin can add a address in customer overview dynamically. [Customer address detail page] [Modal popup to save address data](https://i.stack.imgur.com/F2iw6.png)][(https://i.stack.imgur.com/2OW4Q.png)] I have followed this to add a single field in product entity https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.html I have managed to create and save it to single field but I want the fields to be added and contents of it saved dynamically. I have then switched to add a field within a modal popup in a custom tab in product edit page ( like in but I'm not able to save the field I have added code as a link https://ray.so/puiipzV
Creating a modal window in product edit page in Shopware6 and saving data to custom table(repository) from a form within the modal window
|vue.js|plugins|shopware6|administration|
null
My experience trying to make this kind of complicated types is that it rarely ends well, it almost always ends up with types that are pretty difficult to use, so I would instead try to simplify things. It seems like you have two different problems you want to solve: - at least one of text and icon should be present - iconProps should only be present when Icon is present For the first problem, I'm not sure how important it actually is. The users of your Button component will end up with a weird-looking empty button, which they will surely notice pretty quickly and fix by adding either a text or an icon (or both). So I would simply ignore this problem and make both optional. For the second problem, instead of expecting a React component as the icon, you could accept instead some arbitrary JSX: ```js // Before <Button Icon={MyIcon} iconProps={{someProp: value}} /> // After <Button icon={<MyIcon someProp={value}/>} /> ``` This way you simply need to accept a prop `icon?: ReactNode` and you don't need to care about `iconProps` at all. It is up to the caller to pass the right JSX. You could even go one step further and simply accept `children: ReactNode` instead of both `text` and `icon`, which gives even more flexibility to the users of this component. Maybe someone wants to put the icon on the other side, or have two icons, or have a png icon, or have some bold text, etc.
# Im trying to instance an object depending the role to set the data, here is my code: ``` <?php // Incluye la definición de las clases CUsuario y CDocente include_once('modelo/CUsuario.php'); include_once('modelo/CDocente.php'); // Verifica si el usuario está autenticado (aquí debes tener tu lógica de autenticación) if (isset($\_SESSION\['usuario'\])) { // Obtiene los datos del usuario de la sesión $usuario = $\_SESSION\['usuario'\]; `<?php // Incluye la definición de las clases CUsuario y CDocente include_once('modelo/CUsuario.php'); include_once('modelo/CDocente.php'); // Verifica si el usuario está autenticado (aquí debes tener tu lógica de autenticación) if (isset($_SESSION['usuario'])) { // Obtiene los datos del usuario de la sesión $usuario = $_SESSION['usuario']; // Obtiene el rol del usuario $rol = $usuario->getRol(); // Instancia el objeto según el rol del usuario if ($rol === 'Alumno') { $usuario = new CUsuario(); } elseif ($rol === 'Docente') { $usuario = new CDocente(); } // Obtiene los valores del correo y la contraseña $correo = $usuario->getCorreo(); $passwd = $usuario->getPasswd(); // Obtiene otros datos del usuario si los necesitas $nombre = $usuario->getNombre(); // Otros getters... // Imprime los valores echo "Correo: " . $correo . "<br>"; echo "Contraseña: " . $passwd . "<br>"; echo "Apepat: " . $usuario->getFecnac() . "<br>"; // Otros datos del usuario... $usuario->setDatos($usuario->getNum($correo, $passwd)); echo "<br>Nombre: " . $nombre . "<br>"; } else { // Si el usuario no está autenticado, puedes redirigirlo a la página de inicio de sesión // o mostrar un mensaje de error, dependiendo de la lógica de tu aplicación echo "El usuario no está autenticado."; } ?> ``` And here is the error: ``` Fatal error: Uncaught Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "CDocente" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in C:\xampp\htdocs\revistaEq1\vista\vstCuenta.php:12 Stack trace: #0 C:\xampp\htdocs\revistaEq1\control\ctrGeneral.php(21): include() #1 C:\xampp\htdocs\revistaEq1\index.php(29): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\revistaEq1\vista\vstCuenta.php on line 12 ``` The error only appears when the role is teacher, when de role is student it work good, creating the object and setting the data, thats why i say that maybe the problem is in the object of techaer or in this line:$rol = $usuario-\>getRol(); La respuesta puede ser en español o en ingles. Thanks I try not to have errors, can create the teachers object and set my data without problems, i expect that someone can recognize this problem and know how to resolve it. If you need more information about the proyect or classes, you can tell me. Thanks
In my App PHP im trying to instance an object depending if the role is teacher or student but i have an error with the object or getting the role. Idk
|php|class|object|get|roles|
null
You are using a modal and the outer `setState` doesn't affect the modal after it's created. (It doesn't trigger a rebuild of a modal.) One solution is to wrap your widget with a `StatefulBuilder` like this: ```dart showModalBottomSheet( context: context, builder: (BuildContext context) { return StatefulBuilder( builder: (BuildContext context, StateSetter setState) { // return your widgets here }, ); }, ); ``` Remember, if you need to update the state of both the parent widget and the modal, you can use different names for the `StateSetter` of the `StatefulBuilder` and the `setState` of the parent widget.
I am automating web scraping using python
|python|selenium-webdriver|web|automation|screen-scraping|
null
I would go for a **lookup array** instead of making edge-cases: So, create a lookup array which contains the **valid** indices. This way you can easily do a normal random on a consecutive array. The selected value is the index you should use on the original array. public class Program { private static Random _rnd = new Random(); public static void Main() { // Some example array containing all the values. var myArray = "abcdefghijklmnop".ToArray(); // The lookup array containing the indices which are valid. var rndLookup = new[] { 2, 3, 4, 5, 6, 7, 8, 15 }; // Choose a random index of the lookup-array. var rndIndex = _rnd.Next(rndLookup.Length); // Select the value from the original array, via the lookup-array. // It would be wise to check if there is no index out of bounds // On the original array. Console.WriteLine("The random value is: " +myArray[rndLookup[rndIndex]]); } }
i created java ee appliation that uses glassfish server 4.1.2, it created just fine, then i created entity classes from database (i'm connecting to a database that has only one table called student) and it also went just fine, the problem appears when i got to the step that says i will create session bean for those entity classes, now while i'm doing this step i always stuck in the part of it : [enter image description here](https://i.stack.imgur.com/BiXoP.png) as you can see it always says scanning in progress and stuck on that, i didn't any solution for it no matter how i tried. i tried several things like restarting glassfish server, restarting netbeans, tried clean and build project option, none of them seemed to work, can someone please help me ??
entity classes are not showing when trying to create new session beans for entity classes in netbeans 9.0 (i'm using java 8)
|netbeans|java-8|ejb|java-ee-7|
null
I am wanting to create a status badge for my unit tests, using the following yaml I see examples where its individual steps but not when its layerd out like mine. You will see I have a step named Test below # This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating- builds-and-tests/building-and-testing-net name: MYAPI on: workflow_dispatch: {} push: branches: [ "dev-1-0-0-3" ] pull_request: branches: [ "dev-1-0-0-3" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore - name: Test run: dotnet test --no-build --verbosity normal
How do I create a test passing badge for my yaml below
`x` is a pointer to a single `vector`. You need to deference the `x` pointer before you can apply `operator[]` to that `vector`, eg: ``` vector<int> *ans = new vector<int>(); vector<int> *x = new vector<int>(); // put some elements in *x, then... ans->push_back((*x)[i]); ```
I am using this query to randomly select a row in the **user** table that has not already been inserted into the **task_pool** table, laterally done per id in **task_dispersal** table. ____ PostgreSQL 16.2 INSERT into task_pool(user_id, order_id) select u.user_id, task_dispersal.id from task_dispersal cross join lateral ( select user_id from users tablesample bernoulli(.1) repeatable(random()) where user_id not in ( select user_id from task_pool where order_id = task_dispersal.id ) order by random() limit 1) u ---- Is there anything that can be done to optimize this query? ---- *I added an "explain analyze verbose" Query Plan result at end of this post* **users** | user_id(serial key)| irellevant_columns| |:----: |:------:| | 1 | ~~~| | ... | ...| | 49156 | ~~~| **task_dispersal** | id(serial key)| irellevant_columns| |:----: |:------:| | 1 |~~~| | 2 |~~~| | ... | ...| | 100 | ~~~| **task_pool** | task_id(serial key)| order_id(not unique) | user_id (not unique)| |:----: |:------:| :-----:| | 1 | 5 | 267| | 2 | 55| 9,999| | ... | ... | ...| | 1 | 23 | 602| | 985187 | 5 | 15 | For example, let's say there's 100 rows in task_dispersal (therefore 100 order_ids). For each of those 100 order_ids, the query will chose a random user_id in the user_table, filtering out user_id's that have already been inserted into the task_pool for that order_id. The query above works great, but slows down as the amount of rows in users and task_pool increase (expected of course, I'd just hope to minimize the delay). Let's say I have 985187 rows in task_pool (so 985187 task_ids), 49156 rows in user table (49156 user_ids), and 100 rows in task_dispersal (100 order_ids). The query now takes ~9.5 seconds to complete. _______________ Here is the info with explain analyze verbose: "Insert on public.task_pool (cost=21150.09..2115016.50 rows=0 width=0) (actual time=9565.389..9565.390 rows=0 loops=1)" " -> Nested Loop (cost=21150.09..2115016.50 rows=100 width=28) (actual time=81.912..9562.038 rows=100 loops=1)" " Output: nextval('pool_task_id_seq'::regclass), task_dispersal.id, users.user_id, CURRENT_TIMESTAMP, NULL::integer, 0" " -> Seq Scan on public.task_dispersal (cost=0.00..4.00 rows=100 width=4) (actual time=0.019..0.147 rows=100 loops=1)" " Output: task_dispersal.id" " -> Limit (cost=21150.09..21150.10 rows=1 width=12) (actual time=95.599..95.599 rows=1 loops=100)" " Output: users.user_id, (random())" " -> Sort (cost=21150.09..21150.15 rows=24 width=12) (actual time=95.593..95.593 rows=1 loops=100)" " Output: users.user_id, (random())" " Sort Key: (random())" " Sort Method: top-N heapsort Memory: 25kB" " -> Sample Scan on public.users (cost=19563.30..21149.97 rows=24 width=12) (actual time=93.586..95.572 rows=47 loops=100)" " Output: users.user_id, random()" " Sampling: bernoulli ('0.1'::real) REPEATABLE (random())" " Filter: (NOT (hashed SubPlan 1))" " Rows Removed by Filter: 0" " SubPlan 1" " -> Seq Scan on public.task_pool task_pool_1 (cost=0.00..19560.84 rows=985 width=4) (actual time=9.673..93.218 rows=995 loops=100)" " Output: task_pool_1.user_id" " Filter: (task_pool_1.order_id = task_dispersal.id)" " Rows Removed by Filter: 984192" "Planning Time: 0.487 ms" "Execution Time: 9565.444 ms" ________ I don't assume this can really be optimized, but I'm still pretty new to SQL so I thought I'd ask here.
I am trying to write a personal project in JavaScript. So I started with an empty folder with two files: card.js constants.js and in `card.js`, I used on the first line: import { SUIT } from "./constants.js"; and run it using `node card.js`. It doesn't work, giving the error: > (node:91577) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. First, > set "type": "module" in the package.json I don't even have a package.json. Must I use it? Can I not use one? If I set "type": "module", does that make my own project become a module? Second, I have never seen any `.mjs` file ever before. What is it about? I can use that and forget everything about NodeJS or package.json? If I look at the [docs for import][1], it has: import { myExport } from "/modules/my-module.js"; So I used `mkdir modules` and moved that `constants.js` in there. And then I used: import { SUIT } from "/modules/constants.js" and it still has the same error. That doc doesn't not mention `package.json` whatsoever. I am wondering if this `import` is the same as `import` in the context of NodeJS (and so it may be different in Deno). How is it done? **P.S.** I renamed `constants.js` to `constants.mjs` and got the same error. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
**You are trying to add a class to an element based on the value of a range slider. there are a couple of issues in your code.** 1. The mousemove event is not suitable for detecting changes in the value of a range slider. you should use the input event. 2. The condition if (this.value == "1", "2", "3", "4", "5") is incorrect. You can't use multiple values like that in an equality check. You should use a range check instead. Here is the corrected code: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> $(document).ready(function() { $("#range-slider").on('input', function() { var value = parseInt($(this).val()); if (value >= 1 && value <= 5) { $('.other-element').addClass('is-active').html(`Slider Value is: ${value}`); } else { $('.other-element').removeClass('is-active'); } }); }); <!-- language: lang-css --> .other-element { margin-top: 20px; padding: 10px; background-color: lightblue; display: none; } .other-element.is-active { display: block; } <!-- language: lang-html --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <input type="range" id="range-slider" min="0" max="9"> <div class="other-element"></div> <!-- end snippet -->
I need to make a separator for new events in my ListView. ListView: return Expanded( child: ListView( physics: const AlwaysScrollableScrollPhysics(), key: ValueKey(selectedProject?.id), controller: _scrollController, children: [ ...eventsByDate.entries .map( (entry) => StickyHeader( header: Padding( padding: const EdgeInsets.only(top: 4, bottom: 4), child: Center( child: Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), decoration: BoxDecoration( color: ColorThemeApp.grayBackground, borderRadius: BorderRadius.circular(12), ), child: Text( formatDateLabel(entry.key), style: TextThemeApp.r12w400(context, color: ColorThemeApp.gray90), ), ), ), ), content: Column( children: [ ...entry.value .map( (event) => EventCard(list: event, contextEvent: widget.context), ) .toList(), ], ), ), ) .toList(), if (context.read<EventListBloc>().state.isPaginationRequesting) const Padding( padding: EdgeInsets.symmetric(vertical: 16.0), child: Center(child: CircularProgressIndicator()), ) else Container(), ], ), ); All I have is the number of new items (`selectedProject.newEventsCount`). Please tell me the best way to implement the separator. Wouldn't it be better to have an `isNew` flag for each event?
Can this query be optimized? (Choosing a random row to insert, that excludes previously inserted Rows)
|postgresql|
I'm attempting to retrieve data from the database that falls between `$booking_start_formatted` and `$booking_end` based on the `session_start` column. However, it only selects data earlier than `$booking_start_formatted`. ```php public function store(Request $request, Utils $utils) { $request->validate([ "user_id" => "required|int", "booking_start" => "required", ]); try { $booking_start = Carbon::parse($request->get("booking_start")); $booking_start_formatted = $booking_start->format("Y-m-d H:i:s"); $booking_end = $booking_start->addMinute(45)->format("Y-m-d H:i:s"); $booking = Bookings::query()->whereBetween("session_start", [$booking_start_formatted, $booking_end])->get(); return $utils->message("error", $booking, 400); } catch (\Throwable $e) { // Handle the exception return $utils->message("error", $e->getMessage(), 400); } } ``` The timestamp format I'm using is '2024-03-31 06:35:13'.
Laravel's whereBetween method not working with two timestamps
|php|laravel|timestamp|php-carbon|
In order to assign a Static IP address on your AWS Fargate task, you will have to create a static IP address (AWS calls this elastic IP address) that will serve as the origin address of traffic originating your VPC from network outsiders point of view. To implement this: You need the following - A VPC - 1x Private Subnet - 1x Public Subnet - 1x Internet Gateway attached to public subnet - An elastic IP address (will serve as a static IP address of all resources inside the private subnets) - 1x NAT Gateway - A route table attached to `private` subnet with route `0.0.0.0/0` pointing to the NAT Gateway - A route table attached to `public` subnet with route `0.0.0.0/0` pointing to the internet gateway You will then need to make sure that: - Your ECS Fargate task is using the VPC mentioned above (Use `awsvpc` as the network mode, and configure your ECS service to use the private subnet) - And that the private subnet(s) mentioned above is selected as the `service task placement` If my explanation is still confusing, you could try giving this [guide][1] a read. [1]: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-configure-network.html
Is there any mechanism to enable/disable "conversation view" programatically in Outlook? I see only four documented conversation-related properties: AlwaysExpandConversation, ShowConversationByDate, ShowConversationSendersAboveSubject, and ShowFullConversations. These all assume that "conversation view" is already applied. Am I missing something in terms of a property/method to turn conversation view on and off entirely?
I have a trivial application which is using version 3.6.1 of the Quarkus framework. ``` package net.example.dashboard.dbcli; import org.slf4j.*; import io.quarkus.runtime.Startup; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.ApplicationScoped; @Startup @ApplicationScoped public class Main { final Logger logger = LoggerFactory.getLogger(Main.class); @PostConstruct public void init() { System.out.println("App started"); logger.error("Logger says hello"); } } ``` If I run the built application in the JVM it works are expected: I see the text printed to the console, and I see my logger output displayed as well as some log output from the framework itself. ``` $ java -jar target/quarkus-app/quarkus-run.jar App started 2024-02-04 18:21:15,701 ERROR [net.exa.das.dbc.Main] (main) Logger says hello 2024-02-04 18:21:15,715 INFO [io.quarkus] (main) dbcli 1.0.0 on JVM (powered by Quarkus 3.6.1) started in 0.768s. 2024-02-04 18:21:15,719 INFO [io.quarkus] (main) Profile prod activated. 2024-02-04 18:21:15,719 INFO [io.quarkus] (main) Installed features: [cdi] ``` However when I run the application native image, I see messages indicating that no SLF4J provider was found, and I do not see my logger output. ``` $ target/dbcli SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. App started 2024-02-04 18:17:41,741 INFO [io.quarkus] (main) dbcli 1.0.0 native (powered by Quarkus 3.6.1) started in 0.030s. 2024-02-04 18:17:41,741 INFO [io.quarkus] (main) Profile prod activated. 2024-02-04 18:17:41,741 INFO [io.quarkus] (main) Installed features: [cdi] ``` It *seems* like the application was using SLF4Jv1 but the provider is SLF4Jv2, although I am not able to prove this. Has anyone encountered this before, or may could provide me some clues on how to better understand what is happening? My platform is: ``` OS: Oracle Linux 8 Java: OpenJDK 21.0.2+13-LTS GraalVM: Mandrel-23.1.2.0-Final (runs in container) Podman 4.0.2 (rootless) ``` pom.xml: ``` <?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>net.example.dashboard</groupId> <artifactId>dbcli</artifactId> <version>1.0.0</version> <properties> <compiler-plugin.version>3.8.1</compiler-plugin.version> <maven.compiler.parameters>true</maven.compiler.parameters> <maven.compiler.source>21</maven.compiler.source> <maven.compiler.target>21</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <quarkus-plugin.version>3.6.1</quarkus-plugin.version> <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> <quarkus.platform.version>3.6.1</quarkus.platform.version> <quarkus.package.output-name>dbcli</quarkus.package.output-name> <quarkus.package.add-runner-suffix>false</quarkus.package.add-runner-suffix> <quarkus.package.type>native</quarkus.package.type> <quarkus.banner.enabled>false</quarkus.banner.enabled> <quarkus.log.level>INFO</quarkus.log.level> <quarkus.log.console.enable>true</quarkus.log.console.enable> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>${quarkus.platform.group-id}</groupId> <artifactId>${quarkus.platform.artifact-id}</artifactId> <version>${quarkus.platform.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-arc</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus-plugin.version}</version> <executions> <execution> <goals> <goal>build</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${compiler-plugin.version}</version> <configuration> <release>21</release> </configuration> </plugin> <plugin> <groupId>org.jboss.jandex</groupId> <artifactId>jandex-maven-plugin</artifactId> <version>1.2.3</version> <executions> <execution> <id>make-index</id> <goals> <goal>jandex</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> ``` Also posted here: [Quarkus Development User Chat][1] [1]: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Quarkus.20native.20app.3A.20No.20SLF4J.20providers.20were.20found Adding maven dependency tree: ``` [INFO] --- dependency:3.6.0:tree (default-cli) @ dbcli --- [INFO] net.example.dashboard:dbcli:jar:1.0.0 [INFO] \- io.quarkus:quarkus-arc:jar:3.6.1:compile [INFO] +- io.quarkus.arc:arc:jar:3.6.1:compile [INFO] | +- jakarta.enterprise:jakarta.enterprise.cdi-api:jar:4.0.1:compile [INFO] | | +- jakarta.enterprise:jakarta.enterprise.lang-model:jar:4.0.1:compile [INFO] | | +- jakarta.el:jakarta.el-api:jar:5.0.1:compile [INFO] | | \- jakarta.interceptor:jakarta.interceptor-api:jar:2.1.0:compile [INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile [INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1:compile [INFO] | +- io.smallrye.reactive:mutiny:jar:2.5.1:compile [INFO] | | \- io.smallrye.common:smallrye-common-annotation:jar:2.1.2:compile [INFO] | \- org.jboss.logging:jboss-logging:jar:3.5.3.Final:compile [INFO] +- io.quarkus:quarkus-core:jar:3.6.1:compile [INFO] | +- jakarta.inject:jakarta.inject-api:jar:2.0.1:compile [INFO] | +- io.smallrye.common:smallrye-common-os:jar:2.1.2:compile [INFO] | +- io.quarkus:quarkus-ide-launcher:jar:3.6.1:compile [INFO] | +- io.quarkus:quarkus-development-mode-spi:jar:3.6.1:compile [INFO] | +- io.smallrye.config:smallrye-config:jar:3.4.4:compile [INFO] | | \- io.smallrye.config:smallrye-config-core:jar:3.4.4:compile [INFO] | | +- org.eclipse.microprofile.config:microprofile-config-api:jar:3.0.3:compile [INFO] | | +- io.smallrye.common:smallrye-common-classloader:jar:2.1.2:compile [INFO] | | \- io.smallrye.config:smallrye-config-common:jar:3.4.4:compile [INFO] | +- org.jboss.logmanager:jboss-logmanager:jar:3.0.2.Final:compile [INFO] | | +- io.smallrye.common:smallrye-common-constraint:jar:2.1.2:compile [INFO] | | +- io.smallrye.common:smallrye-common-cpu:jar:2.1.2:compile [INFO] | | +- io.smallrye.common:smallrye-common-expression:jar:2.1.2:compile [INFO] | | | \- io.smallrye.common:smallrye-common-function:jar:2.1.2:compile [INFO] | | +- io.smallrye.common:smallrye-common-net:jar:2.1.2:compile [INFO] | | +- io.smallrye.common:smallrye-common-ref:jar:2.1.2:compile [INFO] | | +- jakarta.json:jakarta.json-api:jar:2.1.3:compile [INFO] | | \- org.eclipse.parsson:parsson:jar:1.1.5:compile [INFO] | +- org.jboss.logging:jboss-logging-annotations:jar:2.2.1.Final:compile [INFO] | +- org.jboss.threads:jboss-threads:jar:3.5.1.Final:compile [INFO] | +- org.slf4j:slf4j-api:jar:2.0.6:compile [INFO] | +- org.jboss.slf4j:slf4j-jboss-logmanager:jar:2.0.0.Final:compile [INFO] | +- org.wildfly.common:wildfly-common:jar:1.7.0.Final:compile [INFO] | +- io.quarkus:quarkus-bootstrap-runner:jar:3.6.1:compile [INFO] | | +- io.smallrye.common:smallrye-common-io:jar:2.1.2:compile [INFO] | | \- io.github.crac:org-crac:jar:0.1.3:compile [INFO] | \- io.quarkus:quarkus-fs-util:jar:0.0.9:compile [INFO] \- org.eclipse.microprofile.context-propagation:microprofile-context-propagation-api:jar:1.3:compile ```
I'm using react-native-maps to create circles on a map. When a user applies a long press and then drags up or down, I dynamically adjust the radius of the circle. However, this approach is causing lagging issues. To mitigate this, I've implemented an animated view circle on the map. Now, the problem I'm facing is that I can't seem to adjust the size of my animated view circle to match the circle on the map. Initially, I set the map circle radius to 20 meters. However, when I zoom out, the map circle remains at 20 meters, while my animated view circle appears larger. I'm seeking a method to calculate the map circle radius in pixels so that I can adjust both circles to be the same size. Any insights on how to achieve this would be greatly appreciated. Thank you!
# Im trying to instance an object depending the role to set the data, here is my code: ``` <?php // Incluye la definición de las clases CUsuario y CDocente include_once('modelo/CUsuario.php'); include_once('modelo/CDocente.php'); // Verifica si el usuario está autenticado (aquí debes tener tu lógica de autenticación) if (isset($\_SESSION\['usuario'\])) { // Obtiene los datos del usuario de la sesión $usuario = $\_SESSION\['usuario'\]; `<?php // Incluye la definición de las clases CUsuario y CDocente include_once('modelo/CUsuario.php'); include_once('modelo/CDocente.php'); // Verifica si el usuario está autenticado (aquí debes tener tu lógica de autenticación) if (isset($_SESSION['usuario'])) { // Obtiene los datos del usuario de la sesión $usuario = $_SESSION['usuario']; // Obtiene el rol del usuario $rol = $usuario->getRol(); // Instancia el objeto según el rol del usuario if ($rol === 'Alumno') { $usuario = new CUsuario(); } elseif ($rol === 'Docente') { $usuario = new CDocente(); } // Obtiene los valores del correo y la contraseña $correo = $usuario->getCorreo(); $passwd = $usuario->getPasswd(); // Obtiene otros datos del usuario si los necesitas $nombre = $usuario->getNombre(); // Otros getters... // Imprime los valores echo "Correo: " . $correo . "<br>"; echo "Contraseña: " . $passwd . "<br>"; echo "Apepat: " . $usuario->getFecnac() . "<br>"; // Otros datos del usuario... $usuario->setDatos($usuario->getNum($correo, $passwd)); echo "<br>Nombre: " . $nombre . "<br>"; } else { // Si el usuario no está autenticado, puedes redirigirlo a la página de inicio de sesión // o mostrar un mensaje de error, dependiendo de la lógica de tu aplicación echo "El usuario no está autenticado."; } ?> ``` And here is the error: ``` Fatal error: Uncaught Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "CDocente" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in C:\xampp\htdocs\revistaEq1\vista\vstCuenta.php:12 Stack trace: #0 C:\xampp\htdocs\revistaEq1\control\ctrGeneral.php(21): include() #1 C:\xampp\htdocs\revistaEq1\index.php(29): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\revistaEq1\vista\vstCuenta.php on line 12 ``` The error only appears when the role is teacher, when de role is student it work good, creating the object and setting the data, thats why i say that maybe the problem is in the object of techaer or in this line:`$rol = $usuario-\>getRol();` La respuesta puede ser en español o en ingles. Thanks I try not to have errors, can create the teachers object and set my data without problems, i expect that someone can recognize this problem and know how to resolve it. If you need more information about the proyect or classes, you can tell me. Thanks
I solved it by cleaning the npm cache ``` npm cache clean --force ``` then delete `node_modules` and `package-lock.json` file and run ``` npm install ```
Using Malvin Lok's answer as a lead, I located `io.netty.handler.codec.http.HttpHeaders` and put a breakpoint for each `set*(..)` and `add*(..)` method. Here's what I found Default headers are added one by one in different places of Netty code. It's hard-coded, there are no injected strategies or configs. There's apparently nothing you can do about it 1. `Accept-Encoding` ```java // reactor.netty.http.client.HttpClient public final HttpClient compress(boolean compressionEnabled) { if (compressionEnabled) { if (!configuration().acceptGzip) { HttpClient dup = duplicate(); HttpHeaders headers = configuration().headers.copy(); headers.add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.GZIP); dup.configuration().headers = headers; dup.configuration().acceptGzip = true; return dup; } } ``` 2, 3, 4. `User-Agent`, `Host`, `Accept` ```java // reactor.netty.http.client.HttpClientConnect.HttpClientHandler Publisher<Void> requestWithBody(HttpClientOperations ch) { try { ch.resourceUrl = this.resourceUrl; ch.responseTimeout = responseTimeout; UriEndpoint uri = toURI; HttpHeaders headers = ch.getNettyRequest() .setUri(uri.getPathAndQuery()) .setMethod(method) .setProtocolVersion(HttpVersion.HTTP_1_1) .headers(); ch.path = HttpOperations.resolvePath(ch.uri()); if (!defaultHeaders.isEmpty()) { headers.set(defaultHeaders); } if (!headers.contains(HttpHeaderNames.USER_AGENT)) { headers.set(HttpHeaderNames.USER_AGENT, USER_AGENT); } SocketAddress remoteAddress = uri.getRemoteAddress(); if (!headers.contains(HttpHeaderNames.HOST)) { headers.set(HttpHeaderNames.HOST, resolveHostHeaderValue(remoteAddress)); } if (!headers.contains(HttpHeaderNames.ACCEPT)) { headers.set(HttpHeaderNames.ACCEPT, ALL); } ``` So it's Netty's "fault" after all
Basically, I am trying to remove special character from xml file. I have tried the below code. I have tested with regex tester. It's working fine. In the production machine, it is replacing string.Empty for = character which is valid. ``` using System; using System.Text.RegularExpressions; class Program { static void Main(string[] args) { string xmlString = "<root><name>John & = Doe</name></root>"; // Replace special characters with their XML entities string cleanedXml = Regex.Replace(xmlString, @"[^\u09\u0A\u0D\u20-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]", string.Empty); Console.WriteLine(cleanedXml); } } ``` Culture : en-US in the prod machine. Please anyone help me on this why it's happening. What's problem in the regex expression? Why regex is replacing equal symbol on prod machine alone? I am using. Net framework 4.8 version.
i am integrating tailwind with flowbite react but this error occured ``` npm ERR! code 1 npm ERR! path C:\\Users\\ASUS\\OneDrive\\Desktop\\Sankalp\\Frontend\\node_modules\\flowbite-react npm ERR! command failed npm ERR! command C:\\WINDOWS\\system32\\cmd.exe /d /s /c bun run build npm ERR! 'bun' is not recognized as an internal or external command, npm ERR! operable program or batch file. npm ERR! A complete log of this run can be found in: C:\\Users\\ASUS\\AppData\\Local\\npm-cache\\\_logs\\2024-03-31T07_04_56_478Z-debug-0.log PS C:\\Users\\ASUS\\OneDrive\\Desktop\\Sankalp\\Frontend\> ``` i am expecting tailwinnd and flowbite work properly but not working
I have product dimension, date dimension, Order fact. There is 1:M relation between dimension and fact. This is a simple star schema. In Order fact the OrderNumber column is unique. I want to introduce a new table into the model called Order suppliers. This table has OrderNumber, Supplier name Supplier location, Supplier code. In this table one OrderNumber can have multiple rows (suppliers). How best to add this table into the model such that user can drill through from the Order fact visual to the page showing Order supplier details. Should I extract and make a common dimension containing Order number that connects to Order and Order Supplier table?
Want descending order of data in hive: Requirement: Our requirement is we want to get pnote column in a way that data for particular invoice number should be in descending order. As we want to get the most recent date record from the top of the array (zeroth element) from pnote column. Currect outputs: 1. selecting concat_dispute_notes SELECT concat(to_date(gppprobnotes.modified_on),"-",b.named_user,"-",gppprobnotes.notes) as concat_dispute_notes FROM Table 1. output of concat_dispute_notes that we are getting. 2023-05-31-LMINCU2-chased for pym plan 2023-08-16-LMINCU2-chased for pym plan 2023-12-07-LMINCU2-chased for pym plan 2024-01-11-LMINCU2-chased for pym plan 2024-01-22-LMINCU2-chased for pym plan 2023-05-16-LMINCU2-chased for pym plan 2023-05-02-LMINCU2-chased for pym plan 2023-03-22-LMINCU2-chased for pym plan 2022-11-22-LMINCU2-chased for pym plan Time taken: 31.091 seconds, Fetched: 9 row(s) ------------------------------------------------------------------------------------------------------------------------------------------ 2. selecting pnote from concat_dispute_note Query-> SELECT concat_ws("... ",collect_set(case when trim(concat_dispute_notes) <>"" then concat_dispute_notes end)) as PNOTE from (SELECT concat(to_date(gppprobnotes.modified_on),"-",b.named_user,"-",gppprobnotes.notes) as concat_dispute_notes FROM Table 2. output of pnote that we are getting-> 2023-05-31-LMINCU2-chased for pym plan... 2023-08-16-LMINCU2-chased for pym plan... 2023-12-07-LMINCU2-chased for pym plan... 2024-01-11-LMINCU2-chased for pym plan... 2024-01-22-LMINCU2-chased for pym plan... 2023-05-16-LMINCU2-chased for pym plan... 2023-05-02-LMINCU2-chased for pym plan... 2023-03-22-LMINCU2-chased for pym plan... 2022-11-22-LMINCU2-chased for pym plan Time taken: 41.456 seconds, Fetched: 1 row(s) ------------------------------------------------------------------------------------------------------------------------------------------ **We have tried using order by but not getting required order of output SELECT concat_ws("... ",collect_set(case when trim(concat_dispute_notes) <>"" then concat_dispute_notes end)) as PNOTE from (SELECT concat(to_date(gppprobnotes.modified_on),"-",b.named_user,"-",gppprobnotes.notes) as concat_dispute_notes FROM Table) order by gppprobnotes.modified_on desc) as t2 order by PNOTE; **output by order by 2023-05-31-LMINCU2-chased for pym plan... 2023-08-16-LMINCU2-chased for pym plan... 2023-12-07-LMINCU2-chased for pym plan... 2024-01-11-LMINCU2-chased for pym plan... 2024-01-22-LMINCU2-chased for pym plan... 2023-05-16-LMINCU2-chased for pym plan... 2023-05-02-LMINCU2-chased for pym plan... 2023-03-22-LMINCU2-chased for pym plan... 2022-11-22-LMINCU2-chased for pym plan Time taken: 38.52 seconds, Fetched: 1 row(s) We tried sort_Array: SELECT concat_ws("...", sort_array(collect_set(case when trim(concat_dispute_notes) <> "" then concat_dispute_notes end))) as PNOTE FROM ( SELECT concat(to_date(gppprobnotes.modified_on), "-", b.named_user, "-", gppprobnotes.notes) as concat_dispute_notes FROM Table) AS Tablepnote11; Output of Sort_Array: 2022-11-22-LMINCU2-chased for pym plan...2023-03-22-LMINCU2-chased for pym plan...2023-05-02-LMINCU2-chased for pym plan...2023-05-16-LMINCU2-chased for pym plan...2023-05-31-LMINCU2-chased for pym plan...2023-08-16-LMINCU2-chased for pym plan...2023-12-07-LMINCU2-chased for pym plan...2024-01-11-LMINCU2-chased for pym plan...2024-01-22-LMINCU2-chased for pym plan Time taken: 31.719 seconds, Fetched: 1 row(s) The output of sort array is Ascending order. We need descending order. ------------------------------------------------------------------------------------------------------------------------------------------ We have also tried sort by, cluster by, reverse sort, sort_array(---,false) but did not get required output. we have tried all the above tried using Sort_Array which sort in Ascending order, tried ranking, sort_by, cluster_by, order_by, group_by, Reverse_array sort array(,false) but nothing worked to get it in descending order as a single record.
Apps script documentation appears to suggest it is possible to copy a table from one slide to another - but I can't seem to get it to work. This is the script I've used - any thoughbts on what I'm doing wrong? Here's a [link][1] to an example of it in "use". ``` /** * @OnlyCurrentDoc */ /* Instructions copied from https://developers.google.com/apps-script/reference/slides/slide#insertShape(ShapeType) // Copy a table between presentations. var otherPresentationSlide = SlidesApp.openById('presentationId').getSlides()[0]; var currentPresentationSlide = SlidesApp.getActivePresentation().getSlides()[0]; var table = otherPresentationSlide.getTables[0]; currentPresentationSlide.insertTable(table); // Also available for Layout, Master, and Page.*/ function test(){ var slide2 = SlidesApp.getActivePresentation().getSlides()[1]; var table = SlidesApp.getActivePresentation.getPageElementById('g2c6eee07fad_0_0').asTable(); slide2.insertTable(table); ``` [1]: https://docs.google.com/presentation/d/1927tG-7Sx3oRtFaQMfq-we4pn0pbnT_9Ag1qaQDJ3Yw/edit?usp=sharing
Problem interpreting how to copy / paste tables within a presentation using apps script