{"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":"
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.
\n\n\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":"Process 'command '/Applications/IntelliJ IDEA CE.app/Contents/jbr/Contents/Home/bin/java'' finished with non-zero exit value 1
\n
I have written this piece of code. When I am running on JDK 8, output is mm-dd-yyyy
. When running JDK 11, the output is yyyy-dd-mm
. How can I output mm-dd-yyyy
regardless of JDK version?
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
\nI worked quite a while with Apache Storm in a distributed setting. But currently, I faced a strange situation.
\nI ran a Storm Cluster with the Nimbus node on the host nodes1
.\nMy storm.yaml
is quite simple:
storm.zookeeper.servers: \n - "nodes1"\nstorm.local.dir: /tmp/storm\nnimbus.seeds: ["nodes1"]\nui.port: 8081\nsupervisor.slots.ports: \n - 6700\n
\nI doublechecked that the Storm nimbus is running, I can run storm list
for example. Looking on my syslog gives the same information, so Storm Nimbus is active and running.
But my problem is, that my nimbus.log
stays empty and is not written!
So, why logging does not work and how to repair this?\nI have not modified any log4j-Files.
\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":"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.
\nconn = 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
\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":"import datetime \n\ndef convert_to_mysql_date(input_date):\n
\nif not input_date:\nreturn "NULL"\nreturn (\ndatetime.dateime.strptime(input_date, "%m/%d/%Y").date().strftime("%Y/%m/%d")\n)
\nfor purchase in processed_response:\npurchase_date = datetime.datetime(2019, 1, 1)
\nMy brain has been working on it for days now.... if some guy can help me!!! :(
\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":"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;
\nIf 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;
\nTo illustrate the error a took theses screenshots;
\nMy Google Chrome version is 91.0.4472.77 64 bits
\n\nAfter display:none
\n\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":" 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
\nI 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.
\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":"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
\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":"R version 4.0.5 (2021-03-31)\nPlatform: x86_64-w64-mingw32/x64 (64-bit)\nRunning under: Windows 10 x64 (build 19042)
\nI 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.
\nMy data are:\ndataset
\nThe image below represents an example of what I kind want to make:\nTime-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.
\nI 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.
\nAny help or guidance would be highly appreciated.
\nThank you in advance.
\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":"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.
\nI 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.
\nThe 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.
\n<!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>
\r\nSo typically, on a basic level, you often see firestore collection triggered functions written like:
\nexports.myFunction = functions.firestore\n .document('my-collection/{docId}')\n .onWrite((change, context) => { /* ... */ });\n
\nThat being said, I am running my deployments a bit different, although structurally identical.
\nI deploy the functions via Terraform where I define:
\nSo 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)
\nSo, with that context:
\nI 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'>.
\nGoal: Giving a depth n, I would like to compute for each value (except the first 2*n-2) :
\nresult(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
\nI want to avoid loops, so is there a better way to achieve my goal using numpy?
\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":"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:
\n/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
\nI'm going to put the file in which I connect to the database and my docker-compose file
\nconnect to database:
\nrequire("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
\nthe HOST is = localhost,
\nI 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,
\nthis is my docker-compose:
\nversion: '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
\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":"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:
\n".read": true\n".write": true\n
\nWhich information is used by others to access my database and how can I hide those informations?
\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":"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]
\n<?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
\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":"In my Spring Boot application, i am having form based login and oAuth2.0 based login with Google, my security configuration is defined as
\n 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
\nI am doing stateless authentication with JWT, for form based login JWTAuthenticationFilter
handles the authentication as below.
JWTAuthenticationFilter
\npublic class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {\n//code to authenticate user and generate JWT\n}\n
\nand JWTAuthorizationFilter
validates the JWT for subsequent requests as below.
JWTAuthorizationFilter
\npublic class JWTAuthorizationFilter extends BasicAuthenticationFilter {\n// code to perform authorization\n}\n
\nNow coming to oAuth2.0 customOAuth2UserService
does register the new users and update the existing user information.\nOAuth2AuthenticationSuccessHandler
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.
Issues
\nhttp://localhost:8080/login
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.What configurations i am missing and what can i change to fix these issues, TIA.
\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":"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
\nThe code above gives the following output-
\n\nAs visible, it displays correctly the value of total_cases_per_100
for USA
and all the other child nodes. But for parent nodes, it sums it up, which is wrong as total_cases_per_100
is a ratio and not a total.
Is there anyway I can hide the value
hoverinfo for all nodes except the children?
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.
\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":"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
\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":"What kind of ML Classification model suits the best when I want to predict if the person had a good day or bad day based on the everyday data entry shown in the table. Note: DayAnswer target variable, and all other columns are independent.
\n\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":"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".
\nSo, the basic configuration is as follows:
\ntype A: "long"\ntype B: "int"\ntype C: "string"\ntype D: "json object"\n
\nwhere 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.
\nI need all of the "typeD*
" 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.
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.
\ninput {\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
\nAlso, 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.
\nI 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?
\nThanks
\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":"Team,
\ni am using ng drag and drop to move my dynamic fields from field area to panel area.
\nin my cunrrent code Drag is working but droppable not working.
\nHere is the reference screen.
\ni want to drag no of fields into personal details form.
\n\nHere is my code for drag.
\n <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
\nHere is the sample droppable
\n <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
\n \nTS code
\nonAnyDrop(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
\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":"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.
\nI am not getting any message on the receiver side.
\nMaybe an infinite loop on the server side creates a problem, but is there a way to make this channel communication working?
\nclient.rs
\nuse 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
\nserver.rs
\nuse 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
\nmessage_receiver.rs
\nuse 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
\nmain.rs
\nmod unix_datagram_server;\nmod message_receiver;\n\nfn main() {\n message_receiver::handle_messages();\n}\n
\nOnce the TCP client is connected:
\nTCP client Connected to TCP Server UnixDatagram { fd: 3, local: (unnamed), peer: "/tmp/datagram.sock" (pathname) }\n
\nI receive no messages on the channel receiver end:
\nWaiting for client to connect...\n
\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":"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:
\n# 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
\ngives this result:\n3D Matrix
\nThe result I'm looking for are the indices of the minimum element from each of the 2D arrays, something like:
\n[[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
\nor 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.
\nAny help is appreciated, thank you!
\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":"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:
\nsuccess({\ndata = {\n id = "eb259a9e-1b71-4df3-9d2a-6aa797a147f6";\n nickname = joeDoe;\n options = {\n avatar = avatar1;\n };\n rooms = "<null>";\n};\n
\n})
\nIt Gives me an error that looks like this:
\nkeyNotFound(CodingKeys(stringValue: "id", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \\"id\\", intValue: nil) (\\"id\\").", underlyingError: nil))\n
\nThe user model looks like this:
\nimport 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
\nAnd the function looks like this:
\n 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
\nHow do i fix the issue?
\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":"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.
\nCurrently, the MaxArraySize
set by the admins is 2048
. I was going to manually set my options like:
First array script:
\n#SBATCH --array=1-2000%300 \n
\nNext script:
\n#SBATCH --array=2001-4000%300\n
\nand so on...
\nBut slurm does not like values above 2048 in the array.
\nWhat's the easiest way of doing this?
\n(All I can think are for loops, but then I'd lose the constraint option from slurm [%300
], to avoid clogging the scheduler.)
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
\nThe problem is that I only know how to do the following:
\n$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
\nAdding text is easy but when it comes to adding tables, I cant get it right.\nAs you can see:
\nActually 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.
\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":"I am trying to deploy a new powerpoint add-in using the Javascript APIs that microsoft has created.
\nI have looked at both
\nOffice.context.document.settings
Powerpoint.run((ctx) => ctx.presentation)
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.
\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":"Below is a 2D array that represents movement of an entity over a 2 second period:
\n[[10, 200, 0], [70, 170, 600], [110, 150, 1000], [155, 120, 1600], [155, 120, 2000]]\n
\nEach array elements contains x-coordinate, y-coordinate, and timestamp in such order.
\nI 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.
\nI know the correct output is:
\n10 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
\nHow can I achieve this?
\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":"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.
\nAn additional error popped up
\n\n\n\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":"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
\n
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?
\nTextAreaCount() {\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
\nThis 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?
\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":"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
\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":"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:
\nI checked the TeX path and it is correctly TeXLive being used. Can anyone help me?
\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":"I am using a bash script (run.sh
) to run a python file (calculate_ssp.py
). The code is working fine. The folder structure is given below
├── 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
\nThe bash script is
\n#!/bin/bash\n\npython3 -m scripts.calculate_ssp 0.5\n
\nNow, I am trying to run the bash script (run.sh
) from the Dockerfile
. The content of the Dockerfile is
#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
\nBut, I am getting an error /usr/local/bin/python3: Error while finding module specification for 'scripts.calculate_ssp' (ModuleNotFoundError: No module named 'scripts')
Could you tell me why I am getting the error (as the code is working fine from the bash script)?
\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":"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.
\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":"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.
\npublic 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
\nHere is class AtomDTO.
\npublic 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
\nHere is class BondDTO.
\npublic 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
\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":"I have a complex case that I would appreciate to have your advice on it.
\nwhen Order_id exist and if there are 2 rows with the same order_id :\nthen select the row that have no null on seller and comment\nelse select the row with seller and null on the comment and change the null to comment not provided
\n(change the null to not provided)
when order_id does not exist - put not found in both seller and comment
\nPlease see the date example and the Desired result on the photo
\n\nWITH 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
\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":"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 :
\ngrowkl TRYNEW /etc/cron.d ./grill/mk\n
\nand then, the growkl file will forward all these arguments ( TRYNEW /etc/cron.d ./grill/mk ) to the command /usr/bin/gkbroot\nIn this way :
\n/usr/bin/gkbroot TRYNEW /etc/cron.d ./grill/mk\n
\nI'm a newbie with these things, so I'm not getting how to do this.\nCan anyone tell me
\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":"Lets say I have multiple variables that measure substance abuse i.e a1 is on alcohal usage,\na2 is on bhang and a3 is on cocaine. I would like to generate variable afin that indicates engaged in substance abuse if any of the the three is yes.
\nIs there a way to shorten the code so I don't specify use multiple ifelse
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 ifelse
may not be ideal.
# 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
\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":"I am using JCS caching in my web application and time to time the JCS get
method throws ClassNotFoundException
upon trying to read object from the IndexedDiskCache
. Usually after server startup and then continues..
Sample code:
\nGenericResult cachedResult = jcs.get( "myKey" );\n
\nCache configurations.
\njcs.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
\nException:
\nRegion [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
\nThe class GenericResult
is bundled with my web application and the dependency JCS
library is provided in the Apache Tomcat's lib folder.JCS version 1.3
My webapps POM :
\n<dependency>\n <groupId>org.apache.jcs</groupId>\n <artifactId>jcs</artifactId>\n <version>1.3</version>\n <scope>provided</scope>\n</dependency>\n
\nThis 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.
\nIf possible kindly let me know how the class loading happens behind the scenes, As per Tomcat Docs 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 com.example.result.GenericResult
should be found in the /WEB-INF/classes
but that is not happening ( or am I wrong here?? )
Following is my code to update view height inside tableview cell
\n 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
\nalthough this is not reflected till I scroll i.e is cell is recreated. How to update constraint inside TableViewCell of a view?
\nhere is entire tableviewcell code
\nimport 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
\nFollowing is view hierarchy from stroryboard
\n\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":"I have a button to send and save the data in firebase
\ndata is : TextFiled and TextView and Color and Image
\nThe problem is in the picture
\nI can not perform the transmission without selecting the image
\nI want to make it optional
\nThis Button Code :
\n@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
\nWhere is the problem and how can I make it optional?
\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":"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!)
\nHow do I do this? Or is it wiser to change it into a String and later change it back into a char array?
\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":"i tried to place the data at column 5 row B but the data place at bottom of the excel table
\nPrivate 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
\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":"I need to check if data typed in a inputtext is valid, and if it is, then execute a method.\n(Validation by a DataAnnotation
).
I tried in the OnFieldChanged
event of EditForm
but this one executes before validation.
How could I do this?
\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":"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.
\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":"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.
\nimport 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
\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":"in ScanKey function which is for keypad 3*4 its work well until numbers length under 4\nit works like this number = (number * 10)
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 CodeVisionAVR\nC language for ATmega16a
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
\n 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
\nunsigned 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
\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":"I have a file that has some info about ticket issuance which looks like that.
\nTest 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
\nThe attributes are passengerName
, Company
, ticketClass
, departureTime
, itenerary
, ticketCost
, gate
, ticketId
, issueDate
which are seperated using "\\t" as the delimiter
.\nEvery input in the file is a String
. The file gets loaded in an Arraylist
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 Collections.sort()
examples that I found but still nothing works. The desired result to get the file sorted so I can display it in a JTextArea
.Every field of the file is a String which is an attribute of the Ticket class
and the ArrayList is of type Ticket (ArrayList<Ticket> = new ArrayList();
). Here is what I have till now.
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
\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":"In ggplot I want to create a facet grid where the y axes are free. This scales
option is available in facet_wrap()
but I want to keep the grid layout. I have attached a drawn example of what I want.
EDIT:\nI added some code for calrity
\n# 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
\n\nNote that no trends are visible for low values because in the grid they are obscured by the high values.
\n# 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
\n\nNote that the grid layout is lost.
\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":"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?
\nEssentially 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.
\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":"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
\nThe ideal solution would be something similar to what is offered by the Visual Studio debugger as described here.\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.
\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":"I use the SpringBoot provided redistemplate to execute the Lua script:
\nreturn redis.call('bf.reserve', KEYS[1],ARGV[1],ARGV[2])\n
\nbut it keeps getting wrong:
\n\n\nERR Error running script (call to f_264cca3824c7a277f5d3cf63f1b2642a0750e989): @user_script:1: ERR bad error rate.
\n
this is my docker image:\nredislabs/rebloom:2.2.5
\ni try to run this script in linux command,it works:
\n[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
\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":"I'm working on a script to do some pricing. Have a dataframe which contains a quantity list:
\nName | \nVolume | \nArea | \n
---|---|---|
Wood | \n133 | \n256 | \n
Steel | \n55 | \n330 | \n
(and 1800 more lines like those)
\nWhat 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.
\nName | \nVolume | \nArea | \nQty | \n
---|---|---|---|
Wood | \n133 | \n256 | \n133 | \n
Steel | \n55 | \n330 | \n330 | \n
So far I've thought to create a dictionary:
\nmy_dict = {'Wood':'Volume', 'Steel':'Area'}
\nUsing map (or replace) I put that into a column in the df:
\nName | \nVolume | \nArea | \nDatafield | \n
---|---|---|---|
Wood | \n133 | \n256 | \nVolume | \n
Steel | \n55 | \n330 | \nArea | \n
Now, how would I go about putting the quantity into the Quantity column, based on what Datafield says?
\nI tried
\ndf['Quantity'] = df[df['Datafield']]
\nBut, it crashed and I'm stuck.
\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":"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:
\nnew_key_path = '.'.join(key_path.split('.')[0:3])\n
\nBut I did this
\nnew_key_path = '.'.join(str.split('.')[0:3])\n
\nkey_path
vs str
. The former is a valid variable (path to file), the latter was apparently not None
, but an empty string. So it didn't error out. The result of this was that all iterations set new_key_path
to .
. The rest of the logic was such that I was essentially copying to the "root" of the s3 bucket...
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
\nEDIT: adding the example renaming code. This is out of the box with Boto3.
\nself.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
\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":"I'm a beginner who just started using R.
\nI 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?
\n 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
\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":"I wrote regular expression
\n/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g\n
\nFor given string
\ntranslateX(381px) translateY(-94px)\n
\nTo capture translateX
and translateY
values. Tested it by regex101.com service, it works well there. But, when I try it in JavaScript it capture translateX
value which is 381
but not capture translateY
which is -94
. Do you have any ideas why is this happening?
regex101
https://i.stack.imgur.com/Nuj5X.png
\nJavaScript exec
console.log(/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g.exec(\"translateX(381px) translateY(-94px)\"));
\r\nUsing matchAll
gives the same result.
JavaScript matchAll
console.log(\"translateX(381px) translateY(-94px)\".matchAll(/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g).next().value.groups);
\r\nI'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:
\nThis part of the SQL is static
\nSELECT TITLE as TitleField,\n GEOM as GeomField,\n GEOM_X as XField,\n GEOM_Y as YField\nFROM fdw_public."MY_TABLE"\n
\nThen an administrator can set a WHERE clause up in the database, for example:
\nCOLUMNNAME LIKE '%{search}%'\n
\nor
\nOTHER_COLUMNNAME = '{search}' AND COLUMNNAME = 'Something Static';\n
\nThis isn't known at compile time and could be any valid WHERE clause.
\nThe {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.
\nThe end result is this SQL
\nSELECT 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
\nThe {search} part however is the user input (from a web application), so this needs parameterizing.
\nThe following works, but is obviously very open to SQL Injection
\nvar 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
\nSo I attempted to use a parameter for the whole where clause
\nvar 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
\nBut this throws the following exception from Npgsql
\n\n\n42804: argument of WHERE must be type boolean, not type text
\n
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.
\nIdeally I need to parametrize just the search term, like this
\nvar 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
\nBut again, this doesn't work, understandably, as it is being interpreted literally.
\nI 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.
\nEither way, to sum up, the requirement is this
\nI just started a intro college C programming class and have the following assignment:
\nUse a loop to load random integer values into a 1 dimensional array.
\nUse a loop to load random integer values into a multidimensional array.
\nCreate a function to search (Linear) for numbers in both.
\na. 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.
\nWrite functions to print the contents of each array.
\nYour function should accept an array as the parameter.
\nWrite a function that increments all the values by an integer that is passed as a parameter. This parameter should be passed by reference.
\nPrint the byte sizes of each array to the screen
\nOur 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.
\nHere's what I have so far.
\n#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
\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":"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.)
\nI tried the disable/enable yesterday, but today, people were saying it looks their code changes were not being used on the website.
\nGreat feature in the future would be to invalidate all files changed since the last validation. That should be easy for them to do.
\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":"I hope get week datetime list by datetime range,I tried the following code get number of weeks per month.
\nvar 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
\nBut,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.
\n2021-06-09 2021-06-13\n.....\n2021-06-28 2021-07-01\n
\nhow to changed my code
\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":"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).
\nlibrary(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
\nGives
\n\nBut I want this:
\n\nHow can this be achieved?
\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":"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.
\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":"I am trying to capture variable names from the variable declaration. The variables are declared and initialized in the following manner:
\nlet URL="https://www.lipsum.com/", error, pass=true;\n
\nI have this above code in the form of a string and I want to obtain the name of the variables using RegEX.
\nI am using this regex expression: /let\\s+([\\w_$]+)(?:=.*),?/;
However, I am only getting URL
in the output
const str = `let URL=\"https://www.lipsum.com/\", error, pass=true;`;\nconst regex = /let\\s+([\\w_$]+)(?:=.*),?/;\n\nconsole.log(str.match(regex));
\r\nHow do I obtain the variable names URL
, error
, and pass
from the given string?
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".
\nThe dataframe would look like this:
\n 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
\nThe expected result looks like such [Column_1, Column 30]
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?
\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":"I get an error message for componentDidUpdate when I try to set state and I'm not sure why.
\ncomponentDidUpdate() {\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
\nconsole log value gets logged only once, when the statement is true, so I'm not sure how and why is it looping..
\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":"I have a video upload form which needs a progress bar. I am using an xhr.upload.addEventListener
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:
let formData = new FormData(e.target[4]); // 4th element in the form is the video\n
\nBut the only way I can get it to send the whole form (but it will not update the progress bar) is as such:
\nlet formData = new FormData(e.target.form);\n
\nThe whole AJAX function is here:
\n<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
\nHow can I monitor the progress but also upload the whole form?
\nAll help is very much appreciated.
\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":"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.
\nGreat, 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?
\nThanks! If there are somewhat easy to follow sources as well, I would gladly appreciate it
\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":"I am training a DDPG agent on my custom environment that I wrote using openai gym. I am getting error during training the model.
\nWhen 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.
\nFor example by using:\ntf.global_variable_initialzer()\n
\nBut 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.
\nHere are the libraries that I used with there versions
\ntensorflow: 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
\nError/Stacktrace:
\nTraining 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
\nThe actor and critic networks are as follows:
\nACTOR 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
\nCRITIC 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
\nHere is the code for DDPG agent
\n# 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
\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":"I am trying to integrate Stripe with redirection to my app, I am using Angular-typescript.
\nHere is the code I have so far in my component:
\nvar 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
\nBut I have the following error running the above code:
\nCannot find name 'Stripe'. Did you mean 'stripe'?
I have installed package with the command npm install --save stripe
following the next guide https://stripe.com/docs/checkout/integration-builder
Is there anyone that faced the same problem when integrating Stripe?
\nThanks!
\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":"I am importing these images :
\nimport Image1 from './assets/image1.png';\nimport Image2 from './assets/image2.png';\n
\nI am then using them in JSX :
\n<img src={Image1} alt="image1"/>\n<img src={Image2} alt="image2"/>\n
\nThe problem is that I would like to be able to set the source dinamically, like this, for example :
\n<img src={`Image${1}`} alt="image1"/>\n
\nbut of course a string won't work.
\nIs there any way to do this ?
\nThanks
\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":"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 awswrangler:
\nimport awswrangler as wr\n\n# read data\ndata = wr.s3.read_parquet("s3://bucket-name/folder/with/parquet/files/", dataset = True)\n
\nThis returns a pandas dataframe:
\nclient_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
\nHowever, 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 this(which is my own question), but seems not to be working correctly.
\nI 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.
\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":"I want to fetch the data from multiple API
with axios
in Vue.js 3. The backend is Laravel API.
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.
\nI need this data to load on page on loaded. The Vue.js code is -
\n<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
\nI got error on console - this- app.js:20666 TypeError: Cannot set property 'patient' of null
How can I assign data to the patient and labGroup, so it will applied to my webpage via v-model
\nThis 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.
\nI hope, someone will give me a solution for this.
\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":"I found some solutions to avoid N+1 problem but this solutions works only for single Many-To-One relationship.
\nFor example, the following question: What is the solution for the N+1 issue in JPA and Hibernate?
\nThe problem that I'm trying to solve is this:
\n@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
\nSolutions like try to fetch through JPQL doesn't work and fetch just one relationship, for example:
\nSELECT b FROM Book b \nINNER JOIN FETCH b.author \nINNER JOIN FETCH b.brand\n
\nIn this case, only 'author' relationship would be fetched and N+1 problem will happen with 'brand' relationship.
\nDo you know any solution to solve this specific problem?
\nThank you!
\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":"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
\nselect \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
\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":"I am trying 'delete' items in 03 different DB-Collections(Reactive MongoDB), using 03 different services/repo (userService + postService + userRepo);
\nMy Goal is DELETE an object (in each collection) simultaneously, using the same chaining-code;
\nBelow is the code for the above situation:
\nCurrent working status: not working;
\nCurrent behaviour: not executes any delete, weither delete-userService, delete-postService, or delete-userRepo.
\n@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
\nThanks a lot for any help
\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":"I'm using Tomcat 10 and eclipse to develop a J2E (or Jakarta EE) web application. I followed this tutorial (http://objis.com/tutoriel-securite-declarative-jee-avec-jaas/#partie2) 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.
\nThe dataSource works, I followed instructions on this page (https://tomcat.apache.org/tomcat-10.0-doc/jndi-datasource-examples-howto.html#Oracle_8i,_9i_&_10g) 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.
\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.
\nMy web.xml :
<?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
\ncontext.xml :
\n<?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
\nserver.xml :
\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<!-- 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 "%r" %s %b" />\n\n </Host>\n </Engine>\n </Service>\n</Server>\n
\nlogin.jsp :
\n<%@ 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
\nerreur-authentifiction.jsp, has same content as login.jsp, but with an error message.
User table (password hash obtained with digest.bat) :\nUser table
\nRole table with foreign key on login referencing login column of user table :\nRole table
\nThis is my project arborescence, if it can help : arborescence
\nSo please, can someone tell me what I did wrong ?
\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":"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] :
\n<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
\n\nHere is my code (removed unnecessary codes) :
\npublic class ViewSalary extends AppCompatActivity {
\nprivate 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
\n}
\nI 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)
\n\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":"The "thead" is giving all the data in side by innerText, but "tbody" is blank. No "tr" and even "td" is helping.
\nSub 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
\nPlease help me there the image is incerted.
\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":"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)
\nIs java 6 works with angular ?\n
If not, must I use java 8 ?
\nAngular works with soap web services or we must go for Rest ?
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.
\nI have two csv files, which look like so:
\nhours,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
\nhours,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
\nAnd I am trying to run this code to detect if there are headers present in the file:
\nwith 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
\nThis works beautifully for file2, but for file1 (and others) it just does not correctly read the data.
\nColumn 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.
\nI'm really scratching my head over this one and I'm unsure why this would be so.
\nAny insight/help would be great, thanks!
\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":"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:
\n#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
\nI 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.
\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":"The scenario:
\nI have an address table with what you'd kind of expect (street, town, postcode etc)
\nI 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).
\nI'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.
\nI'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)!
\nI'm trying to do this using a CodeFirst approach, I have no additional config in my modelBuilder configuration.
\nThe project is using .NET 5 with EF Core 5
\nI'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.
\nDB Schema:
\n\n\nClientDetails.cs
\npublic 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
\nSite.cs
\npublic 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
\nAddress.cs
\n 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
\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":"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?
\n\n netsh advfirewall firewall add rule name="javaw.exe" dir=in action=allow program= $fullPath enable=yes profile=domain\n
\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":"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
\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":"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.
\nThis works quite well, but I cannot get rid of one problem in a special action sequence:
\nIf I press buttons "one" and "three", the corresponding input forms are filled properly, this is what I want.
\nNow if after that I press the "Delete A" button, one of two unwanted things happen:
\nIf 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.
\nIf 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.
\nI do not want to clear the complete form to be reloaded at any stage.
\nEDIT: The problem is not a question of returning false
values from functions to prevent form submission as discussed in JavaScript code to stop form submission . in fact all my fucntions are returning false
values.
<!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>
\r\nI need to count how many times certain value occurs in a column
\nIt looks like this (select * from znajezyki order by klos
)
klos - is a serial number of a person (this value is repeated)
\nNow I need to create a query that will show me how many people knows 1,2,3 languages
\nIf 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
\nI'd like my result to look something like this:\n
\nI tried refering to this post here but i cannot understand it and can't get it to work
\nI hope y'all can understand what I am talking about :)
\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":"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:
\nfunc 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
\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":"I have a data frame which looks like this:
\n\nI 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:
\nfor i in (number+1 for number in range(data_gpd.index[-1]-1)):\nif (data_gpd['distance'][i+1]< 250):\n
\nI'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.
\nI really appreciate your help as I'm new to python and not sure which syntax would work better
\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":"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
\nColumn1 | \nColumn2 | \n
---|---|
String | \nStringString | \n
I have the following query:
\nWHERE Column1 LIKE 'String' OR Column2 LIKE '%String%'\n
\nHow 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?
\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":"When I bundle code with wasm and run it in a browser using deno, I get an error.
\nRunning command.
\n$ 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
\nThen, the following error occurs.
\nUncaught TypeError: Cannot read property '__wbindgen_malloc' of undefined\n
\nIf you change the typescript code, you will get various other errors.
\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":"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.)
\nAny help would be appreciated. I'll post an example of what I mean.\nlike so
\nTitle 1 Title 2 Title 3
Row 1 Something 1 SomethingElse 1
\nRow 2 Something 2 SomethingElse 2
\nRow 3 Something 3 SomethingElse 3
\nRow 4 Something 4 SomethingElse 4 <User is on Cell A, shown here as Bolded
\nRow 5 Something 5 SomethingElse 5
\nRow 6 Something 6 SomethingElse 6
\nRow 7 Something 7 SomethingElse 7
\nRow 8 Something 8 SomethingElse 8
\nRow 9 Something 9 SomethingElse 9
\nRow 10 Something 10 SomethingElse 10
\nThis is what I'd Like after the macro gets done. Just the top row and selected row.
\nTitle 1 Title 2 Title 3
\nRow 4 Something 4 SomethingElse 4
\nThank you again, everyone!
\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":"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.
\nHere 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
\nERROR:
\nTraceback (most recent call last):\n
\nFile "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 init\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
\nDuring handling of the above exception, another exception occurred:
\nTraceback (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.
\nCODE:
\n 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
\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":"I'm trying to make HTTP requests to Docker Engine API but I'm getting a NotFound error
\nconst 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
\nThis is the error I got.
\ncode: 'ENOTFOUND',\nsyscall: 'getaddrinfo',\nhostname: 'unix',\n
\nI 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
\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":"Are there any negative issues with canceling a running alter table
statement that alters a column from nvarchar(100)
to nvarchar(25)
? The table has at least 35M rows.
I'm asking because it's been running for the last 1.5 hours. This is the statement:
\nALTER TABLE HourlyTable\nALTER COLUMN EmpId nvarchar(25);\n
\nWe're using Microsoft SQL Server 2016 (SP2-GDR)
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.
\n#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
\nI have no idea how party->fragments[] is being set as the address for party->fragment_sizes[], but I need them to be separate.
\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":"I'm implementing a check to see if a type is stripped of any qualifications:
\ntemplate <class T>\nstruct is_plain : std::integral_constant<\n bool, \n std::is_same_v<T, std::decay_t<T>> // *\n>;\n
\nIs the logic in std::is_same_v<T, std::decay_t<T>>
, i.e. check if a type is stripped of anything that decay
would remove,available as a standard trait?
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.
\nAs pointed out by @NathanOliver, decay
won't remove pointerness (if that's a word), so decay_t<int*>==int*
. I wasn't aware of that, so an addition to the desciprion would be that I want to remove pointers from the type as well.
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.
\n* {\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
\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":"Excuse the short question, but this seems relatively simple but can't get the toolbar color to change:
\n\nChanging the textSize or even the parent of the ToolbarTitle
property does cause changes to the text, but I cannot get the color to change no matter what I try.
<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
\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":"I have a list of checkboxes as shown below:
\n <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
\nI have to check if the checbox is checked or unchecked. How do I proceed?
\n"}],"has_more":true,"backoff":10,"quota_max":300,"quota_remaining":273}