mirror of
https://github.com/djohnlewis/stackdump
synced 2024-12-04 15:07:36 +00:00
1 line
253 KiB
JSON
1 line
253 KiB
JSON
{"items":[{"tags":["java","macos","gradle","java-home"],"owner":{"reputation":1,"user_id":8525077,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b0d94eb2b8ac2db09cfb92949dd05ed9?s=128&d=identicon&r=PG&f=1","display_name":"Sanjay","link":"https://stackoverflow.com/users/8525077/sanjay"},"is_answered":false,"view_count":15,"answer_count":0,"score":-1,"last_activity_date":1623258356,"creation_date":1623233893,"last_edit_date":1623258356,"question_id":67902148,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67902148/java-home-inconsistent-type-for-assignment-why-this-issue-occurs-after-updatin","title":"JAVA_HOME: inconsistent type for assignment, why this issue occurs after updating the JAVA_HOME in zshrc and how to fix it?","body":"<p>I am switching between java 8 and java 11 for some reason recently after updating the JAVA_HOME , I see a problem in IntelliJ IDEA for my Gradle project. so I am trying from scratch to setup java in Mac. but stuck with this inconsistent issue.</p>\n<blockquote>\n<p>Process 'command '/Applications/IntelliJ IDEA CE.app/Contents/jbr/Contents/Home/bin/java'' finished with non-zero exit value 1</p>\n</blockquote>\n"},{"tags":["java","java-11","javacompiler"],"owner":{"reputation":1,"user_id":16175596,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJwNpfZ0IpWyOuHI_HzCUiLsfRQy09t3NTgeZ2ZC=k-s128","display_name":"RASHIKA SACHAN","link":"https://stackoverflow.com/users/16175596/rashika-sachan"},"is_answered":false,"view_count":20,"answer_count":0,"score":-1,"last_activity_date":1623258353,"creation_date":1623241696,"last_edit_date":1623258353,"question_id":67904137,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67904137/different-date-format-result-on-jdk8-vs-jdk11","title":"Different date format result on jdk8 vs jdk11","body":"<p>I have written this piece of code. When I am running on JDK 8, output is <code>mm-dd-yyyy</code>. When running JDK 11, the output is <code>yyyy-dd-mm</code>. How can I output <code>mm-dd-yyyy</code> regardless of JDK version?</p>\n<pre class=\"lang-java prettyprint-override\"><code> public static void main(String args[]){\n \n SimpleDateFormat sdfMedium =(SimpleDateFormat)DateFormat.getDateInstance(DateFormat.MEDIUM,newLocale(“en-US”)));\n \n System.out.println("Medium Format: "sdfMedium.toPattern());\n</code></pre>\n<ul>\n<li>we cannot hard code</li>\n<li>also can not use default method.</li>\n</ul>\n"},{"tags":["java","distributed-computing","apache-storm","stream-processing"],"owner":{"reputation":57,"user_id":13847890,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5088050f68218225a54898db760d2143?s=128&d=identicon&r=PG&f=1","display_name":"moosehead42","link":"https://stackoverflow.com/users/13847890/moosehead42"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258353,"creation_date":1623258353,"question_id":67908714,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908714/why-doesnt-apache-storms-nimbus-generate-any-logs","title":"Why doesn`t Apache Storms Nimbus generate any logs?","body":"<p>I worked quite a while with Apache Storm in a distributed setting. But currently, I faced a strange situation.</p>\n<p>I ran a Storm Cluster with the Nimbus node on the host <code>nodes1</code>.\nMy <code>storm.yaml</code> is quite simple:</p>\n<pre><code>storm.zookeeper.servers: \n - "nodes1"\nstorm.local.dir: /tmp/storm\nnimbus.seeds: ["nodes1"]\nui.port: 8081\nsupervisor.slots.ports: \n - 6700\n</code></pre>\n<p>I doublechecked that the Storm nimbus is running, I can run <code>storm list</code> for example. Looking on my syslog gives the same information, so Storm Nimbus is active and running.</p>\n<p>But my problem is, that my <code>nimbus.log</code> stays empty and is not written!</p>\n<p><strong>So, why logging does not work and how to repair this?</strong>\nI have not modified any log4j-Files.</p>\n"},{"tags":["python","sql","postgresql"],"owner":{"reputation":27,"user_id":14110251,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9a26ef883bc2858767675b3f7296f02a?s=128&d=identicon&r=PG&f=1","display_name":"Bcat13","link":"https://stackoverflow.com/users/14110251/bcat13"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258348,"creation_date":1623258348,"question_id":67908713,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908713/postgresql-unable-to-add-record-to-table","title":"PostgreSQL- Unable to add record to table","body":"<p>I'm very new to SQL, and am trying to add a record to a table. I debugged my code and have already successfully made a database with a table called "weather." However, when I try to insert a record into the table and then print the table, no data prints in Terminal. I was wondering what I am doing wrong. Thank you.</p>\n<pre><code>conn = psycopg2.connect(database="postgres", user='postgres',password='password', host='127.0.0.1', port= '5432' )\nconn.autocommit = True\ncursor = conn.cursor()\ncursor.execute('''INSERT INTO WEATHER (HUMIDITY, CITY, FEELSLIKE, HIGHLOW, TEMPERATURE) VALUES ('{%s}', '{%s}', '{%s}', '{%s}', '{%s}')'''), (humidityVal, cityVal, feelslikeVal, highlowVal, tempVal)\ncursor.execute('''SELECT * from WEATHER''')\nresult = cursor.fetchall()\nprint(result) \nconn.close()\n</code></pre>\n"},{"tags":["python","scripting"],"owner":{"reputation":1,"user_id":16178272,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJxjSDhNZRoyhnVDnqPgRd7S7GxYTLWD401Yy3ih=k-s128","display_name":"Kirsten B.","link":"https://stackoverflow.com/users/16178272/kirsten-b"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258345,"creation_date":1623258345,"question_id":67908711,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908711/i-cant-figure-out-the-date-time-python-doesnt-work","title":"I cant figure out the date time... python, doesnt work","body":"<pre><code>import datetime \n\ndef convert_to_mysql_date(input_date):\n</code></pre>\n<p>if not input_date:\nreturn "NULL"\nreturn (\ndatetime.dateime.strptime(input_date, "%m/%d/%Y").date().strftime("%Y/%m/%d")\n)</p>\n<p>for purchase in processed_response:\npurchase_date = datetime.datetime(2019, 1, 1)</p>\n<p>My brain has been working on it for days now.... if some guy can help me!!! :(</p>\n"},{"tags":["javascript","css","google-chrome","pdf"],"owner":{"reputation":77,"user_id":10624531,"user_type":"registered","profile_image":"https://graph.facebook.com/2232219823478884/picture?type=large","display_name":"Felipe Augusto Gonalves Basili","link":"https://stackoverflow.com/users/10624531/felipe-augusto-gonalves-basili"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258343,"creation_date":1623258343,"question_id":67908710,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908710/bug-on-google-chrome-when-showing-pdf","title":"Bug on google Chrome when showing PDF","body":"<p>Recently a have been faced with a problem on Google Chrome I don't know if this error is in the google or in my code;</p>\n<p>If set the div as display: none; and show it again the PDF-view show only grey background; if I do a zoom in or out, it appears again;</p>\n<p>To illustrate the error a took theses screenshots;</p>\n<p>My Google Chrome version is 91.0.4472.77 64 bits</p>\n<p><a href=\"https://i.stack.imgur.com/TPI0f.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/TPI0f.png\" alt=\"enter image description here\" /></a></p>\n<p>After display:none</p>\n<p><a href=\"https://i.stack.imgur.com/n4HlS.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/n4HlS.png\" alt=\"enter image description here\" /></a></p>\n"},{"tags":["javascript","google-sheets-api"],"owner":{"reputation":11,"user_id":15790364,"user_type":"registered","profile_image":"https://lh6.googleusercontent.com/-Wl25wDidqNY/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuclne4ErijuCUDv6MilqD0L9JrTI8Q/s96-c/photo.jpg?sz=128","display_name":"light1","link":"https://stackoverflow.com/users/15790364/light1"},"is_answered":false,"view_count":12,"answer_count":1,"score":0,"last_activity_date":1623258341,"creation_date":1623255411,"question_id":67908008,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908008/how-to-delete-row-in-google-sheets-using-api-v4-in-javascript","title":"how to delete row in google sheets using api v4 in Javascript?","body":"<pre><code> var params1 = {\n spreadsheetId: 'Id', \n range: "sheet 1!A2",\n };\n \n var clearValuesRequestBody = {\n };\n \n var request = await gapi.client.sheets.spreadsheets.values.clear(params1, clearValuesRequestBody);\n</code></pre>\n<p>I am trying to delete a row in google sheets using google sheets API in javascript. But I am able to delete only the first cell of the row. I believe there has to be something in clear values request body but I don't know what. Also if you can suggest me how to remove that blank row that has been created by deleting this row, that would be great.</p>\n"},{"tags":["c#","date-formatting","c#-5.0","c#-8.0"],"owner":{"reputation":1,"user_id":15571409,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e35a5532bc78f79f0a446c7338c74408?s=128&d=identicon&r=PG&f=1","display_name":"kumar","link":"https://stackoverflow.com/users/15571409/kumar"},"is_answered":false,"view_count":46,"closed_date":1623243697,"answer_count":2,"score":-3,"last_activity_date":1623258337,"creation_date":1623243138,"last_edit_date":1623258337,"question_id":67904537,"link":"https://stackoverflow.com/questions/67904537/how-to-convert-different-dates-with-string-format-to-specific-format-like-yyyymm","closed_reason":"Duplicate","title":"How to convert different dates with string format to specific format like YYYYMMDD","body":"<p>I am trying to convert different string date formats to a specific format i.e., YYYYMMDD and all the incoming dates are valid. How can I return a new list of strings representing this format</p>\n"},{"tags":["r","ggplot2","rstudio","data-visualization","bar-chart"],"owner":{"reputation":1,"user_id":15197952,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgejEfm71-nDZK6wiJlcsyQK7OQ0Uu86aE40yR95g=k-s128","display_name":"Spanias Charalampos","link":"https://stackoverflow.com/users/15197952/spanias-charalampos"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258334,"creation_date":1623258334,"question_id":67908708,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908708/ggplot2-r-percent-stacked-barchart-with-multiple-variables","title":"ggplot2 R : Percent stacked barchart with multiple variables","body":"<p>R version 4.0.5 (2021-03-31)\nPlatform: x86_64-w64-mingw32/x64 (64-bit)\nRunning under: Windows 10 x64 (build 19042)</p>\n<p>I want to create a percent stacked barchart including 2 groups (regional, international) and the means of 4 different numerical variables (ground low-intensity, ground high-intensity, standing low-intensity, standing high-intensity). The latter variables are representing the duration of each time period in seconds.</p>\n<p>My data are:\n<a href=\"https://i.stack.imgur.com/Uzmnm.png\" rel=\"nofollow noreferrer\">dataset</a></p>\n<p>The image below represents an example of what I kind want to make:\n<a href=\"https://i.stack.imgur.com/qAxBl.png\" rel=\"nofollow noreferrer\">Time-motion analysis description relative to total fight time, considering modalities and positions of actions Coswig, V. S., Gentil, P., Bueno, J. C., Follmer, B., Marques, V. A., & Del Vecchio, F. B. (2018). Physical fitness predicts technical-tactical and time-motion profile in simulated Judo and Brazilian Jiu-Jitsu matches. PeerJ, 6, e4851.</a></p>\n<p>I have read a lot of guides and watched many YT tutorials, but most of them are using 2 categorical and 1 numerical variable, thus, it does not work in my case.</p>\n<p>Any help or guidance would be highly appreciated.</p>\n<p>Thank you in advance.</p>\n"},{"tags":["javascript","html","function","dropdown","html-select"],"owner":{"reputation":69,"user_id":10215791,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5fac0f428cbf0b557252f469f82981cd?s=128&d=identicon&r=PG&f=1","display_name":"QuestionsAndAnswers","link":"https://stackoverflow.com/users/10215791/questionsandanswers"},"is_answered":false,"view_count":17,"answer_count":0,"score":0,"last_activity_date":1623258330,"creation_date":1623257859,"last_edit_date":1623258330,"question_id":67908604,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908604/search-function-not-working-and-not-showing-results-in-html-element","title":"Search function not working and not showing results in html element","body":"<p>I am creating a web page, on which by clicking the dropdown options and then clicking the Display-button the user can search and load search results of external library web page url into my web page. By clicking the search-button, my web page should fire/call setSearchParameters() -function (which calls other functions related to those specific dropdown options) and load the search results on my webpage.</p>\n<p>I have checked answers on Stackoverflow from different threads (also those automatically suggested as writing this question), but nothing seems to work. Here is my code so far. Onclick-event by clicking the Display-button should call setSearchParameters() -function and load the results for example on form element.</p>\n<p>The problem with my code right now is that when I choose options from the dropdown list and click the Display-button, it does not load the search results at all. It does not show/display any results. I tried Axios for creating search functions for certain dropdown option combinations.</p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-html lang-html prettyprint-override\"><code><!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n <title>Page for library search</title>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css\">\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js\"></script>\n <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js\"></script>\n\n <!--JQuery-libraries: -->\n <link rel=\"stylesheet\" href=\"//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css\">\n <link rel=\"stylesheet\" href=\"/resources/demos/style.css\">\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js\"></script>\n <!-- Axios -->\n <script src=\"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js\"></script>\n\n <script>\n function getFinnishBooks() {\n axios.get('https://finna.fi/Search/Results?limit=0&filter%5B%5D=%7Eformat%3A%220%2FBook%2F%22&filter%5B%5D=%7Elanguage%3A%22fin%22&type=AllFields')\n .then(res => {\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function getEnglishBooks() {\n axios.get('https://finna.fi/Search/Results?limit=0&filter%5B%5D=%7Eformat%3A%220%2FBook%2F%22&filter%5B%5D=%7Elanguage%3A%22fin%22&filter%5B%5D=%7Elanguage%3A%22eng%22&type=AllFields')\n .then(res => {\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function getFinnishRecordings() {\n axios.get('https://finna.fi/Search/Results?sort=relevance&bool0%5B%5D=AND&lookfor0%5B%5D=&type0%5B%5D=AllFields&lookfor0%5B%5D=&type0%5B%5D=AllFields&join=AND&filter%5B%5D=%7Elanguage%3A%22fin%22&filter%5B%5D=%7Eformat%3A%220%2FSound%2F%22&limit=20')\n .then(res => {\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function getEnglishRecordings() {\n axios.get('https://finna.fi/Search/Results?sort=relevance&bool0%5B%5D=AND&lookfor0%5B%5D=&type0%5B%5D=AllFields&lookfor0%5B%5D=&type0%5B%5D=AllFields&join=AND&filter%5B%5D=%7Elanguage%3A%22eng%22&filter%5B%5D=%7Eformat%3A%220%2FSound%2F%22&limit=20');\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function setSearchParameters() {\n const choice = select.value;\n\n if (choice == 'books' && choice == 'finnish') {\n getFinnishBooks();\n\n } else if (choice == 'books' && choice == 'english') {\n getEnglishBooks();\n } else if (choice == 'books' && choice == 'swedish') {\n getEnglishBooks();\n } else if (choice == 'recordings' && choice == 'finnish') {\n getFinnishRecordings();\n } else if (choice == 'recordings' && choice == 'english') {\n getFinnishRecordings();\n\n else if (choice == 'recordings' && choice == 'swedish') {\n getFinnishRecordings();\n }\n }\n </script>\n\n</head>\n\n<body>\n <!-- /*Style begins*/ -->\n <style>\n .navbar-custom .navbar-brand,\n .navbar-custom .navbar-text {\n color: #FFFFFF;\n }\n /* Modify the background color */\n \n .navbar-custom {\n /*background-color: #AB47BC;*/\n background-color: #4A148C;\n }\n \n .navbar-collapse .collapse {\n color: #FFFFFF;\n }\n \n .dropdown {\n background-color: #FFEBEE;\n }\n \n iframe {\n width: 400px;\n height: 200px;\n border: 1px solid black;\n border-radius: 5px;\n }\n </style>\n <!-- /* Style ends */ -->\n <div class=\"jumbotron text-center\">\n <h1>Search library books and other stuff!</h1>\n <p>Search library books, recordings and other products from the library selection</p>\n </div>\n <!-- /*\n\n*/ -->\n <div class=\"container\">\n <div class=\"example\">\n <script type=\"text/javascript\">\n $(document).ready(function() {\n $('#option-droup-demo').multiselect({\n enableClickableOptGroups: true\n });\n });\n </script>\n <select id=\"option-droup-demo\" multiple=\"multiple\">\n <optgroup label=\"Material\">\n <option value=\"books\">Books</option>\n <option value=\"recordings\">Recordings</option>\n <optgroup label=\"Languages\">\n <option value=\"finnish\">Finnish</option>\n <option value=\"english\">English</option>\n <option value=\"swedish\">Swedish</option>\n </optgroup>\n </select>\n </div>\n </div>\n </div>\n <form>\n <!-- <button type=\"submit\" onclick=\"return setSearchParameters();\">Submit</button> -->\n <input type=\"button\" onclick=\"setSearchParameters()\" value=\"Display\">\n </form>\n</body>\n<footer class=\"bg-light text-center text-lg-start\">\n <div class=\"text-center p-3\" style=\"background-color: rgba(0, 0, 0, 0.2); margin-top: 1%; background-color: #4A148C; color: #FFFFFF; margin-bottom:0%\">\n\n <a class=\"text-white\" href=\"https://finna.fi/\">Original page</a>\n </div>\n</footer>\n\n</html></code></pre>\r\n</div>\r\n</div>\r\n</p>\n"},{"tags":["firebase","google-cloud-firestore","google-cloud-functions","terraform","terraform-provider-gcp"],"owner":{"reputation":93,"user_id":7470153,"user_type":"registered","accept_rate":47,"profile_image":"https://www.gravatar.com/avatar/6c64f335fd8807dc41a4a72a34f02921?s=128&d=identicon&r=PG&f=1","display_name":"insta catering","link":"https://stackoverflow.com/users/7470153/insta-catering"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258327,"creation_date":1623258327,"question_id":67908707,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908707/is-there-any-way-to-setup-firestore-triggers-stemming-from-multiple-firestore-co","title":"Is there any way to setup firestore triggers stemming from multiple firestore collections to trigger only one cloud (javascript) function?","body":"<p>So typically, on a basic level, you often see firestore collection triggered functions written like:</p>\n<pre><code>exports.myFunction = functions.firestore\n .document('my-collection/{docId}')\n .onWrite((change, context) => { /* ... */ });\n</code></pre>\n<p>That being said, I am running my deployments a bit different, although structurally identical.</p>\n<ul>\n<li>I have a exports.main = (content, event) where:\n<ul>\n<li>event holds the EVENT information:</li>\n<li>eventId (e.x: 66e9e123-d3fg-1234-123a-1234f110b71b-0)</li>\n<li>eventType (e.x: providers/cloud.firestore/eventTypes/document.create)</li>\n<li>notSupported (e.x: {})</li>\n<li>params (e.x: {eventId: 1CB89AD0-5AS0-1233-SD70-E3B7DS52D23D})</li>\n<li>resource (e.x: projects/its-the-project-id/databases/(default)/documents/TheCollection/1CB89AD0-5AS0-1233-SD70-E3B7DS52D23D</li>\n<li>timestamp (e.x: 2021-05-19T20:00:24.131151Z)</li>\n</ul>\n</li>\n<li>and content is, well, the data</li>\n</ul>\n<p>I deploy the functions via Terraform where I define:</p>\n<ul>\n<li>event_trigger:\n<ul>\n<li>event_type = providers/cloud.firestore/eventTypes/document.create</li>\n<li>resource = ${TheCollection}/{eventId}</li>\n</ul>\n</li>\n</ul>\n<p>So as you can see, while the way I do it is certainly requires more configuration, it's very much identical, it's just configured in a more GCP-able fashion (if you will)</p>\n<p>So, with that context:</p>\n<ol>\n<li>Is there any possible way to have more than one collection/document trigger, trigger only 1 cloud function?\n<ul>\n<li>So say I have collection x and collection y, I want them both to trigger the same cloud function</li>\n</ul>\n</li>\n<li>If there is a way, feel free to write it in the oftenly written Firebase-able fashion and I can try to translate that over to be deployable in Firestore</li>\n</ol>\n"},{"tags":["python","pandas","numpy"],"owner":{"reputation":1,"user_id":16177507,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJzVUrgLWzXXQ4nMgSlMHHXbqYRlt1h7DjYofVHw=k-s128","display_name":"Pi R","link":"https://stackoverflow.com/users/16177507/pi-r"},"is_answered":false,"view_count":20,"answer_count":0,"score":-1,"last_activity_date":1623258326,"creation_date":1623255006,"last_edit_date":1623258326,"question_id":67907898,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907898/using-numpy-to-compute-the-squared-sum-of-distances-between-values","title":"Using numpy to compute the squared sum of distances between values","body":"<p>I am a newbie in python and stackoverflow. I am trying to change my way of thinking about loops.\nI have a series of values which type is <class 'pandas.core.series.Series'>.</p>\n<p><strong>Goal:</strong> Giving a depth n, I would like to compute for each value (except the first 2*n-2) :</p>\n<pre><code>result(i) = sum[j=0 to n-1](distance(i,j)*value[i-j])/sum[j=0 to n-1](distance[j])\n\nwith distance(i,j) = sum[k=1 to n-1]((value[i-j]-value[i-j-k])^2)\n</code></pre>\n<p>I want to avoid loops, so is there a better way to achieve my goal using numpy?</p>\n"},{"tags":["mysql","node.js","docker","docker-compose","sequelize.js"],"owner":{"reputation":1,"user_id":15919166,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/15419b912a5c2d50aaf5035a516bc290?s=128&d=identicon&r=PG&f=1","display_name":"Lagoss","link":"https://stackoverflow.com/users/15919166/lagoss"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258322,"creation_date":1623258322,"question_id":67908706,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908706/throw-new-sequelizeerrors-connectionerrorerr","title":"throw new SequelizeErrors.ConnectionError(err);","body":"<p>I'm creating a project with docker-compose sequelize nodejs and mysql, where mysql is running in docker-compose, but when I go to do an insert it tells me:</p>\n<pre><code>/usr/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116\napp_1 | throw new SequelizeErrors.ConnectionRefusedError(err);\napp_1 | ^\napp_1 | \napp_1 | ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3308\napp_1 | at ConnectionManager.connect (/usr/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116:17)\napp_1 | at processTicksAndRejections (node:internal/process/task_queues:96:5)\napp_1 | at async ConnectionManager._connect (/usr/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)\napp_1 | at async /usr/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32\napp_1 | at async ConnectionManager.getConnection (/usr/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)\napp_1 | at async /usr/app/node_modules/sequelize/lib/sequelize.js:613:26\napp_1 | at async MySQLQueryInterface.insert (/usr/app/node_modules/sequelize/lib/dialects/abstract/query-interface.js:749:21)\napp_1 | at async User.save (/usr/app/node_modules/sequelize/lib/model.js:3954:35)\napp_1 | at async Function.create (/usr/app/node_modules/sequelize/lib/model.js:2207:12)\napp_1 | at async createUser (/usr/app/src/controllers/UserController.js:11:18) {\napp_1 | parent: Error: connect ECONNREFUSED 127.0.0.1:3308\napp_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1133:16) {\napp_1 | errno: -111,\napp_1 | code: 'ECONNREFUSED',\napp_1 | syscall: 'connect',\napp_1 | address: '127.0.0.1',\napp_1 | port: 3308,\napp_1 | fatal: true\napp_1 | },\napp_1 | original: Error: connect ECONNREFUSED 127.0.0.1:3308\napp_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1133:16) {\napp_1 | errno: -111,\napp_1 | code: 'ECONNREFUSED',\napp_1 | syscall: 'connect',\napp_1 | address: '127.0.0.1',\napp_1 | port: 3308,\napp_1 | fatal: true\napp_1 | }\napp_1 | }\napp_1 | [nodemon] app crashed - waiting for file changes before starting...\n\n</code></pre>\n<p>I'm going to put the file in which I connect to the database and my docker-compose file</p>\n<p>connect to database:</p>\n<pre><code>require("dotenv").config();\n\nmodule.exports = {\n dialect: 'mysql',\n host: process.env.HOST,\n port: 3308,\n username: process.env.USER,\n password: process.env.PASSWORD,\n database: process.env.DATABASE,\n define: {\n timestamps: true,\n underscored: true,\n }\n };\n</code></pre>\n<p>the HOST is = localhost,</p>\n<p>I tested the connection in dbeaver and it connected normally, I also managed to create my migrations, only when inserting data using postman, it doesn't work,</p>\n<p>this is my docker-compose:</p>\n<pre><code>version: '3.7'\nservices: \n db:\n container_name: 'database-node'\n image: mysql:8.0.25\n command: --default-authentication-plugin=mysql_native_password\n restart: always\n ports: \n - '3308:3306'\n environment: \n - MYSQL_ROOT_PASSWORD=root\n - TZ=America/Sao_Paulo \n \n app: \n build: .\n command: npm start\n ports: \n - '3090:3090'\n volumes: \n - .:/usr/app\n</code></pre>\n"},{"tags":["firebase","firebase-security","firebase-app-check"],"owner":{"reputation":63,"user_id":16164526,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyzeHn9qZzhpeZmzhTrZRfOgyqUOqLwtCcLmhof=k-s128","display_name":"Pooja","link":"https://stackoverflow.com/users/16164526/pooja"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258319,"creation_date":1623258319,"question_id":67908705,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908705/which-data-should-i-hide-to-prevent-unwanted-access-to-my-firebase-database","title":"Which data should I hide to prevent unwanted access to my firebase database?","body":"<p>Firebase provides strong security rules and recently they have introduced Firebase App Check at I/O 2021. All these are good security measures. But even if I do not enforce App Check and write the rules as:</p>\n<pre><code>".read": true\n".write": true\n</code></pre>\n<p>Which information is used by others to access my database and how can I hide those informations?</p>\n"},{"tags":["php","mysql","amazon-web-services"],"owner":{"reputation":1,"user_id":16177988,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ggl42f5-jHqDBg4IxFVIiRLvuLEPpP4l4XeSO-o=k-s128","display_name":"Codest BD","link":"https://stackoverflow.com/users/16177988/codest-bd"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258310,"creation_date":1623258310,"question_id":67908704,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908704/why-not-write-data-mariadb-database-in-aws-server","title":"Why not write data mariadb database in aws server","body":"<p>I have installed aapanel in AWS server. I transfered my website to aws from namecheap shared hosting. when I transfered my website in aws website work normally without withdraw page. Then I tried in xampp server its work fine. All time not work in AWS server. [Problem: Not write data in database]</p>\n<pre><code><?php \n include('config.php');\n session_start();\n $uid=$_SESSION['user']['user_id'];\n date_default_timezone_set('Asia/Dhaka');\n $date=date("Y-m-d h:i");\n $status=1;\n\n $statement290 = $pdo->prepare("SELECT * FROM tbl_member WHERE user_id=?");\n $statement290->execute(array($uid));\n $result290 = $statement290->fetchAll(PDO::FETCH_ASSOC);\n foreach ($result290 as $row290){\n $wcredit=$row290['credit'];\n }\n $amount=$_POST['withdraw_amount']+10;\n \n if \n ($amount >= $wcredit)\n {\n $status=0;\n echo json_encode(array("wstatues"=>"<div role='alert' class='alert alert-danger'>\n <strong>Your withdraw amount is more than your balance!</strong>\n </div>"));\n }\n else if \n ($amount < 500)\n {\n $status=0;\n echo json_encode(array("wstatues"=>"<div role='alert' class='alert alert-danger'>\n <strong>Minimum withdraw 500tk !</strong>\n </div>"));\n }\n if ($status==1){\n\n $state = $pdo->prepare("SELECT * FROM tbl_member WHERE user_id=?");\n $state->execute(array($uid));\n $results = $state->fetchAll(PDO::FETCH_ASSOC);\n foreach ($results as $row) {\n $credit = $row['credit'];\n }\n $final_amount = $credit-$_POST['withdraw_amount'];\n $statement = $pdo->prepare("UPDATE tbl_member SET credit=? WHERE user_id=?");\n $statement->execute(array($final_amount,$uid));\n $a="0";\n $statement = $pdo->prepare("INSERT INTO tbl_withdraw (request_by, amount, method, send_to, account_type, date, withdraw_status) VALUES (?,?,?,?,?,?,?)");\n $statement->execute(array($uid,$_POST['withdraw_amount'],$_POST['withdraw_method'],$_POST['withdraw_to'],$_POST['account_type'],$date,$a));\n\n echo json_encode(array("wstatues"=>"<div role='alert' class='alert alert-success'>\n <strong>Your withdraw has been successfully requested!</strong>\n </div>"));\n $id = $pdo->lastInsertId();\n $detail="Withdraw Request By You";\n $date=date("Y-m-d h:i");\n $type="Withdraw-R";\n $statement2 = $pdo->prepare("INSERT INTO tbl_transaction \n (detail_id, type, description,transaction_date,user_balance)\n VALUES (?,?,?,?,?)");\n $statement2->execute(array($id,$type,$detail,$date,$final_amount));\n }\n?>\n</code></pre>\n"},{"tags":["java","spring-boot","spring-security","oauth-2.0","spring-security-oauth2"],"owner":{"reputation":576,"user_id":7773888,"user_type":"registered","accept_rate":40,"profile_image":"https://i.stack.imgur.com/iVXmp.jpg?s=128&g=1","display_name":"raviraja","link":"https://stackoverflow.com/users/7773888/raviraja"},"is_answered":false,"view_count":19,"bounty_amount":150,"bounty_closes_date":1623862135,"answer_count":0,"score":0,"last_activity_date":1623258304,"creation_date":1623084471,"last_edit_date":1623258304,"question_id":67875673,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67875673/spring-security-with-oauth2-0-and-form-login","title":"Spring Security with oAuth2.0 and form login","body":"<p>In my Spring Boot application, i am having form based login and oAuth2.0 based login with Google, my security configuration is defined as</p>\n<pre><code> http\n .cors()\n .and()\n .sessionManagement()\n .sessionCreationPolicy(SessionCreationPolicy.STATELESS)\n .and()\n .csrf()\n .disable()\n .authorizeRequests()\n .antMatchers("/oauth2/**")\n .permitAll()\n .anyRequest()\n .authenticated()\n .and()\n .addFilter(new JWTAuthenticationFilter(authenticationManager()))\n .addFilter(jwtAuthorizationFilter)\n .formLogin()\n .and()\n .oauth2Login()\n .authorizationEndpoint()\n .authorizationRequestRepository(httpCookieOAuth2AuthorizationRequestRepository)\n .and()\n .userInfoEndpoint()\n .userService(customOAuth2UserService)\n .and()\n .successHandler(oAuth2AuthenticationSuccessHandler)\n .failureHandler(oAuth2AuthenticationFailureHandler);\n</code></pre>\n<p>I am doing stateless authentication with JWT, for form based login <code>JWTAuthenticationFilter</code>handles the authentication as below.</p>\n<p><strong>JWTAuthenticationFilter</strong></p>\n<pre><code>public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {\n//code to authenticate user and generate JWT\n}\n</code></pre>\n<p>and <code>JWTAuthorizationFilter</code> validates the JWT for subsequent requests as below.</p>\n<p><strong>JWTAuthorizationFilter</strong></p>\n<pre><code>public class JWTAuthorizationFilter extends BasicAuthenticationFilter {\n// code to perform authorization\n}\n</code></pre>\n<p>Now coming to oAuth2.0 <code>customOAuth2UserService</code> does register the new users and update the existing user information.\n<code>OAuth2AuthenticationSuccessHandler</code> generates JWT on successful oAuth2.0 authentication.\nNow functionality wise both form login and oAuth2.0 works fine, but there are few tiny issues i am trying to solve which i need help for.</p>\n<p><strong>Issues</strong></p>\n<ol>\n<li>If i hit <code>http://localhost:8080/login</code> with wrong form login credentials i am getting a Sign In HTML form with Google login as response body and 200 as status code, ideally I want 400 bad request or something.</li>\n<li>When i don't provide a JWT token along with request, i am getting the same HTML response body with 200 status code, ideally i would like a 401 for that as well.</li>\n</ol>\n<p>What configurations i am missing and what can i change to fix these issues, TIA.</p>\n"},{"tags":["python","plotly","data-visualization","treemap","plotly-python"],"owner":{"reputation":732,"user_id":9524160,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=128","display_name":"callmeanythingyouwant","link":"https://stackoverflow.com/users/9524160/callmeanythingyouwant"},"is_answered":false,"view_count":13,"answer_count":1,"score":0,"last_activity_date":1623258304,"creation_date":1623245252,"question_id":67905114,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67905114/plotly-show-hoverinfo-in-treemap-only-for-child-nodes","title":"Plotly: Show hoverinfo in treemap only for child nodes","body":"<pre><code>import pandas as pd\nimport plotly.express as px\n\ndf = pd.DataFrame({'world':['world']*4,\n 'continent':['SA','SA','NA','NA'],\n 'country':['Brazil','Uruguay','USA','Canada'],\n 'total_cases_per_100':[6,1,12,8]})\n\nfig = px.treemap(df, path=['world','continent','country'],values='total_cases_per_100')\nfig.update_traces(hovertemplate=None, hoverinfo='value')\n</code></pre>\n<p>The code above gives the following output-</p>\n<p><a href=\"https://i.stack.imgur.com/uZv4m.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/uZv4m.png\" alt=\"enter image description here\" /></a></p>\n<p>As visible, it displays correctly the value of <code>total_cases_per_100</code> for <code>USA</code> and all the other child nodes. But for parent nodes, it sums it up, which is wrong as <code>total_cases_per_100</code> is a ratio and not a total.</p>\n<p>Is there anyway I can hide the <code>value</code> hoverinfo for all nodes except the children?</p>\n<p>In case this is not possible, the actual value for the parent nodes is also available with me but I am not sure how I could replace the generated value with it.</p>\n"},{"tags":["java","python","backend"],"owner":{"reputation":1,"user_id":16178177,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GiEJYZ5-Aay0sMH5xBPk3zvUqfy_t3FWpyqQVEw2w=k-s128","display_name":"ridhvikaa vasudevan","link":"https://stackoverflow.com/users/16178177/ridhvikaa-vasudevan"},"is_answered":false,"view_count":4,"answer_count":0,"score":-1,"last_activity_date":1623258297,"creation_date":1623258297,"question_id":67908702,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908702/how-am-i-suppose-to-add-a-folder-in-macintosh-hd","title":"How am i suppose to add a folder in Macintosh HD","body":"<p>I am trying to download MongoDB in my Macbook Air. The only problem is I currently have the version 10.15.5 which is why I am not able to add my folder in macintosh HD. How do I fix this problem</p>\n"},{"tags":["python","pandas","machine-learning","scikit-learn"],"owner":{"reputation":1,"user_id":16006685,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgzYt46_FJu6mEsZRfD8n64v7D-kmMEA7lXIxvO=k-s128","display_name":"Md Masud Rana","link":"https://stackoverflow.com/users/16006685/md-masud-rana"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258293,"creation_date":1623258293,"question_id":67908701,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908701/ml-classification-model-selection-based-on-the-following-data","title":"ML Classification model selection based on the following data?","body":"<p>What kind of ML Classification model suits the best when I want to predict if the person had a <strong>good day or bad day</strong> based on the everyday data entry shown in the table. Note: DayAnswer target variable, and all other columns are independent.</p>\n<p><a href=\"https://i.stack.imgur.com/rrxpa.png\" rel=\"nofollow noreferrer\">Sample Data</a></p>\n"},{"tags":["json","elasticsearch","logstash","kibana","elk"],"owner":{"reputation":1,"user_id":15646025,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/7bce4c3f1d60410498482f967df9cfb5?s=128&d=identicon&r=PG&f=1","display_name":"ES-G","link":"https://stackoverflow.com/users/15646025/es-g"},"is_answered":false,"view_count":7,"answer_count":1,"score":0,"last_activity_date":1623258289,"creation_date":1623253480,"question_id":67907508,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907508/logstash-configuration-to-globally-mutate-sub-index-patterns","title":"Logstash configuration to globally mutate sub index patterns","body":"<p>I have an ELK stack, with some configured index patterns. As part of internal requirements, I need to edit a json object (which is part of that index pattern), globally to "string".\nAs of now, such json object is randomly populated by numerous sub-fields, like "date", "temps", and many more others.\nAll of these are automatically managed by ELK, but I need all of them to be processed and converted (casted) as "strings".</p>\n<p>So, the basic configuration is as follows:</p>\n<pre><code>type A: "long"\ntype B: "int"\ntype C: "string"\ntype D: "json object"\n</code></pre>\n<p>where type D is a nested json object which includes (as sub fields) numerous other index patterns and fields, like (for example) "typeD.date", "typeD.temps", "typeD.extrastuff", and so on.</p>\n<p>I need all of the "<code>typeD*</code>" objects to be casted and converted as strings.\nSo far, I tried to use a .conf with logstash, but it did not work. I will paste my configuration after (numerous) attempts. I tried all these configuration in my own local docker environment.</p>\n<p>The log which I tested logstash from was called log_file.json and it contains numerous sample lines, including also the index patterns I want to edit globally with this mutate operation.</p>\n<pre><code>input {\n file{\n type => "json"\n path => "/home/container/logstash/log_file.json"\n start_position => "beginning"\n sincedb_path => "/dev/null"\n codec => json\n }\n}\n\nfilter {\n if [message] =~ /\\A\\{.+\\}\\z/ {\n json {\n source => "message"\n }\n\n json {\n source => "[message][typeD]"\n}\n\n mutate {\n convert => ["typeD.*","string"]\n}\n }\n}\n\noutput {\n elasticsearch {\n hosts => "http://localhost:9200"\n index => "logstash-test-%{+yyyy.MM.dd}"\n }\n stdout{}\n}\n</code></pre>\n<p>Also, after logging in via Kibana, I can see that the (conf) file has been correctly created and loaded by logstash, but still it fails to convert the index patterns as strings.</p>\n<p>I would need to know which edits are necessary for the configuration to work. Does the logstash config file need some edit? Is there anything wrong in the setup?</p>\n<p>Thanks</p>\n"},{"tags":["angular","typescript","drag-and-drop","angular8"],"owner":{"reputation":1227,"user_id":4659026,"user_type":"registered","accept_rate":68,"profile_image":"https://www.gravatar.com/avatar/8f979c90540bc9b5b766ad8f55475c59?s=128&d=identicon&r=PG&f=1","display_name":"Mr.M","link":"https://stackoverflow.com/users/4659026/mr-m"},"is_answered":false,"view_count":52,"answer_count":0,"score":0,"last_activity_date":1623258284,"creation_date":1623221393,"last_edit_date":1623258284,"question_id":67898936,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67898936/drag-and-drop-dynamic-fields-using-ng-drag-drop-using-angular-not-working-as-exp","title":"drag and drop dynamic fields using ng drag drop using angular not working as expected","body":"<p>Team,</p>\n<p>i am using ng drag and drop to move my dynamic fields from field area to panel area.</p>\n<p>in my cunrrent code Drag is working but droppable not working.</p>\n<p>Here is the reference screen.</p>\n<p>i want to drag no of fields into personal details form.</p>\n<p><a href=\"https://i.stack.imgur.com/qkhRO.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/qkhRO.png\" alt=\"enter image description here\" /></a></p>\n<p>Here is my code for drag.</p>\n<pre><code> <div class="fieldexplorer">\n <div class="sectionHeader_field">\n Field Explorer\n </div>\n <div draggable [dragData]="label" *ngFor="let label of labels;">\n <div class="hoverselect" style="padding: 8px;border: 1px solid black;">\n <span [ngClass]="(label.fieldType=='Number'?'numberbefore':(label.fieldType=='List'?'listbefore':'radiobefore'))">\n </span> {{label.labelName}}\n </div>\n </div>\n</code></pre>\n<p>Here is the sample droppable</p>\n<pre><code> <div class="row" [droppable] [dragHintClass]="'drag-hint'" (onDrop)="onAnyDrop($event, 'personalDetails')">\n <div class="col-md-12">\n <div class="form">\n <div class="bgwhite">\n <form [formGroup]="personalDetails">\n <div class="container-fluid">\n <div class="row">\n <div class="col-md-3">\n <mat-form-field class="example-full-width">\n <mat-label>Date of Birth</mat-label>\n <input matInput formControlName="dob" [matDatepicker]="picker" [min]="minDate" [max]="maxDate" />\n <mat-datepicker-toggle [for]="picker"> </mat-datepicker-toggle>\n <mat-datepicker #picker> </mat-datepicker>\n <span *ngIf="personalFieldsLocks['dateOfBirth']" class="fa fa-lock lock_field"></span>\n </mat-form-field>\n </div>\n </div> \n </div>\n </form>\n </div>\n </div>\n </div>\n <div class="row" [droppable] [dragHintClass]="'drag-hint'" (onDrop)="onAnyDrop($event, 'contactDetails')">\n <div class="col-md-12">\n <div class="form_cont">\n <div class="bgwhite_cont">\n <form [formGroup]="contactDetails">\n <div class="container-fluid">\n <div class="row">\n <div class="col-md-3 form-group">\n <mat-form-field>\n <mat-label>Address 1</mat-label>\n <input matInput formControlName="address1" class="form-control" placeholder="Address 1" />\n <span class="fa fa-lock lock_field"></span>\n </mat-form-field>\n </div>\n </div>\n </div>\n </form>\n </div>\n </div>\n</code></pre>\n \n<p>TS code</p>\n<pre><code>onAnyDrop(e: any, formGroupName: string) {\n console.log(e, formGroupName);\n if (formGroupName === 'personalDetails') {\n this.addInput(this.personalDetails, e.fieldType, 'ABCED', false);\n } else if (formGroupName === 'contactDetails') {\n this.addInput(this.contactDetails, e.fieldType, 'XYZABC', false);\n }\n }\n</code></pre>\n"},{"tags":["rust","channels"],"owner":{"reputation":33,"user_id":12114471,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/500568ec03a17b67adf36abc159152a1?s=128&d=identicon&r=PG&f=1","display_name":"JNP","link":"https://stackoverflow.com/users/12114471/jnp"},"is_answered":false,"view_count":9,"answer_count":0,"score":-1,"last_activity_date":1623258282,"creation_date":1623257269,"last_edit_date":1623258282,"question_id":67908477,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908477/receive-message-from-channel-between-modules","title":"Receive message from channel between modules","body":"<p>I have four modules. The client is sending messages and the server is receiving messages. Once the server receives the message, it tries to send the message to the MPSC channel. I put the receiver in the other .rs file where I intend to receive the message.</p>\n<p>I am not getting any message on the receiver side.</p>\n<p>Maybe an infinite loop on the server side creates a problem, but is there a way to make this channel communication working?</p>\n<p><strong>client.rs</strong></p>\n<pre><code>use std::io::prelude::*;\nuse std::os::unix::net::UnixDatagram;\nuse std::path::Path;\nuse std::sync::mpsc;\n\npub fn tcp_datagram_client() {\n pub static FILE_PATH: &'static str = "/tmp/datagram.sock";\n let socket = UnixDatagram::unbound().unwrap();\n match socket.connect(FILE_PATH) {\n Ok(socket) => socket,\n Err(e) => {\n println!("Couldn't connect: {:?}", e);\n return;\n }\n };\n println!("TCP client Connected to TCP Server {:?}", socket);\n loop {\n socket\n .send(b"Hello from client to server")\n .expect("recv function failed");\n }\n}\n\nfn main() {\n tcp_datagram_client();\n}\n</code></pre>\n<p><strong>server.rs</strong></p>\n<pre><code>use std::os::unix::net::UnixDatagram;\nuse std::path::Path;\nuse std::str::from_utf8;\nuse std::sync::mpsc::Sender;\n\nfn unlink_socket(path: impl AsRef<Path>) {\n let path = path.as_ref();\n if path.exists() {\n if let Err(e) = std::fs::remove_file(path) {\n eprintln!("Couldn't remove the file: {:?}", e);\n }\n }\n}\n\nstatic FILE_PATH: &'static str = "/tmp/datagram.sock";\npub fn tcp_datagram_server(tx: Sender<String>) {\n unlink_socket(FILE_PATH);\n let socket = match UnixDatagram::bind(FILE_PATH) {\n Ok(socket) => socket,\n Err(e) => {\n eprintln!("Couldn't bind: {:?}", e);\n return;\n }\n };\n let mut buf = vec![0; 1024];\n println!("Waiting for client to connect...");\n loop {\n let received_bytes = socket.recv(&mut buf).expect("recv function failed");\n println!("Received {:?}", received_bytes);\n let received_message = from_utf8(&buf).expect("utf-8 convert failed");\n tx.send(received_message.to_string());\n }\n}\n</code></pre>\n<p><strong>message_receiver.rs</strong></p>\n<pre><code>use crate::unix_datagram_server;\nuse std::sync::mpsc;\n\npub fn handle_messages() {\n let (tx, rx) = mpsc::channel();\n unix_datagram_server::tcp_datagram_server(tx);\n let message_from_tcp_server = rx.recv().unwrap();\n println!("{:?}", message_from_tcp_server);\n}\n</code></pre>\n<p><strong>main.rs</strong></p>\n<pre><code>mod unix_datagram_server;\nmod message_receiver;\n\nfn main() {\n message_receiver::handle_messages();\n}\n</code></pre>\n<p>Once the TCP client is connected:</p>\n<pre class=\"lang-none prettyprint-override\"><code>TCP client Connected to TCP Server UnixDatagram { fd: 3, local: (unnamed), peer: "/tmp/datagram.sock" (pathname) }\n</code></pre>\n<p>I receive no messages on the channel receiver end:</p>\n<pre class=\"lang-none prettyprint-override\"><code>Waiting for client to connect...\n</code></pre>\n"},{"tags":["python","arrays","numpy","multidimensional-array","sub-array"],"owner":{"reputation":1,"user_id":16177879,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b61b9b920195f67176a972e50ed35cc2?s=128&d=identicon&r=PG&f=1","display_name":"Wilfred","link":"https://stackoverflow.com/users/16177879/wilfred"},"is_answered":false,"view_count":9,"answer_count":1,"score":0,"last_activity_date":1623258277,"creation_date":1623256889,"question_id":67908381,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908381/finding-the-indices-of-the-minimum-in-each-2d-array-from-a-3d-array","title":"Finding the indices of the minimum in each 2D array from a 3D array","body":"<p>I'm new to numpy and python in general and I am looking to find the minimum of each 2D subarray, given a 3D array. For example:</p>\n<pre><code># construct an example 3D array\na = np.array([[5,4,1,5], [0,1,2,3], [3,2,8,1]]).astype(np.float32)\nb = np.array([[3,2,9,3], [8,6,5,3], [6,7,2,8]]).astype(np.float32)\nc = np.array([[9,7,6,5], [4,7,6,3], [1,2,3,4]]).astype(np.float32)\nd = np.array([[5,4,9,2], [4,2,6,1], [7,5,9,1]]).astype(np.float32)\ne = np.array([[4,5,2,9], [7,1,5,8], [0,2,6,4]]).astype(np.float32)\n\na = np.insert(a, 0, [np.inf]*len(a), axis=1)\nb = np.insert(b, 1, [np.inf]*len(b), axis=1)\nc = np.insert(c, 2, [np.inf]*len(c), axis=1)\nd = np.insert(d, 3, [np.inf]*len(d), axis=1)\ne = np.insert(e, 4, [np.inf]*len(e), axis=1)\n\narr = np.swapaxes(np.dstack((a,b,c,d,e)), 1, 2)\nprint(arr) \n</code></pre>\n<p>gives this result:\n<a href=\"https://i.stack.imgur.com/bBK26.png\" rel=\"nofollow noreferrer\">3D Matrix</a></p>\n<p>The result I'm looking for are the indices of the minimum element from each of the 2D arrays, something like:</p>\n<pre><code>[[0, 0, 3], # corresponding to the coordinates of element with value 1 in the first 2D array\n [1, 0, 1], # corresponding to the coordinates of element with value 0 in the second 2D array\n [2, 4, 0]] # corresponding to the coordinates of element with value 0 in the third 2D array\n</code></pre>\n<p>or something similar along those lines. I plan on using the indices to get that value, then replace the column and row in that 2D subarray with infinite values to find a next minimum that isn't in the same row/column.</p>\n<p>Any help is appreciated, thank you!</p>\n"},{"tags":["ios","swift","api","alamofire"],"owner":{"reputation":150,"user_id":4975287,"user_type":"registered","profile_image":"https://i.stack.imgur.com/yoZWB.png?s=128&g=1","display_name":"Asbis","link":"https://stackoverflow.com/users/4975287/asbis"},"is_answered":false,"view_count":6,"answer_count":1,"score":0,"last_activity_date":1623258276,"creation_date":1623257978,"question_id":67908629,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908629/error-to-parse-from-alomofire-post-request","title":"Error to parse from alomofire post request","body":"<p>I have an issue with parsing using alamofire. I get an error to try to decode the json file that i get in return from the request.\nI have tried to parse JSON file that looks like this:</p>\n<pre><code>success({\ndata = {\n id = "eb259a9e-1b71-4df3-9d2a-6aa797a147f6";\n nickname = joeDoe;\n options = {\n avatar = avatar1;\n };\n rooms = "<null>";\n};\n</code></pre>\n<p>})</p>\n<p>It Gives me an error that looks like this:</p>\n<pre><code>keyNotFound(CodingKeys(stringValue: "id", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \\"id\\", intValue: nil) (\\"id\\").", underlyingError: nil))\n</code></pre>\n<p>The user model looks like this:</p>\n<pre><code>import Foundation\n\nstruct userModel: Codable {\n let id: String\n let nickname: String\n let options: options\n let rooms: String\n\nenum CodingKeys: String, CodingKey {\n case id = "id"\n case nickname = "nickname"\n case options = "options"\n case rooms = "rooms"\n }\n}\n\nstruct options: Codable {\n var avatar: String?\nenum CodingKeys: String, CodingKey {\n case avatar = "avatar"\n }\n }\n</code></pre>\n<p>And the function looks like this:</p>\n<pre><code> func postUser(){\n AF.request("http://test.com/", method: .post, parameters: user).responseJSON {response in\n guard let itemsData = response.data else {\n print("test1")\n return\n }\n do {\n print("hallo!")\n let decoder = JSONDecoder()\n print("")\n print(itemsData)\n print("")\n print(response.description)\n let items = try decoder.decode(userModel.self, from: itemsData)\n print(items)\n DispatchQueue.main.async {\n print("test2")\n }\n } catch {\n print(error)\n print("test3")\n }\n}\n</code></pre>\n<p>How do i fix the issue?</p>\n"},{"tags":["bash","slurm"],"owner":{"reputation":121,"user_id":9654966,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0e16ec0f5c28f1bb42cccdb2f65292b7?s=128&d=identicon&r=PG&f=1","display_name":"Rodrigo Duarte","link":"https://stackoverflow.com/users/9654966/rodrigo-duarte"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258274,"creation_date":1623258274,"question_id":67908698,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908698/submitting-slurm-array-job-with-a-limit-above-maxarraysize","title":"Submitting slurm array job with a limit above MaxArraySize?","body":"<p>I need to submit a slurm array that will run the same script 18000 times (for independent genes), and I wanted to do this in a way that won't cause problems for my Uni's cluster.</p>\n<p>Currently, the <code>MaxArraySize</code> set by the admins is <code>2048</code>. I was going to manually set my options like:</p>\n<p>First array script:</p>\n<pre><code>#SBATCH --array=1-2000%300 \n</code></pre>\n<p>Next script:</p>\n<pre><code>#SBATCH --array=2001-4000%300\n</code></pre>\n<p>and so on...</p>\n<p>But slurm does not like values above 2048 in the array.</p>\n<p>What's the easiest way of doing this?</p>\n<p>(All I can think are for loops, but then I'd lose the constraint option from slurm [<code>%300</code>], to avoid clogging the scheduler.)</p>\n"},{"tags":["powershell","ms-word","comobject","word-table"],"owner":{"reputation":11,"user_id":15114015,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-ZYH3YukEx30/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuclL41JUtWfSYfLSb-gPEa8ASOEjOQ/s96-c/photo.jpg?sz=128","display_name":"Milan Patel","link":"https://stackoverflow.com/users/15114015/milan-patel"},"is_answered":false,"view_count":8,"answer_count":0,"score":0,"last_activity_date":1623258270,"creation_date":1623257680,"last_edit_date":1623258270,"question_id":67908571,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908571/powershell-adding-multiple-stylized-tables-in-word-document-mixed-with-text","title":"Powershell Adding Multiple Stylized Tables in Word Document Mixed With Text","body":"<p>Essentially I am making a list of invoices as a bill, it will look like this (in word through powershell, note that the word file doesn't pre-emptively exists, i create a new one and start adding to it):\n<a href=\"https://i.stack.imgur.com/C9vQ7.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/C9vQ7.png\" alt=\"enter image description here\" /></a></p>\n<p>The problem is that I only know how to do the following:</p>\n<pre><code>$word = New-Object -comobject word.application\n$word.Visible = $false\n$doc = $word.Documents.Add()\n$Selection = $word.Selection\n$Selection.Style="Title"\n$Selection.Font.Bold = 1\n$Selection.ParagraphFormat.Alignment = 2\n$Selection.TypeText("Expected Billing")\n$Selection.TypeParagraph()\n$Selection.Style="No Spacing"\n$Selection.Font.Bold = 0\n$Selection.TypeParagraph()\n</code></pre>\n<p>Adding text is easy but when it comes to adding tables, I cant get it right.\nAs you can see:</p>\n<ul>\n<li>The addresses table is 2 columns and 3 rows but no borders</li>\n<li>the amount of invoice tables isn't fixed</li>\n<li>the first column is aligned left</li>\n<li>Quantity and Amount are aligned right (since they will be numbers)</li>\n<li>Supplier and Dealer are centered</li>\n</ul>\n<p>Actually the numbered tables aren't supposed to have borders either but I left them so you visually see.\nThen of course the total calculated amount which I can do. But notice it comes after the tables so I want tables appending and want to know how to append after them.\nCan someone help me out? I don't know the coding for this.</p>\n"},{"tags":["javascript","powerpoint"],"owner":{"reputation":93,"user_id":5700239,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/96ada05bb04da1523fb1074399a6a0a4?s=128&d=identicon&r=PG&f=1","display_name":"Avneesh Srivastava","link":"https://stackoverflow.com/users/5700239/avneesh-srivastava"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258265,"creation_date":1623258265,"question_id":67908697,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908697/office-js-powerpoint-reading-custom-properties-from-add-in","title":"office.js, Powerpoint: Reading custom properties from add-in","body":"<p>I am trying to deploy a new powerpoint add-in using the Javascript APIs that microsoft has created.</p>\n<p>I have looked at both</p>\n<ol>\n<li><code>Office.context.document.settings</code></li>\n<li><code>Powerpoint.run((ctx) => ctx.presentation)</code></li>\n</ol>\n<p>But I cannot find the custom properties anywhere, Is there any workaround to fetch the same? I thought of parsing OOXML but that seems too tedious for a large document.</p>\n"},{"tags":["javascript","arrays"],"owner":{"reputation":563,"user_id":15212955,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/25246ba7477630430cb2e58af462e504?s=128&d=identicon&r=PG&f=1","display_name":"Siva Pradhan","link":"https://stackoverflow.com/users/15212955/siva-pradhan"},"is_answered":true,"view_count":48,"answer_count":3,"score":0,"last_activity_date":1623258265,"creation_date":1623168377,"last_edit_date":1623173582,"question_id":67890653,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67890653/two-dimentional-array-problem-statement-in-javascript","title":"Two dimentional array problem statement in javascript","body":"<p>Below is a 2D array that represents movement of an entity over a 2 second period:</p>\n<pre><code>[[10, 200, 0], [70, 170, 600], [110, 150, 1000], [155, 120, 1600], [155, 120, 2000]]\n</code></pre>\n<p>Each array elements contains x-coordinate, y-coordinate, and timestamp in such order.</p>\n<p>I need to transform this data which shows location at sporadic moments in time to an array showing the location at a fixed rate of every 200ms. I need to interpolate the missing values.</p>\n<p>I know the correct output is:</p>\n<pre><code>10 200 0\n30 190 200\n50 180 400 \n70 170 600\n90 160 800\n110 150 1000\n125 140 1200\n140 130 1400\n155 120 1600\n155 120 1800\n155 120 2000\n</code></pre>\n<p>How can I achieve this?</p>\n"},{"tags":["azure","form-recognizer"],"owner":{"reputation":244,"user_id":1729816,"user_type":"registered","accept_rate":80,"profile_image":"https://www.gravatar.com/avatar/cba5aa80773b7edde6d445cd4c1abb26?s=128&d=identicon&r=PG","display_name":"Johnnygizmo","link":"https://stackoverflow.com/users/1729816/johnnygizmo"},"is_answered":false,"view_count":12,"answer_count":1,"score":0,"last_activity_date":1623258261,"creation_date":1623247490,"last_edit_date":1623249446,"question_id":67905749,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67905749/unable-to-load-asset-for-pdfs-in-form-recognizer-labeling-tool","title":""Unable to Load Asset" for PDF's in Form Recognizer Labeling Tool","body":"<p>Form Recognizer shows 'unable to load asset' on PDFs. I have tried multiple PDF's from various sources and they all return this error. JPGs work as expected.</p>\n<p>An additional error popped up</p>\n<blockquote>\n<p>Uncaught NetworkError: Failed to execute 'importScripts' on\n'WorkerGlobalScope': The script at\n'http://fotts.azureedge.net/npm/pdfjs-dist/2.3.200/pdf.worker.js'\nfailed to load</p>\n</blockquote>\n<p><a href=\"https://i.stack.imgur.com/qGlao.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/qGlao.png\" alt=\"Error\" /></a></p>\n"},{"tags":["java","split"],"owner":{"reputation":11,"user_id":14603352,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-DDu8Hn64Gf0/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuck79kly9Wf0I6tmJuo2ncRJdrglnA/s96-c/photo.jpg?sz=128","display_name":"Aishwarya Roy","link":"https://stackoverflow.com/users/14603352/aishwarya-roy"},"is_answered":false,"view_count":9,"answer_count":0,"score":0,"last_activity_date":1623258261,"creation_date":1623256908,"last_edit_date":1623258261,"question_id":67908388,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908388/counting-mechanism-of-capital-s-in-split-function-in-java","title":"Counting mechanism of Capital S in split function in Java","body":"<p>Whenever I write \\\\S (caps S) , then I get output 13,\nCan anyone tell me how this count 13, I mean why it just remove the last word?</p>\n<pre><code>TextAreaCount() {\n\n l1=new Label();\n l1.setBounds(150,50,100,30);\n add(l1);\n\n l2=new Label();\n l2.setBounds(250,50,100,30);\n add(l2);\n\n\n area = new TextArea();\n area.setBounds(20, 100, 450, 300);\n add(area);\n\n b = new Button("Count");\n b.setBounds(200, 450, 100, 30);\n b.addActionListener(this);\n add(b);\n\n setSize(500, 500);\n setLayout(null);\n setVisible(true);\n}\n\npublic void actionPerformed(ActionEvent e){\n String Text = area.getText();\n String words[]=Text.split("\\\\S");\n l1.setText("Words : "+words.length);\n l2.setText("Character : "+Text.length());\n}\n\n\n\n\n\npublic static void main(String[] args) {\n new TextAreaCount();\n}\n</code></pre>\n<p>This code has the counting for words and characters,\nBut I just want to know why it shows 13 words, I mean, \\\\S split the words, but why it do not count the last word, and just count the all character without the last word?</p>\n"},{"tags":["html","css","drop-down-menu"],"owner":{"reputation":1,"user_id":16178157,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/396406f920f044469dc74449adccfa9e?s=128&d=identicon&r=PG&f=1","display_name":"Titir","link":"https://stackoverflow.com/users/16178157/titir"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258254,"creation_date":1623258254,"question_id":67908695,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908695/drop-down-menu-link-change-colour","title":"drop-down menu link change colour","body":"<p>I have created a drop-down menu with links.\nWhen i hover on the names, the drop-down menu appears.\nBefore adding the links, I could change colors of the name when the drop-down menu appears.\nI made all names golden and the name over which I hover, turns black and gives drop-down menu and the name remains black while I go through drop-down menu.\nBut ever since I added links and changed all the names to golden, it refuses to turn black when drop-down menu appears</p>\n"},{"tags":["latex","pdflatex","lyx"],"owner":{"reputation":1,"user_id":16178202,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/06fa2069e28905743a2c7b2a7e5ab752?s=128&d=identicon&r=PG&f=1","display_name":"ska96","link":"https://stackoverflow.com/users/16178202/ska96"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258244,"creation_date":1623258244,"question_id":67908693,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908693/latex-error-missing-begindocument-using-lyx","title":"LaTeX Error: Missing \\begin{document} using LyX","body":"<p>I just switched from MikTeX to TeXLive and I tried to preview a LyX file and I got 3 errors of "LaTeX Error: Missing \\begin{document}". I tried to add it to the preamble, but that did not work. I can use show output anyway and the document runs fine (correctly showing the content) except for the first page which are 4 lines that are just the path to these different filenames:</p>\n<ul>\n<li>"geometry.cfg"</li>\n<li>"bblopts.cfg"</li>\n<li>"english.cfg</li>\n<li>"[filename].aux"</li>\n</ul>\n<p>I checked the TeX path and it is correctly TeXLive being used. Can anyone help me?</p>\n"},{"tags":["python","python-3.x","bash","docker","dockerfile"],"owner":{"reputation":91,"user_id":15864414,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/f2833ab9521869de79e0beffc626d7ca?s=128&d=identicon&r=PG&f=1","display_name":"Opps_0","link":"https://stackoverflow.com/users/15864414/opps-0"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258235,"creation_date":1623258235,"question_id":67908692,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908692/how-to-run-a-bash-script-from-dockerfile","title":"How to run a bash script from dockerfile","body":"<p>I am using a bash script (<code>run.sh</code>) to run a python file (<code>calculate_ssp.py</code>). The code is working fine. The folder structure is given below</p>\n<pre><code>├── dataset\n └── dataset_1.csv\n├── Dockerfile\n├── __init__.py\n├── output\n├── run.sh\n├── scripts\n│ ├── calculate_ssp.py\n│ ├── __init__.py\n</code></pre>\n<p>The bash script is</p>\n<pre><code>#!/bin/bash\n\npython3 -m scripts.calculate_ssp 0.5\n</code></pre>\n<p>Now, I am trying to run the bash script (<code>run.sh</code>) from the <code>Dockerfile</code>. The content of the Dockerfile is</p>\n<pre><code>#Download base image ubuntu 20.04\nFROM ubuntu:20.04\n\n#Download python\nFROM python:3.8.5\n\nADD run.sh .\n\nRUN pip install pandas\nRUN pip install rdkit-pypi\n\nCMD ["bash", "run.sh"]\n</code></pre>\n<p>But, I am getting an error <code>/usr/local/bin/python3: Error while finding module specification for 'scripts.calculate_ssp' (ModuleNotFoundError: No module named 'scripts')</code></p>\n<p>Could you tell me why I am getting the error (as the code is working fine from the bash script)?</p>\n"},{"tags":["python"],"owner":{"reputation":1,"user_id":16178154,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e6235fcea91fe80bb2f588f3611c8694?s=128&d=identicon&r=PG&f=1","display_name":"whited_evil_hack3r","link":"https://stackoverflow.com/users/16178154/whited-evil-hack3r"},"is_answered":false,"view_count":15,"closed_date":1623257722,"answer_count":0,"score":-6,"last_activity_date":1623258234,"creation_date":1623257645,"last_edit_date":1623258234,"question_id":67908564,"link":"https://stackoverflow.com/questions/67908564/write-a-function-that-takes-two-equal-length-strings-and-produces-there-xor-comb","closed_reason":"Needs details or clarity","title":"Write a function that takes two equal length strings and produces there xor combination","body":"<p>My mentor has asked me to study on this question. I'm a complete beginner so please help. This is not a Homework. I wanted to be a ethical hacker, so my father contacted a Person who wanted to check my thinking skills. He said this "you have to write the logic of this code". I'm a complete beginner so please just let me know what I have to do basically. And I don't know anything about xor and etc.</p>\n"},{"tags":["java","oop","copy-constructor","deep-copy"],"owner":{"reputation":25,"user_id":14979447,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/34c21cf9285487947fa462425695309d?s=128&d=identicon&r=PG&f=1","display_name":"eeelll","link":"https://stackoverflow.com/users/14979447/eeelll"},"is_answered":true,"view_count":16,"answer_count":1,"score":1,"last_activity_date":1623258227,"creation_date":1623257191,"question_id":67908455,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908455/how-to-make-a-deep-copy-of-an-object-with-a-list-variable-in-java","title":"How to make a deep copy of an object with a List variable in Java?","body":"<p>I am working in Java and I want to make a deep copy of a MoleculeDTO object. I tried to make a copy constructor too, but it is not working and it is refering to the initial object.</p>\n<pre><code>public class MoleculeDTO {\n private int ID;\n private String name;\n private List<AtomDTO> atoms = new ArrayList<>();\n private int nrAtoms =0;\n\n public MoleculeDTO(String name, List<AtomDTO> atoms, int nrAtoms) {\n this.name = name;\n this.atoms = atoms;\n this.nrAtoms = nrAtoms;\n }\n\n public MoleculeDTO(MoleculeDTO molecule) {\n this(molecule.getName(), molecule.getAtoms(), molecule.getNrAtoms());\n }\n...getter, setter\n}\n</code></pre>\n<p>Here is class AtomDTO.</p>\n<pre><code>public class AtomDTO{\n private int ID;\n private String name;\n private String symbol;\n private int nrOfBonds;\n private List<BondDTO> bonds = new ArrayList<>();\n private int type;\n private AnchorNode anchorNode;\n\n\n public AtomDTO(String name, String symbol, int nrOfBonds, List<BondDTO> bonds, int type) {\n this.name = name;\n this.nrOfBonds = nrOfBonds;\n this.bonds = bonds;\n this.type = type;\n }\n\n public AtomDTO(AtomDTO copyAtom) {\n this(copyAtom.getName(),copyAtom.getSymbol(), copyAtom.getNrOfBonds(), copyAtom.getBonds(), copyAtom.getType());\n }\n...getter, setter\n}\n</code></pre>\n<p>Here is class BondDTO.</p>\n<pre><code>public class BondDTO {\n private int ID;\n private int otherAtomID;\n private int otherAtomType;\n private int bondType;\n\n public BondDTO(int otherAtomID, int otherAtomType, int bondType) {\n this.otherAtomID = otherAtomID;\n this.otherAtomType = otherAtomType;\n this.bondType = bondType;\n }\n\n public BondDTO(BondDTO copyBond) {\n this(copyBond.getOtherAtomID(), copyBond.otherAtomType, copyBond.bondType);\n }\n...getter, setter\n}\n</code></pre>\n"},{"tags":["sql","hiveql"],"owner":{"reputation":9,"user_id":14655684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0a3f5f074c1785727ae76a71c32f50ae?s=128&d=identicon&r=PG&f=1","display_name":"Matias021","link":"https://stackoverflow.com/users/14655684/matias021"},"is_answered":false,"view_count":20,"answer_count":0,"score":-1,"last_activity_date":1623258223,"creation_date":1623251729,"last_edit_date":1623258223,"question_id":67907054,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907054/complex-case-with-3-ways","title":"complex case with 3 ways","body":"<p>I have a complex case that I would appreciate to have your advice on it.</p>\n<p>when <strong>Order_id</strong> exist and if there are 2 rows with the same order_id :\n<strong>then</strong> select the row that have no null on <strong>seller</strong> and <strong>comment</strong>\n<strong>else</strong> select the row with <strong>seller</strong> and null on the <strong>comment</strong> and change the null to <em><strong>comment not provided</strong></em><br />\n(change the null to not provided)</p>\n<p>when order_id does not exist - put not found in both <strong>seller</strong> and <strong>comment</strong></p>\n<p>Please see the date example and the Desired result on the photo</p>\n<p><a href=\"https://i.stack.imgur.com/AF8au.png\" rel=\"nofollow noreferrer\">enter image description here</a></p>\n<pre><code>WITH cte1 as (\nSELECT \n a.order_id, \n ,a.cat_id,\n ,COALESCE(b.seller, 'No reason found') as seller\n ,COALESCE(b.comment, 'No comment found') as comment\n FROM table2 AS a\nLEFT JOIN table1 AS b\nON a.order_id = b.order_id\nand a.cat_id = b.cat_id\nGROUP BY \na.order_id\n ,a.cat_id\n ,COALESCE(b.seller, 'No reason found') \n ,COALESCE(b.comment, 'No comment found') \n)\n,\ncte2 as (\nselect \norder_id, \ncat_id,\nname,\nbrand,\nyear,\n\nfrom table2 \n\n\n) \n\nselect\ncb.order_id, \ncb.cat_id,\ncb.name,\ncb.brand,\ncb.year,\nca.seller,\nca.comment\nfrom cte1 as ca left join mca as cte2 as cb on \nca.order_id=cb.order_id\nand ca.cat_id=cb.cat_id\nGROUP BY\ncb.order_id, \ncb.cat_id,\ncb.name,\ncb.brand,\ncb.year,\nca.seller,\nca.comment\n</code></pre>\n"},{"tags":["c","command-line-arguments"],"owner":{"reputation":1,"user_id":16178169,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyGO2dy6KfymSm1J9AnFDkqcRib7NgpRr8YPxMM=k-s128","display_name":"Rakesh Sharma chemist","link":"https://stackoverflow.com/users/16178169/rakesh-sharma-chemist"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623258221,"creation_date":1623257778,"question_id":67908589,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908589/how-to-get-list-of-all-command-line-argument-and-forward-all-of-those-arguments","title":"How to get list of all command line argument and forward all of those arguments to another command in C","body":"<p>i have been searched for this issue but didn't found any solution.\nActually i want to create a Compiled in C, and if i enter ant argument to that file then it forwards the argument to another command via system()\nLet me explain,\nsuppose, growkl is my C compiled file.\nand in terminal, i wrote this :</p>\n<pre><code>growkl TRYNEW /etc/cron.d ./grill/mk\n</code></pre>\n<p>and then, the growkl file will forward all these arguments ( TRYNEW /etc/cron.d ./grill/mk ) to the command <strong>/usr/bin/gkbroot</strong>\nIn this way :</p>\n<pre><code>/usr/bin/gkbroot TRYNEW /etc/cron.d ./grill/mk\n</code></pre>\n<p>I'm a newbie with these things, so I'm not getting how to do this.\nCan anyone tell me</p>\n"},{"tags":["r","dplyr"],"owner":{"reputation":321,"user_id":13734451,"user_type":"registered","profile_image":"https://i.stack.imgur.com/phKcJ.jpg?s=128&g=1","display_name":"Moses","link":"https://stackoverflow.com/users/13734451/moses"},"is_answered":true,"view_count":20,"accepted_answer_id":67904850,"answer_count":3,"score":2,"last_activity_date":1623258219,"creation_date":1623244008,"last_edit_date":1623258219,"question_id":67904783,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67904783/is-there-a-way-to-collapse-related-variables-into-a-single-based-on-a-condition","title":"Is there a way to collapse related variables into a single based on a condition?","body":"<p>Lets say I have multiple variables that measure substance abuse i.e <em>a1 is on alcohal usage</em>,\n<em>a2 is on bhang</em> and <em>a3 is on cocaine</em>. I would like to generate variable <em>afin</em> that indicates engaged in substance abuse if any of the the three is yes.</p>\n<p>Is there a way to shorten the code so I don't specify use multiple <code>ifelse</code> statements as below? Trying to find the best way to do it because I have more than 10 variables to collapse into one and writing <code>ifelse</code> may not be ideal.</p>\n<pre><code># Anymatch\nlibrary(tidyverse)\n\nset.seed(2021)\n\nmydata <- tibble(\n a1 = factor(round(runif(20, 1, 3)),\n labels = c("Yes", "No", "N/A")),\n a2 = factor(round(runif(20, 1, 3)),\n labels = c("Yes", "No", "N/A")),\n a3 = factor(round(runif(20, 1, 3)),\n labels = c("Yes", "No", "N/A")),\n b1 = round(rnorm(20, 10, 2)))\nmydata\n\nmydata <- mydata %>%\n mutate(afin = ifelse(a1 == "Yes"|a2=="Yes"|a3=="Yes", "Yes", "No"))\n\n</code></pre>\n"},{"tags":["java","tomcat","classloader","classnotfoundexception","jcs"],"owner":{"reputation":1429,"user_id":9341540,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/7dde858ecafcaa645e231e3c64dd79ea?s=128&d=identicon&r=PG&f=1","display_name":"Klaus","link":"https://stackoverflow.com/users/9341540/klaus"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258218,"creation_date":1623258218,"question_id":67908689,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908689/classnotfoundexception-while-reading-object-from-file-in-jcs-cache","title":"ClassNotFoundException while reading object from file in JCS Cache","body":"<p>I am using JCS caching in my web application and time to time the JCS <code>get</code> method throws <code>ClassNotFoundException</code> upon trying to read object from the <code>IndexedDiskCache</code>. Usually after server startup and then continues..</p>\n<p>Sample code:</p>\n<pre><code>GenericResult cachedResult = jcs.get( "myKey" );\n</code></pre>\n<p>Cache configurations.</p>\n<pre><code>jcs.region.generic_result_store='DC'\njcs.region.generic_result_store.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache\njcs.region.generic_result_store.cacheattributes.MaxMemoryIdleTimeSeconds=3600\njcs.region.generic_result_store.elementattributes.IdleTime=3600\njcs.region.generic_result_store.cacheattributes.MaxObjects=400\njcs.region.generic_result_store.cacheattributes.MaxSpoolPerRun=500\njcs.region.generic_result_store.elementattributes.MaxLifeSeconds=7200\njcs.region.generic_result_store.elementattributes.IsLateral=false\njcs.region.generic_result_store.elementattributes.IsRemote=false\njcs.region.generic_result_store.cacheattributes.UseMemoryShrinker=true\njcs.region.generic_result_store.elementattributes.IsEternal=true\njcs.region.generic_result_store.elementattributes.IsSpool=true\njcs.region.generic_result_store.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes\njcs.region.generic_result_store.elementattributes=org.apache.jcs.engine.ElementAttributes\njcs.region.generic_result_store.cacheattributes.ShrinkerIntervalSeconds=300\n</code></pre>\n<p>Exception:</p>\n<pre><code>Region [generic_result_store] Exception, Problem reading object from file java.lang.ClassNotFoundException: com.example.result.GenericResult\nat java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435) ~[?:?]\nat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[?:?]\nat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]\nat java.base/java.lang.Class.forName0(Native Method) ~[?:?]\nat java.base/java.lang.Class.forName(Class.java:468) ~[?:?]\nat java.base/java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:782) ~[?:?]\nat java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2028) ~[?:?]\nat java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1895) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2202) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:519) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:477) ~[?:?]\nat java.base/java.util.ArrayList.readObject(ArrayList.java:899) ~[?:?]\nat java.base/jdk.internal.reflect.GeneratedMethodAccessor1272.invoke(Unknown Source) ~[?:?]\nat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]\nat java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]\nat java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1226) ~[?:?]\nat java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2401) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2540) ~[?:?]\nat java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2434) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2540) ~[?:?]\nat java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2434) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:519) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:477) ~[?:?]\nat org.apache.jcs.utils.serialization.StandardSerializer.deSerialize(StandardSerializer.java:73) ~[jcs-1.3.jar:1.3]\n</code></pre>\n<p>The class <code>GenericResult</code> is bundled with my web application and the dependency <code>JCS</code> library is provided in the Apache Tomcat's lib folder.JCS version 1.3</p>\n<p>My webapps POM :</p>\n<pre><code><dependency>\n <groupId>org.apache.jcs</groupId>\n <artifactId>jcs</artifactId>\n <version>1.3</version>\n <scope>provided</scope>\n</dependency>\n</code></pre>\n<p>This only happens time to time and when this happens, restarting the tomcat fixes this issue for a period of time. Is there anything I am missing here or can someone explain to me why this is happening.</p>\n<p>If possible kindly let me know how the class loading happens behind the scenes, As per <a href=\"https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html\" rel=\"nofollow noreferrer\">Tomcat Docs</a> from the perspective of a web application, class or resource loading looks in Bootstrap classes of your JVM -> /WEB-INF/classes of your web application -> /WEB-INF/lib/*.jar of your web application -> System class loader classes -> Common class loader classes. In my scenario, the class <code>com.example.result.GenericResult</code> should be found in the <code>/WEB-INF/classes</code> but that is not happening ( or am I wrong here?? )</p>\n"},{"tags":["ios","uitableview","constraints","tableview"],"owner":{"reputation":4129,"user_id":4153589,"user_type":"registered","accept_rate":38,"profile_image":"https://www.gravatar.com/avatar/96eadb8859ebb1c0aa162dc7ce195fe6?s=128&d=identicon&r=PG&f=1","display_name":"amodkanthe","link":"https://stackoverflow.com/users/4153589/amodkanthe"},"is_answered":false,"view_count":17,"answer_count":1,"score":0,"last_activity_date":1623258217,"creation_date":1623251436,"last_edit_date":1623258217,"question_id":67906969,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67906969/uitableviewcell-constraints-not-updated-till-i-scroll-tableview","title":"UITableViewCell constraints not updated till I scroll tableview","body":"<p>Following is my code to update view height inside tableview cell</p>\n<pre><code> override func layoutSubviews() {\n super.layoutSubviews()\n layout()\n}\n\nfileprivate func layout() {\n rootFlexContainer.frame.size.width = frame.width - 20\n rootFlexContainer.flex.layout(mode: .adjustHeight)\n if(rootFlexContainer.frame.height != 0) {\n tagsHeight.constant = rootFlexContainer.frame.height\n \n }\n \n \n}\n</code></pre>\n<p>although this is not reflected till I scroll i.e is cell is recreated. How to update constraint inside TableViewCell of a view?</p>\n<p>here is entire tableviewcell code</p>\n<pre><code>import UIKit\nimport FlexLayout\nimport SDWebImage\n\n\n\nclass StoreListTableViewCell: UITableViewCell {\n\n\n@IBOutlet weak var menuLbl: UILabel!\n\n\n@IBOutlet weak var menuView: UIView!\n\n@IBOutlet weak var cellBgview: UIView!\n@IBOutlet weak var storeImg: UIImageView!\n@IBOutlet weak var storeLocation: UILabel!\n@IBOutlet weak var storeTitle: UILabel!\n\n@IBOutlet weak var cellContainer: UIView!\n\n\n@IBOutlet weak var stackView: UIStackView!\n\n\n@IBOutlet weak var tagsHeight: NSLayoutConstraint!\nvar storeImgStr = ""\nvar storeTitleStr = ""\nvar storeLocationStr = ""\nvar score : Double = 0.0\nvar tagsStr = ""\nvar isMenuAvailble = 0\nvar retailerTags: [String]?\nvar cashbackString = ""\nfileprivate let rootFlexContainer = UIView()\n\n\n\n@IBOutlet weak var tagsView: UIView!\n\n\n@IBOutlet weak var ratingBtn: UIButton!\noverride func awakeFromNib() {\n super.awakeFromNib()\n self.layoutIfNeeded()\n cellBgview.clipsToBounds = true\n cellBgview.layer.cornerRadius = 5\n cellContainer.layer.shadowColor = UIColor.lightGray.cgColor\n cellContainer.layer.shadowOpacity = 0.5\n cellContainer.layer.shadowRadius = 5.0\n cellContainer.layer.shadowOffset = CGSize(width: 0, height: 2)\n cellContainer.backgroundColor = UIColor.clear\n cellContainer.layer.cornerRadius = 5.0\n cellContainer.layer.borderColor = UIColor.white.cgColor\n cellContainer.layer.borderWidth = 0.5\n ratingBtn.layer.borderWidth = 1\n ratingBtn.layer.cornerRadius = 5\n tagsView.addSubview(rootFlexContainer)\n \n //cellContainer.layer.shadowPath = UIBezierPath(rect: cellBgview.bounds).cgPath\n }\n\nfunc setSetupStoreUI() {\n \n if isMenuAvailble == 1 {\n menuView.isHidden = false\n menuView.layer.cornerRadius = 10\n } else {\n menuView.isHidden = true\n }\n \n storeTitle.text = storeTitleStr\n // storeTitle.sizeToFit()\n storeLocation.text = storeLocationStr\n //storeLocation.sizeToFit()\n \n\n //.filter{ $0.name != " " }\n //storeImg.sd_imageIndicator = SDWebImageActivityIndicator.gray\n storeImg.backgroundColor = UIColor.hexStringToUIColor(hex: AppStrings.placeHolderColor)\n if let url = URL(string: storeImgStr.encoded), !(storeImgStr.isEmpty) {\n self.storeImg.sd_setImage(with: url)\n \n }\n \n \n menuLbl.text = AppLocalString.PREORDER_TEXT.localized()\n menuLbl.font = FontStyle.ProximaNovaBold(size: 12)\n\n storeTitle.font = FontStyle.ProximaNovaSemibold(size: 14)\n storeLocation.font = FontStyle.ProximaNovaRegular(size: 12)\n storeLocation.textColor = .gray\n // ratingBtn.isHidden = (score == 0)\n ratingBtn.setTitle(score == 0 ? "-" : String(format: "%.1f", score), for: .normal)\n ratingBtn.backgroundColor = UIColor.hexStringToUIColor(hex: Utility.getRatingColor(rating: score))\n ratingBtn.layer.borderColor = UIColor.hexStringToUIColor(hex: Utility.getRatingColor(rating: score)).cgColor\n \n rootFlexContainer.subviews.forEach({ $0.removeFromSuperview() })\n //tagsView.willRemoveSubview(rootFlexContainer)\n //rootFlexContainer.frame = tagsView.frame\n //tagsView.addSubview(rootFlexContainer)\n rootFlexContainer.flex.direction(.row).wrap(.wrap).alignSelf(.auto).justifyContent(.start).paddingRight(2).define { (flex) in\n for i in 0..<((retailerTags?.count ?? 0) > 3 ? 3 : (retailerTags?.count ?? 0)) {\n let nameLabel = UIButton()\n nameLabel.isUserInteractionEnabled = false\n nameLabel.setTitle((retailerTags?[i] ?? "").trim(), for: .normal)\n nameLabel.setTitleColor(.black, for: .normal)\n nameLabel.titleLabel?.font = FontStyle.ProximaNovaRegular(size: 11)\n nameLabel.contentEdgeInsets = UIEdgeInsets(top: 1.5, left: 4, bottom: 1.5, right:4)\n nameLabel.layer.borderColor = UIColor.hexStringToUIColor(hex: AppStrings.grayBorderColor).cgColor\n nameLabel.layer.cornerRadius = 8\n nameLabel.layer.borderWidth = 1.0\n nameLabel.sizeToFit()\n flex.addItem(nameLabel).margin(2)\n \n }\n if cashbackString != "" {\n let cashbackLabel = UIButton()\n \n cashbackLabel.backgroundColor = UIColor.hexStringToUIColor(hex: AppStrings.orangeCashbackColor)\n cashbackLabel.isUserInteractionEnabled = false\n cashbackLabel.setTitle(cashbackString, for: .normal)\n cashbackLabel.setTitleColor(.black, for: .normal)\n cashbackLabel.titleLabel?.font = FontStyle.ProximaNovaRegular(size: 10)\n cashbackLabel.contentEdgeInsets = UIEdgeInsets(top: 1.5, left: 5, bottom: 1.5, right: 5)\n cashbackLabel.layer.cornerRadius = 5\n cashbackLabel.layer.borderWidth = 0\n cashbackLabel.sizeToFit()\n flex.addItem(cashbackLabel).margin(2)\n }\n \n }\n rootFlexContainer.flex.layout()\n if retailerTags?.count ?? 0 == 0 {\n tagsView.isHidden = true\n } else {\n tagsView.isHidden = false\n }\n \n \n \n}\n\n\noverride func layoutSubviews() {\n super.layoutSubviews()\n layout()\n}\n\nfileprivate func layout() {\n rootFlexContainer.frame.size.width = frame.width - 20\n rootFlexContainer.flex.layout(mode: .adjustHeight)\n if(rootFlexContainer.frame.height != 0) {\n tagsHeight.constant = rootFlexContainer.frame.height\n \n }\n \n \n}\n\n\n\noverride func setSelected(_ selected: Bool, animated: Bool) {\n super.setSelected(selected, animated: animated)\n \n // Configure the view for the selected state\n}\n\n}\n</code></pre>\n<p>Following is view hierarchy from stroryboard</p>\n<p><a href=\"https://i.stack.imgur.com/KEqAM.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/KEqAM.png\" alt=\"enter image description here\" /></a></p>\n"},{"tags":["swift","firebase","firebase-realtime-database"],"owner":{"reputation":13,"user_id":16069696,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/566941fd877c1da2c346cd5a899a5732?s=128&d=identicon&r=PG&f=1","display_name":"bdriii","link":"https://stackoverflow.com/users/16069696/bdriii"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258215,"creation_date":1623258215,"question_id":67908688,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908688/the-problem-is-that-selecting-the-image-is-mandatory-in-firebase-swift","title":"The problem is that selecting the image is mandatory in firebase swift","body":"<p>I have a button to send and save the data in firebase</p>\n<p>data is : TextFiled and TextView and Color and Image</p>\n<p>The problem is in the picture</p>\n<p>I can not perform the transmission without selecting the image</p>\n<p>I want to make it optional</p>\n<p>This Button Code :</p>\n<pre><code>@IBAction func SendBtn(_ sender: Any) {\n\n if let profileImage = SelecSubStorge , let profileIMG = profileImage.jpegData(compressionQuality: 0.1) {\n \n let udidImage = NSUUID().uuidString\n let storeg = Storage.storage().reference(withPath: "gs://myproduct-744cb.appspot.com").child(udidImage)\n \n storeg.putData(profileIMG, metadata: nil) { metaDate, error in\n if error != nil {\n print(error?.localizedDescription)\n return\n } else {\n storeg.downloadURL { url, error in\n let imgSub = url?.absoluteString\n \n let cgColor = self.ColorIsColor!.cgColor\n self.labelColor = CIColor(cgColor: cgColor).stringRepresentation\n \n let ref = Database.database().reference()\n let sub = ref.child("Sub")\n let udid = sub.childByAutoId().key\n let setRef = sub.child(udid!)\n let value = ["sub": self.subjectLB.text , "detiles" : self.detilesTextview.text , "ImgSub" : imgSub , "SubID" : udid , "Color" : self.labelColor , "Alignment" : self.data0 , "sizeFont" : self.SliderSize ] as [String : Any]\n setRef.setValue(value) { error, ref in\n if error != nil {\n print(error?.localizedDescription)\n } else {\n \n let alert = UIAlertController(title: "Done", message: "Done Send", preferredStyle: UIAlertController.Style.alert)\n\n alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))\n\n self.present(alert, animated: true, completion: nil)\n \n \n }\n }\n }\n }\n }\n }\n}\n</code></pre>\n<p>Where is the problem and how can I make it optional?</p>\n"},{"tags":["java","arrays","char"],"owner":{"reputation":47,"user_id":15393275,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5bb1dc9724fcc8822a160be3fd44d773?s=128&d=identicon&r=PG&f=1","display_name":"Ciro Mertens","link":"https://stackoverflow.com/users/15393275/ciro-mertens"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623258207,"creation_date":1623258207,"question_id":67908687,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908687/start-a-char-array-from-a-certain-index","title":"start a char array from a certain index","body":"<p>I already have a char array called data. I should write a method that makes it possible to return the array but with a starting point that is an integer variable called beginIndex.\nExample: array is A, B, C, D and beginIndex = 2. Then it should return B, C, D (yes the index himself in this case the 2nd letter should be included as well!)</p>\n<p>How do I do this? Or is it wiser to change it into a String and later change it back into a char array?</p>\n"},{"tags":["excel","vba"],"owner":{"reputation":1,"user_id":10615000,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/812f8844227e4a73152395be36d136bb?s=128&d=identicon&r=PG&f=1","display_name":"kekehere","link":"https://stackoverflow.com/users/10615000/kekehere"},"is_answered":false,"view_count":3,"closed_date":1623258256,"answer_count":0,"score":0,"last_activity_date":1623258207,"creation_date":1623258207,"question_id":67908686,"link":"https://stackoverflow.com/questions/67908686/why-my-data-is-not-place-in-a-specific-row","closed_reason":"Duplicate","title":"Why my data is not place in a specific row?","body":"<p>i tried to place the data at column 5 row B but the data place at bottom of the excel table</p>\n<pre><code>Private Sub CommandButton20_Click() \n\nDim sh As Worksheet\nDim le As Long\nDim lastrow As Double\nSet sh = ThisWorkbook.Sheets("SUM-REBAR (C)")\nlastrow = ActiveSheet.Cells(Rows.Count, 5).End(xlUp).Row \nWith sh\n.Cells(lastrow + 1, "B") = TextBox33.Value \n.Cells(lastrow + 1, "C") = TextBox35.Value\n.Cells(lastrow + 1, "D") = TextBox34.Value\n.Cells(lastrow + 1, "E") = TextBox36.Value\nEnd With\nEnd Sub\n</code></pre>\n"},{"tags":["validation","blazor","data-annotations","blazor-editform"],"owner":{"reputation":21,"user_id":8919663,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9f7e2b8dea3104c58a3da4ebab209796?s=128&d=identicon&r=PG&f=1","display_name":"Antonito","link":"https://stackoverflow.com/users/8919663/antonito"},"is_answered":false,"view_count":22,"answer_count":1,"score":0,"last_activity_date":1623258202,"creation_date":1623171883,"last_edit_date":1623175690,"question_id":67891540,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67891540/in-blazor-execute-a-method-after-validating-an-inputtext-by-dataannotation","title":"In Blazor, execute a method after validating an InputText by DataAnnotation","body":"<p>I need to check if data typed in a inputtext is valid, and if it is, then execute a method.\n(Validation by a <code>DataAnnotation</code>).</p>\n<p>I tried in the <code>OnFieldChanged</code> event of <code>EditForm</code> but this one executes before validation.</p>\n<p>How could I do this?</p>\n"},{"tags":["android","flutter","app-actions"],"owner":{"reputation":1,"user_id":16172032,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJw30eLoGC5_UVtDwY7j_5jlpBABbH7SsiKQiy0Z=k-s128","display_name":"Prashant Nath","link":"https://stackoverflow.com/users/16172032/prashant-nath"},"is_answered":false,"view_count":13,"answer_count":0,"score":-1,"last_activity_date":1623258200,"creation_date":1623219527,"last_edit_date":1623258200,"question_id":67898585,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67898585/how-to-use-google-assistant-app-actions-from-my-flutter-app","title":"How to use Google Assistant app actions from my Flutter app?","body":"<p>I am facing this issue for a long time and I want to know if someone can help me to solve this problem. I want to use app actions feature powered by google assistant to control the custom app actions using flutter app,but I am unable to find something till know as google developers shown this feature with koatlin language and I have not any clue that how same can be done on flutter app.</p>\n"},{"tags":["swift","augmented-reality","arkit","realitykit"],"owner":{"reputation":1,"user_id":16178188,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GivGf0rLDumlJzao7aftaW0M_U54FVrHwn6XO57Yw=k-s128","display_name":"Jonathan Lessiohadi","link":"https://stackoverflow.com/users/16178188/jonathan-lessiohadi"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258196,"creation_date":1623258196,"question_id":67908684,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908684/arkit-realitykit-shows-coloring-based-on-distance","title":"ARKit/RealityKit shows coloring based on distance","body":"<p>I have been trying to find an answer to this for hours to no avail. Currently the mesh that shows scene reconstruction shows different colors based on how far the object is from the camera. I have tried all kinds of variations of the code below from many different sources (including from the Swift documentation), but no matter what I do, I cannot get the colors to be uniform or be colored based on classification. If anyone has any ideas on how to fix this, that would be greatly appreciated. Alternatively, I have heard that there is something similar to this in SceneKit, so if no one can figure this out, then I will also take suggestions on how to do it with SceneKit. Thanks in advance.</p>\n<pre><code>import UIKit\nimport RealityKit\nimport ARKit\n\nextension ARMeshClassification {\n var description: String {\n switch self {\n case .ceiling: return "Ceiling"\n case .door: return "Door"\n case .floor: return "Floor"\n case .seat: return "Seat"\n case .table: return "Table"\n case .wall: return "Wall"\n case .window: return "Window"\n case .none: return "None"\n @unknown default: return "Unknown"\n }\n }\n var color: UIColor {\n switch self {\n case .ceiling: return .red\n case .door: return .green\n case .floor: return .blue\n case .seat: return .cyan\n case .table: return .magenta\n case .wall: return .yellow\n case .window: return .black\n case .none: return .systemOrange\n @unknown default: return .white\n }\n }\n}\n\nclass ViewController: UIViewController {\n \n @IBOutlet var arView: ARView!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n arView.automaticallyConfigureSession = false\n let config = ARWorldTrackingConfiguration()\n config.sceneReconstruction = .meshWithClassification\n arView.debugOptions.insert(.showSceneUnderstanding)\n }\n}\n</code></pre>\n"},{"tags":["c","math","numbers","keypad","codevisionavr"],"owner":{"reputation":58,"user_id":15899360,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ghh109vjCXAI5UBujH35PSQajbJOVVncuG0A8w6zg=k-s128","display_name":"Zavosh Ghorbanpour","link":"https://stackoverflow.com/users/15899360/zavosh-ghorbanpour"},"is_answered":false,"view_count":48,"answer_count":0,"score":1,"last_activity_date":1623258193,"creation_date":1623152938,"last_edit_date":1623258193,"question_id":67886300,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67886300/keypad-function-return-wrong-number","title":"keypad function return wrong number","body":"<p>in ScanKey function which is for keypad 3*4 its work well until numbers length under 4\nit works like this <code>number = (number * 10)</code> but for a number like this 123456 which have more than 4 number it gives me other numbers what should I do? my program works with an int that's I use integer.\nwhen I enter a number like 555555 it changes to 31267.\nIDE <strong>CodeVisionAVR</strong>\n<strong>C</strong> language for <strong>ATmega16a</strong></p>\n<pre class=\"lang-c prettyprint-override\"><code>struct User\n{\n unsigned long int username;\n unsigned long int password;\n bool role;\n};\n\nunsigned long int username;\nunsigned long int password;\n\n</code></pre>\n<pre class=\"lang-c prettyprint-override\"><code> do\n {\n lcd_clear();\n lcd_putsf("Enter Username:");\n lcd_gotoxy(0, 1);\n sprintf(show, "%d", username);\n lcd_puts(show);\n lcd_gotoxy(0, 2);\n lcd_putsf("Enter Password:");\n lcd_gotoxy(0, 3);\n password = ScanKey();\n if (!password)\n {\n break;\n }\n else if (password / 10 < 10)\n {\n PORTC .1 = 1;\n lcd_clear();\n lcd_putsf("At least 3 numbers !");\n delay_ms(150);\n PORTC .1 = 0;\n }\n } while (password / 10 < 10);\n\n if (username && password)\n {\n user[UL].role = false;\n lcd_clear();\n if (currentUser < 0 && !currentUser)\n {\n lcd_putsf("Promote to admin ? ");\n lcd_gotoxy(0, 1);\n lcd_putsf("Yes press 1");\n lcd_gotoxy(0, 2);\n lcd_putsf("No press 2");\n if (ScanKey() == 1)\n {\n user[UL].role = true;\n }\n lcd_gotoxy(0, 3);\n }\n user[UL].username = username;\n user[UL].password = password;\n UL++;\n PORTC .0 = 1;\n lcd_putsf("User added !!");\n delay_ms(150);\n PORTC .0 = 0;\n }\n</code></pre>\n<pre class=\"lang-c prettyprint-override\"><code>unsigned long int ScanKey(void)\n{\n unsigned long int num = 0;\n _lcd_write_data(0x0F);\n PORTC .2 = 1;\n while (1)\n {\n PORTD .0 = 0;\n PORTD .1 = 1;\n PORTD .2 = 1;\n delay_ms(5);\n if (PIND .3 == 0)\n {\n while (PIND .3 == 0)\n ;\n lcd_putchar('1');\n num = (num * 10) + 1;\n }\n else if (PIND .4 == 0)\n {\n while (PIND .4 == 0)\n ;\n lcd_putchar('4');\n num = (num * 10) + 4;\n }\n else if (PIND .5 == 0)\n {\n while (PIND .5 == 0)\n ;\n lcd_putchar('7');\n num = (num * 10) + 7;\n }\n else if (PIND .6 == 0)\n {\n while (PIND .6 == 0)\n ;\n _lcd_write_data(0x10);\n lcd_putchar(' ');\n _lcd_write_data(0x10);\n num /= 10;\n }\n\n PORTD .0 = 1;\n PORTD .1 = 0;\n PORTD .2 = 1;\n delay_ms(5);\n if (PIND .3 == 0)\n {\n while (PIND .3 == 0)\n ;\n lcd_putchar('2');\n num = (num * 10) + 2;\n }\n else if (PIND .4 == 0)\n {\n while (PIND .4 == 0)\n ;\n lcd_putchar('5');\n num = (num * 10) + 5;\n }\n else if (PIND .5 == 0)\n {\n while (PIND .5 == 0)\n ;\n lcd_putchar('8');\n num = (num * 10) + 8;\n }\n else if (PIND .6 == 0)\n {\n while (PIND .6 == 0)\n ;\n lcd_putchar('0');\n num = (num * 10) + 0;\n }\n\n PORTD .0 = 1;\n PORTD .1 = 1;\n PORTD .2 = 0;\n delay_ms(5);\n if (PIND .3 == 0)\n {\n while (PIND .3 == 0)\n ;\n lcd_putchar('3');\n num = (num * 10) + 3;\n }\n else if (PIND .4 == 0)\n {\n while (PIND .4 == 0)\n ;\n lcd_putchar('6');\n num = (num * 10) + 6;\n }\n else if (PIND .5 == 0)\n {\n while (PIND .5 == 0)\n ;\n lcd_putchar('9');\n num = (num * 10) + 9;\n }\n else if (PIND .6 == 0)\n {\n while (PIND .6 == 0)\n ;\n break;\n }\n }\n PORTC .2 = 0;\n _lcd_write_data(0x0C);\n return num;\n}```\n</code></pre>\n"},{"tags":["java","sorting","oop","arraylist"],"owner":{"reputation":109,"user_id":9269308,"user_type":"registered","profile_image":"https://graph.facebook.com/199011024012083/picture?type=large","display_name":"Jonathan Baxevanidis","link":"https://stackoverflow.com/users/9269308/jonathan-baxevanidis"},"is_answered":false,"view_count":8,"answer_count":0,"score":0,"last_activity_date":1623258185,"creation_date":1623256794,"last_edit_date":1623258185,"question_id":67908351,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908351/how-to-sort-file-using-arraylist-according-to-specific-token","title":"How to sort file using Arraylist according to specific token?","body":"<p>I have a file that has some info about ticket issuance which looks like that.</p>\n<pre><code>Test Passenger Aegean Business 06:00 Athens-London 650.92 E1 T9759 09/06/2021 12:45:22\nTest Passenger RyanAir Economy 10:30 Athens-London 200.65 E2 T9946 09/06/2021 12:45:30\nTest Passenger Lufthansa Business 12:30 Athens-London 700.50 E3 T8189 09/06/2021 12:45:37\n</code></pre>\n<p>The attributes are <code>passengerName</code>, <code>Company</code>, <code>ticketClass</code>, <code>departureTime</code>, <code>itenerary</code>, <code>ticketCost</code>, <code>gate</code>, <code>ticketId</code>, <code>issueDate</code> which are seperated using "\\t" as the <code>delimiter</code>.\nEvery input in the file is a <code>String</code>. The file gets loaded in an <code>Arraylist</code> from where I try to sort it according to the price of the ticket. What I do is I split the arraylist in tokens in order to get the correct thing to compare from each arraylist, but it doesn’t seem to work. Also I have tried to implement all the <code>Collections.sort()</code> examples that I found but still nothing works. The desired result to get the file sorted so I can display it in a <code>JTextArea</code>.Every field of the file is a String which is an attribute of the <code>Ticket class</code> and the ArrayList is of type Ticket (<code>ArrayList<Ticket> = new ArrayList();</code>). Here is what I have till now.</p>\n<pre><code>private void loadFromFile(String fileName) {\n \n ArrayList<Ticket> ticketsList = new ArrayList();\n\n try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {\n \n String line = "";\n String[] tokens;\n Ticket ticket = new Ticket();\n \n float totalTicketCost = (float) 0.00;\n int numberOfLines = 0;\n\n while(reader.ready()){\n line = reader.readLine();\n\n tokens = line.split("\\t");\n\n if (tokens.length == 9) {\n\n ticket = new Ticket(tokens[0], tokens[1], tokens[2], tokens[3], tokens[4], tokens[5],tokens[6], tokens[7], tokens[8]);\n ticketsList.add(ticket);\n }\n\n area.append(ticket.toString());\n\n totalTicketCost += Float.parseFloat(tokens[5]);\n \n // format dacimals for total cost\n DecimalFormat df = new DecimalFormat();\n df.setMaximumFractionDigits(2);\n\n numberOfTickets.setText(String.valueOf(numberOfLines));\n totalCost.setText(String.valueOf(df.format(totalTicketCost)));\n\n numberOfLines++; //Total number of tickets\n \n }\n \n // Since nothing works let's try the C way of finding the the biggest ticketCost\n float tmp = Float.valueOf(ticketsList.get(0).getTicketPrice());\n float max = Float.valueOf(ticketsList.get(0).getTicketPrice());\n \n for( int i = 0; i < ticketsList.size(); i++){\n \n tmp = Float.valueOf(ticketsList.get(i).getTicketPrice());\n \n if( max < tmp ){\n max = tmp;\n // currentBig = Float.valueOf(ticketsList.get(i+1).getTicketPrice());\n } \n System.out.println(tmp + "\\n");\n }\n \n } catch (Exception e) {\n }\n} \n</code></pre>\n"},{"tags":["r","ggplot2"],"owner":{"reputation":393,"user_id":3337399,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2014e9655c30e9b504c841fdfb9fb8f5?s=128&d=identicon&r=PG&f=1","display_name":"moooh","link":"https://stackoverflow.com/users/3337399/moooh"},"is_answered":false,"view_count":39,"answer_count":2,"score":0,"last_activity_date":1623258180,"creation_date":1623232179,"last_edit_date":1623237422,"question_id":67901691,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67901691/ggplot-create-a-facet-grid-with-free-scales","title":"ggplot: create a facet grid with free scales","body":"<p>In ggplot I want to create a facet grid where the y axes are free. This <code>scales</code> option is available in <code>facet_wrap()</code> but I want to keep the grid layout. I have attached a drawn example of what I want.</p>\n<p><a href=\"https://i.stack.imgur.com/gCxgX.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/gCxgX.png\" alt=\"example of facet grid with free y axes\" /></a></p>\n<p>EDIT:\nI added some code for calrity</p>\n<pre><code># Create data\nnX <- 3\nnY <- 3\nnVal <- 2\ndf <- data.frame(M = sort(rep(paste0("M",1:nX), nVal * nY)),\n n = rep(sort(paste0("n",rep((1:nY)-1, nVal))),nX),\n G = rep(1:2,nX * nY),\n val = c(100,300,20,10,1,2,10,25,NA,NA,0.1,0.2,25,27,2,5,0.5,0.6))\n\n# Delete observations to resemble my data\ndf <- subset(df, !is.na(val))\n\n# scales does not work in facet_grid(), thus obscuring trends for low values\nggplot(df, aes(x = G,\n y = val)) +\n geom_line()+\n ylim(0,NA)+\n facet_grid(n ~ M,scales = "free_y")\n</code></pre>\n<p><a href=\"https://i.stack.imgur.com/Q8JF6.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/Q8JF6.png\" alt=\"with facet grid\" /></a></p>\n<p>Note that no trends are visible for low values because in the grid they are obscured by the high values.</p>\n<pre><code># the grid is lost in facet_wrap()\nggplot(df, aes(x = G,\n y = val)) +\n geom_line()+\n ylim(0,NA)+\n facet_wrap(n+M~.,scales = "free_y")\n</code></pre>\n<p><a href=\"https://i.stack.imgur.com/6YCdk.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/6YCdk.png\" alt=\"enter image description here\" /></a></p>\n<p>Note that the grid layout is lost.</p>\n"},{"tags":["dialogflow-es","actions-on-google"],"owner":{"reputation":1,"user_id":16172188,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1a81be67c92b879c514fca408a0855fe?s=128&d=identicon&r=PG","display_name":"Karan Sheth","link":"https://stackoverflow.com/users/16172188/karan-sheth"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623258169,"creation_date":1623218212,"last_edit_date":1623221405,"question_id":67898367,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67898367/google-actions-re-certification-requirements","title":"Google Actions Re-certification requirements","body":"<p>Do we need to re-certify a deployed skill if we edit Entities (eg: add synonyms) to Dialogflow or edit Types in case of using Actions Builder?</p>\n<p>Essentially is there an "Update Live Skill" option similar to Alexa Skills Kit, where any published skill can be updated immediately when changes are limited to sample utterances within an intent or slot/entity values.</p>\n"},{"tags":["c++","debugging","gdb"],"owner":{"reputation":36,"user_id":5640590,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/938d2a44aaaeedfb07144ba3686acc9f?s=128&d=identicon&r=PG&f=1","display_name":"nkgt_","link":"https://stackoverflow.com/users/5640590/nkgt"},"is_answered":false,"view_count":26,"answer_count":1,"score":0,"last_activity_date":1623258168,"creation_date":1623228865,"question_id":67900767,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67900767/debugging-multiprocess-project-with-gdb","title":"Debugging multiprocess project with GDB","body":"<p>I'd like to to debug a multiprocess C++ project with GDB, specifically I'd like to know if there is a way to achieve the following</p>\n<ul>\n<li>Attach multiple processes to a single instance of GDB while letting all the processes run</li>\n<li>Setting up a breakpoint in the source code of one of the processes stops all the attached processes</li>\n</ul>\n<p>The ideal solution would be something similar to what is offered by the Visual Studio debugger as described <a href=\"https://docs.microsoft.com/en-us/visualstudio/debugger/debug-multiple-processes?view=vs-2019#BKMK_Switch_processes__break_and_continue_execution__step_through_source\" rel=\"nofollow noreferrer\">here</a>.\nAt the moment I'm able to attach multiple processes to a GDB instance but then only the current selected inferior is executed while the others are stopped and waiting for a continue command.</p>\n"},{"tags":["redis","lua","bloom-filter"],"owner":{"reputation":11,"user_id":16152972,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/3525f704f6188322de0eecb431056e79?s=128&d=identicon&r=PG&f=1","display_name":"tom","link":"https://stackoverflow.com/users/16152972/tom"},"is_answered":false,"view_count":42,"answer_count":1,"score":1,"last_activity_date":1623258165,"creation_date":1623063429,"last_edit_date":1623080618,"question_id":67870349,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67870349/springboot-use-lua-to-create-redis-bloom-filter-user-script1-err-bad-error","title":"springboot use lua to create redis bloom filter : @user_script:1: ERR bad error rate","body":"<p>I use the SpringBoot provided redistemplate to execute the Lua script:</p>\n<pre class=\"lang-lua prettyprint-override\"><code>return redis.call('bf.reserve', KEYS[1],ARGV[1],ARGV[2])\n</code></pre>\n<p>but it keeps getting wrong:</p>\n<blockquote>\n<p>ERR Error running script (call to f_264cca3824c7a277f5d3cf63f1b2642a0750e989): @user_script:1: ERR bad error rate.</p>\n</blockquote>\n<p>this is my docker image:\nredislabs/rebloom:2.2.5</p>\n<p>i try to run this script in linux command,it works:</p>\n<pre><code>[root@daice ~]# redis-cli --eval a.lua city , 0.001 100000\nOK\n[root@daice ~]# redis-cli\n127.0.0.1:6379> keys *\n1) "city"\n</code></pre>\n"},{"tags":["python","pandas"],"owner":{"reputation":21,"user_id":9091034,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d986002a55ba762358207f7f60b05516?s=128&d=identicon&r=PG&f=1","display_name":"Stgauss","link":"https://stackoverflow.com/users/9091034/stgauss"},"is_answered":false,"view_count":23,"answer_count":1,"score":0,"last_activity_date":1623258161,"creation_date":1623257486,"question_id":67908527,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908527/pandas-get-column-based-on-another-column-which-contains-column-names","title":"Pandas: get column, based on another column which contains column names","body":"<p>I'm working on a script to do some pricing. Have a dataframe which contains a quantity list:</p>\n<div class=\"s-table-container\">\n<table class=\"s-table\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Volume</th>\n<th>Area</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Wood</td>\n<td>133</td>\n<td>256</td>\n</tr>\n<tr>\n<td>Steel</td>\n<td>55</td>\n<td>330</td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>(and 1800 more lines like those)</p>\n<p>What I need to do is create a third column in the df that contains the "true" quantity.\nPretty much, on some materials it's the volume, on others it's the area.</p>\n<div class=\"s-table-container\">\n<table class=\"s-table\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Volume</th>\n<th>Area</th>\n<th>Qty</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Wood</td>\n<td>133</td>\n<td>256</td>\n<td>133</td>\n</tr>\n<tr>\n<td>Steel</td>\n<td>55</td>\n<td>330</td>\n<td>330</td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>So far I've thought to create a dictionary:</p>\n<p>my_dict = {'Wood':'Volume', 'Steel':'Area'}</p>\n<p>Using map (or replace) I put that into a column in the df:</p>\n<div class=\"s-table-container\">\n<table class=\"s-table\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Volume</th>\n<th>Area</th>\n<th>Datafield</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Wood</td>\n<td>133</td>\n<td>256</td>\n<td>Volume</td>\n</tr>\n<tr>\n<td>Steel</td>\n<td>55</td>\n<td>330</td>\n<td>Area</td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Now, how would I go about putting the quantity into the Quantity column, based on what Datafield says?</p>\n<p>I tried</p>\n<p>df['Quantity'] = df[df['Datafield']]</p>\n<p>But, it crashed and I'm stuck.</p>\n"},{"tags":["python-3.x","string","amazon-web-services","amazon-s3","boto3"],"owner":{"reputation":339,"user_id":8942319,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b7aad150d47f39c523e91c65834b44bf?s=128&d=identicon&r=PG&f=1","display_name":"sam","link":"https://stackoverflow.com/users/8942319/sam"},"is_answered":false,"view_count":15,"answer_count":0,"score":0,"last_activity_date":1623258157,"creation_date":1623183261,"last_edit_date":1623258157,"question_id":67894019,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67894019/aws-boto3-s3-i-accidentally-renamed-a-set-of-files-as-empty-string-theyre-gon","title":"AWS Boto3 S3: I accidentally renamed a set of files as empty string. They're gone right?","body":"<p>To "rename" some files I copied them with a new name and then deleted the originals. In creating the new name I meant to do this:</p>\n<pre><code>new_key_path = '.'.join(key_path.split('.')[0:3])\n</code></pre>\n<p>But I did this</p>\n<pre><code>new_key_path = '.'.join(str.split('.')[0:3])\n</code></pre>\n<p><code>key_path</code> vs <code>str</code>. The former is a valid variable (path to file), the latter was apparently not <code>None</code>, but an empty string. So it didn't error out. The result of this was that all iterations set <code>new_key_path</code> to <code>.</code>. The rest of the logic was such that I was essentially copying to the "root" of the s3 bucket...</p>\n<p>Anyway, I can get the data back elsewhere but just want to validate that I indeed messed up in this specific way. I don't see it anywhere else in the bucket. Thanks</p>\n<p>EDIT: adding the example renaming code. <a href=\"https://boto3.amazonaws.com/v1/documentation/api/1.9.42/reference/services/s3.html#S3.MultipartUploadPart.copy_from\" rel=\"nofollow noreferrer\">This is out of the box with Boto3</a>.</p>\n<pre><code>self.s3_resource.Object(self._bucket_name, new_key_path).copy_from(CopySource=copy_src)\nself.s3_resource.Object(self._bucket_name, key_path).delete()\n</code></pre>\n"},{"tags":["r","auc"],"owner":{"reputation":1,"user_id":16176963,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgGy4Hd4T8V96BsIBYyYlU3dw2jshxzwaQeLTpOBSA=k-s128","display_name":"shinyhill","link":"https://stackoverflow.com/users/16176963/shinyhill"},"is_answered":false,"view_count":13,"answer_count":0,"score":-2,"last_activity_date":1623258153,"creation_date":1623257430,"last_edit_date":1623258153,"question_id":67908515,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908515/auc-by-trapezoid-method-in-r","title":"AUC by trapezoid method in R","body":"<p>I'm a beginner who just started using R.</p>\n<p>I am trying to obtain the AUC for each time section using the trapezoid method with the results measured at 0,10,20,30,40, 50, 60 minutes for each ID.\nWhat should I do?</p>\n<pre><code> CASET0 T10 T20 T30 T40 T50 T60\n1 88 89 91 105 107 139 159\n2 92 NA 102 NA NA 189 144\n3 79 NA 82 98 106 140 118\n5 81 81 82 92 86 101 124\n8 90 89 89 106 115 134 101\n9 91 77 87 82 95 133 156\n</code></pre>\n"},{"tags":["javascript","regex","string"],"owner":{"reputation":3,"user_id":13567734,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-MuWuOfcASF0/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rf82T7_IDLxKMcN1ay9h41RNF25DA/mo/photo.jpg?sz=128","display_name":"Vlad","link":"https://stackoverflow.com/users/13567734/vlad"},"is_answered":true,"view_count":15,"accepted_answer_id":67908679,"answer_count":1,"score":0,"last_activity_date":1623258153,"creation_date":1623257029,"last_edit_date":1623257653,"question_id":67908425,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908425/regex-do-not-capture-group-in-javascript","title":"Regex do not capture group in JavaScript","body":"<p>I wrote regular expression</p>\n<pre><code>/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g\n</code></pre>\n<p>For given string</p>\n<pre><code>translateX(381px) translateY(-94px)\n</code></pre>\n<p>To capture <code>translateX</code> and <code>translateY</code> values. Tested it by regex101.com service, it works well there. But, when I try it in JavaScript it capture <code>translateX</code> value which is <code>381</code> but not capture <code>translateY</code> which is <code>-94</code>. Do you have any ideas why is this happening?</p>\n<p><strong><p>regex101</p></strong></p>\n<p><a href=\"https://i.stack.imgur.com/Nuj5X.png\" rel=\"nofollow noreferrer\">https://i.stack.imgur.com/Nuj5X.png</a></p>\n<p><strong><p>JavaScript exec</p></strong></p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>console.log(/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g.exec(\"translateX(381px) translateY(-94px)\"));</code></pre>\r\n</div>\r\n</div>\r\n</p>\n<p>Using <code>matchAll</code> gives the same result.</p>\n<p><strong><p>JavaScript matchAll</p></strong></p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>console.log(\"translateX(381px) translateY(-94px)\".matchAll(/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g).next().value.groups);</code></pre>\r\n</div>\r\n</div>\r\n</p>\n"},{"tags":[".net","postgresql","entity-framework-core","npgsql"],"owner":{"reputation":2627,"user_id":863487,"user_type":"registered","accept_rate":89,"profile_image":"https://i.stack.imgur.com/fuh8Q.jpg?s=128&g=1","display_name":"Rob Quincey","link":"https://stackoverflow.com/users/863487/rob-quincey"},"is_answered":false,"view_count":8,"answer_count":1,"score":0,"last_activity_date":1623258152,"creation_date":1623256824,"question_id":67908362,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908362/ef-core-npgsql-parameterize-an-entire-where-clause","title":"EF Core/Npgsql Parameterize an entire where clause","body":"<p>I'm attempting to use Entity Framework Core with Npgsql to perform a raw SQL query where the WHERE clause part is pulled in from the database, with the actual 'value' supplied by a user. As a concrete example:</p>\n<p>This part of the SQL is static</p>\n<pre><code>SELECT TITLE as TitleField,\n GEOM as GeomField,\n GEOM_X as XField,\n GEOM_Y as YField\nFROM fdw_public."MY_TABLE"\n</code></pre>\n<p>Then an administrator can set a WHERE clause up in the database, for example:</p>\n<pre><code>COLUMNNAME LIKE '%{search}%'\n</code></pre>\n<p>or</p>\n<pre><code>OTHER_COLUMNNAME = '{search}' AND COLUMNNAME = 'Something Static';\n</code></pre>\n<p>This isn't known at compile time and could be any valid WHERE clause.</p>\n<p>The {search} part is a placeholder. I trust the clause coming from the database, this is only controlled by the application owner and if they want to break their own table, that's fine.</p>\n<p>The end result is this SQL</p>\n<pre><code>SELECT TITLE as TitleField,\n GEOM as GeomField,\n GEOM_X as XField,\n GEOM_Y as YField\nFROM fdw_public."MY_TABLE"\nWHERE COLUMNNAME LIKE '%{search}%'\n</code></pre>\n<p>The {search} part however is the user input (from a web application), so this needs parameterizing.</p>\n<p>The following works, but is obviously very open to SQL Injection</p>\n<pre><code>var sql = $@"SELECT TITLE as TitleField,\n GEOM as GeomField,\n XFIELD as XField,\n YFIELD as YField\n FROM fdw_public."MY_TABLE"\n WHERE {searchDefinition.WhereClause.Replace("{search}", searchTerm)}";\n \nvar dbResults = _context.DatabaseSearchResults.FromSqlRaw(sql).ToList();\n</code></pre>\n<p>So I attempted to use a parameter for the whole where clause</p>\n<pre><code>var sql = $@"SELECT TITLE as TitleField,\n GEOM as GeomField,\n XFIELD as XField,\n YFIELD as YField\n FROM fdw_public."MY_TABLE"\n WHERE @whereClause";\n\n var whereClauseParam = new Npgsql.NpgsqlParameter("@whereClause", searchDefinition.WhereClause.Replace("{search}", searchTerm));\n var dbResults = _context.DatabaseSearchResults.FromSqlRaw(sql,whereClauseParam).ToList();\n</code></pre>\n<p>But this throws the following exception from Npgsql</p>\n<blockquote>\n<p>42804: argument of WHERE must be type boolean, not type text</p>\n</blockquote>\n<p>This does makes sense to me, as it feels wrong paramterizing ann entire clause, but I can't figure out a better way round it.</p>\n<p>Ideally I need to parametrize just the search term, like this</p>\n<pre><code>var sql = $@"SELECT TITLE as TitleField,\n GEOM as GeomField,\n XFIELD as XField,\n YFIELD as YField\n FROM fdw_public."MY_TABLE"\n WHERE {searchDefinition.WhereClause.Replace("{search}","@p0")}";\n\n var searchTermParam = new Npgsql.NpgsqlParameter("p0", searchTerm);\n var dbResults = _context.DatabaseSearchResults.FromSqlRaw(sql, searchTermParam).ToList();\n</code></pre>\n<p>But again, this doesn't work, understandably, as it is being interpreted literally.</p>\n<p>I feel this may involve a change in how I'm doing this completely, or at worse, falling back to sanitizing the search string using some well known sanitization, but I don't want to do this, I want to use parameters.</p>\n<p>Either way, to sum up, the requirement is this</p>\n<ul>\n<li>The WHERE clause must come from the database but it CAN be trusted</li>\n<li>The WHERE clause from the db can be any valid WHERE with a {search} placeholder, allowing us to do things like wildcarding (the admins are expected to know the data types and whether the value should be wrapped in quotes or not etc.)</li>\n<li>The search term must be sanitized</li>\n</ul>\n"},{"tags":["c","multidimensional-array"],"owner":{"reputation":1,"user_id":16178193,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJy-ndnJ2RBdowkl2CepoBcLLQby2xIG5_NnjPkg=k-s128","display_name":"andrew c.","link":"https://stackoverflow.com/users/16178193/andrew-c"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623258150,"creation_date":1623258150,"question_id":67908678,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908678/random-values-of-multidimensional-array-new-to-programming-arrays-assignment","title":"Random values of multidimensional array. new to programming arrays assignment","body":"<p>I just started a intro college C programming class and have the following assignment:</p>\n<ol>\n<li><p>Use a loop to load random integer values into a 1 dimensional array.</p>\n</li>\n<li><p>Use a loop to load random integer values into a multidimensional array.</p>\n</li>\n<li><p>Create a function to search (Linear) for numbers in both.</p>\n<p>a. The search should find all numbers divisible by 3 and return the number back to the user , as well as print the number to the screen.</p>\n</li>\n<li><p>Write functions to print the contents of each array.</p>\n</li>\n<li><p>Your function should accept an array as the parameter.</p>\n</li>\n<li><p>Write a function that increments all the values by an integer that is passed as a parameter. This parameter should be passed by reference.</p>\n</li>\n<li><p>Print the byte sizes of each array to the screen</p>\n</li>\n</ol>\n<p>Our professor has yet to teach anything. She just kind of handed us a textbook and said get to it. after watching a couple of youtube videos and reading other threads, I've been able to do #1 successfully but am just lost when it comes to the rest. Any help would be greatly appreciated.</p>\n<p>Here's what I have so far.</p>\n<pre><code>#include <stdlib.h>\n#include <time.h>\n\nconst int r = 5;\nconst int c = 5;\n\nint main(void)\n{\n srand(time(NULL)); //generator for random numbers\n int rndmNum[25]; //random number array for 25 ints\n int i;\n\nprintf("One-Dimensional Array\\n"); //objective 1\n for (i = 0; i < 25; i++) //loop 25 times\n {\n rndmNum[i] = i + 1;\n printf("%d\\n", (rand() % 50) + 1);} //print random ints from 1-100 objective 4\n\nprintf("\\nMulti-Dimensional Array\\n"); //objective 2\n int mltdim[r][c]; //multidim array for 25 nuumbers\n \n\n\n\n return 0;\n\n\n}\n</code></pre>\n"},{"tags":["amazon-web-services","amazon-cloudfront"],"owner":{"reputation":14078,"user_id":160245,"user_type":"registered","accept_rate":80,"profile_image":"https://www.gravatar.com/avatar/ad3772721158c9ed78c4fccbc1d1b9f9?s=128&d=identicon&r=PG","display_name":"NealWalters","link":"https://stackoverflow.com/users/160245/nealwalters"},"is_answered":false,"view_count":6,"answer_count":1,"score":0,"last_activity_date":1623258148,"creation_date":1623256932,"question_id":67908392,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908392/does-cloudfront-disable-enable-effectively-invalidate-all-files","title":"Does Cloudfront Disable/Enable effectively "invalidate" all files?","body":"<p>I know it takes longer and more resources, but does doing a full disable/enable in Cloudfront invalidate all the files? Sometimes it seems safer to just do everything than rely on the developers sending us an exactly list of files. (We have a static HTML site with javascript code hosted in S3 and exposed via Cloudfront.)</p>\n<p>I tried the disable/enable yesterday, but today, people were saying it looks their code changes were not being used on the website.</p>\n<p>Great feature in the future would be to invalidate all files changed since the last validation. That should be easy for them to do.</p>\n"},{"tags":[".net","asp.net-core"],"owner":{"reputation":3,"user_id":9551458,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ff0ad13b2d83752d5b3532c760aebd58?s=128&d=identicon&r=PG&f=1","display_name":"beiduoan","link":"https://stackoverflow.com/users/9551458/beiduoan"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258145,"creation_date":1623258145,"question_id":67908676,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908676/net-core-how-to-get-week-datetime-list-by-datetime-range","title":".net core how to get week datetime list by datetime range","body":"<p>I hope get week datetime list by datetime range,I tried the following code get number of weeks per month.</p>\n<pre><code>var start = new DateTime(2021, 6, 09);\n var end = new DateTime(2021, 7, 01);\n\n end = new DateTime(end.Year, end.Month, DateTime.DaysInMonth(end.Year, end.Month));\n\n var diff = Enumerable.Range(0, Int32.MaxValue)\n .Select(e => start.AddMonths(e))\n .TakeWhile(e => e <= end)\n .Select(e => Convert.ToDateTime(e.ToString("yyyy-MM")));\n\n foreach (var item in diff)\n {\n\n DateTime dateTime = item;\n Calendar calendar = CultureInfo.CurrentCulture.Calendar;\n IEnumerable<int> daysInMonth = Enumerable.Range(1, calendar.GetDaysInMonth(dateTime.Year, dateTime.Month));\n List<Tuple<DateTime, DateTime>> weeks = daysInMonth.Select(day => new DateTime(dateTime.Year, dateTime.Month, day))\n .GroupBy(d => calendar.GetWeekOfYear(d, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday))\n .Select(g => new Tuple<DateTime, DateTime>(g.First(), g.Last()))\n .ToList();\n }\n</code></pre>\n<p>But,I hope get DateTime(2021, 6, 09) between Week starting on the 9th and DateTime(2021, 7, 01) Week ending on the 1th of weeks time, like this.</p>\n<pre><code>2021-06-09 2021-06-13\n.....\n2021-06-28 2021-07-01\n</code></pre>\n<p>how to changed my code</p>\n"},{"tags":["r","ggplot2","legend","sf"],"owner":{"reputation":2193,"user_id":4224718,"user_type":"registered","accept_rate":91,"profile_image":"https://i.stack.imgur.com/0zvNV.jpg?s=128&g=1","display_name":"M. Beausoleil","link":"https://stackoverflow.com/users/4224718/m-beausoleil"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258141,"creation_date":1623258141,"question_id":67908675,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908675/mix-colour-fill-and-linetype-in-r-ggplot-legend","title":"Mix colour, fill and linetype in R ggplot legend","body":"<p>I have a map where I'm trying to add to a legend with 2 filled polygons and 1 polygon but with only the contour that is outlined (which would be represented only by a dotted line).</p>\n<pre><code>library(sf);library(ggplot)\n# point\np <- rbind(c(1,2), c(2,1), c(3,2), c(3.5,3.5), c(3.4,3.6), c(3.9,1.4))\n(mp <- st_multipoint(p))\n\np1 <- rbind(c(0,0), c(1,0), c(3,2), c(2,4), c(1,4), c(0,0))\np2 <- rbind(c(1,1), c(1,2), c(2,2), c(1,1))\npol <-st_polygon(list(p1,p2))\n\np3 <- rbind(c(3,0), c(4,0), c(4,1), c(3,1), c(3,0))\np4 <- rbind(c(3.3,0.3), c(3.8,0.3), c(3.8,0.8), c(3.3,0.8), c(3.3,0.3))[5:1,]\np5 <- rbind(c(3,3), c(4,2), c(4,3), c(3,3))\n(mpol1 <- st_multipolygon(list(list(p3))))\n(mpol2 <- st_multipolygon(list(list(p4))))\n(mpol3 <- st_multipolygon(list(list(p5))))\n\nggplot(mp, aes(geometry = geometry)) + \n geom_sf(data = pol, aes(geometry = geometry), inherit.aes = FALSE) +\n # Add the points \n geom_sf(data = mpol1, alpha = 0.5, aes(geometry = geometry, colour = "grey90", fill = "grey90"), size = 0.05) + \n geom_sf(data = mpol2, alpha = 0.5, aes(geometry = geometry, colour = "grey20", fill = "grey20"), size = 0.05) +\n geom_sf(data = mpol3, alpha = 0.5, aes(geometry = geometry,colour = "grey30", fill=NA), size = 0.8, linetype = "dotted") +\n scale_color_manual(values = c(alpha("grey90",.5),alpha("grey20",.5),alpha("grey30",.5)), labels = c("item1", "item2","item3"), name="My Leg. hurts") +\n scale_fill_manual( values = c(alpha("grey90",.5),alpha("grey20",.5),NA), labels = c("item1", "item2","item3"), name="My Leg. hurts") + \n theme_bw()+\n theme(legend.key = element_rect(fill = NA), \n legend.background = element_rect(fill = NA),\n legend.text = element_text(size = 12), \n legend.title = element_text(size = 12,face='bold'))\n</code></pre>\n<p>Gives</p>\n<p><a href=\"https://i.stack.imgur.com/aS0eX.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/aS0eX.png\" alt=\"enter image description here\" /></a></p>\n<p>But I want this:</p>\n<p><a href=\"https://i.stack.imgur.com/L4j1a.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/L4j1a.png\" alt=\"enter image description here\" /></a></p>\n<p>How can this be achieved?</p>\n"},{"tags":["sql","plsql","oracle11g","rdbms"],"owner":{"reputation":11,"user_id":15908800,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/863c6dd0e26ce7cb2f06c2660d45f37d?s=128&d=identicon&r=PG&f=1","display_name":"water_drinker","link":"https://stackoverflow.com/users/15908800/water-drinker"},"is_answered":false,"view_count":8,"answer_count":1,"score":0,"last_activity_date":1623258137,"creation_date":1623257837,"question_id":67908600,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908600/how-to-stop-a-running-command-in-oracle-11g-dbms","title":"How to stop a running command in oracle 11g DBMS","body":"<p>I used to write PL/SQL procedures in oracle dbms. Few times I would end up in situations like Infinite loop and the query continuously running I want to stop it. If I press ctrl + C whole command line gets closed.</p>\n"},{"tags":["javascript","regex"],"owner":{"reputation":55,"user_id":11361543,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-aAWlAXnzPyw/AAAAAAAAAAI/AAAAAAAAAwY/o-PtlTaNlwE/photo.jpg?sz=128","display_name":"Shantanu Kaushik","link":"https://stackoverflow.com/users/11361543/shantanu-kaushik"},"is_answered":true,"view_count":24,"answer_count":1,"score":0,"last_activity_date":1623258136,"creation_date":1623239917,"question_id":67903700,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67903700/capturing-variable-names-using-regex-javascript","title":"Capturing variable names using RegEX JavaScript?","body":"<p>I am trying to capture variable names from the variable declaration. The variables are declared and initialized in the following manner:</p>\n<pre><code>let URL="https://www.lipsum.com/", error, pass=true;\n</code></pre>\n<p>I have this above code in the form of a string and I want to obtain the name of the variables using RegEX.</p>\n<p>I am using this regex expression: <code>/let\\s+([\\w_$]+)(?:=.*),?/;</code></p>\n<p>However, I am only getting <code>URL</code> in the output</p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>const str = `let URL=\"https://www.lipsum.com/\", error, pass=true;`;\nconst regex = /let\\s+([\\w_$]+)(?:=.*),?/;\n\nconsole.log(str.match(regex));</code></pre>\r\n</div>\r\n</div>\r\n</p>\n<p>How do I obtain the variable names <code>URL</code>, <code>error</code>, and <code>pass</code> from the given string?</p>\n"},{"tags":["python","pandas","list","dataframe"],"owner":{"reputation":73,"user_id":6585375,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d768f4f5645846927074e1998b938f7f?s=128&d=identicon&r=PG&f=1","display_name":"Skipper Lin","link":"https://stackoverflow.com/users/6585375/skipper-lin"},"is_answered":true,"view_count":20,"answer_count":2,"score":1,"last_activity_date":1623258132,"creation_date":1623257486,"question_id":67908526,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908526/obtain-the-pandas-dataframe-column-names-in-a-list-when-one-cell-value-equals-to","title":"Obtain the pandas dataframe column names in a list when one cell value equals to a specific string","body":"<p>I have a pandas dataframe with around 20-30 columns. I would like to obtain the column names in a list when one cell value equals to the string "Fail".</p>\n<p>The dataframe would look like this:</p>\n<pre><code> Column_1 Column_2 ... Column_30\n0 Pass Pass Fail\n1 Pass Pass Pass\n2 Fail Pass Pass\n3 Pass Pass Pass\n4 Pass Pass Pass\n..\n</code></pre>\n<p>The expected result looks like such <code>[Column_1, Column 30]</code></p>\n"},{"tags":["github"],"owner":{"reputation":1,"user_id":16178240,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJzKIDUlwP3sqIkOGZOR5wUNMTCfL-eZljZGqswM=k-s128","display_name":"mike","link":"https://stackoverflow.com/users/16178240/mike"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258130,"creation_date":1623258130,"question_id":67908671,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908671/how-to-convert-existing-github-appliance-server-into-github-replica-server","title":"How to convert existing GitHub Appliance server into GitHub Replica server?","body":"<p>we have two GitHub Enterprise Appliance we installed as "New Install" however; we would want to configure the second GitHub Enterprise Appliance as a "Configure as Replica" although it is currently installed as a "New Install". How do we go about this?</p>\n"},{"tags":["reactjs"],"owner":{"reputation":41,"user_id":12378060,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/7b5af6dbec6c53af1f1def286bbf7c5f?s=128&d=identicon&r=PG&f=1","display_name":"LosProgramer","link":"https://stackoverflow.com/users/12378060/losprogramer"},"is_answered":false,"view_count":21,"answer_count":1,"score":0,"last_activity_date":1623258130,"creation_date":1623257343,"question_id":67908492,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908492/componentdidupdate-infinite-loop","title":"componentDidUpdate() infinite loop","body":"<p>I get an error message for componentDidUpdate when I try to set state and I'm not sure why.</p>\n<pre><code>componentDidUpdate() {\n if(this.props.isLoadingDept===false && this.props.isLoadingEmpStatus===false\n && this.props.isLoadingGroup===false && this.props.isLoadingEmpDesig===false){\n this.setState({\n button:false\n })\n console.log('UPDATE')\n}\n}\n</code></pre>\n<p>console log value gets logged only once, when the statement is true, so I'm not sure how and why is it looping..</p>\n"},{"tags":["javascript"],"owner":{"reputation":1133,"user_id":10796680,"user_type":"registered","profile_image":"https://i.stack.imgur.com/rgfvm.jpg?s=128&g=1","display_name":"David Alford","link":"https://stackoverflow.com/users/10796680/david-alford"},"is_answered":false,"view_count":18,"answer_count":0,"score":0,"last_activity_date":1623258127,"creation_date":1623257818,"last_edit_date":1623258127,"question_id":67908597,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908597/how-to-add-event-listener-for-file-upload","title":"How to add event listener for file upload","body":"<p>I have a video upload form which needs a progress bar. I am using an <code>xhr.upload.addEventListener</code> function to monitor the progress of the upload. Problem is that the only way I can get the progress bar to display the upload progress is by only uploading the video field as such:</p>\n<pre><code>let formData = new FormData(e.target[4]); // 4th element in the form is the video\n</code></pre>\n<p>But the only way I can get it to send the whole form (but it will not update the progress bar) is as such:</p>\n<pre><code>let formData = new FormData(e.target.form);\n</code></pre>\n<p>The whole AJAX function is here:</p>\n<pre><code><script>\n function saveVideo(e) {\n e.preventDefault();\n let formData = new FormData(e.target[4]);\n\n $.ajax({\n async : true,\n type : 'POST',\n url : videoFormURL,\n headers : {"X-CSRFToken": token},\n enctype : 'multipart/form-data',\n processData : false,\n contentType : false,\n data : formData,\n xhr : function () {\n let xhr = new XMLHttpRequest();\n xhr.upload.addEventListener('progress', function (e) {\n if (e.lengthComputable) {\n let percent = Math.round(e.loaded / e.total * 100);\n $('#progress-bar').attr('aria-valuenow', percent).css('width', percent + '%');\n }\n });\n return xhr;\n },\n });\n }\n</script>\n</code></pre>\n<p>How can I monitor the progress but also upload the whole form?</p>\n<p>All help is very much appreciated.</p>\n"},{"tags":["parallel-processing","hardware","cpu-architecture","sse"],"owner":{"reputation":1,"user_id":16177793,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8ca0f4c5c752b4a7433447f7780d3dc2?s=128&d=identicon&r=PG&f=1","display_name":"akmopp","link":"https://stackoverflow.com/users/16177793/akmopp"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258125,"creation_date":1623258125,"question_id":67908669,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908669/why-isnt-everything-sse-or-simd-by-default","title":"Why isn't everything SSE (or "SIMD") by default?","body":"<p>I don't know much about the internal working of the CPU, and my understanding of SSE is equally basic; it works in the form of additional long registers that pack some number of data types you want a perform a single operation on (in parallel) using a single instruction.</p>\n<p>Great, but why isn't every register and every operation like that by default? If I want to add two integers, why would I need to place each in two separate registers and do the operation through multiple instructions when I could just do it through SSE? does it interfere with concurrency somehow? is it a hardware limitation?</p>\n<p>Thanks! If there are somewhat easy to follow sources as well, I would gladly appreciate it</p>\n"},{"tags":["python","keras","tensorflow2.0","reinforcement-learning","keras-rl"],"owner":{"reputation":33,"user_id":15915226,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5b0af37108f3b739f3f5f52bf96a758c?s=128&d=identicon&r=PG&f=1","display_name":"KnownUnknown","link":"https://stackoverflow.com/users/15915226/knownunknown"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258120,"creation_date":1623258120,"question_id":67908668,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908668/failedpreconditionerror-while-using-ddpg-rl-algorithm-in-python-with-keras-ke","title":"FailedPreconditionError while using DDPG RL algorithm, in python, with keras, keras-rl2","body":"<p>I am training a DDPG agent on my custom environment that I wrote using openai gym. I am getting error during training the model.</p>\n<p>When I search for a solution on web, I found that some people who faced similar issue were able to resolve it by initializing the variable.</p>\n<pre><code>For example by using:\ntf.global_variable_initialzer()\n</code></pre>\n<p>But I am using tensorflow version 2.5.0 which does not have this method. Which means there should be some other way to solve this error. But I am unable to find the solution.</p>\n<p>Here are the libraries that I used with there versions</p>\n<pre><code>tensorflow: 2.5.0\ngym: 0.18.3\nnumpy: 1.19.5\nkeras: 2.4.3\nkeras-rl2: 1.0.5 DDPG agent comes from this library\n</code></pre>\n<p>Error/Stacktrace:</p>\n<pre><code>Training for 1000 steps ...\nInterval 1 (0 steps performed)\n 17/10000 [..............................] - ETA: 1:04 - reward: 256251545.0121\nC:\\Users\\vchou\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\keras\\engine\\training.py:2401: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically.\n warnings.warn('`Model.state_updates` will be removed in a future version. '\n 100/10000 [..............................] - ETA: 1:03 - reward: 272267266.5754\nC:\\Users\\vchou\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:2426: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically.\n warnings.warn('`Model.state_updates` will be removed in a future version. '\n---------------------------------------------------------------------------\nFailedPreconditionError Traceback (most recent call last)\n<ipython-input-17-0938aa6056e8> in <module>\n 1 # Training\n----> 2 ddpgAgent.fit(env, 1000, verbose=1, nb_max_episode_steps = 100)\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\rl\\core.py in fit(self, env, nb_steps, action_repetition, callbacks, verbose, visualize, nb_max_start_steps, start_step_policy, log_interval, nb_max_episode_steps)\n 191 # Force a terminal state.\n 192 done = True\n--> 193 metrics = self.backward(reward, terminal=done)\n 194 episode_reward += reward\n 195 \n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\rl\\agents\\ddpg.py in backward(self, reward, terminal)\n 279 state0_batch_with_action = [state0_batch]\n 280 state0_batch_with_action.insert(self.critic_action_input_idx, action_batch)\n--> 281 metrics = self.critic.train_on_batch(state0_batch_with_action, targets)\n 282 if self.processor is not None:\n 283 metrics += self.processor.metrics\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\keras\\engine\\training_v1.py in train_on_batch(self, x, y, sample_weight, class_weight, reset_metrics)\n 1075 self._update_sample_weight_modes(sample_weights=sample_weights)\n 1076 self._make_train_function()\n-> 1077 outputs = self.train_function(ins) # pylint: disable=not-callable\n 1078 \n 1079 if reset_metrics:\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\keras\\backend.py in __call__(self, inputs)\n 4017 self._make_callable(feed_arrays, feed_symbols, symbol_vals, session)\n 4018 \n-> 4019 fetched = self._callable_fn(*array_vals,\n 4020 run_metadata=self.run_metadata)\n 4021 self._call_fetch_callbacks(fetched[-len(self._fetches):])\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\tensorflow\\python\\client\\session.py in __call__(self, *args, **kwargs)\n 1478 try:\n 1479 run_metadata_ptr = tf_session.TF_NewBuffer() if run_metadata else None\n-> 1480 ret = tf_session.TF_SessionRunCallable(self._session._session,\n 1481 self._handle, args,\n 1482 run_metadata_ptr)\n\nFailedPreconditionError: Could not find variable dense_5_1/kernel. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status=Not found: Resource localhost/dense_5_1/kernel/class tensorflow::Var does not exist.\n [[{{node ReadVariableOp_21}}]]\n</code></pre>\n<p>The actor and critic networks are as follows:</p>\n<pre><code>ACTOR NETWORK\nModel: "sequential"\n_________________________________________________________________\nLayer (type) Output Shape Param # \n=================================================================\nflatten (Flatten) (None, 10) 0 \n_________________________________________________________________\ndense (Dense) (None, 32) 352 \n_________________________________________________________________\nactivation (Activation) (None, 32) 0 \n_________________________________________________________________\ndense_1 (Dense) (None, 32) 1056 \n_________________________________________________________________\nactivation_1 (Activation) (None, 32) 0 \n_________________________________________________________________\ndense_2 (Dense) (None, 32) 1056 \n_________________________________________________________________\nactivation_2 (Activation) (None, 32) 0 \n_________________________________________________________________\ndense_3 (Dense) (None, 10) 330 \n_________________________________________________________________\nactivation_3 (Activation) (None, 10) 0 \n=================================================================\nTotal params: 2,794\nTrainable params: 2,794\nNon-trainable params: 0\n_________________________________________________________________\nNone\n</code></pre>\n<pre><code>CRITIC NETWORK\nModel: "model"\n__________________________________________________________________________________________________\nLayer (type) Output Shape Param # Connected to \n==================================================================================================\nobservation_input (InputLayer) [(None, 1, 10)] 0 \n__________________________________________________________________________________________________\naction_input (InputLayer) [(None, 10)] 0 \n__________________________________________________________________________________________________\nflatten_1 (Flatten) (None, 10) 0 observation_input[0][0] \n__________________________________________________________________________________________________\nconcatenate (Concatenate) (None, 20) 0 action_input[0][0] \n flatten_1[0][0] \n__________________________________________________________________________________________________\ndense_4 (Dense) (None, 32) 672 concatenate[0][0] \n__________________________________________________________________________________________________\nactivation_4 (Activation) (None, 32) 0 dense_4[0][0] \n__________________________________________________________________________________________________\ndense_5 (Dense) (None, 32) 1056 activation_4[0][0] \n__________________________________________________________________________________________________\nactivation_5 (Activation) (None, 32) 0 dense_5[0][0] \n__________________________________________________________________________________________________\ndense_6 (Dense) (None, 32) 1056 activation_5[0][0] \n__________________________________________________________________________________________________\nactivation_6 (Activation) (None, 32) 0 dense_6[0][0] \n__________________________________________________________________________________________________\ndense_7 (Dense) (None, 1) 33 activation_6[0][0] \n__________________________________________________________________________________________________\nactivation_7 (Activation) (None, 1) 0 dense_7[0][0] \n==================================================================================================\nTotal params: 2,817\nTrainable params: 2,817\nNon-trainable params: 0\n__________________________________________________________________________________________________\nNone\n</code></pre>\n<p>Here is the code for DDPG agent</p>\n<pre><code># Create DDPG agent\nddpgAgent = DDPGAgent(\n nb_actions = nb_actions,\n actor = actor,\n critic = critic,\n critic_action_input = action_input,\n memory = memory,\n nb_steps_warmup_critic = 100,\n nb_steps_warmup_actor = 100,\n random_process = random_process,\n gamma = 0.99,\n target_model_update = 1e-3\n)\n\nddpgAgent.compile(Adam(learning_rate=0.001, clipnorm=1.0), metrics=['mae'])\n</code></pre>\n"},{"tags":["angular","typescript","stripe-payments"],"owner":{"reputation":13,"user_id":14744187,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/bf5bb3bc0c3d87c7b17b5f02f1d5f8c5?s=128&d=identicon&r=PG&f=1","display_name":"wildpopones","link":"https://stackoverflow.com/users/14744187/wildpopones"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258118,"creation_date":1623258118,"question_id":67908667,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908667/integration-stripe-angular-cannot-find-name-stripe-did-you-mean-stripe","title":"Integration Stripe Angular, Cannot find name 'Stripe'. Did you mean 'stripe'?","body":"<p>I am trying to integrate Stripe with redirection to my app, I am using Angular-typescript.</p>\n<p>Here is the code I have so far in my component:</p>\n<pre><code>var head = document.getElementsByTagName('head')[0];\nvar script = document.createElement('script');\nscript.onload = function() {\n console.log('Script loaded');\n var stripe = Stripe(MY_PUBLICK_KEY);\n return stripe.redirectToCheckout({ sessionId: SESSION_I_RETURNED_FROM_MY_BACKEND});\n}\nscript.src = 'https://js.stripe.com/v3/';\nhead.appendChild(script);\n</code></pre>\n<p>But I have the following error running the above code:</p>\n<p><code>Cannot find name 'Stripe'. Did you mean 'stripe'?</code></p>\n<p>I have installed package with the command <code>npm install --save stripe</code> following the next guide <a href=\"https://stripe.com/docs/checkout/integration-builder\" rel=\"nofollow noreferrer\">https://stripe.com/docs/checkout/integration-builder</a></p>\n<p>Is there anyone that faced the same problem when integrating Stripe?</p>\n<p>Thanks!</p>\n"},{"tags":["reactjs"],"owner":{"reputation":49,"user_id":13398497,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GguMV_amD6S8ZcMIa9irT7jG05Z7RK6qwXUTROJ2A=k-s128","display_name":"Enyak Stew","link":"https://stackoverflow.com/users/13398497/enyak-stew"},"is_answered":false,"view_count":19,"answer_count":2,"score":0,"last_activity_date":1623258117,"creation_date":1623254918,"question_id":67907872,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907872/set-image-source-dinamically-in-react-js","title":"set image source dinamically in React.js","body":"<p>I am importing these images :</p>\n<pre><code>import Image1 from './assets/image1.png';\nimport Image2 from './assets/image2.png';\n</code></pre>\n<p>I am then using them in JSX :</p>\n<pre><code><img src={Image1} alt="image1"/>\n<img src={Image2} alt="image2"/>\n</code></pre>\n<p>The problem is that I would like to be able to set the source dinamically, like this, for example :</p>\n<pre><code><img src={`Image${1}`} alt="image1"/>\n</code></pre>\n<p>but of course a string won't work.</p>\n<p>Is there any way to do this ?</p>\n<p>Thanks</p>\n"},{"tags":["python","amazon-s3","pyspark","apache-spark-sql","awswrangler"],"owner":{"reputation":377,"user_id":13254554,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GhUqdXhtIy0MJhnwup3cuy2MU-vxp7Mm0MQ8oT78zQ=k-s128","display_name":"brenda","link":"https://stackoverflow.com/users/13254554/brenda"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258114,"creation_date":1623258114,"question_id":67908664,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908664/store-parquet-files-in-aws-s3-into-a-spark-dataframe-using-pyspark","title":"store parquet files (in aws s3) into a spark dataframe using pyspark","body":"<p>I'm trying to read data from a specific folder in my s3 bucket. This data is in parquet format. To do that I'm using <a href=\"https://github.com/awslabs/aws-data-wrangler\" rel=\"nofollow noreferrer\">awswrangler</a>:</p>\n<pre><code>import awswrangler as wr\n\n# read data\ndata = wr.s3.read_parquet("s3://bucket-name/folder/with/parquet/files/", dataset = True)\n</code></pre>\n<p>This returns a pandas dataframe:</p>\n<pre><code>client_id center client_lat client_lng inserted_at matrix_updated\n0700292081 BFDR -23.6077 -46.6617 2021-04-19 2021-04-19 \n7100067781 BFDR -23.6077 -46.6617 2021-04-19 2021-04-19 \n7100067787 BFDR -23.6077 -46.6617 2021-04-19 2021-04-19 \n</code></pre>\n<p>However, instead of a pandas dataframe I would like to store this data retrieved from my s3 bucket in a spark dataframe. I've tried doing <a href=\"https://stackoverflow.com/questions/67908306/how-to-read-parquet-files-from-aws-s3-using-spark-dataframe-in-python-pyspark\">this</a>(which is my own question), but seems not to be working correctly.</p>\n<p>I was wondering if there is any way I could store this data into a spark dataframe using awswrangler. Or if you have an alternative I would like to read about it.</p>\n"},{"tags":["javascript","api","vue.js","axios","web-frontend"],"owner":{"reputation":13,"user_id":8278279,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Xddr2.png?s=128&g=1","display_name":"Kamal Kunwar","link":"https://stackoverflow.com/users/8278279/kamal-kunwar"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258114,"creation_date":1623258114,"question_id":67908663,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908663/fetch-the-data-from-multiple-api-axios-and-get-it-in-the-page-on-load-vue-js-3","title":"fetch the data from multiple api - axios and get it in the page on load vue.js 3","body":"<p>I want to fetch the data from multiple <code>API</code> with <code>axios</code> in Vue.js 3. The backend is Laravel API.</p>\n<p>I am able to get data on response1.data and response2.data on console but how can I assign this data to the object defined on data() function of Vue.js.</p>\n<p>I need this data to load on page on loaded. The Vue.js code is -</p>\n<pre><code><script>\nexport default {\n name:'Followup',\n data() {\n return {\n patient:{},\n labGroup:{},\n }\n },\n created() { \n this.$axios.get('/sanctum/csrf-cookie').then(response => {\n this.$axios.all([\n this.$axios.get(`/api/patients/showSomeDetails/${this.$route.params.id}`),\n this.$axios.get('/api/labitems/getGroup')\n ])\n .then(this.$axios.spread(function (response1, response2) {\n console.log(response1.data) // this has given result on console. \n this.patient = response1.data // It is giving error on console. => TypeError: Cannot set property 'patient' of null\n this.labGroup = response2.data // same\n console.log(response2.data)\n\n }))\n .catch(function (error) {\n console.error(error);\n });\n\n })\n },\ncomputed() {\n},\nmethods: {\n}\n} \n</script>\n</code></pre>\n<p>I got error on console - this- <code>app.js:20666 TypeError: Cannot set property 'patient' of null</code></p>\n<p>How can I assign data to the patient and labGroup, so it will applied to my webpage via v-model</p>\n<p>This is my patient followup up form, where I need to get the patient details from patient table, and labitems to fill lab reports from labitems table.</p>\n<p>I hope, someone will give me a solution for this.</p>\n"},{"tags":["java","hibernate","jpa","join","fetch"],"owner":{"reputation":1,"user_id":16178077,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GhgLLCnlqcqr4yeIX9EtDXJLeLYZIS30nlEX_dNRg=k-s128","display_name":"Bruno Trindade","link":"https://stackoverflow.com/users/16178077/bruno-trindade"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623258111,"creation_date":1623258111,"question_id":67908661,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908661/solution-to-n1-issue-in-jpa-and-hibernate-with-multiples-many-to-one","title":"Solution to N+1 issue in JPA and Hibernate with multiples Many-To-One","body":"<p>I found some solutions to avoid N+1 problem but this solutions works only for single Many-To-One relationship.</p>\n<p>For example, the following question: <a href=\"https://stackoverflow.com/questions/32453989/what-is-the-solution-for-the-n1-issue-in-jpa-and-hibernate\">What is the solution for the N+1 issue in JPA and Hibernate?</a></p>\n<p>The problem that I'm trying to solve is this:</p>\n<pre><code>@Entity \npublic class Book implements Serializable { \n \n @Id \n private Long id; \n\n private String title; \n \n @ManyToOne(fetch = FetchType.LAZY) \n private Author author; \n\n @ManyToOne(fetch = FetchType.LAZY) \n private Brand brand;\n}\n</code></pre>\n<p>Solutions like try to fetch through JPQL doesn't work and fetch just one relationship, for example:</p>\n<pre><code>SELECT b FROM Book b \nINNER JOIN FETCH b.author \nINNER JOIN FETCH b.brand\n</code></pre>\n<p>In this case, only 'author' relationship would be fetched and N+1 problem will happen with 'brand' relationship.</p>\n<p><strong>Do you know any solution to solve this specific problem?</strong></p>\n<p>Thank you!</p>\n"},{"tags":["sql","if-statement","group-by","count","case"],"owner":{"reputation":1,"user_id":11429634,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1011ee3ccdb18fe311626b06ec50ab81?s=128&d=identicon&r=PG&f=1","display_name":"user11429634","link":"https://stackoverflow.com/users/11429634/user11429634"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258111,"creation_date":1623258111,"question_id":67908660,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908660/use-a-count-function-in-a-case-statment","title":"Use a count function in a case statment","body":"<p>I have the below code for which I need to enter a count function in one condition of the case statement and then group by the case statement like below. But it is not letting me group the case statement. I essentially want to create a third bucket called "Both" with the condition below</p>\n<pre><code>select \nCASE\n WHEN i.CLASSIFICATION in ('CUSTOMER','PARTNER') THEN 'API'\n WHEN i.CLASSIFICATION in ('MOBILE','NDSE') THEN 'APP' \n WHEN (i.CLASSIFICATION in ('MOBILE','NDSE','CUSTOMER','PARTNER') OR count(distinct UPPER(p.ACCOUNTID)) >=2) THEN 'BOTH' \n ELSE 'Other' END AS "Bucket", \ncount(distinct ACCOUNTID) as No_Accounts,count(distinct envelopeid_hash) as numenvelopes\nfrom ENVELOPE_TABLE e \nJOIN DIMDATE_TABLE b on to_date(e.sentinitial)=b.standarddate\njoin PAYING_TABLE p\non UPPER(e.ACCOUNTID)=UPPER(p.ACCOUNTID) \nLEFT JOIN IK_TABLE i ON i.IntegratorKeyId = e.InitiatingIntegratorKeyId AND i.SourceKey = e.SourceKey\ngroup by 1\n</code></pre>\n"},{"tags":["spring-webflux","project-reactor","webflux","spring-data-mongodb-reactive","reactive-mongo-java"],"owner":{"reputation":317,"user_id":7681696,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0c2d9b34b00d577f21472cdca00de3c0?s=128&d=identicon&r=PG&f=1","display_name":"PaulDev","link":"https://stackoverflow.com/users/7681696/pauldev"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258107,"creation_date":1623254858,"last_edit_date":1623258107,"question_id":67907864,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907864/in-spring-webflux-how-to-chaining-methods-from-multiple-services-repo-in-order","title":"In Spring WebFlux, How to chaining methods from multiple services/repo, in order to 'delete' elements in multiples DB-Collections'?","body":"<h2>1) Contextualization about the problem:</h2>\n<p>I am trying 'delete' items in 03 different DB-Collections(Reactive MongoDB), using 03 different services/repo (userService + postService + userRepo);</p>\n<p>My Goal is DELETE an object (in each collection) simultaneously, using the same chaining-code;</p>\n<p>Below is the code for the above situation:</p>\n<h3>1.1) Code:</h3>\n<p><strong>Current working status:</strong> not working;</p>\n<p><strong>Current behaviour:</strong> not executes any delete, weither delete-userService, delete-postService, or delete-userRepo.</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Slf4j\n@Service\n@AllArgsConstructor\npublic class UserService implements UserServiceInt {\n\n private final UserRepo userRepo;\n\n private final PostServiceInt postServ;\n\n private final CommentServiceInt comServ;\n\n private final CustomExceptions customExceptions;\n\n @Override\n public Mono<Void> deleteInTwoCollections(String id) {\n return userRepo\n .findById(id)\n .switchIfEmpty(customExceptions.userNotFoundException())\n \n .map(user -> {\n userRepo.delete(user); // First deletion - delete-method from userRepo\n return user;\n })\n\n .flatMapMany(user -> postServ.findPostsByAuthorId(user.getId()))\n .map(post -> {\n postServ.delete(post); // Second deletion - delete-method from postService\n return post;\n })\n\n .flatMap(post -> comServ.findCommentsByPostId(post.getPostId()))\n .map(comServ::delete) // Third deletion - delete-method from commentService\n .then()\n ;\n }\n}\n</code></pre>\n<hr />\n<h2>2) Question:</h2>\n<ul>\n<li>How Can I delete different elements in different DB-Collections,\n<ul>\n<li>by using only ONE ‘chained delete method’ that uses THREE ‘delete methods’ from\n<ul>\n<li>THREE different services/repo (userService + postService + userRepo?</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n<p><em>Thanks a lot for any help</em></p>\n"},{"tags":["tomcat","jakarta-ee"],"owner":{"reputation":1,"user_id":16177221,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyGWCT6kx-FXdD22qu_eF8IjtJpbaNQz1H3mUxA=k-s128","display_name":"Pyrockx","link":"https://stackoverflow.com/users/16177221/pyrockx"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623258104,"creation_date":1623255937,"last_edit_date":1623258104,"question_id":67908137,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908137/how-to-login-successfully-using-a-java-ee-jakarta-ee-web-application-jaas-or-h","title":"How to login successfully using a Java EE/Jakarta EE web application (JAAS) or how to configure correctly a realm using Tomcat 10?","body":"<p>I'm using Tomcat 10 and eclipse to develop a J2E (or Jakarta EE) web application. I followed this tutorial (<a href=\"http://objis.com/tutoriel-securite-declarative-jee-avec-jaas/#partie2\" rel=\"nofollow noreferrer\">http://objis.com/tutoriel-securite-declarative-jee-avec-jaas/#partie2</a>) which seems old (it's a french document, because i'm french, sorry if my english isn't perfect), but I also read the Tomcat 10 documentation. <br>\nThe dataSource works, I followed instructions on this page (<a href=\"https://tomcat.apache.org/tomcat-10.0-doc/jndi-datasource-examples-howto.html#Oracle_8i,_9i_&_10g\" rel=\"nofollow noreferrer\">https://tomcat.apache.org/tomcat-10.0-doc/jndi-datasource-examples-howto.html#Oracle_8i,_9i_&_10g</a>) and tested it, but it seems that the realm doesn't work, because I can't login successfully. I always have an authentification error, even if I use the right login and password.<br>\nI tried a lot of "solutions" to correct this, but no one works. And I still don't know if I have to put the realm tag inside context.xml, server.xml or both. I tried context.xml and both, but i don't see any difference.<br><br>\nMy web.xml :</p>\n<pre><code><?xml version="1.0" encoding="UTF-8"?>\n<web-app \n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n xmlns="http://Java.sun.com/xml/ns/javaee" \n xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" \n version="3.0">\n \n <!-- Servlet -->\n \n <servlet>\n <servlet-name>Accueil</servlet-name>\n <servlet-class>servlet.Accueil</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Accueil</servlet-name>\n <url-pattern></url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Bar</servlet-name>\n <servlet-class>servlet.Bar</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Bar</servlet-name>\n <url-pattern>/bar</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Galerie</servlet-name>\n <servlet-class>servlet.Galerie</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Galerie</servlet-name>\n <url-pattern>/galerie</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Cave</servlet-name>\n <servlet-class>servlet.Cave</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Cave</servlet-name>\n <url-pattern>/cave</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Mentions</servlet-name>\n <servlet-class>servlet.Mentions</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Mentions</servlet-name>\n <url-pattern>/mentions-legales</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Plan</servlet-name>\n <servlet-class>servlet.Plan</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Plan</servlet-name>\n <url-pattern>/plan-acces</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Restaurant</servlet-name>\n <servlet-class>servlet.Restaurant</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Restaurant</servlet-name>\n <url-pattern>/restaurant</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Catalogue</servlet-name>\n <servlet-class>servlet.catalogue</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Catalogue</servlet-name>\n <url-pattern>/catalogue</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>AdminCatalogue</servlet-name>\n <servlet-class>servlet.AdminCatalogue</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>AdminCatalogue</servlet-name>\n <url-pattern>/admin/administration-catalogue</url-pattern>\n </servlet-mapping>\n \n <security-constraint>\n <display-name>Test authentification Tomcat</display-name>\n <!-- Liste des pages protégées -->\n <web-resource-collection>\n <web-resource-name>Page sécurisée</web-resource-name>\n <url-pattern>/admin/*</url-pattern>\n </web-resource-collection>\n <!-- Rôles des utilisateurs ayant le droit d'y accéder -->\n <auth-constraint>\n <role-name>admin</role-name>\n </auth-constraint>\n <!-- Connection sécurisée -->\n <!-- <user-data-constraint>\n <transport-guarantee>CONFIDENTIAL</transport-guarantee>\n </user-data-constraint> -->\n </security-constraint>\n \n <!-- Configuration de l'authentification -->\n <login-config>\n <auth-method>FORM</auth-method>\n <realm-name>Espace administration</realm-name>\n <form-login-config>\n <form-login-page>/WEB-INF/login.jsp</form-login-page>\n <form-error-page>/WEB-INF/erreur-authentification.jsp</form-error-page>\n </form-login-config>\n </login-config>\n \n <!-- Rôles utilisés dans l'application -->\n <security-role>\n <description>Administrateur</description>\n <role-name>admin</role-name>\n </security-role>\n \n <!-- Ajoute taglibs.jsp au début de chaque jsp -->\n <jsp-config>\n <jsp-property-group>\n <url-pattern>*.jsp</url-pattern>\n <include-prelude>/WEB-INF/taglibs.jsp</include-prelude>\n </jsp-property-group>\n </jsp-config>\n \n <!-- Déclaration de référence à une source de données JNDI -->\n <resource-ref>\n <description>DB Connection</description>\n <res-ref-name>jdbc/caradoc</res-ref-name>\n <res-type>javax.sql.DataSource</res-type>\n <res-auth>Container</res-auth>\n </resource-ref>\n \n</web-app>\n</code></pre>\n<p>context.xml :</p>\n<pre><code><?xml version="1.0" encoding="UTF-8"?>\n<!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n contributor license agreements. See the NOTICE file distributed with\n this work for additional information regarding copyright ownership.\n The ASF licenses this file to You under the Apache License, Version 2.0\n (the "License"); you may not use this file except in compliance with\n the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an "AS IS" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-->\n<!-- The contents of this file will be loaded for each web application -->\n<Context>\n\n <!-- Default set of monitored resources. If one of these changes, the -->\n <!-- web application will be reloaded. -->\n <WatchedResource>WEB-INF/web.xml</WatchedResource>\n <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>\n <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>\n\n <!-- Uncomment this to enable session persistence across Tomcat restarts -->\n <!--\n <Manager pathname="SESSIONS.ser" />\n -->\n <Resource name="jdbc/caradoc" auth="Container" type="javax.sql.DataSource"\n maxTotal="100" maxIdle="30" maxWaitMillis="10000"\n username="root" password="Caradoc22600!" driverClassName="com.mysql.jdbc.Driver"\n url="jdbc:mysql://localhost:3307/caradoc"/>\n \n <Realm className="org.apache.catalina.realm.DataSourceRealm" \n daraSourceName="jdbc/caradoc" localDataSource="true" userTable="utilisateurs"\n userRoleTable="roles" userNameCol="login" userCredCol="mdp"\n roleNameCol="role">\n <CredentialHandler className="org.apache.catalina.realm.SecretKeyCredentialHandler"\n algorithm="PBKDF2WithHmacSHA512"\n iterations="100000"\n keyLength="256"\n saltLength="16"\n />\n </Realm>\n</Context>\n</code></pre>\n<p>server.xml :</p>\n<pre><code><!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n contributor license agreements. See the NOTICE file distributed with\n this work for additional information regarding copyright ownership.\n The ASF licenses this file to You under the Apache License, Version 2.0\n (the "License"); you may not use this file except in compliance with\n the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an "AS IS" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-->\n<!-- Note: A "Server" is not itself a "Container", so you may not\n define subcomponents such as "Valves" at this level.\n Documentation at /docs/config/server.html\n -->\n<Server port="9000" shutdown="SHUTDOWN">\n <Listener className="org.apache.catalina.startup.VersionLoggerListener" />\n <!-- Security listener. Documentation at /docs/config/listeners.html\n <Listener className="org.apache.catalina.security.SecurityListener" />\n -->\n <!--APR library loader. Documentation at /docs/apr.html -->\n <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />\n <!-- Prevent memory leaks due to use of particular java/javax APIs-->\n <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />\n <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />\n <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />\n\n <!-- Global JNDI resources\n Documentation at /docs/jndi-resources-howto.html\n -->\n <GlobalNamingResources>\n <!-- Editable user database that can also be used by\n UserDatabaseRealm to authenticate users\n -->\n <Resource name="UserDatabase" auth="Container"\n type="org.apache.catalina.UserDatabase"\n description="User database that can be updated and saved"\n factory="org.apache.catalina.users.MemoryUserDatabaseFactory"\n pathname="conf/tomcat-users.xml" />\n </GlobalNamingResources>\n\n <!-- A "Service" is a collection of one or more "Connectors" that share\n a single "Container" Note: A "Service" is not itself a "Container",\n so you may not define subcomponents such as "Valves" at this level.\n Documentation at /docs/config/service.html\n -->\n <Service name="Catalina">\n\n <!--The connectors can use a shared executor, you can define one or more named thread pools-->\n <!--\n <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"\n maxThreads="150" minSpareThreads="4"/>\n -->\n\n\n <!-- A "Connector" represents an endpoint by which requests are received\n and responses are returned. Documentation at :\n HTTP Connector: /docs/config/http.html\n AJP Connector: /docs/config/ajp.html\n Define a non-SSL/TLS HTTP/1.1 Connector on port 8080\n -->\n <Connector port="8080" protocol="HTTP/1.1"\n connectionTimeout="20000"\n redirectPort="8443"\n URIEncoding = "UTF-8" />\n\n <!-- <Connector port="8443"\n protocol="org.apache.coyote.http11.Http11NioProtocol"\n maxThreads="150"\n SSLEnabled="true"\n scheme="https"\n secure="true"\n clientAuth="false"\n sslProtocol="TLS"\n keystoreFile="autosigned-cert.keystore"\n keyAlias="tomcat"\n keystorePass="azertyuiop" /> -->\n <!-- A "Connector" using the shared thread pool-->\n <!--\n <Connector executor="tomcatThreadPool"\n port="8080" protocol="HTTP/1.1"\n connectionTimeout="20000"\n redirectPort="8443" />\n -->\n <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443\n This connector uses the NIO implementation. The default\n SSLImplementation will depend on the presence of the APR/native\n library and the useOpenSSL attribute of the\n AprLifecycleListener.\n Either JSSE or OpenSSL style configuration may be used regardless of\n the SSLImplementation selected. JSSE style configuration is used below.\n -->\n <!--\n <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"\n maxThreads="150" SSLEnabled="true">\n <SSLHostConfig>\n <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"\n type="RSA" />\n </SSLHostConfig>\n </Connector>\n -->\n\n <!-- Define an AJP 1.3 Connector on port 8009 -->\n <!--\n <Connector protocol="AJP/1.3"\n address="::1"\n port="8009"\n redirectPort="8443" />\n -->\n\n <!-- An Engine represents the entry point (within Catalina) that processes\n every request. The Engine implementation for Tomcat stand alone\n analyzes the HTTP headers included with the request, and passes them\n on to the appropriate Host (virtual host).\n Documentation at /docs/config/engine.html -->\n\n <!-- You should set jvmRoute to support load-balancing via AJP ie :\n <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">\n -->\n <Engine name="Catalina" defaultHost="localhost">\n\n <!--For clustering, please take a look at documentation at:\n /docs/cluster-howto.html (simple how to)\n /docs/config/cluster.html (reference documentation) -->\n <!--\n <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>\n -->\n\n <!-- Use the LockOutRealm to prevent attempts to guess user passwords\n via a brute-force attack -->\n <Realm className="org.apache.catalina.realm.LockOutRealm">\n <!-- This Realm uses the UserDatabase configured in the global JNDI\n resources under the key "UserDatabase". Any edits\n that are performed against this UserDatabase are immediately\n available for use by the Realm. -->\n <Realm className="org.apache.catalina.realm.UserDatabaseRealm"\n resourceName="UserDatabase"/>\n </Realm>\n\n <Realm className="org.apache.catalina.realm.LockOutRealm">\n <Realm className="org.apache.catalina.realm.DataSourceRealm" \n daraSourceName="jdbc/caradoc" localDataSource="true" userTable="utilisateurs"\n userRoleTable="roles" userNameCol="login" userCredCol="mdp"\n roleNameCol="role">\n <CredentialHandler className="org.apache.catalina.realm.SecretKeyCredentialHandler"\n algorithm="PBKDF2WithHmacSHA512"\n iterations="100000"\n keyLength="256"\n saltLength="16"\n />\n </Realm>\n </Realm>\n\n <Host name="localhost" appBase="webapps"\n unpackWARs="true" autoDeploy="true">\n\n <!-- SingleSignOn valve, share authentication between web applications\n Documentation at: /docs/config/valve.html -->\n <!--\n <Valve className="org.apache.catalina.authenticator.SingleSignOn" />\n -->\n\n <!-- Access log processes all example.\n Documentation at: /docs/config/valve.html\n Note: The pattern used is equivalent to using pattern="common" -->\n <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"\n prefix="localhost_access_log" suffix=".txt"\n pattern="%h %l %u %t &quot;%r&quot; %s %b" />\n\n </Host>\n </Engine>\n </Service>\n</Server>\n</code></pre>\n<p>login.jsp :</p>\n<pre><code><%@ page language="java" contentType="text/html; charset=UTF-8"\n pageEncoding="UTF-8"%>\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset="UTF-8">\n<title>Connexion Administrateur</title>\n</head>\n<body>\n <div align="center">\n <h2>Identification</h2>\n </div>\n <form action="j_security_check" method="post" accept-charset="utf-8">\n <table align="center">\n <tr>\n <td>Login : </td>\n <td><input type="text" name="j_username"/></td>\n </tr>\n <tr>\n <td>Mot de passe : </td>\n <td><input type="password" name="j_password"/></td>\n </tr>\n </table>\n <p align="center"><input type="submit" value="Connexion"/></p>\n </form>\n</body>\n</html>\n</code></pre>\n<p>erreur-authentifiction.jsp, has same content as login.jsp, but with an error message.<br></p>\n<p>User table (password hash obtained with digest.bat) :\n<a href=\"https://i.stack.imgur.com/2HCae.png\" rel=\"nofollow noreferrer\">User table</a></p>\n<p>Role table with foreign key on login referencing login column of user table :\n<a href=\"https://i.stack.imgur.com/gYoPe.png\" rel=\"nofollow noreferrer\">Role table</a></p>\n<p>This is my project arborescence, if it can help : <a href=\"https://i.stack.imgur.com/0w8d6.png\" rel=\"nofollow noreferrer\">arborescence</a></p>\n<p>So please, can someone tell me what I did wrong ?</p>\n"},{"tags":["java","android","android-linearlayout","visibility","show-hide"],"owner":{"reputation":1,"user_id":16177674,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ghq1-kEBr_o9EZvxjj3eU7RT2_uVgmCW6yGY5DXOQ=k-s128","display_name":"Suraj Verma","link":"https://stackoverflow.com/users/16177674/suraj-verma"},"is_answered":false,"view_count":10,"answer_count":0,"score":0,"last_activity_date":1623258101,"creation_date":1623257797,"last_edit_date":1623258101,"question_id":67908594,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908594/how-to-set-visibility-gone-of-a-linear-layout-which-is-inside-a-scroll-view-and","title":"How to set visibility GONE of a Linear Layout which is inside a scroll view and contains two TextViews inside?","body":"<p><strong>The main layout is a Linear layout inside that a scroll view is there which contain sublayouts. Here is my layout [omitted everything except the specific layout (marked with red) as it will be very long] :</strong></p>\n<pre><code><ScrollView\n android:layout_width="match_parent"\n android:layout_height="match_parent">\n\n <LinearLayout\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical">\n\n <androidx.cardview.widget.CardView\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:layout_gravity="center"\n android:layout_marginStart="10dp"\n android:layout_marginTop="8dp"\n android:layout_marginEnd="10dp"\n android:layout_marginBottom="8dp"\n android:foreground="?android:attr/selectableItemBackground"\n app:cardCornerRadius="8dp"\n app:cardElevation="10dp">\n\n <LinearLayout\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical"\n android:padding="8dp">\n\n\n <LinearLayout\n android:id="@+id/layoutIncomeTax"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:orientation="horizontal">\n\n <TextView\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:gravity="start"\n android:text="Income Tax:"\n android:textColor="@color/black"\n android:textSize="16sp" />\n\n <TextView\n android:id="@+id/tvIncomeTax"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_weight="1"\n android:gravity="end"\n android:text="0"\n android:textColor="@color/black"\n android:textSize="16sp"\n android:textStyle="bold" />\n\n </LinearLayout>\n\n </LinearLayout>\n\n </androidx.cardview.widget.CardView>\n\n </LinearLayout>\n\n</ScrollView>\n</code></pre>\n\n<p><strong>Here is my code (removed unnecessary codes) :</strong></p>\n<p>public class ViewSalary extends AppCompatActivity {</p>\n<pre><code>private Spinner selectShift, selectYear, selectMonth;\nprivate EditText edtEmployeeCode;\nprivate Button viewSalaryBtn;\nprivate String shift, year, month;\n\n\nDatabaseReference rootDatabaseRef;\n\nprivate LinearLayout layoutIncomeTax;\n\nprivate TextView tvIncomeTax;\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_view_salary);\n\n\n viewSalaryBtn = findViewById(R.id.viewSalaryBtn);\n\n layoutIncomeTax = findViewById(R.id.layoutIncomeTax);\n\n tvIncomeTax = findViewById(R.id.tvIncomeTax);\n\n rootDatabaseRef = FirebaseDatabase.getInstance().getReference().child("Salary");\n\n viewSalaryBtn.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n\n viewSalary();\n\n String checkIncomeTax = tvIncomeTax.getText().toString();\n if (checkIncomeTax.equals("0.0")) {\n layoutIncomeTax.setVisibility(layoutIncomeTax.GONE);\n }\n\n }\n });\n\n\n}\n\nprivate void viewSalary() {\n\n final String empCode = edtEmployeeCode.getText().toString();\n\n DatabaseReference empRef = rootDatabaseRef.child(shift).child(year).child(month).child(empCode);\n\n empRef.addValueEventListener(new ValueEventListener() {\n @Override\n public void onDataChange(@NonNull DataSnapshot dataSnapshot) {\n if (dataSnapshot.exists()) {\n\n String incomeTax = dataSnapshot.child("IncomeTax").getValue(String.class);\n\n tvIncomeTax.setText(incomeTax);\n\n } else {\n Toast.makeText(ViewSalary.this, "Data does not exist!", Toast.LENGTH_SHORT).show();\n }\n }\n\n @Override\n public void onCancelled(@NonNull DatabaseError error) {\n Toast.makeText(ViewSalary.this, error.getMessage(), Toast.LENGTH_SHORT).show();\n }\n });\n\n}\n</code></pre>\n<p>}</p>\n<p><strong>I want to hide all linear layouts on button click after getting the data loaded and if TextView value is "0.0" (like the one marked with red in screenshot)</strong></p>\n<p><a href=\"https://i.stack.imgur.com/LvAea.jpg\" rel=\"nofollow noreferrer\">Screenshot</a></p>\n"},{"tags":["excel","vba","selenium","export-to-excel"],"owner":{"reputation":15,"user_id":13804833,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e302eb75ecb95fb24f5eafc8ecfa7750?s=128&d=identicon&r=PG&f=1","display_name":"AAdi","link":"https://stackoverflow.com/users/13804833/aadi"},"is_answered":false,"view_count":36,"answer_count":1,"score":0,"last_activity_date":1623258097,"creation_date":1623231368,"question_id":67901448,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67901448/the-innertext-in-tbody-is-not-printing","title":"The innerText in tbody is not printing","body":"<p>The "thead" is giving all the data in side by innerText, but "tbody" is blank. No "tr" and even "td" is helping.</p>\n<pre><code>Sub ScrapeOddsUsingXMLHTTP11()\nDim XMLRequest As New MSXML2.XMLHTTP60\nDim HTMLDoc As New MSHTML.HTMLDocument\nDim HTMLDiv As MSHTML.IHTMLElement\nDim HTMLTable1, HTMLTable2 As MSHTML.IHTMLElement\n\nXMLRequest.Open "GET", "https://www.nseindia.com/get-quotes/equity?symbol=MCX", False\nXMLRequest.send\n\nIf XMLRequest.Status <> 200 Then\n MsgBox XMLRequest.Status & " - " & XMLRequest.statusText\n Exit Sub\nEnd If\n\nHTMLDoc.body.innerHTML = XMLRequest.responseText\n\nSet HTMLDiv = HTMLDoc.getElementById("priceInfoTable")\nSet HTMLTable1 = HTMLDiv.getElementsByTagName("thead")(0)\nSet HTMLTable2 = HTMLDiv.getElementsByTagName("tbody")(0)\n\nDebug.Print HTMLTable1.innerText\nDebug.Print HTMLTable2.innerText\n\nEnd Sub\n</code></pre>\n<p>Please help me there the image is incerted.<a href=\"https://i.stack.imgur.com/JGNfS.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/JGNfS.png\" alt=\"enter image description here\" /></a></p>\n"},{"tags":["java","angular","version"],"owner":{"reputation":85,"user_id":7551051,"user_type":"registered","profile_image":"https://lh4.googleusercontent.com/-weUfbjvkvV8/AAAAAAAAAAI/AAAAAAAAAvE/1vAomyTRBog/photo.jpg?sz=128","display_name":"Hatim Setti","link":"https://stackoverflow.com/users/7551051/hatim-setti"},"is_answered":false,"view_count":16,"closed_date":1623255968,"answer_count":0,"score":0,"last_activity_date":1623258084,"creation_date":1623255658,"last_edit_date":1623258084,"question_id":67908057,"link":"https://stackoverflow.com/questions/67908057/which-version-of-java-is-needed-for-angular","closed_reason":"Duplicate","title":"which version of java is needed for angular","body":"<p>I have a question, we have an existing project with java 6 and GWT and we want to migrate to angular (we are using soap web services)<br>\nIs java 6 works with angular ?\n<br> If not, must I use java 8 ? <br>\nAngular works with soap web services or we must go for Rest ?</p>\n"},{"tags":["python","csv"],"owner":{"reputation":11,"user_id":14199995,"user_type":"registered","profile_image":"https://lh4.googleusercontent.com/-ywwp5uMS2kw/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuclBdCFmzhGQXIl4CJgiuJZhZzttvw/photo.jpg?sz=128","display_name":"lolwatpie","link":"https://stackoverflow.com/users/14199995/lolwatpie"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258084,"creation_date":1623258084,"question_id":67908659,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908659/sniffer-has-header-returning-incorrect-value-dependent-upon-variable-type","title":"Sniffer has_header returning incorrect value dependent upon variable type","body":"<p>I am trying to check when loading arbitrary csv files if they have a header or not, and I have been using the built-in sniffer to do so.</p>\n<p>I have two csv files, which look like so:</p>\n<pre><code>hours,cumulative\n0,0\n0.167,0\n1,0.844751725\n2,1.036681406\n4,3.574853513\n8,6.658784849\n24,17.99046989\n48,28.71241914\n120,45.19487011\n168,55.48073423\n240,63.42035593\n336,71.46442916\n</code></pre>\n<pre><code>hours,cumulative\n0.00,0\n24.00,3001.516\n48.00,4183.836\n72.00,5090.53\n96.00,5869.408\n120.00,6588.484\n144.00,7251.586\n168.00,7882.792\n192.00,8457.52\n216.00,8986.762\n240.00,9482.2\n264.00,9945.37\n288.00,10388.204\n312.00,10800.012\n336.00,11219.976\n360.00,11620.11\n384.00,12006.216\n408.00,12371.944\n432.00,12724.996\n456.00,13066.336\n</code></pre>\n<p>And I am trying to run this code to detect if there are headers present in the file:</p>\n<pre><code>with open(file,encoding='utf-8-sig') as f:\n has_header = csv.Sniffer().has_header(f.read(1024))\nheader = 0 if has_header == True else None\n</code></pre>\n<p>This works beautifully for file2, but for file1 (and others) it just does not correctly read the data.</p>\n<p>Column one is a float for file1, but int for file2 (copied from notepad++ so not sure why the decimals are there). When I switch the data to be a float for file2 (e.g. 24 -> 24.000001), then has_header returns the incorrect value. I have tested this with numerous files, and for any file with an int type for column one, then has_header = True. Conversely, any column that is a float will return has_header = False even though there is one.</p>\n<p>I'm really scratching my head over this one and I'm unsure why this would be so.</p>\n<p>Any insight/help would be great, thanks!</p>\n"},{"tags":["c"],"owner":{"reputation":99,"user_id":11478529,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/29b4713b937df82a2612d28bd03b5564?s=128&d=identicon&r=PG&f=1","display_name":"Akil","link":"https://stackoverflow.com/users/11478529/akil"},"is_answered":false,"view_count":35,"answer_count":2,"score":-1,"last_activity_date":1623258083,"creation_date":1623256086,"last_edit_date":1623256545,"question_id":67908167,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908167/trying-to-remove-hyphens-from-a-string-in-c","title":"Trying to remove hyphens from a string in C","body":"<p>I am solving a problem in which I have a date (YYYY-MM-DD) as user input and I need to find out the day(Sunday, Monday,.. ). I have tried to remove the hyphen so that I can proceed with Zellor's rule. To achieve that I used a loop. However, it doesn't seem to work.\nHere's is my code:</p>\n<pre><code>#include<stdio.h>\nint main(){\n char date[11], datenum[9]; \n int date_num;\n printf("Enter the date in yyyy-mm-dd format\\n");\n scanf("%s", &date);\n int j = 0;\n for (int i=0; i<10; i++){\n if (date[i]!='-' && j<8){\n datenum[j] = date[i];\n printf("%c", datenum[j]);\n j++;\n }\n } \n printf("%s\\n", datenum);\n return 0;\n}\n</code></pre>\n<p>I was expecting 20210609 as output when I gave 2021-06-09 as input but that doesn't seem to be the case. Instead, I got 2021060920210609█2021-06-09.</p>\n"},{"tags":["mysql","ef-code-first","razor-pages","asp.net-core-5.0","ef-core-5.0"],"owner":{"reputation":387,"user_id":1798229,"user_type":"registered","accept_rate":50,"profile_image":"https://www.gravatar.com/avatar/177fd0c20f226cc118b716438d0a803c?s=128&d=identicon&r=PG","display_name":"Chris","link":"https://stackoverflow.com/users/1798229/chris"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258078,"creation_date":1623258078,"question_id":67908657,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908657/entityframeword-core-5-mysql-table-sharing","title":"EntityFrameword Core 5, MySQL, Table sharing","body":"<p>The scenario:</p>\n<p>I have an address table with what you'd kind of expect (street, town, postcode etc)</p>\n<p>I have 2 other entities (Site and Client Details), both of these have an address property (another way of thinking of the structure is to think of it like ClientDetails.Address as a head office and Sites/Site.Address as office buildings around the country).</p>\n<p>I'm trying to figure out getting the relationship sorted, currently it's complaining because when I add a ClientDetails.Address, its failing on the ClientDetails.Sites.Address FK constraint.</p>\n<p>I'm thinking I might need to configure the relationships manually through the Fluent API, but figured I'd ask in case anyone has had similar (I'm sure I'm not the first one wanting to do this)!</p>\n<p>I'm trying to do this using a CodeFirst approach, I have no additional config in my modelBuilder configuration.</p>\n<p>The project is using .NET 5 with EF Core 5</p>\n<p>I'm starting to think that Table Splitting is how is resolve this but the examples I've seen thus far don't quite seem to make sense to me.</p>\n<p>DB Schema:</p>\n<p><a href=\"https://i.stack.imgur.com/iz68X.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/iz68X.png\" alt=\"enter image description here\" /></a></p>\n<p>Error:\n<a href=\"https://i.stack.imgur.com/oqlnw.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/oqlnw.png\" alt=\"enter image description here\" /></a></p>\n<p>ClientDetails.cs</p>\n<pre><code>public class ClientDetails\n{\n public Guid ClientDetailsId { get; set; }\n\n public string Name { get; set; }\n\n public virtual Address Address { get; set; }\n\n public Byte[] Image { get; set; }\n\n public List<ClientStaff> Staff { get; set; }\n\n public List<Site> Sites { get; set; }\n}\n</code></pre>\n<p>Site.cs</p>\n<pre><code>public class Site\n{\n public Guid? SiteId { get; set; }\n\n public string AccessCode { get; set; }\n\n public PointOfContact PointOfContact { get; set; }\n\n public Guid ClientDetailsId { get; set; }\n\n public ClientDetails ClientDetails { get; set; }\n\n public virtual Address Address { get; set; } \n}\n</code></pre>\n<p>Address.cs</p>\n<pre><code> public class Address\n{\n public Guid AddressId { get; set; }\n\n public string LineOne { get; set; }\n\n public string LineTwo { get; set; }\n\n public string LineThree { get; set; }\n\n public string PostalCode { get; set; }\n\n public Guid ClientDetailsId { get; set; }\n public virtual ClientDetails ClientDetails { get; set; }\n public Guid SiteId { get; set; }\n public virtual Site Site { get; set; }\n}\n</code></pre>\n"},{"tags":["windows","powershell","firewall","silent-installer"],"owner":{"reputation":1,"user_id":16178083,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgKHr8A1n93Ez_bhtpvJK_JA49kEtYSl0Yqb-XL-g=k-s128","display_name":"FutureHistory24","link":"https://stackoverflow.com/users/16178083/futurehistory24"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258078,"creation_date":1623258078,"question_id":67908658,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908658/powershell-silent-install-windows-defender-firewall-prompt","title":"PowerShell - Silent Install - Windows Defender Firewall Prompt","body":"<p>I am trying to write a silent install for an application but during the install, a Windows Firewall Security Alert appears for allowing access to the domain/private/public network. I have already created an inbound rule to allow the application over the domain network, but the window asking for permission will still display, which is an issue since its suppose to be a silent install. I verified that the inbound rule was successful in Windows Defender Firewall with Advanced Security. What would be the best way to get this prompt closed?</p>\n<p><a href=\"https://i.stack.imgur.com/mgLbZ.png\" rel=\"nofollow noreferrer\">Windows Security Alert</a></p>\n<pre><code> netsh advfirewall firewall add rule name="javaw.exe" dir=in action=allow program= $fullPath enable=yes profile=domain\n</code></pre>\n"},{"tags":["p4-lang"],"owner":{"reputation":119,"user_id":5712225,"user_type":"registered","profile_image":"https://graph.facebook.com/1521385268157472/picture?type=large","display_name":"Mahmoud Bahnasy","link":"https://stackoverflow.com/users/5712225/mahmoud-bahnasy"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258077,"creation_date":1623258077,"question_id":67908656,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908656/can-we-set-queue-depth-length-per-priority-in-p4","title":"Can we set queue depth/length per priority in P4?","body":"<p>I'm trying to implement a priority Queue in P4 and I need to limit the number of packets that can be served in a low priority queue so I won't choke the high priority traffic.\nTherefore, I need to either:\n1- Set a fixed size per queue per priority.\n2- Drop a packet if the priority queue length exceeded certain threshold\nAny idea on how to accomplish either one of them.\nThanks</p>\n"},{"tags":["javascript","html"],"owner":{"reputation":5152,"user_id":4352930,"user_type":"registered","accept_rate":78,"profile_image":"https://i.stack.imgur.com/54DOb.png?s=128&g=1","display_name":"tfv","link":"https://stackoverflow.com/users/4352930/tfv"},"is_answered":true,"view_count":39,"accepted_answer_id":67903946,"answer_count":1,"score":0,"last_activity_date":1623258075,"creation_date":1623233729,"last_edit_date":1623258075,"question_id":67902098,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67902098/cannot-get-rid-of-page-reload-in-html-javascript-form","title":"Cannot get rid of page reload in html/javascript form","body":"<p>I am trying to set up a form in which buttons fill input fields and in which those input fields can again be emptied by other "delete" buttons.</p>\n<p>This works quite well, but I cannot get rid of one problem in a special action sequence:</p>\n<p>If I press buttons "one" and "three", the corresponding input forms are filled properly, this is what I want.</p>\n<p>Now if after that I press the "Delete A" button, one of two unwanted things happen:</p>\n<ul>\n<li><p>If the command event.preventDefault() exists in line 15, then (only) the first input field gets cleared correctly and the buttons are restored. But when I then again press button "one", the complete form gets cleared and the word "three" vanishes from form 2.</p>\n</li>\n<li><p>If the command event.preventDefault() is deleted from line 15, then as soon as I press "Delete A", the complete form gets cleared and also the word "three" vanishes from form 2.</p>\n</li>\n</ul>\n<p>I do not want to clear the complete form to be reloaded at any stage.</p>\n<p><strong>EDIT</strong>: The problem is not a question of returning <code>false</code> values from functions to prevent form submission as discussed in <a href=\"https://stackoverflow.com/questions/8664486/javascript-code-to-stop-form-submission\">JavaScript code to stop form submission</a> . in fact all my fucntions are returning <code>false</code>values.</p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-html lang-html prettyprint-override\"><code><!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"ISO-8859-1\">\n\n</head>\n<script> \n\nfunction evt_r(){\nvar task = document.getElementById(\"task_\"+arguments[0]);\nvar tasklabel = arguments[0];\nvar texts = Array.from(arguments).slice(1)\nvar length = task.getElementsByTagName(\"button\").length - 1;\n\nevent.preventDefault()\n\n// remove existing buttons\nfor (let i =0; i < length; i++){\ntask.removeChild(task.getElementsByTagName(\"button\")[0]);\n}\n\n// recreate all buttons from scratch\nfor (let i =texts.length-1; i >=0 ; i--){\nbtn = document.createElement(\"button\");\nbtn.innerHTML = texts[i];\nbtn.onClick= \"evt_\"+String(tasklabel)+\"_\"+String(i)+\"()\";\nbtn.id=\"id_btn_\"+String(tasklabel)+\"_\"+String(i);\ntask.insertBefore(btn, task.firstChild);\ntask.children[0].style.marginRight =\"5px\";\n}\ndocument.getElementById(\"id_task_\"+String(tasklabel)).value=\"\";\n\nreturn false;\n}\n\nfunction evt_0_0(){\nvar elem = document.getElementById(\"id_btn_0_0\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_0\").value=document.getElementById(\"id_task_0\").value +\"one \"\nreturn false;\n}\nfunction evt_0_1(){\nvar elem = document.getElementById(\"id_btn_0_1\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_0\").value=document.getElementById(\"id_task_0\").value +\"two \"\nreturn false;\n}\n\nfunction evt_1_0(){\nvar elem = document.getElementById(\"id_btn_1_0\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_1\").value=document.getElementById(\"id_task_1\").value +\"three \"\nreturn false;\n}\nfunction evt_1_1(){\nvar elem = document.getElementById(\"id_btn_1_1\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_1\").value=document.getElementById(\"id_task_1\").value +\"four \"\nreturn false;\n}\n\n</script>\n\n<body>\n<ol>\n<li style=\"margin-bottom:8px\"><form id = \"task_0\" >\n<button id=\"id_btn_0_0\" onclick=\"evt_0_0()\">one</button>\n<button id=\"id_btn_0_1\" onclick=\"evt_0_1()\">two</button>\n\n<button id=\"id_btn_0_r\" onclick='evt_r(\"0\", \"one\", \"two\")' style=\"margin-left:50px\">Delete A</button>\n<br>\n<input id=\"id_task_0\" style=\"margin-top:10px\" ></input>\n</form>\n<li style=\"margin-bottom:8px\"><form id = \"task_1\" >\n<button id=\"id_btn_1_0\" onclick=\"evt_1_0()\">three</button>\n<button id=\"id_btn_1_1\" onclick=\"evt_1_1()\">four</button>\n<button id=\"id_btn_1_r\" onclick='evt_r(\"1\", \"three\", \"four\")' style=\"margin-left:50px\">Delete B</button>\n<br>\n<input id=\"id_task_1\" style=\"margin-top:10px\" ></input>\n</form>\n\n</body>\n</html></code></pre>\r\n</div>\r\n</div>\r\n</p>\n"},{"tags":["postgresql","count"],"owner":{"reputation":17,"user_id":13818062,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/fc7c726cd746b43255cdf8a993f9cb78?s=128&d=identicon&r=PG&f=1","display_name":"antekkalafior","link":"https://stackoverflow.com/users/13818062/antekkalafior"},"is_answered":false,"view_count":8,"answer_count":1,"score":0,"last_activity_date":1623258071,"creation_date":1623255970,"question_id":67908142,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908142/counting-several-repeated-values-in-a-cloumn","title":"Counting several repeated values in a cloumn","body":"<p>I need to count how many times certain value occurs in a column</p>\n<p>It looks like this (<code>select * from znajezyki order by klos</code>)</p>\n<p><a href=\"https://i.stack.imgur.com/uJ41b.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/uJ41b.png\" alt=\"enter image description here\" /></a></p>\n<p>klos - is a serial number of a person (this value is repeated)</p>\n<p>Now I need to create a query that will show me how many people knows 1,2,3 languages</p>\n<p>If the same "klos" value is repeated 2 times that means that this person knows 2 languages if it occurs 3 times that means that pearson knows 3 languages and so on</p>\n<p>I'd like my result to look something like this:\n<a href=\"https://i.stack.imgur.com/izSuq.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/izSuq.png\" alt=\"enter image description here\" /></a></p>\n<p>I tried refering to this post <a href=\"https://stackoverflow.com/questions/28156795/how-to-find-duplicate-records-in-postgresql\">here</a> but i cannot understand it and can't get it to work</p>\n<p>I hope y'all can understand what I am talking about :)</p>\n"},{"tags":["go"],"owner":{"reputation":387,"user_id":12293663,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-YRO5C6xRN0g/AAAAAAAAAAI/AAAAAAAAARg/CWKAIE4BUxI/photo.jpg?sz=128","display_name":"cosmos multi","link":"https://stackoverflow.com/users/12293663/cosmos-multi"},"is_answered":false,"view_count":9,"answer_count":0,"score":0,"last_activity_date":1623258070,"creation_date":1623258070,"question_id":67908654,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908654/how-to-keep-the-value-of-a-cookie","title":"how to keep the value of a cookie","body":"<p>I am in the process of user authentication in my application which is done through a cookie that the jwt saves, when I make the request the client obtains the cookie without problems, but when the client updates the page or only f5 the cookie is deleted , I was investigating if it was happening on localhost or there was a problem in my code, but I didn't find anything related to my problem.\nThis is my code in Go:</p>\n<pre><code>func Login(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Content-Type", "application/json")\n\n u := model.User{}\n if err := json.NewDecoder(r.Body).Decode(&u); err != nil {\n http.Error(w, "format incorrect", http.StatusBadRequest)\n return\n }\n\n user, equals, err := u.AccessControll(u.Email, u.Password)\n if err != nil {\n http.Error(w, err.Error(), http.StatusBadRequest)\n return\n }\n\n if !equals {\n http.Error(w, "ups", http.StatusBadRequest)\n return\n }\n\n token, err := jwt.CreateToken(user)\n if err != nil {\n http.Error(w, err.Error(), http.StatusBadRequest)\n return\n }\n\n cookie := http.Cookie{\n Name: "token",\n Value: token,\n Expires: time.Now().Add(5 * time.Minute),\n HttpOnly: true,\n }\n\n http.SetCookie(w, &cookie)\n}\n</code></pre>\n"},{"tags":["python","pandas","if-statement","next"],"owner":{"reputation":1,"user_id":16158116,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2a0dfcf8f95a93cf74074c48d85bf0a3?s=128&d=identicon&r=PG&f=1","display_name":"yosi","link":"https://stackoverflow.com/users/16158116/yosi"},"is_answered":false,"view_count":17,"answer_count":1,"score":0,"last_activity_date":1623258069,"creation_date":1623255218,"question_id":67907956,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907956/finding-the-first-row-which-stratifies-two-conditions-in-python-data-frame","title":"Finding the first row which stratifies two conditions in python data frame","body":"<p>I have a data frame which looks like this:</p>\n<p><a href=\"https://i.stack.imgur.com/c6XA8.jpg\" rel=\"nofollow noreferrer\">data frame</a></p>\n<p>I want to write a code which locates points that have distance less than 250 from the next point. When it finds the point searches for the first point that is more than 250 away with speed greater than 5.\nFor example in the sample data set, first find row 7 and then locate row 10 which is more than 250 away and has speed of 10.8 and return the index of row 10\nI have write this code so far:</p>\n<pre><code>for i in (number+1 for number in range(data_gpd.index[-1]-1)):\nif (data_gpd['distance'][i+1]< 250):\n</code></pre>\n<p>I'm not sure what should I do after this condition. I had in mind to use "Next" statement with conditions but I was only able to find it for list comprehension with one condition.</p>\n<p>I really appreciate your help as I'm new to python and not sure which syntax would work better</p>\n"},{"tags":["sqlite"],"owner":{"reputation":87,"user_id":11704346,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/44942af2f7847e6a6a0ba38e0a10ecbd?s=128&d=identicon&r=PG&f=1","display_name":"UncommentedCode","link":"https://stackoverflow.com/users/11704346/uncommentedcode"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258069,"creation_date":1623258069,"question_id":67908652,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908652/sqlite-sort-by-source-column","title":"SQLite Sort by Source Column","body":"<p>In my SQLite database, I have a query that selects records where a string is present in one of several columns - i.e with the following</p>\n<div class=\"s-table-container\">\n<table class=\"s-table\">\n<thead>\n<tr>\n<th>Column1</th>\n<th>Column2</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>String</td>\n<td>StringString</td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>I have the following query:</p>\n<pre><code>WHERE Column1 LIKE 'String' OR Column2 LIKE '%String%'\n</code></pre>\n<p>How can I make it so that the results are ordered based on which column they matched with? I.e. put items that matched from Column1 before items that were matched with Column2, or vice versa?</p>\n"},{"tags":["typescript","webassembly","deno"],"owner":{"reputation":47,"user_id":11576753,"user_type":"registered","profile_image":"https://i.stack.imgur.com/KtOlW.png?s=128&g=1","display_name":"nabezokodaikon","link":"https://stackoverflow.com/users/11576753/nabezokodaikon"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258068,"creation_date":1623258068,"question_id":67908651,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908651/when-i-bundle-code-with-wasm-and-run-it-in-a-browser-using-deno-i-get-an-error","title":"When I bundle code with wasm and run it in a browser using deno, I get an error","body":"<p>When I bundle code with wasm and run it in a browser using deno, I get an error.</p>\n<p>Running command.</p>\n<pre class=\"lang-sh prettyprint-override\"><code>$ cargo build --target=wasm32-unknown-unknown --release\n$ wasm-bindgen target/wasm32-unknown-unknown/release/wasm_deno.wasm --out-dir ./server/public/pkg --target web\n$ deno bundle server/public/ts/greet.ts server/public/js/greet.js\n</code></pre>\n<p>Then, the following error occurs.</p>\n<pre><code>Uncaught TypeError: Cannot read property '__wbindgen_malloc' of undefined\n</code></pre>\n<p>If you change the typescript code, you will get various other errors.</p>\n"},{"tags":["excel","vba"],"owner":{"reputation":45,"user_id":5555327,"user_type":"registered","accept_rate":67,"profile_image":"https://www.gravatar.com/avatar/b8c037c1dbe477fd741f5e23fa399dd0?s=128&d=identicon&r=PG&f=1","display_name":"SomeNewPythonGuy","link":"https://stackoverflow.com/users/5555327/somenewpythonguy"},"is_answered":false,"view_count":23,"answer_count":1,"score":0,"last_activity_date":1623258066,"creation_date":1623184013,"last_edit_date":1623184071,"question_id":67894153,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67894153/excel-vba-macro-to-hide-all-rows-except-top-5-rows-and-selected-row","title":"Excel VBA/Macro to hide all rows except top 5 rows and selected row?","body":"<p>good afternoon, everyone. I have several worksheets in progress that have various rows of data in the field. I have one aspect of unhiding all of the rows through a macro, as well as creating VBA to select and hide all rows without colored squares from within the worksheet. My main dilemma is that in a section with let's say 200 rows, I want to have it so that only the row the user has selected through the cursor and the top 5 rows (Or maybe just the top row or so, depending on the table.)</p>\n<p>Any help would be appreciated. I'll post an example of what I mean.\n<code>like so</code>\nTitle 1 Title 2 Title 3</p>\n<p>Row 1 Something 1 SomethingElse 1</p>\n<p>Row 2 Something 2 SomethingElse 2</p>\n<p>Row 3 Something 3 SomethingElse 3</p>\n<p><strong>Row 4</strong> Something 4 SomethingElse 4 <User is on Cell A, shown here as Bolded</p>\n<p>Row 5 Something 5 SomethingElse 5</p>\n<p>Row 6 Something 6 SomethingElse 6</p>\n<p>Row 7 Something 7 SomethingElse 7</p>\n<p>Row 8 Something 8 SomethingElse 8</p>\n<p>Row 9 Something 9 SomethingElse 9</p>\n<p>Row 10 Something 10 SomethingElse 10</p>\n<p>This is what I'd Like after the macro gets done. Just the top row and selected row.</p>\n<p>Title 1 Title 2 Title 3</p>\n<p>Row 4 Something 4 SomethingElse 4</p>\n<p>Thank you again, everyone!</p>\n"},{"tags":["python","opencv","python-imaging-library","png","python-tesseract"],"owner":{"reputation":1,"user_id":16178153,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GiSQiolB1SiDc7FUJFU--MM4ooRbLTJK0gMeCqS=k-s128","display_name":"Eli Norris","link":"https://stackoverflow.com/users/16178153/eli-norris"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258065,"creation_date":1623258065,"question_id":67908648,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908648/running-into-weird-erros-when-coverting-a-png-screenshot-of-a-table-into-a-exce","title":"Running Into weird erros when coverting a .png screenshot of a table into a excel file","body":"<p>I am currently trying to convert a .png screenshot of a table into an excel file with all the data. Creating the new images, vertical, inverted, horizontal, and img_vh are all working. The seems to be somewhere towards the end of the program. I found this skeleton code online and have made slight modifications but I do not have a complete understanding of what is happening.</p>\n<p>Here is my error followed by the code, apologies if the question is not well written, this is my first post. Any advice/ideas are greatly appreciated</p>\n<p>ERROR:</p>\n<pre><code>Traceback (most recent call last):\n</code></pre>\n<p>File "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 255, in run_tesseract\nproc = subprocess.Popen(cmd_args, **subprocess_args())\nFile "C:\\ProgramData\\Anaconda3\\lib\\subprocess.py", line 775, in <strong>init</strong>\nrestore_signals, start_new_session)\nFile "C:\\ProgramData\\Anaconda3\\lib\\subprocess.py", line 1178, in _execute_child\nstartupinfo)\nFileNotFoundError: [WinError 2] The system cannot find the file specified</p>\n<p>During handling of the above exception, another exception occurred:</p>\n<p>Traceback (most recent call last):\nFile "C:/Users/19038/PycharmProjects/1st Day/ExEqsENGR102_528eli.norris.py", line 187, in \nout = pytesseract.image_to_string(erosion)\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 413, in image_to_string\n}output_type\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 412, in \nOutput.STRING: lambda: run_and_get_output(*args),\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 287, in run_and_get_output\nrun_tesseract(**kwargs)\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 259, in run_tesseract\nraise TesseractNotFoundError()\npytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.</p>\n<p>CODE:</p>\n<pre><code> import cv2\n import numpy as np\n import pandas as pd\n import matplotlib.pyplot as plt\n import csv\n \n try:\n from PIL import Image\n except ImportError:\n import Image\n import pytesseract\n \n \n #read your file\n #file=r'/Users\\19038\\Desktop/Picture.png'\n img = cv2.imread('C:/Users/19038/Desktop/Research Things/Test/Picture.png',0)\n #print(img)\n img.shape\n \n #thresholding the image to a binary image\n thresh,img_bin = cv2.threshold(img,128,255,cv2.THRESH_BINARY |cv2.THRESH_OTSU)\n \n #inverting the image\n img_bin = 255-img_bin\n cv2.imwrite('C:/Users/19038/Desktop/Research Things/Test/inverted_Picture.png', img_bin)\n \n #Plotting the image to see the output\n plotting = plt.imshow(img_bin,cmap='gray')\n plt.show()\n \n # countcol(width) of kernel as 100th of total width\n kernel_len = np.array(img).shape[1] // 100\n # Defining a vertical kernel to detect all vertical lines of image\n ver_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (1, kernel_len))\n # Defining a horizontal kernel to detect all horizontal lines of image\n hor_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (kernel_len, 1))\n # A kernel of 2x2\n kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (2, 2))\n \n # Use vertical kernel to detect and save the vertical lines in a jpg\n image_1 = cv2.erode(img_bin, ver_kernel, iterations=3)\n vertical_lines = cv2.dilate(image_1, ver_kernel, iterations=3)\n cv2.imwrite("C:/Users/19038/Desktop/Research Things/Test/vertical.jpg", vertical_lines)\n # Plot the generated image\n plotting = plt.imshow(image_1, cmap='gray')\n plt.show()\n \n # Use horizontal kernel to detect and save the horizontal lines in a jpg\n image_2 = cv2.erode(img_bin, hor_kernel, iterations=3)\n horizontal_lines = cv2.dilate(image_2, hor_kernel, iterations=3)\n cv2.imwrite("C:/Users/19038/Desktop/Research Things/Test/horizontal.jpg", horizontal_lines)\n # Plot the generated image\n plotting = plt.imshow(image_2, cmap='gray')\n plt.show()\n \n # Combine horizontal and vertical lines in a new third image, with both having same weight.\n img_vh = cv2.addWeighted(vertical_lines, 0.5, horizontal_lines, 0.5, 0.0)\n # Eroding and thesholding the image\n img_vh = cv2.erode(~img_vh, kernel, iterations=2)\n thresh, img_vh = cv2.threshold(img_vh, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)\n cv2.imwrite("C:/Users/19038/Desktop/Research Things/Test/img_vh.jpg", img_vh)\n bitxor = cv2.bitwise_xor(img, img_vh)\n bitnot = cv2.bitwise_not(bitxor)\n # Plotting the generated image\n plotting = plt.imshow(bitnot, cmap='gray')\n plt.show()\n \n # Detect contours for following box detection\n contours, hierarchy = cv2.findContours(img_vh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)\n \n \n def sort_contours(cnts, method="left-to-right"):\n # initialize the reverse flag and sort index\n reverse = False\n i = 0\n # handle if we need to sort in reverse\n if method == "right-to-left" or method == "bottom-to-top":\n reverse = True\n # handle if we are sorting against the y-coordinate rather than\n # the x-coordinate of the bounding box\n if method == "top-to-bottom" or method == "bottom-to-top":\n i = 1\n # construct the list of bounding boxes and sort them from top to\n # bottom\n boundingBoxes = [cv2.boundingRect(c) for c in cnts]\n (cnts, boundingBoxes) = zip(*sorted(zip(cnts, boundingBoxes),\n key=lambda b: b[1][i], reverse=reverse))\n # return the list of sorted contours and bounding boxes\n return (cnts, boundingBoxes)\n \n \n # Sort all the contours by top to bottom.\n contours, boundingBoxes = sort_contours(contours, method="top-to-bottom")\n \n # Creating a list of heights for all detected boxes\n heights = [boundingBoxes[i][3] for i in range(len(boundingBoxes))]\n \n # Get mean of heights\n mean = np.mean(heights)\n \n # Create list box to store all boxes in\n box = []\n # Get position (x,y), width and height for every contour and show the contour on image\n for c in contours:\n x, y, w, h = cv2.boundingRect(c)\n if (w < 1000 and h < 500):\n image = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)\n box.append([x, y, w, h])\n \n plotting = plt.imshow(image, cmap='gray')\n plt.show()\n \n # Creating two lists to define row and column in which cell is located\n row = []\n column = []\n j = 0\n \n # Sorting the boxes to their respective row and column\n for i in range(len(box)):\n \n if (i == 0):\n column.append(box[i])\n previous = box[i]\n \n else:\n if (box[i][1] <= previous[1] + mean / 2):\n column.append(box[i])\n previous = box[i]\n \n if (i == len(box) - 1):\n row.append(column)\n \n else:\n row.append(column)\n column = []\n previous = box[i]\n column.append(box[i])\n \n print(column)\n print(row)\n \n # calculating maximum number of cells\n countcol = 0\n for i in range(len(row)):\n countcol = len(row[i])\n if countcol > countcol:\n countcol = countcol\n \n # Retrieving the center of each column\n center = [int(row[i][j][0] + row[i][j][2] / 2) for j in range(len(row[i])) if row[0]]\n \n center = np.array(center)\n center.sort()\n print(center)\n # Regarding the distance to the columns center, the boxes are arranged in respective order\n \n finalboxes = []\n for i in range(len(row)):\n lis = []\n for k in range(countcol):\n lis.append([])\n for j in range(len(row[i])):\n diff = abs(center - (row[i][j][0] + row[i][j][2] / 4))\n minimum = min(diff)\n indexing = list(diff).index(minimum)\n lis[indexing].append(row[i][j])\n finalboxes.append(lis)\n \n # from every single image-based cell/box the strings are extracted via pytesseract and stored in a list\n outer = []\n for i in range(len(finalboxes)):\n for j in range(len(finalboxes[i])):\n inner = ''\n if (len(finalboxes[i][j]) == 0):\n outer.append(' ')\n else:\n for k in range(len(finalboxes[i][j])):\n y, x, w, h = finalboxes[i][j][k][0], finalboxes[i][j][k][1], finalboxes[i][j][k][2], \\\n finalboxes[i][j][k][3]\n finalimg = bitnot[x:x + h, y:y + w]\n kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (2, 1))\n border = cv2.copyMakeBorder(finalimg, 2, 2, 2, 2, cv2.BORDER_CONSTANT, value=[255, 255])\n resizing = cv2.resize(border, None, fx=2, fy=2, interpolation=cv2.INTER_CUBIC)\n dilation = cv2.dilate(resizing, kernel, iterations=1)\n erosion = cv2.erode(dilation, kernel, iterations=2)\n \n out = pytesseract.image_to_string(erosion)\n if (len(out) == 0):\n out = pytesseract.image_to_string(erosion, config='--psm 3')\n inner = inner + " " + out\n outer.append(inner)\n \n # Creating a dataframe of the generated OCR list\n arr = np.array(outer)\n dataframe = pd.DataFrame(arr.reshape(len(row), countcol))\n print(dataframe)\n data = dataframe.style.set_properties(align="left")\n # Converting it in a excel-file\n data.to_excel("C:/Users/19038/Desktop/Research Things/Test/output.xlsx")\n</code></pre>\n"},{"tags":["macos","docker","http"],"owner":{"reputation":335,"user_id":6521289,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/789067089fcc5fa817d0715240593ab0?s=128&d=identicon&r=PG&f=1","display_name":"lak","link":"https://stackoverflow.com/users/6521289/lak"},"is_answered":false,"view_count":16,"answer_count":1,"score":0,"last_activity_date":1623258062,"creation_date":1623101218,"question_id":67878890,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67878890/docker-engine-api-url-in-mac","title":"Docker Engine API URL in mac","body":"<p>I'm trying to make HTTP requests to Docker Engine API but I'm getting a NotFound error</p>\n<pre><code>const response = await axios({\n method: 'POST',\n url: "http://unix:///var/run/docker.sock:/v1.39/images/create?fromImage=my-image&tag=latest",\n headers: {\n 'Content-Type': 'application/json'\n }\n });\n</code></pre>\n<p>This is the error I got.</p>\n<pre><code>code: 'ENOTFOUND',\nsyscall: 'getaddrinfo',\nhostname: 'unix',\n</code></pre>\n<p>I have read some articles, apparently I have to edit a file called docker.service, but I'm not able to find it in MAC. Any idea</p>\n"},{"tags":["sql-server","tsql","sql-server-2016"],"owner":{"reputation":2817,"user_id":4191466,"user_type":"registered","accept_rate":50,"profile_image":"https://www.gravatar.com/avatar/5e8319491a3bf6019ad5ebaf8163be55?s=128&d=identicon&r=PG&f=1","display_name":"fdkgfosfskjdlsjdlkfsf","link":"https://stackoverflow.com/users/4191466/fdkgfosfskjdlsjdlkfsf"},"is_answered":false,"view_count":17,"answer_count":1,"score":0,"last_activity_date":1623258059,"creation_date":1623254844,"last_edit_date":1623255620,"question_id":67907856,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907856/tsql-issues-with-canceling-long-running-alter-table","title":"Tsql: Issues with canceling long-running alter table?","body":"<p>Are there any negative issues with canceling a running <code>alter table</code> statement that alters a column from <code>nvarchar(100)</code> to <code>nvarchar(25)</code>? The table has at least 35M rows.</p>\n<p>I'm asking because it's been running for the last 1.5 hours. This is the statement:</p>\n<pre><code>ALTER TABLE HourlyTable\nALTER COLUMN EmpId nvarchar(25);\n</code></pre>\n<p>We're using <code>Microsoft SQL Server 2016 (SP2-GDR)</code></p>\n"},{"tags":["c","multidimensional-array","struct","malloc","field"],"owner":{"reputation":31,"user_id":12787203,"user_type":"registered","profile_image":"https://lh6.googleusercontent.com/-WBGdNduscPs/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rc0GOBjkm7W51dWNrc0Faw-1FoW4w/photo.jpg?sz=128","display_name":"user12787203","link":"https://stackoverflow.com/users/12787203/user12787203"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258055,"creation_date":1623258055,"question_id":67908645,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908645/int-value-inside-array-cell-somehow-being-stored-as-a-separate-2d-array-address","title":"Int value inside array cell somehow being stored as a separate 2d array address","body":"<p>I've created this struct, and a function that initializes all of the fields within that struct and returns a struct pointer. Within this struct I have one single dimensional array of integers, and a two dimensional array of pointers. However, somehow the value inside the cells of the single dimensional array are being stored inside the address of the two dimensional array. I have no idea how, but it's messing me up pretty badly.</p>\n<pre><code>#include <stdio.h>\n#include <stdlib.h>\n\ntypedef struct LonelyPartyArray\n{\n int **fragments; // the address of fragments[i] is being set as\n int *fragment_sizes; // the value inside fragment_sizes[i]\n} LonelyPartyArray;\n\nLonelyPartyArray *createParty(int num_fragments)\n{\n int i;\n\n // Allocating LonelyPartyArray struct pointer\n LonelyPartyArray *party = malloc(sizeof(LonelyPartyArray));\n\n // I am allocating these separately, is something going on with how my system is\n // allocating space for these arrays?\n\n // Allocating LonelyPartyArray\n party->fragments = malloc(sizeof(int *) * num_fragments);\n\n // Allocating LonelyPartyArray fragment size\n party->fragment_sizes = malloc(sizeof(int) * num_fragments);\n\n // Initializing party->fragments to NULL (not used) and fragment_sizes to zero\n for (i = 0; i < num_fragments; i++)\n party->fragments[i] = NULL;\n\n for (i = 0; i < num_fragments; i++)\n party->fragment_sizes[i] = 0;\n\n for (i = 0; i < num_fragments; i++)\n {\n if (party->fragments[i] != party->fragment_sizes[i])\n break;\n printf("Why is this happening???? [%d]\\n", i);\n return NULL;\n }\nreturn party;\n}\n\nint main(void)\n{\n LonelyPartyArray *party = createParty(3);\n\n return 0;\n}\n</code></pre>\n<p>I have no idea how party->fragments[] is being set as the address for party->fragment_sizes[], but I need them to be separate.</p>\n"},{"tags":["c++","template-meta-programming"],"owner":{"reputation":3901,"user_id":4224575,"user_type":"registered","accept_rate":82,"profile_image":"https://i.stack.imgur.com/Nvq43.gif?s=128&g=1","display_name":"Lorah Attkins","link":"https://stackoverflow.com/users/4224575/lorah-attkins"},"is_answered":true,"view_count":26,"accepted_answer_id":67908206,"answer_count":2,"score":1,"last_activity_date":1623258053,"creation_date":1623254490,"last_edit_date":1623255673,"question_id":67907777,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907777/trait-for-non-qualified-or-pointer-reference-types","title":"Trait for non qualified or pointer/reference types","body":"<p>I'm implementing a check to see if a type is stripped of any qualifications:</p>\n<pre><code>template <class T>\nstruct is_plain : std::integral_constant<\n bool, \n std::is_same_v<T, std::decay_t<T>> // *\n>;\n</code></pre>\n<p>Is the logic in <code>std::is_same_v<T, std::decay_t<T>></code>, i.e. check if a type is stripped of anything that <code>decay</code> would remove,available as a standard trait?</p>\n<p>If not, is my implementation missing something? I just want to make sure (in a static assertion) that one does not pass pointers or references to some class.</p>\n<h2>Update</h2>\n<p>As pointed out by @NathanOliver, <code>decay</code> won't remove pointerness (if that's a word), so <code>decay_t<int*>==int*</code>. I wasn't aware of that, so an addition to the desciprion would be that <strong>I want to remove pointers from the type as well</strong>.</p>\n"},{"tags":["css","browser","linear-gradients"],"owner":{"reputation":1,"user_id":16177771,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b946ae003bd821cffc1f9c3858d5fece?s=128&d=identicon&r=PG&f=1","display_name":"MilesMorales314","link":"https://stackoverflow.com/users/16177771/milesmorales314"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623258051,"creation_date":1623255965,"question_id":67908139,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908139/linear-gradient-from-my-code-is-not-working-on-any-browser","title":"linear gradient from my code is not working on any browser","body":"<p>I tried making few adjustments but still, it did not work. I've read that adding height to and would work. And why is adding height working.</p>\n<pre><code>* {\nmargin: 0;\npadding: 0;\n}\n\nbody {\nbackground-color: -webkit-linear-gradient(-45deg, #d93b32, #D932D1, #9232d9);\nbackground-color: -moz-linear-gradient(-45deg, #d93b32, #D932D1, #9232d9);\nfont-family: 'Raleway', sans-serif;\n}\n\nhtml,\nbody {\nheight: 100%;\n}\n</code></pre>\n"},{"tags":["android","material-design"],"owner":{"reputation":904,"user_id":1060673,"user_type":"registered","accept_rate":42,"profile_image":"https://i.stack.imgur.com/VxuL9.png?s=128&g=1","display_name":"FTLRalph","link":"https://stackoverflow.com/users/1060673/ftlralph"},"is_answered":false,"view_count":11,"answer_count":1,"score":0,"last_activity_date":1623258049,"creation_date":1623253226,"question_id":67907453,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907453/android-custom-theme-color-not-changing-for-toolbar","title":"Android custom theme, color not changing for Toolbar","body":"<p>Excuse the short question, but this seems relatively simple but can't get the toolbar color to change:</p>\n<p><a href=\"https://i.stack.imgur.com/S5XJr.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.stack.imgur.com/S5XJr.png\" alt=\"enter image description here\" /></a></p>\n<p>Changing the textSize or even the parent of the <code>ToolbarTitle</code> property <strong>does</strong> cause changes to the text, but I cannot get the color to change no matter what I try.</p>\n<pre><code><style name="Theme.Custom" parent="Theme.MaterialComponents.DayNight.NoActionBar">\n <item name="toolbarStyle">@style/Toolbar</item>\n</style>\n\n<style name="Toolbar" parent="Widget.MaterialComponents.Toolbar">\n <item name="titleTextAppearance">@style/ToolbarTitle</item>\n <item name="android:textColor">#FFFFFF</item>\n</style>\n\n<style name="ToolbarTitle" parent="TextAppearance.MaterialComponents.Button">\n <item name="android:textSize">12sp</item>\n <item name="android:textColor">#FFFFFF</item>\n</style>\n</code></pre>\n"},{"tags":["angular","checkbox"],"owner":{"reputation":1011,"user_id":8760028,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/63b1af9245d3c42448c0a0b5efe04ce1?s=128&d=identicon&r=PG&f=1","display_name":"pranami","link":"https://stackoverflow.com/users/8760028/pranami"},"is_answered":false,"view_count":12,"answer_count":0,"score":0,"last_activity_date":1623258042,"creation_date":1623257527,"last_edit_date":1623258042,"question_id":67908545,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908545/how-do-i-get-the-checked-and-unchecked-values-of-a-checkbox-in-angular","title":"How do I get the checked and unchecked values of a checkbox in angular","body":"<p>I have a list of checkboxes as shown below:</p>\n<pre><code> <div class="col-md-4 md-padding" *ngFor="let node of nodeList; let j=index;">\n <md-checkbox-group>\n <md-checkbox\n class="md-h6 row md-padding--xs"\n name="{{node.FQDN}}"\n label="{{node.FQDN}}"\n value="{{node.FQDN}}"\n required="true"\n htmlId="filter_label_{{j}}"\n (click)="updatefilter(node.FQDN)"\n [formControlName]="servers"\n [(ngModel)]="node.selected">\n </md-checkbox>\n\n\n </md-checkbox-group>\n\n\n </div>\n</code></pre>\n<p>I have to check if the checbox is checked or unchecked. How do I proceed?</p>\n"}],"has_more":true,"backoff":10,"quota_max":300,"quota_remaining":273} |