qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,388,741
<p>I have received a json object that shows comparison between two tags on github repo. I want to show all messages that are available inside the JSON object. The json object can be seen here: <a href="https://api.github.com/repos/git/git/compare/v2.37.4...v2.38.1" rel="nofollow noreferrer">https://api.github.com/repos/git/git/compare/v2.37.4...v2.38.1</a></p> <p>I have used the requests library available in python to receive the object:</p> <pre><code>import requests response= requests.get('https://api.github.com/repos/git/git/compare/v2.37.4...v2.38.1') json_obj=response.json() </code></pre> <p>Now how can I print the values of each instance of attribute named 'message' found in the json object?</p>
[ { "answer_id": 74388946, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 1, "selected": false, "text": "mask['key2'] = mask['key2'].fillna(' '.join([str(x) for x in data['key2'].unique()])).astype(str).str.split(' ')\nmask = mask.explode('key2')\nmask['key2'] = pd.to_numeric(mask['key2'])\npd.merge(mask,data,on=['key1','key2'],how='left')\n" }, { "answer_id": 74389043, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": false, "text": "concat" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12436327/" ]
74,388,748
<p>I have a react app that uses azure ad and msal for authentication.</p> <p>Facing 2 problems in production environment: 1- When i visit the site on localhost it shows me the unauthenticated view as it should, and then i can log in to access my protected routes, but when i do the same to the application that is hosted on azure, i get asked to log in immediately and after logging in then it shows me the unauthenticated view and need to log in again to see the authenticated template. 2- Randomly when i try to login i get redirected to the main page showing the unauthenticated view and losing the URL parameters, so i need to log in again by pressing the login button for the second time, then i see the main page of the authenticated template but the url param is gone.</p> <p>this is my authConfig.js file:</p> <pre><code>import { LogLevel } from '@azure/msal-browser' export const msalConfig = { auth: { authority: 'https://login.microsoftonline.com/xxxxxxxxxxxxxxxxxxx', clientId: 'xxxxxxxxxxxxxxxxxxxxxx', redirectUri: '/', }, cache: { cacheLocation: 'localStorage', storeAuthStateInCookie: false, }, } export const logInRequest = { scopes: ['api://xxxxxxxxx/access_as_user'], } </code></pre> <p>And this is my SignIn func:</p> <pre><code>const handleLogin = (instance) =&gt; { instance.loginPopup(logInRequest).catch((e) =&gt; { console.log(e) }) } </code></pre> <p>the signout func:</p> <pre><code>const handleLogout = (instance) =&gt; { instance.logoutRedirect({ postLogoutRedirectUri: '/', }) } </code></pre> <p>This is how i implement the library in app.js:</p> <pre><code> const isAuthenticated = useIsAuthenticated() isAuthenticated &amp;&amp; requestAccessToken(instance, accounts) return ( &lt;&gt; &lt;AuthenticatedTemplate&gt; &lt;Routes&gt; &lt;Route path=&quot;/&quot; element={&lt;zzzz/&gt;} /&gt; &lt;Route path=&quot;/xx&quot; element={&lt;xxxx/&gt;} /&gt; otherRoutes..... &lt;/Routes&gt; &lt;/AuthenticatedTemplate&gt; &lt;UnauthenticatedTemplate&gt; &lt;NotAuthenticatedView /&gt; &lt;/UnauthenticatedTemplate&gt; &lt;/&gt; </code></pre> <p>and lastly this is my index.js where i wrap the app with the provider:</p> <pre><code>import { msalConfig } from './authConfig' const msalInstance = new PublicClientApplication(msalConfig) ReactDOM.render( &lt;React.StrictMode&gt; &lt;MsalProvider instance={msalInstance}&gt; &lt;BrowserRouter&gt; &lt;App /&gt; &lt;/BrowserRouter&gt; &lt;/MsalProvider&gt; &lt;/React.StrictMode&gt;, document.getElementById('root') ) </code></pre> <p>appreciate any help</p> <p>I tried pop up and redirect for both login and out, expected the app in production to behave in the same way as in dev, but i'm getting asked to login directly when i visit the site aven before i see the unauthenticated view, then seeing it though i already logged in, and in sometimes the login pop up get stock where i see the same page in a pop up and cant press the login either, where i should close down the pop up and try the login button multiple times, and sometimes i login then it shows the unauthenticated view and the param in url is lost.</p>
[ { "answer_id": 74388946, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 1, "selected": false, "text": "mask['key2'] = mask['key2'].fillna(' '.join([str(x) for x in data['key2'].unique()])).astype(str).str.split(' ')\nmask = mask.explode('key2')\nmask['key2'] = pd.to_numeric(mask['key2'])\npd.merge(mask,data,on=['key1','key2'],how='left')\n" }, { "answer_id": 74389043, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": false, "text": "concat" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14442167/" ]
74,388,850
<p>I have an array of numbers which can be a value of either <code>1</code> or <code>0</code>. I need to create a function that detects if there is <strong>one instance</strong> where there is a consecutive <code>1</code> and no other <code>1</code> exist outside of that instance, returns <code>true</code> else <code>false</code></p> <p>So to sum it up here's a clearer view of the constraints to return <code>true</code>:</p> <ol> <li>must have <em><strong>only one set</strong></em> of consecutive <code>1</code></li> <li>there must be no other <code>1</code> outside of that one instance of consecutive <code>1</code></li> </ol> <p>Test cases:</p> <pre><code>[0, 0, 1, 1, 0, 0] true [1, 0, 1, 0, 0, 0] false [1, 0, 1, 1, 0, 0] false [1, 1, 0, 1, 1, 0] false [0, 1, 1, 1, 1, 0] true [0, 0, 1, 1, 1, 1] true </code></pre>
[ { "answer_id": 74389496, "author": "Trevor Dixon", "author_id": 711902, "author_profile": "https://Stackoverflow.com/users/711902", "pm_score": 3, "selected": true, "text": "function hasOneRun(arr) {\n let switches = 0;\n for (let i = 0; i < arr.length; i++) {\n switches += arr[i] ^ arr[i-1];\n if (switches > 2) return false;\n }\n return switches > 0;\n}\n" }, { "answer_id": 74390108, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 1, "selected": false, "text": "const testCases = [\n [[0, 0, 1, 1, 0, 0], true],\n [[1, 0, 1, 0, 0, 0], false],\n [[1, 0, 1, 1, 0, 0], false],\n [[1, 1, 0, 1, 1, 0], false],\n [[0, 1, 1, 1, 1, 0], true],\n [[0, 0, 1, 1, 1, 1], true]\n];\nconst f = a => a.join('').split(/0+/).filter(i=>i).length===1;\ntestCases.forEach(t=>console.log(f(t[0])===t[1] ? 'pass' : 'fail'));" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9123173/" ]
74,388,884
<p>I'm trying to secure my application with Spring Security oAuth2. Is there a way to return 401 for some URL while other pages go to the login page if a user is not logged in.</p> <p>For example, return login form for /ui/*, and return 401 for /api/*</p> <p>I tried to use two <code>SecurityWebFilterChain</code>, but didn't success.</p>
[ { "answer_id": 74389648, "author": "Marcus Hert da Coregio", "author_id": 5454842, "author_profile": "https://Stackoverflow.com/users/5454842", "pm_score": 1, "selected": true, "text": "AuthenticationEntryPoint" }, { "answer_id": 74399916, "author": "kai", "author_id": 3770378, "author_profile": "https://Stackoverflow.com/users/3770378", "pm_score": 1, "selected": false, "text": " http.exceptionHandling().authenticationEntryPoint(new DelegatingServerAuthenticationEntryPoint(\n new DelegatingServerAuthenticationEntryPoint.DelegateEntry(\n ServerWebExchangeMatchers.pathMatchers(\"/ui/**\"),\n new RedirectServerAuthenticationEntryPoint(\"/login\")\n ),\n new DelegatingServerAuthenticationEntryPoint.DelegateEntry(\n ServerWebExchangeMatchers.pathMatchers(\"/api/**\"),\n new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED)\n ))\n );\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3770378/" ]
74,388,911
<p>I have a text file with:</p> <blockquote> <p>8-9, 12, 14-16, 19, 27-28, 33, 41, 43, 45-46, 48-49, 51,54-60, 62-74, 76-82, 84-100, 102-105, 107-108</p> </blockquote> <p>It is basically a list of integers in a text file. Using Python, I want to turn this into a list where every variable is stored separately. But the problem is that the dashes between the numbers represents a range, implying that 62-74 is actually 62,63,64,65,66,67,68,69,70,71,72,73,74.</p> <p>So my program should be able to read the text and if it encounters any dash it should append the list with the numbers within that range.</p> <p>Do you have any idea how to do that?</p> <p>I tried to create a list with integers in a text file.</p>
[ { "answer_id": 74389578, "author": "LiiVion", "author_id": 19328707, "author_profile": "https://Stackoverflow.com/users/19328707", "pm_score": 1, "selected": false, "text": "num_list = [\"8-9\", \"12\", \"14-16\", \"19\", \"27-28\", \"33\", \"41\", \"43\", \"45-46\", \"48-49\", \"51\",\"54-60\", \"62-74\", \"76-82\", \"84-100\", \"102-105\", \"107-108\"]\noutput_list = []\n\nfor number in num_list:\n if \"-\" in number: # Checks if the string contains \"-\"\n num1, num2 = number.split(sep=\"-\") # Splits the numbers\n num1 = int(num1) # Setting the number from string to integer\n num2 = int(num2) # Setting the number from string to integer\n while num1 <= num2:\n output_list.append(num1) # append to output list\n num1 += 1\n else:\n output_list.append(int(number)) # append to output list\n\nprint(output_list)\n" }, { "answer_id": 74389724, "author": "Steinn Hauser Magnusson", "author_id": 13819183, "author_profile": "https://Stackoverflow.com/users/13819183", "pm_score": 0, "selected": false, "text": "\"-\"" }, { "answer_id": 74390329, "author": "Axeltherabbit", "author_id": 8340761, "author_profile": "https://Stackoverflow.com/users/8340761", "pm_score": 0, "selected": false, "text": "with open(\"list.txt\",\"f\") as f:\n content = f.read()\n result = [x for rng in content.split(\",\") for x in range(*map(int, rng.split(\"-\")))]\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12216993/" ]
74,388,919
<p>I'm looking for a way to extract only tags that don't have another tag in it</p> <p>For example:</p> <pre><code>from bs4 import BeautifulSoup html = &quot;&quot;&quot; &lt;p&gt;&lt;a href='XYZ'&gt;Text1&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Text2&lt;/p&gt; &lt;p&gt;&lt;a href='QWERTY'&gt;Text3&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Text4&lt;/p&gt; &quot;&quot;&quot; soup = BeautifulSoup(html, 'html.parser') soup.find_all('p') </code></pre> <p>Gives</p> <pre><code>[&lt;p&gt;&lt;a href=&quot;XYZ&quot;&gt;Text1&lt;/a&gt;&lt;/p&gt;, &lt;p&gt;Text2&lt;/p&gt;, &lt;p&gt;&lt;a href=&quot;QWERTY&quot;&gt;Text3&lt;/a&gt;&lt;/p&gt;, &lt;p&gt;Text4&lt;/p&gt;] </code></pre> <p>This is what I want to achieve:</p> <pre><code>[&lt;p&gt;Text2&lt;/p&gt;, &lt;p&gt;Text4&lt;/p&gt;] </code></pre>
[ { "answer_id": 74389069, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 0, "selected": false, "text": "if/else" }, { "answer_id": 74389536, "author": "TomerG", "author_id": 1885248, "author_profile": "https://Stackoverflow.com/users/1885248", "pm_score": 2, "selected": false, "text": "Tag" }, { "answer_id": 74390221, "author": "0nelight", "author_id": 5288820, "author_profile": "https://Stackoverflow.com/users/5288820", "pm_score": 0, "selected": false, "text": "from bs4 import BeautifulSoup\n\nhtml = \"\"\"\n<p><a href='XYZ'>Text1</a></p>\n<p>Text2</p>\n<p><a href='QWERTY'>Text3</a></p>\n<p>Text4</p>\n<p>Text6: <a href='QWERTY'>Text5</a></p>\n\"\"\"\n\nsoup = BeautifulSoup(html, 'html.parser')\n\ndef p_tag_with_only_strings_as_children(tag):\n return tag.name == \"p\" and all(isinstance(x, str) for x in tag.children)\n\nresult = soup.find_all(p_tag_with_only_strings_as_children)\n\nprint(result)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20467659/" ]
74,388,945
<p>The PostgreSQL database is just installed directly into the linux host machine (not as docker container).</p> <p>In a docker container (built with docker compose) I have an application that needs to connect to the database.</p> <p>The client container needs to be on a docker bridge network and cannot be on the host network directly because it needs to reach other containers on the bridge network.</p> <p>I connect to the Postgres database using the <code>host.docker.internal</code> hostname <a href="https://stackoverflow.com/a/67158212/2051646">as described here</a>.</p> <p>From within that container I can reach the database no problem that way. But PostgreSQL needs to allow this connection in <code>pg_hba.conf</code> or else I get the error:</p> <blockquote> <p>no pg_hba.conf entry for host &quot;172.22.0.3&quot;</p> </blockquote> <p>Of course I can add that IP address to <code>pg_hba.conf</code> <a href="https://stackoverflow.com/questions/72438399/cant-connect-to-postgresql-on-host-machine-from-docker-container">like done here</a> but that won't give me a very stable solution because the IP address will not always be the same.</p> <p>What would be the best practice? Allow all connection from 172.<em>.</em>.* ? Or...?</p>
[ { "answer_id": 74389069, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 0, "selected": false, "text": "if/else" }, { "answer_id": 74389536, "author": "TomerG", "author_id": 1885248, "author_profile": "https://Stackoverflow.com/users/1885248", "pm_score": 2, "selected": false, "text": "Tag" }, { "answer_id": 74390221, "author": "0nelight", "author_id": 5288820, "author_profile": "https://Stackoverflow.com/users/5288820", "pm_score": 0, "selected": false, "text": "from bs4 import BeautifulSoup\n\nhtml = \"\"\"\n<p><a href='XYZ'>Text1</a></p>\n<p>Text2</p>\n<p><a href='QWERTY'>Text3</a></p>\n<p>Text4</p>\n<p>Text6: <a href='QWERTY'>Text5</a></p>\n\"\"\"\n\nsoup = BeautifulSoup(html, 'html.parser')\n\ndef p_tag_with_only_strings_as_children(tag):\n return tag.name == \"p\" and all(isinstance(x, str) for x in tag.children)\n\nresult = soup.find_all(p_tag_with_only_strings_as_children)\n\nprint(result)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2051646/" ]
74,388,957
<p>When querying a table in Oracle Dev I need to ignore any ID that doesn't have a null date.</p> <p>An ID can be returned multiple times e.g. 5 times, 4 can have a null date but one might have 01.01.2022 in which case all of them need to be ignored.</p> <p>Here is the SQL:</p> <pre><code>SELECT ID, ACTIVATION_DATE, ACCEPTED_DATE FROM TABLE WHERE ACCEPTED_DATE IS NOT NULL --AND ACTIVATION_DATE IS NULL AND ID IN ('AA1','AA2'); </code></pre> <p>And the result:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>ACTIVATION_DATE</th> <th>ACCEPTED_DATE</th> </tr> </thead> <tbody> <tr> <td>AA1</td> <td></td> <td>01/04/2022</td> </tr> <tr> <td>AA1</td> <td></td> <td>15/03/2022</td> </tr> <tr> <td>AA1</td> <td>22/08/2022</td> <td>07/06/2022</td> </tr> <tr> <td>AA1</td> <td></td> <td>11/05/2022</td> </tr> <tr> <td>AA2</td> <td></td> <td>06/06/2022</td> </tr> <tr> <td>AA2</td> <td>25/09/2022</td> <td>12/12/2021</td> </tr> </tbody> </table> </div> <p>You can see AA1 has pulled 4 rows but because it has one activation date, they now all need to be ignored. If I leave AND ACTIVATION_DATE IS NULL in there it will still return the blank rows, which need to be ignored altogether.</p> <p>Assume this will need to be a subquery? Any help would be much appreciated!</p> <p>I have tried the SQL query as above</p>
[ { "answer_id": 74389144, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 0, "selected": false, "text": "not exists" }, { "answer_id": 74389165, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 2, "selected": false, "text": "COUNT" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468160/" ]
74,388,972
<p>I use oak server with Deno. But there is some problem with the response in post request. My example:</p> <pre><code>const loginEp = async (ctx, next) =&gt; {//loginEp if(!ctx.request.hasBody) {//if ctx.throw(415); }//if const reqBody = await ctx.request.body({ type: 'json' }).value; console.log(reqBody, typeof reqBody); ctx.response.status = 200; ctx.response.body = {key_one: &quot;One&quot;}; ctx.response.type = &quot;json&quot;; };//loginEp const router = new Router() router.post(&quot;/api/login&quot;, loginEp) app.use(router.allowedMethods()); app.use(router.routes()); </code></pre> <p>Try use:</p> <pre><code>curl --header &quot;Content-Type: application/json&quot; \ --request POST \ --data '{&quot;login&quot;:&quot;test&quot;,&quot;password&quot;:&quot;test123&quot;}' \ http://localhost:8010/api/login </code></pre> <p>The server receives the request and prints the body to the console. But I am not getting a response from the server.</p> <p>If comment <code>const reqBody = await ctx.request.body({ type: 'json' }).value; console.log(reqBody, typeof reqBody);</code> then I get response.</p> <p>I can't understand how to get the request body on the server and respond.</p>
[ { "answer_id": 74391050, "author": "zja", "author_id": 6599384, "author_profile": "https://Stackoverflow.com/users/6599384", "pm_score": 1, "selected": false, "text": "const reqBody = await (await ctx.request.body({ type: 'json' })).value; " } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5287908/" ]
74,388,973
<pre><code>public class Main { public static void main(String[] args) { String satz = &quot;Heute ist wunderbares Wetter, fahren wir doch zum Strand&quot;; System.out.println(satz); System.out.print(satz.substring(22)); } } </code></pre> <p>I tried different things, but i have always errors. i am a beginner with Java, and i try to understand strings. I tried to understand them in ANSI C, but i have no clue :D</p>
[ { "answer_id": 74391050, "author": "zja", "author_id": 6599384, "author_profile": "https://Stackoverflow.com/users/6599384", "pm_score": 1, "selected": false, "text": "const reqBody = await (await ctx.request.body({ type: 'json' })).value; " } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468325/" ]
74,388,974
<p>I have a directory with several files tab-delimited (txt format). Each file is a table with a lot of rows, but I am interested in the 10th column. I want to extract all uniq values of this column and count the occurrence for all files. For this purpose, I have used the code below in bash, which works, but when the files are extremely heavy, it does not respond.</p> <pre><code>awk -F'\t' 'FNR==1{next} { ++n[$10]; if ($10 in a) { a[$10]=a[$10]&quot;,&quot;ARGV[ARGIND] }else{ a[$10]=ARGV[ARGIND] } } END{ printf(&quot;%-24s %6s %s\n&quot;,&quot;Variant&quot;,&quot;Nº of repeats&quot;,&quot;Location&quot;); for (v in n) printf(&quot;%-24s %6d %s\n&quot;,v,n[v],a[v])}' * &gt; var_freq.txt </code></pre> <p>The output should see something like this:</p> <pre><code>Variant Nº of repeats Location variant1 3 file1,file2,file3 variant2 5 file1,file3,file4,file5,file7 variant3 2 file1,file4 </code></pre> <p>The header of a possible file looks like this:</p> <pre><code>Chr Start END COL4 COL5 COL6 COL7 COL8 COL9 Variant 1 1234 1345 ABC 123 234 345 456 567 c.1236A&gt;G </code></pre> <p>Anyone could tell me how to do that in other languages that can handle BigData? (python, R...) Thanks</p>
[ { "answer_id": 74389503, "author": "Santiago", "author_id": 13507658, "author_profile": "https://Stackoverflow.com/users/13507658", "pm_score": 0, "selected": false, "text": "library(dplyr)\nlibrary(purrr)\nlibrary(tibble)\n" }, { "answer_id": 74389778, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 2, "selected": true, "text": "library(data.table)\n\nfile_list <- list.files(pattern = \"\\\\.txt\")\n\nmyData <- lapply(file_list, \\(x){\n dat <- fread(x, select = 10) |>\n table() |>\n data.table()\n dat[,file := sub(\"\\\\.txt\", \"\", x)]\n}) |>\n rbindlist()\n\nfinal <- myData[, .(`Nº of repeats` = sum(N), Location = paste(file, collapse = \",\")),\n by = list(Variant = V1)]\n\nprint(final)\n" }, { "answer_id": 74390071, "author": "Ottie", "author_id": 17732851, "author_profile": "https://Stackoverflow.com/users/17732851", "pm_score": 0, "selected": false, "text": "mydir <- \"/location/of/my/dir\"\nfiles <- list.files(filedir, pattern = \"*.txt\", full.names = TRUE)\n\nvariants <- lapply(seq_along(files), \\(i) data.frame(\n \"Location\" = basename(files[i]),\n \"Variant\" = unique(read.delim(files[i])[,10])\n))\n\noutput <- aggregate(Location~Variant, do.call(rbind, variants), paste, sep=\",\")\noutput$Nrepeats <- nchar(gsub(\"[^,]\", \"\", output$Location)) + 1\n\n> output\n Variant Location Nrepeats\n1 variant1 file1.csv, file3.csv 2\n2 variant2 file1.csv, file2.csv 2\n3 variant3 file1.csv 1\n4 variant4 file1.csv, file2.csv, file3.csv 3\n5 variant5 file2.csv 1\n6 variant6 file2.csv, file3.csv 2\n7 variant9 file3.csv 1\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9152842/" ]
74,388,979
<p>Anybody an idea how to get the offsetTop of an element in Vue3 with the composite API? Like this version of Vue2?</p> <pre><code>goto(refName) { var element = this.$refs[refName]; var top = element.offsetTop; window.scrollTo(0, top); } </code></pre> <p>i have in my setup():</p> <pre><code>const accordions = ref([]); ... &lt;Disclosure v-slot=&quot;{ open }&quot; v-for=&quot;(region, index) of data&quot; :key=&quot;index&quot; :ref=&quot;(el) =&gt; pushToRef(el, index)&quot; &gt;...&lt;/Disclosure&gt; function pushToRef(el, index) { accordions[index] = el; } </code></pre> <p>it is filled by elements of a v-for. I could get the proxy out of the array later. But not the offset:</p> <pre><code>const element = accordions[region]; console.log(&quot;Region: &quot; + region); //got the name console.log(&quot;Element: &quot;, element); // Proxy of element const top = element.offsetTop; // UNDEFINED ??? console.log(&quot;OffsetTop: &quot; + top); // !!! Undefined window.scrollTo({ top: top, left: 0, behavior: &quot;smooth&quot;, }); </code></pre>
[ { "answer_id": 74389503, "author": "Santiago", "author_id": 13507658, "author_profile": "https://Stackoverflow.com/users/13507658", "pm_score": 0, "selected": false, "text": "library(dplyr)\nlibrary(purrr)\nlibrary(tibble)\n" }, { "answer_id": 74389778, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 2, "selected": true, "text": "library(data.table)\n\nfile_list <- list.files(pattern = \"\\\\.txt\")\n\nmyData <- lapply(file_list, \\(x){\n dat <- fread(x, select = 10) |>\n table() |>\n data.table()\n dat[,file := sub(\"\\\\.txt\", \"\", x)]\n}) |>\n rbindlist()\n\nfinal <- myData[, .(`Nº of repeats` = sum(N), Location = paste(file, collapse = \",\")),\n by = list(Variant = V1)]\n\nprint(final)\n" }, { "answer_id": 74390071, "author": "Ottie", "author_id": 17732851, "author_profile": "https://Stackoverflow.com/users/17732851", "pm_score": 0, "selected": false, "text": "mydir <- \"/location/of/my/dir\"\nfiles <- list.files(filedir, pattern = \"*.txt\", full.names = TRUE)\n\nvariants <- lapply(seq_along(files), \\(i) data.frame(\n \"Location\" = basename(files[i]),\n \"Variant\" = unique(read.delim(files[i])[,10])\n))\n\noutput <- aggregate(Location~Variant, do.call(rbind, variants), paste, sep=\",\")\noutput$Nrepeats <- nchar(gsub(\"[^,]\", \"\", output$Location)) + 1\n\n> output\n Variant Location Nrepeats\n1 variant1 file1.csv, file3.csv 2\n2 variant2 file1.csv, file2.csv 2\n3 variant3 file1.csv 1\n4 variant4 file1.csv, file2.csv, file3.csv 3\n5 variant5 file2.csv 1\n6 variant6 file2.csv, file3.csv 2\n7 variant9 file3.csv 1\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1627225/" ]
74,388,998
<p>I try to allocate the memory of the array dynamically using malloc function. The array (d) is composed of two vectors. The code is as follows:</p> <blockquote> </blockquote> <pre><code>#include &lt;stdio.h&gt; void main() { int ind; int nlfc; double x[5], y[5], z[5]; nlfc=4; double **d; double dt[3][nlfc]; d=malloc(4*sizeof(double)); for(ind=0; ind&lt;nlfc; ind++) { d[ind]=malloc(4*sizeof(double)); } x[4]=0; y[4]=0; z[4]=0; x[0]=-1; x[1]=0; x[2]=1; x[3]=0; y[0]=0; y[1]=-1; y[2]=0; y[3]=1; z[0]=0; z[1]=0; z[2]=0; z[3]=0; for (ind=0;ind&lt;nlfc;ind++){ d[ind][0]=x[ind]-x[4]; d[ind][1]=y[ind]-y[4]; d[ind][2]=z[ind]-z[4]; } for (ind=0;ind&lt;nlfc;ind++){ printf(&quot;%f\n&quot;,sizeof(d[ind][1])); } free(d); } </code></pre> <p>The output is as follows:</p> <p>0.000000 0.000000 0.000000 0.000000</p> <p>But the output needs to be as follows:</p> <p>-1 0 1 0</p> <p>So it seems I implemented malloc function in a wrong way. Could you help me how to implement correctly malloc function in this code?</p> <p>Kind regards</p>
[ { "answer_id": 74389063, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 2, "selected": false, "text": "d=malloc(4*sizeof(double));\n" }, { "answer_id": 74389190, "author": "user253751", "author_id": 106104, "author_profile": "https://Stackoverflow.com/users/106104", "pm_score": 1, "selected": false, "text": "printf(\"%f\\n\",sizeof(d[ind][1])); \n" }, { "answer_id": 74389714, "author": "tstanisl", "author_id": 4989451, "author_profile": "https://Stackoverflow.com/users/4989451", "pm_score": 0, "selected": false, "text": "double (*d)[4] = calloc(4, sizeof *d);\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74388998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20461675/" ]
74,389,040
<p>In my program, I have a RecyclerView with an adapter, in which I'm checking which element of RecyclerView is clicked.</p> <pre><code>override fun onBindViewHolder(holder: ViewHolder, position: Int) { val currentBreakfast = breakfastList[position] holder.breakfastTitle.text = context.getText(currentBreakfast.breakfastStringResourceId) holder.breakfastImage.setImageResource(currentBreakfast.breakfastImageResourceId) holder.breakfastImage.setOnClickListener { holder.itemView.findNavController().navigate(R.id.action_breakfastFragment_to_DetailsFragment) showDetails(currentBreakfast) } } </code></pre> <p>I want to pass the data about specific clicked element, such as <strong>imageId</strong>, <strong>stringId</strong>, <strong>Name</strong>, etc. to another fragment <strong>DetailsFragment</strong> in which I would like to display further data</p> <p>How can I do it?</p>
[ { "answer_id": 74389374, "author": "zaifrun", "author_id": 324975, "author_profile": "https://Stackoverflow.com/users/324975", "pm_score": 0, "selected": false, "text": "class ReportAdapter(var reports: List<Report>,val clickFunc : (Report) -> (Unit)) : RecyclerView.Adapter<ReportAdapter.ViewHolder>() {...}\n" }, { "answer_id": 74389486, "author": "Mert", "author_id": 4058604, "author_profile": "https://Stackoverflow.com/users/4058604", "pm_score": 2, "selected": true, "text": "this" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15158080/" ]
74,389,056
<p>Is there a way I can pass the iframe src into a variable without using <code>getElementById</code> ?</p> <p>I dont know the ID of the iframe as its dynamically generated - but I want to be able to check the src to see if it matches a defined string - the iframe has a class which I can target which is <strong>fancybox-iframe</strong></p> <p>I was hoping this would work but it does not:</p> <pre><code> var srcURL = document.getElementsByClassName('fancybox-iframe').src; </code></pre>
[ { "answer_id": 74389374, "author": "zaifrun", "author_id": 324975, "author_profile": "https://Stackoverflow.com/users/324975", "pm_score": 0, "selected": false, "text": "class ReportAdapter(var reports: List<Report>,val clickFunc : (Report) -> (Unit)) : RecyclerView.Adapter<ReportAdapter.ViewHolder>() {...}\n" }, { "answer_id": 74389486, "author": "Mert", "author_id": 4058604, "author_profile": "https://Stackoverflow.com/users/4058604", "pm_score": 2, "selected": true, "text": "this" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1197577/" ]
74,389,139
<p>I'm working on a Vue/Quasar app and what I want to do is show the following layout only once when the page is loaded:</p> <pre><code>&lt;template&gt; &lt;div v-for=&quot;(section, index) in sections&quot; :key=&quot;index&quot;&gt; &lt;div class=&quot;row q-gutter-md&quot;&gt; &lt;q-input v-model=&quot;sectionName&quot; bottom-slots dense :label=&quot;labelText&quot;&gt; &lt;template v-slot:append&gt; &lt;q-btn flat dense icon=&quot;add&quot; color=&quot;grey &quot; @click=&quot;addNew&quot; /&gt; &lt;q-btn flat dense icon=&quot;delete&quot; color=&quot;grey &quot; @click=&quot;removeSection&quot; /&gt; &lt;/template&gt; &lt;/q-input&gt; &lt;/div&gt; &lt;/div&gt; &lt;/template&gt; </code></pre> <p>Here is the code snippet from the script section:</p> <pre><code> setup() { const sections = ref(1); const addNew = () =&gt; { sections.value++ }; const removeSection = () =&gt; { //... }; return{ //...} </code></pre> <p>The <code>addNew</code> function works well: new sections will be added to the screen. But how could I remove a particular (which was clicked) section? What should I change?</p>
[ { "answer_id": 74389374, "author": "zaifrun", "author_id": 324975, "author_profile": "https://Stackoverflow.com/users/324975", "pm_score": 0, "selected": false, "text": "class ReportAdapter(var reports: List<Report>,val clickFunc : (Report) -> (Unit)) : RecyclerView.Adapter<ReportAdapter.ViewHolder>() {...}\n" }, { "answer_id": 74389486, "author": "Mert", "author_id": 4058604, "author_profile": "https://Stackoverflow.com/users/4058604", "pm_score": 2, "selected": true, "text": "this" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11672206/" ]
74,389,155
<p>I am having the following issue <strong>:</strong></p> <p>BE is returning a JSON file that has <code>keys</code> and <code>values</code> but some values are in XML format. How can I turn them into JSON as well ?</p> <p>It's the first time I am seeing this kind of structure. So any help would be appreciated. I am working on in a React environment.</p> <pre><code>[{ &quot;price&quot;: 19, &quot;currency&quot;: &quot;GBP&quot;, &quot;productImage&quot;: &quot;https://daye.cdn.prismic.io/daye/ee153f6163435330b18495535217c531300382a8_product2x.png&quot;, &quot;items&quot;: [ { &quot;size&quot;: &quot;regular&quot;, &quot;coating&quot;: &quot;none&quot;, &quot;amount&quot;: 8 }, { &quot;size&quot;: &quot;regular&quot;, &quot;coating&quot;: &quot;CBD&quot;, &quot;amount&quot;: 4 } ] }, { &quot;price&quot;: 18, &quot;currency&quot;: &quot;GBP&quot;, &quot;productImage&quot;: &quot;https://daye.cdn.prismic.io/daye/ee153f6163435330b18495535217c531300382a8_product2x.png&quot;, &quot;items&quot;: &quot;&lt;items&gt;&lt;item&gt;&lt;size&gt;regular&lt;/size&gt;&lt;coating&gt;none&lt;/coating&gt;&lt;amount&gt;10&lt;/amount&gt;&lt;/item&gt;&lt;item&gt;&lt;size&gt;regular&lt;/size&gt;&lt;coating&gt;CBD&lt;/coating&gt;&lt;amount&gt;2&lt;/amount&gt;&lt;/item&gt;&lt;/items&gt;&quot; }, { &quot;price&quot;: 19, &quot;currency&quot;: &quot;GBP&quot;, &quot;productImage&quot;: &quot;https://daye.cdn.prismic.io/daye/ee153f6163435330b18495535217c531300382a8_product2x.png&quot;, &quot;items&quot;: [ { &quot;size&quot;: &quot;small&quot;, &quot;coating&quot;: &quot;none&quot;, &quot;amount&quot;: 8 }, { &quot;size&quot;: &quot;small&quot;, &quot;coating&quot;: &quot;CBD&quot;, &quot;amount&quot;: 4 } ] }, { &quot;price&quot;: 18, &quot;currency&quot;: &quot;GBP&quot;, &quot;productImage&quot;: &quot;https://daye.cdn.prismic.io/daye/ee153f6163435330b18495535217c531300382a8_product2x.png&quot;, &quot;items&quot;: &quot;&lt;items&gt;&lt;item&gt;&lt;size&gt;small&lt;/size&gt;&lt;coating&gt;none&lt;/coating&gt;&lt;amount&gt;10&lt;/amount&gt;&lt;/item&gt;&lt;item&gt;&lt;size&gt;small&lt;/size&gt;&lt;coating&gt;CBD&lt;/coating&gt;&lt;amount&gt;2&lt;/amount&gt;&lt;/item&gt;&lt;/items&gt;&quot; }, { &quot;price&quot;: 17, &quot;currency&quot;: &quot;GBP&quot;, &quot;productImage&quot;: &quot;https://daye.cdn.prismic.io/daye/ee153f6163435330b18495535217c531300382a8_product2x.png&quot;, &quot;items&quot;: &quot;&lt;items&gt;&lt;item&gt;&lt;size&gt;regular&lt;/size&gt;&lt;coating&gt;none&lt;/coating&gt;&lt;amount&gt;12&lt;/amount&gt;&lt;/item&gt;&lt;/items&gt;&quot; }, { &quot;price&quot;: 17, &quot;currency&quot;: &quot;GBP&quot;, &quot;productImage&quot;: &quot;https://daye.cdn.prismic.io/daye/ee153f6163435330b18495535217c531300382a8_product2x.png&quot;, &quot;items&quot;: &quot;&lt;items&gt;&lt;item&gt;&lt;size&gt;small&lt;/size&gt;&lt;coating&gt;none&lt;/coating&gt;&lt;amount&gt;12&lt;/amount&gt;&lt;/item&gt;&lt;/items&gt;&quot; }] </code></pre>
[ { "answer_id": 74389374, "author": "zaifrun", "author_id": 324975, "author_profile": "https://Stackoverflow.com/users/324975", "pm_score": 0, "selected": false, "text": "class ReportAdapter(var reports: List<Report>,val clickFunc : (Report) -> (Unit)) : RecyclerView.Adapter<ReportAdapter.ViewHolder>() {...}\n" }, { "answer_id": 74389486, "author": "Mert", "author_id": 4058604, "author_profile": "https://Stackoverflow.com/users/4058604", "pm_score": 2, "selected": true, "text": "this" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15721007/" ]
74,389,164
<p>I have car-list.component.ts with:</p> <pre><code>**export class CarListComponent implements OnInit { public cars$!: Observable&lt;CarInterface[]&gt;; constructor( private carService: CarService # ) { # } ngOnInit(): void { this.cars$ = this.carService.getAllCars(); # } # }** </code></pre> <p>car.service.ts</p> <pre><code>**export class CarService { constructor( private httpClient: HttpClient ) { } public getAllCars(): Observable&lt;CarInterface[]&gt; { return this.httpClient.get&lt;CarInterface[]&gt;('http://localhost:8080/car/cars'); } }** </code></pre> <p>and car.list.html</p> <pre><code>&lt;body&gt; &lt;div class=&quot;main-content&quot;&gt; &lt;div class=&quot;section-content section-content-p30&quot;&gt; &lt;div class=&quot;container-fluid&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div *ngFor=&quot;let car of cars$ | async&quot; class=&quot;col-md-3&quot;&gt; &lt;div class=&quot;product-box&quot;&gt; &lt;img src=&quot;{{'data:image/jpg;base64,' + car.image }}&quot; alt=&quot;&quot;&gt; &lt;h3&gt;{{ car.name }}&lt;/h3&gt; &lt;div class=&quot;price&quot;&gt;{{ car.price | currency:'USD' }}&lt;/div&gt; &lt;button class=&quot;btn btn-primary btn-sm&quot;&gt;Add to cart&lt;/button&gt; &lt;!--(click)=&quot;addToCart(tempProduct)&quot;--&gt; &lt;/div&gt; &lt;br&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- begin footer --&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-md-12 d-flex justify-content-center&quot;&gt; &lt;!-- &lt;div class=&quot;form-inline float-left mr-1&quot;&gt;--&gt; &lt;!-- &lt;select class=&quot;form-control&quot; [value]=&quot;carsPerPage&quot; (change)=&quot;changePageSize($event)&quot;&gt;--&gt; &lt;!-- &lt;option value=&quot;4&quot;&gt;4&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;8&quot;&gt;8&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;12&quot;&gt;12&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;16&quot;&gt;16&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;20&quot;&gt;20&lt;/option&gt;--&gt; &lt;!-- &lt;/select&gt;--&gt; &lt;!-- &lt;/div&gt;--&gt; &lt;div class=&quot;btn-group flot-right&quot;&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary active&quot; *ngFor=&quot;let page of pageNumbers&quot;&gt;1&lt;/button&gt;--&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary&quot;&gt;2&lt;/button&gt;--&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary&quot;&gt;3&lt;/button&gt;--&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary&quot;&gt;4&lt;/button&gt;--&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- end footer --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>how to make pagination?</p> <p>try</p> <pre><code> &lt;div class=&quot;col-md-12 d-flex justify-content-center&quot;&gt; &lt;!-- &lt;div class=&quot;form-inline float-left mr-1&quot;&gt;--&gt; &lt;!-- &lt;select class=&quot;form-control&quot; [value]=&quot;carsPerPage&quot; (change)=&quot;changePageSize($event)&quot;&gt;--&gt; &lt;!-- &lt;option value=&quot;4&quot;&gt;4&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;8&quot;&gt;8&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;12&quot;&gt;12&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;16&quot;&gt;16&lt;/option&gt;--&gt; &lt;!-- &lt;option value=&quot;20&quot;&gt;20&lt;/option&gt;--&gt; &lt;!-- &lt;/select&gt;--&gt; &lt;!-- &lt;/div&gt;--&gt; &lt;div class=&quot;btn-group flot-right&quot;&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary active&quot; *ngFor=&quot;let page of pageNumbers&quot;&gt;1&lt;/button&gt;--&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary&quot;&gt;2&lt;/button&gt;--&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary&quot;&gt;3&lt;/button&gt;--&gt; &lt;!-- &lt;button class=&quot;btn btn-outline-primary&quot;&gt;4&lt;/button&gt;--&gt; &lt;/div&gt; </code></pre> <p>I tried to make a method that would help me implement pagination, but I can't get the length from cars$.wanted to take this function: return Array(Math.ceil(Number(this.cars$.subscribe(result =&gt; result.length)) / this.carsPerPage)), but an error occurred.</p>
[ { "answer_id": 74389374, "author": "zaifrun", "author_id": 324975, "author_profile": "https://Stackoverflow.com/users/324975", "pm_score": 0, "selected": false, "text": "class ReportAdapter(var reports: List<Report>,val clickFunc : (Report) -> (Unit)) : RecyclerView.Adapter<ReportAdapter.ViewHolder>() {...}\n" }, { "answer_id": 74389486, "author": "Mert", "author_id": 4058604, "author_profile": "https://Stackoverflow.com/users/4058604", "pm_score": 2, "selected": true, "text": "this" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468277/" ]
74,389,166
<p>I am trying to create a dumbbell chart comparing baseline to endline values along several metrics and I am <em>so close</em> to having it just how I want it. I start with this data:</p> <pre><code>&gt; dput(mydata) structure(list(category = c(&quot;food security&quot;, &quot;food security&quot;, &quot;child survival&quot;, &quot;child survival&quot;, &quot;boosted incomes&quot;, &quot;boosted incomes&quot;, &quot;empowered churches&quot;, &quot;empowered churches&quot;, &quot;food security&quot;, &quot;food security&quot;, &quot;child survival&quot;, &quot;child survival&quot;, &quot;boosted incomes&quot;, &quot;boosted incomes&quot;, &quot;empowered churches&quot;, &quot;empowered churches&quot; ), metric = c(&quot;Never going to bed hungry&quot;, &quot;Children at a healthy weight&quot;, &quot;Poor health is not a \&quot;serious problem\&quot;&quot;, &quot;No children sent to work in the city&quot;, &quot;Low income is not a \&quot;serious problem\&quot;&quot;, &quot;At least one stable income source&quot;, &quot;Spiritual support is not a \&quot;serious problem\&quot;&quot;, &quot;Women who feel hope for the future&quot;, &quot;Never going to bed hungry&quot;, &quot;Children at a healthy weight&quot;, &quot;Poor health is not a \&quot;serious problem\&quot;&quot;, &quot;No children sent to work in the city&quot;, &quot;Low income is not a \&quot;serious problem\&quot;&quot;, &quot;At least one stable income source&quot;, &quot;Spiritual support is not a \&quot;serious problem\&quot;&quot;, &quot;Women who feel hope for the future&quot; ), round = c(&quot;baseline&quot;, &quot;baseline&quot;, &quot;baseline&quot;, &quot;baseline&quot;, &quot;baseline&quot;, &quot;baseline&quot;, &quot;baseline&quot;, &quot;baseline&quot;, &quot;endline&quot;, &quot;endline&quot;, &quot;endline&quot;, &quot;endline&quot;, &quot;endline&quot;, &quot;endline&quot;, &quot;endline&quot;, &quot;endline&quot; ), percentage = c(0.53, 0.79, 0.8, 0.8, 0.75, 0.72, 0.75, 0.53, 0.98, 0.93, 0.95, 0.96, 0.93, 0.94, 0.97, 0.84)), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -16L)) </code></pre> <p>and I run the following code to basically prepare it for my ggplot function</p> <pre><code>mydata &lt;- mydata %&gt;% mutate(bump_percentage = if_else(round == &quot;baseline&quot;, percentage - .03, percentage + .03)) %&gt;% mutate(bump_percentage = bump_percentage*100, percentage = percentage*100) %&gt;% arrange(category, round) %&gt;% mutate(category = factor(category, c(&quot;food security&quot;, &quot;child survival&quot;, &quot;boosted incomes&quot;, &quot;empowered churches&quot;))) midpoints &lt;- mydata %&gt;% group_by(metric) %&gt;% summarise(midpoint = mean(percentage)) mydata &lt;- mydata %&gt;% inner_join(midpoints, by = &quot;metric&quot;) </code></pre> <p>It is not necessary to understand all of that to answer my question, but I provide it just in case my bug is somewhere I don't expect. the &quot;bump&quot; stuff is only there so I can create the percentage labels you'll see on the graph below.</p> <p>My current issue is that I want to add arrows to indicate the passage of time (left to right). The midpoint variable is created to indicate the position of the arrows in the graph below.</p> <p>After running the code above on the initial data, I use this:</p> <pre><code>ggplot(mydata, aes(x=percentage, y=metric, color=category)) + geom_line(color=&quot;gray&quot;, size=1.75) + geom_path(aes(x = midpoint), arrow = arrow(angle = 30, length = unit(.15, &quot;inches&quot;), type = &quot;closed&quot;), color = &quot;gray&quot;, ) + geom_point(size=2) + scale_color_viridis(discrete = T) + geom_text(aes(label=glue(&quot;{percentage}%&quot;), x=bump_percentage), color = &quot;dimgray&quot;, size=3) + theme_fivethirtyeight() + facet_grid(category ~ ., scales = &quot;free_y&quot;, switch = &quot;y&quot;) + theme(legend.title=element_blank(), axis.text.x = element_text(color = &quot;dimgray&quot;), panel.grid.major.x = element_line(color=&quot;gray&quot;, size=.2), panel.grid.major.y = element_line(color=&quot;gray&quot;, size=.2, linetype = &quot;dashed&quot;), strip.placement = &quot;outside&quot;, panel.spacing.y = unit(0, &quot;mm&quot;), strip.text = element_blank(), legend.justification = 1) + scale_x_continuous(labels=glue(&quot;{seq(50,100,10)}%&quot;)) </code></pre> <p>which produces this:</p> <p><a href="https://i.stack.imgur.com/4dTcM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4dTcM.png" alt="" /></a></p> <p>WHY ARE THE ARROWS POINTED THE WRONG WAY? My first thought was that the data was simply ordered incorrectly, which is why I added <code>round</code> to the <code>arrange()</code> function you see above. That didn't do it for me.</p> <p>I think that in my actual <code>geom_path</code> call, there is something I need to do to indicate the direction of the arrows. Right now, the aes is only providing this one point, which doesn't specify a direction. But I am not sure what I am missing here.</p>
[ { "answer_id": 74389310, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 1, "selected": false, "text": "geom_path" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13238171/" ]
74,389,253
<p>I have questionnaire (EHP30) answers from a list of participants, where they are rating something between 0 and 4, or -9 for not relevant. The overall score is the sum of the scores scaled to 100. If there are any not relevant answers they are ignored (unless they are all not relevant, in which case the output is missing). Any missing items sets the whole output to missing.</p> <p>I have written a function that calculates the score from an input vector:</p> <pre><code>ehp30_sexual &lt;- function(scores = c(0, 0, 0, 0, 0)){ if(anyNA(scores)){ return(NA) } else if(!all(scores %in% c(-9, 0, 1, 2, 3, 4))){ stop(&quot;Values not in correct range (-9, 0, 1, 2, 3, 4)&quot;) } else if(length(scores) != 5){ stop(&quot;Must be vector length of 5&quot;) } else if(all(scores == -9)){ return(NA) } else if(any(scores == -9)){ newscores &lt;- scores[which(scores != -9)] sum(newscores) * 100 / (4 * length(newscores)) } else { sum(scores) * 100 / (4 * length(scores)) } } </code></pre> <p>I wish to apply this function to each row of a dataframe using mutate if possible (or apply if not):</p> <pre><code>ans &lt;- c(NA, -9, 0, 1, 2, 3, 4) set.seed(1) data &lt;- data.frame(id = 1:10, ePainAfterSex = sample(ans, 10, TRUE), eWorriedSex = sample(ans, 10, TRUE), eAvoidSex = sample(ans, 10, TRUE), eGuiltyNoSex = sample(ans, 10, TRUE), eFrustratedNoSex = sample(ans, 10, TRUE)) </code></pre> <p>Any ideas? I'm happy to rewrite the function or use a <code>case_when</code> solution if it is any simpler.</p>
[ { "answer_id": 74389757, "author": "edvinsyk", "author_id": 16252296, "author_profile": "https://Stackoverflow.com/users/16252296", "pm_score": 0, "selected": false, "text": "data = tibble(data)\n\ndata |> \n mutate(across(where(is.numeric), ~ ifelse(.x == -9, NA, .x))) |> \n rowwise() |> \n mutate(index = sum(c_across(2:6), na.rm = TRUE)) |> \n ungroup() |> \n mutate(score = round(scales::rescale(index, to = c(0, 100))))\n\n id ePainAfterSex eWorriedSex eAvoidSex eGuiltyNoSex eFrustratedNoSex index score\n <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>\n 1 1 NA 0 NA NA NA 0 0\n 2 2 1 0 4 3 3 11 100\n 3 3 4 NA 2 NA 4 10 91\n 4 4 NA 2 2 1 1 6 55\n 5 5 NA 2 NA 4 1 7 64\n 6 6 2 NA NA NA 1 3 27\n 7 7 4 3 3 1 NA 11 100\n 8 8 0 3 2 0 1 6 55\n 9 9 3 NA 2 3 NA 8 73\n10 10 NA 4 NA NA 4 8 73\n\n" }, { "answer_id": 74389896, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "dplyr::rowwise()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19414769/" ]
74,389,269
<p><a href="https://i.stack.imgur.com/o3Qne.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o3Qne.png" alt="enter image description here" /></a></p> <p>I have changed the margin in the row in the CSS file but it wont applied in small devices</p> <pre><code>&lt;body style=&quot;background-color: #353839;&quot;&gt; &lt;div class=&quot;container-fluid&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;div class=&quot;col-12&quot;&gt; &lt;h1 class=&quot;text-center mt-2&quot; style=&quot;color: white;&quot;&gt;Cyber Cloud&lt;/h1&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;row r1 &quot; style=&quot;background-color: black; &quot;&gt; &lt;div class=&quot;col-12 &quot;&gt; &lt;h3 class=&quot;text-center&quot; style=&quot;color: white;&quot;&gt;Join Now&lt;/h3&gt; &lt;p class=&quot;text-center&quot; style=&quot;color: white;&quot;&gt;And Start Buying Games&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;row &quot;&gt; &lt;div class=&quot;col-12 r2&quot;&gt; &lt;input type=&quot;text&quot; placeholder=&quot;Email&quot;/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>My CSS:</p> <pre><code>.r1{ margin-left: 500px; margin-right: 500px; } </code></pre> <p>I have tried to apply bootstrap responsive CSS(added d-none d-lg-block) yet it doesn't work .</p>
[ { "answer_id": 74389757, "author": "edvinsyk", "author_id": 16252296, "author_profile": "https://Stackoverflow.com/users/16252296", "pm_score": 0, "selected": false, "text": "data = tibble(data)\n\ndata |> \n mutate(across(where(is.numeric), ~ ifelse(.x == -9, NA, .x))) |> \n rowwise() |> \n mutate(index = sum(c_across(2:6), na.rm = TRUE)) |> \n ungroup() |> \n mutate(score = round(scales::rescale(index, to = c(0, 100))))\n\n id ePainAfterSex eWorriedSex eAvoidSex eGuiltyNoSex eFrustratedNoSex index score\n <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>\n 1 1 NA 0 NA NA NA 0 0\n 2 2 1 0 4 3 3 11 100\n 3 3 4 NA 2 NA 4 10 91\n 4 4 NA 2 2 1 1 6 55\n 5 5 NA 2 NA 4 1 7 64\n 6 6 2 NA NA NA 1 3 27\n 7 7 4 3 3 1 NA 11 100\n 8 8 0 3 2 0 1 6 55\n 9 9 3 NA 2 3 NA 8 73\n10 10 NA 4 NA NA 4 8 73\n\n" }, { "answer_id": 74389896, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "dplyr::rowwise()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19966203/" ]
74,389,275
<p>I have a typedef struct with different data types in it. The number array has negative and non-negative values. How do I convert this struct in to a unint8t array in C++ on the Linux platform. Appreciate some help on this. Thank you. The reason I am trying to do the conversation is to send this uint8_t buffer as a parameter to a function.</p> <pre><code>typedef struct { int enable; char name; int numbers[5]; float counter; }; </code></pre> <p>appreciate any example on doing this. thank you</p>
[ { "answer_id": 74389757, "author": "edvinsyk", "author_id": 16252296, "author_profile": "https://Stackoverflow.com/users/16252296", "pm_score": 0, "selected": false, "text": "data = tibble(data)\n\ndata |> \n mutate(across(where(is.numeric), ~ ifelse(.x == -9, NA, .x))) |> \n rowwise() |> \n mutate(index = sum(c_across(2:6), na.rm = TRUE)) |> \n ungroup() |> \n mutate(score = round(scales::rescale(index, to = c(0, 100))))\n\n id ePainAfterSex eWorriedSex eAvoidSex eGuiltyNoSex eFrustratedNoSex index score\n <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>\n 1 1 NA 0 NA NA NA 0 0\n 2 2 1 0 4 3 3 11 100\n 3 3 4 NA 2 NA 4 10 91\n 4 4 NA 2 2 1 1 6 55\n 5 5 NA 2 NA 4 1 7 64\n 6 6 2 NA NA NA 1 3 27\n 7 7 4 3 3 1 NA 11 100\n 8 8 0 3 2 0 1 6 55\n 9 9 3 NA 2 3 NA 8 73\n10 10 NA 4 NA NA 4 8 73\n\n" }, { "answer_id": 74389896, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "dplyr::rowwise()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19677040/" ]
74,389,299
<p>Is it possible to auto login users when they open the app after their first login?</p> <p>I'm not sure what is the best way to implement auto login. One of the best options to me is to create refresh-token after the first login. Refresh-token will have a couple of months of lifespan. So far localStorage seems like the only option to store it.</p> <p>Is this way of creating auto login is a good option? Is there a better way to do create auto login?</p>
[ { "answer_id": 74389757, "author": "edvinsyk", "author_id": 16252296, "author_profile": "https://Stackoverflow.com/users/16252296", "pm_score": 0, "selected": false, "text": "data = tibble(data)\n\ndata |> \n mutate(across(where(is.numeric), ~ ifelse(.x == -9, NA, .x))) |> \n rowwise() |> \n mutate(index = sum(c_across(2:6), na.rm = TRUE)) |> \n ungroup() |> \n mutate(score = round(scales::rescale(index, to = c(0, 100))))\n\n id ePainAfterSex eWorriedSex eAvoidSex eGuiltyNoSex eFrustratedNoSex index score\n <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>\n 1 1 NA 0 NA NA NA 0 0\n 2 2 1 0 4 3 3 11 100\n 3 3 4 NA 2 NA 4 10 91\n 4 4 NA 2 2 1 1 6 55\n 5 5 NA 2 NA 4 1 7 64\n 6 6 2 NA NA NA 1 3 27\n 7 7 4 3 3 1 NA 11 100\n 8 8 0 3 2 0 1 6 55\n 9 9 3 NA 2 3 NA 8 73\n10 10 NA 4 NA NA 4 8 73\n\n" }, { "answer_id": 74389896, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 3, "selected": true, "text": "dplyr::rowwise()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5375131/" ]
74,389,314
<p>`</p> <pre><code>import requests from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from time import sleep import os login_page = &quot;https://fap.fpt.edu.vn/Default.aspx&quot; # page = &quot;https://fap.fpt.edu.vn/Report/ScheduleOfWeek.aspx&quot; email = &quot;&quot; password = &quot;&quot; options = Options() options.add_argument(&quot;--window-size=1920,1080&quot;) options.binary_location = &quot;C:\Program Files\Google\Chrome\Application\chrome.exe&quot; driver = webdriver.Chrome(options = options) driver.get(login_page) login1 = driver.find_element(&quot;xpath&quot;,&quot;//div[@class='abcRioButtonContentWrapper']&quot;).click() driver.find_element(By.NAME, &quot;identifier&quot;).send_keys(email) sleep(3) driver.find_element(By.ID, &quot;identifierNext&quot;).click() sleep(2) driver.find_element(By.NAME, &quot;password&quot;).send_keys(password) sleep(2) driver.find_element(By.ID, &quot;passwordNext&quot;).click() sleep(999999) </code></pre> <p>`</p> <p>I believe i chose the right By.NAME ( &quot;indentifier&quot; ) but the code still not work and return message no such element.</p> <p>I tried to change the syntax, using xpath change By.NAME to By.ID but it still not work</p>
[ { "answer_id": 74389771, "author": "Tal Angel", "author_id": 5359846, "author_profile": "https://Stackoverflow.com/users/5359846", "pm_score": 0, "selected": false, "text": "userAccount = driver.find_element_by_xpath(\"//*[text()='YourGoogleAccountName']\")\nuserAccount.click()\n" }, { "answer_id": 74394453, "author": "Eugeny Okulik", "author_id": 12023661, "author_profile": "https://Stackoverflow.com/users/12023661", "pm_score": 1, "selected": false, "text": "login1 = driver.find_element(\"xpath\",\"//div[@class='abcRioButtonContentWrapper']\").click()\n\nwindows = driver.window_handles\ndriver.switch_to.window(windows[1])\n\ndriver.find_element(By.NAME, \"identifier\").send_keys(email)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15515026/" ]
74,389,328
<p>In Azure Logic Apps, there is an action for Send Approval Email under Office 365 Outlook. I want to have multiple approval options in the same email. Is there a way to do it?</p> <p>I tried looping over and sending emails but that sends a new email every time with option to approve.</p>
[ { "answer_id": 74389771, "author": "Tal Angel", "author_id": 5359846, "author_profile": "https://Stackoverflow.com/users/5359846", "pm_score": 0, "selected": false, "text": "userAccount = driver.find_element_by_xpath(\"//*[text()='YourGoogleAccountName']\")\nuserAccount.click()\n" }, { "answer_id": 74394453, "author": "Eugeny Okulik", "author_id": 12023661, "author_profile": "https://Stackoverflow.com/users/12023661", "pm_score": 1, "selected": false, "text": "login1 = driver.find_element(\"xpath\",\"//div[@class='abcRioButtonContentWrapper']\").click()\n\nwindows = driver.window_handles\ndriver.switch_to.window(windows[1])\n\ndriver.find_element(By.NAME, \"identifier\").send_keys(email)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468578/" ]
74,389,341
<p>Here's my way of calculating running count by groups in Sheets:</p> <p><code>=LAMBDA(a,INDEX(if(a=&quot;&quot;,,COUNTIFS(a,a,row(a),&quot;&lt;=&quot;&amp;row(a)))))(B4:B)</code></p> <p>The complexity of this formula is R^2 = 1000000 operations for 1K rows. I'd love to make more efficient formula, and tried combinations of <code>LABMDA</code> and <code>SCAN</code>. For now I've found only the way to do it fast with 1 group at a time:</p> <p><code>=INDEX(IF(B4:B=&quot; Corn&quot;,SCAN(0,B4:B,LAMBDA(i,v,if(v=&quot; Corn&quot;,i+1,i))),))</code></p> <p>Can we do the same for all groups? Do you have an idea?</p> <hr /> <p>Note: the script solution would use object and <code>hash</code> to make it fast.</p> <p><a href="https://i.stack.imgur.com/tRTki.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tRTki.png" alt="enter image description here" /></a></p> <hr /> <h2>Legal Tests</h2> <p>We have a list of <code>N</code> items total with <code>m</code> groups. Group <code>m(i)</code> is a unique item which may repeat randomly. Samlpe dataset:</p> <pre><code>a b b b a </code></pre> <p>↑ Sample for 5 items total and 2 groups: <code>N=5</code>; <code>m=2</code>. Groups are &quot;a&quot; and &quot;b&quot;</p> <p>The task is to find the function which will work faster for different numbers of <code>N</code> and <code>m</code>:</p> <ol> <li>Case #1. 1000+ accurances of an item from a group <code>m(i)</code></li> <li>Case #2. 1000+ different groups <code>m</code></li> <li>General case sagnificant number of total items <code>N</code> ~ 50K+</li> </ol> <h2>Playground</h2> <p>Samlpe Google Sheet with 50K rows of data. Please click on the button 'Use Tamplate':</p> <p><a href="https://docs.google.com/spreadsheets/d/1vQu7hVr7FwH8H5N8JOlOGfvjlJgKtpfoM2DPPjgUaLo/template/preview" rel="nofollow noreferrer">Test Sheet with 50K values</a></p> <h2>Speed Results</h2> <p>Tested solutions:</p> <ol> <li><a href="https://docs.google.com/spreadsheets/d/1euWuW5FJIqRz7Nt2jcpesZmcliDeeiMxRWyeIH7-ifQ/edit#gid=0" rel="nofollow noreferrer"><code>Countifs</code></a> from the question and <a href="https://docs.google.com/spreadsheets/d/1TgC29Yh2vaOyxhrRRr394aX_RObWFmqPLf3xRjcgAYc/edit#gid=0" rel="nofollow noreferrer"><code>Countif</code></a> and from <a href="https://stackoverflow.com/a/74389906/5372400">answer</a>.</li> <li><a href="https://docs.google.com/spreadsheets/d/1LSisdg010ENP3F5eSz8Buvb69-uzJHtlV2gTZ1F-G34/edit#gid=0" rel="nofollow noreferrer"><code>Xlookup</code></a> from <a href="https://stackoverflow.com/a/74405498/5372400">answer</a></li> <li><a href="https://docs.google.com/spreadsheets/d/1ZyuSYqJJe7VQRjZUgqdBcBbNkP7njfCqlTRohzHIoFc/edit#gid=0" rel="nofollow noreferrer">Complex <code>Match</code></a> logic from <a href="https://stackoverflow.com/a/74413414/5372400">answer</a></li> <li><a href="https://docs.google.com/spreadsheets/d/12lAEt86lL6lalYbIDuRif16paOCJHi3pJA6d-jNbVZQ/edit#gid=0" rel="nofollow noreferrer"><code>Sorting</code> logic</a> from the <a href="https://stackoverflow.com/a/74441904/5372400">answer</a></li> </ol> <p>In my enviroment, the <code>sorting</code> option works faster than other provided solutions. Test results are <a href="https://docs.google.com/spreadsheets/d/12lAEt86lL6lalYbIDuRif16paOCJHi3pJA6d-jNbVZQ/edit#gid=501018673" rel="nofollow noreferrer">here</a>, tested with the <a href="https://stackoverflow.com/a/74443574/5372400">code from here</a>.</p>
[ { "answer_id": 74389906, "author": "Martín", "author_id": 20363318, "author_profile": "https://Stackoverflow.com/users/20363318", "pm_score": 1, "selected": false, "text": "=Byrow(B4:B,lambda(each,if(each=\"\",\"\",countif(B4:each,each))))" }, { "answer_id": 74390875, "author": "Max Makhrov", "author_id": 5372400, "author_profile": "https://Stackoverflow.com/users/5372400", "pm_score": 2, "selected": false, "text": "Transpose" }, { "answer_id": 74405498, "author": "kishkin", "author_id": 279806, "author_profile": "https://Stackoverflow.com/users/279806", "pm_score": 1, "selected": false, "text": "=QUERY(\n REDUCE(\n {\"\", 0},\n B4:B10000,\n LAMBDA(\n acc,\n cur,\n {\n acc;\n cur, XLOOKUP(\n cur,\n INDEX(acc, 0, 1),\n INDEX(acc, 0, 2),\n 0,\n 0,\n -1\n ) + 1\n }\n )\n ),\n \"SELECT Col2 OFFSET 1\",\n 0\n)\n" }, { "answer_id": 74413414, "author": "kishkin", "author_id": 279806, "author_profile": "https://Stackoverflow.com/users/279806", "pm_score": 1, "selected": false, "text": "=LAMBDA(\n shift,\n ref,\n big_ref,\n LAMBDA(\n base_ref,\n big_ref,\n ARRAYFORMULA(\n IF(\n A2:A = \"\",,\n MATCH(VLOOKUP(A2:A, base_ref, 2,) + ROW(A2:A), big_ref,) - VLOOKUP(A2:A, base_ref, 3,)\n )\n )\n )\n (\n ARRAYFORMULA(\n {\n ref,\n SEQUENCE(ROWS(ref)) * shift,\n MATCH(SEQUENCE(ROWS(ref)) * shift, big_ref,)\n }\n ),\n big_ref\n )\n)\n(\n 10 ^ INT(LOG10(ROWS(A:A)) + 1),\n UNIQUE(A2:A),\n SORT(\n {\n MATCH(A2:A, UNIQUE(A2:A),) * 10 ^ INT(LOG10(ROWS(A:A)) + 1) + ROW(A2:A);\n SEQUENCE(ROWS(UNIQUE(A2:A))) * 10 ^ INT(LOG10(ROWS(A:A)) + 1)\n }\n )\n)\n" }, { "answer_id": 74441904, "author": "Max Makhrov", "author_id": 5372400, "author_profile": "https://Stackoverflow.com/users/5372400", "pm_score": 2, "selected": true, "text": "Sorting" }, { "answer_id": 74483003, "author": "doubleunary", "author_id": 13045193, "author_profile": "https://Stackoverflow.com/users/13045193", "pm_score": 1, "selected": false, "text": "=arrayformula( \n lambda( \n groups, \n lambda( \n uniques, shiftingFactor, \n lambda( \n shiftedOrdinals, \n lambda( \n ordinalLookup, \n lambda( \n groupLookup, \n iferror( \n match( \n vlookup(groups, groupLookup, 2, true) + row(groups), \n ordinalLookup, \n 1 \n ) \n - \n vlookup(groups, groupLookup, 3, true) \n ) \n )( \n sort( \n { \n uniques, \n shiftedOrdinals, \n match(shiftedOrdinals, ordinalLookup, 1) \n } \n ) \n ) \n )( \n sort( \n { \n match(groups, uniques, 1) * shiftingFactor + row(groups); \n shiftedOrdinals \n } \n ) \n ) \n )(sequence(rows(uniques)) * shiftingFactor) \n )( \n unique(groups), \n 10 ^ int(log10(rows(groups)) + 1)\n ) \n )(A2:A) \n)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5372400/" ]
74,389,360
<p>I have two dataframes:</p> <p><strong>dists</strong>:</p> <pre><code>label1 label2 dist sameCol ID1 ID2 193 194 0.7219847 NA N53 &lt;NA&gt; 193 195 0.5996300 FALSE N53 N43 193 196 0.2038451 FALSE N5 N45 194 195 0.2190454 NA &lt;NA&gt; N43 194 196 0.8894645 NA &lt;NA&gt; N45 195 196 0.7910169 TRUE N38 N5 </code></pre> <p><strong>networkDistances</strong>:</p> <pre><code>ID1 ID2 colony value networkDist N38 N5 10 0.05 1 N36 N5 10 0.03 1 N4 N3 12 10.00 1 N4 N5 12 10.00 1 N4 N15 12 5.00 1 N15 N14 12 5.00 1 </code></pre> <p>I am trying to join them, IF <code>dists$sameCol == TRUE</code> &amp;&amp; ID1 and ID2 match, then paste the columns from networkDistances (all other rows should be NA), to look like:</p> <pre><code>label1 label2 dist sameCol ID1 ID2 colony value networkDist 193 194 0.7219847 NA N53 &lt;NA&gt; NA NA NA 193 195 0.5996300 FALSE N53 N43 NA NA NA 193 196 0.2038451 FALSE N5 N45 NA NA NA 194 195 0.2190454 NA &lt;NA&gt; N43 NA NA NA 194 196 0.8894645 NA &lt;NA&gt; N45 NA NA NA 195 196 0.7910169 TRUE N38 N5 10 0.05 1 </code></pre> <p>I have tried these and they are not working, they paste some info into rows where <code>dists$sameCol == FALSE</code></p> <pre><code>r &lt;- left_join(dists, networkDistances, by = c(&quot;ID1&quot; = &quot;ID1&quot;, &quot;ID2&quot; = &quot;ID2&quot;)) r &lt;- left_join(dists, networkDistances, by = c(&quot;ID1&quot; = &quot;ID1&quot;, &quot;ID2&quot; = &quot;ID2&quot;)) %&gt;% mutate(networkDist = case_when(sameCol %in% T ~ networkDist)) r &lt;-dists %&gt;% left_join(networkDistances, by = c(&quot;ID1&quot;,&quot;ID2&quot;))%&gt;% mutate(networkDist = case_when(sameCol== T ~ networkDist)) </code></pre>
[ { "answer_id": 74389685, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 2, "selected": false, "text": "sameCol" }, { "answer_id": 74389693, "author": "Paul Stafford Allen", "author_id": 16730940, "author_profile": "https://Stackoverflow.com/users/16730940", "pm_score": 1, "selected": false, "text": "r <- left_join(dists, networkDistances, by = c(\"ID1\", \"ID2\"))\nr[r$sameCol != TRUE | is.na(r$sameCol), c(\"colony\", \"value\", \"networkDist\")] <- NA\n" }, { "answer_id": 74390084, "author": "Andre Wildberg", "author_id": 9462095, "author_profile": "https://Stackoverflow.com/users/9462095", "pm_score": 0, "selected": false, "text": "dists\n label1 label2 dist sameCol ID1 ID2\n1 193 194 0.7219847 NA N53 <NA>\n2 193 195 0.5996300 FALSE N53 N43\n3 193 196 0.2038451 FALSE N5 N45\n4 194 195 0.2190454 NA <NA> N43\n5 194 196 0.8894645 NA <NA> N45\n6 195 196 0.7910169 TRUE N38 N5\n7 195 196 0.7910169 FALSE N38 N5\n8 195 196 0.7910169 TRUE N36 N5\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11697741/" ]
74,389,365
<p>When SAS EG creates a query in the query builder it puts &quot;work.&quot; in front of tables here is an example:</p> <pre><code>%_eg_conditional_dropds(WORK.QUERY_FOR_UNL_OBLIGATIONSBEHOLDN); PROC SQL; CREATE TABLE WORK.QUERY_FOR_UNL_OBLIGATIONSBEHOLDN AS SELECT t1.CUSTOM_1, t1.CUSTOM_2, /* REPORTING_AMOUNT */ (SUM(t1.REPORTING_AMOUNT)) AS REPORTING_AMOUNT, t1.LINE_ITEM, t1.CUSTOM_5 FROM WORK.UNL_OBLIGATIONSBEHOLDNING t1 WHERE t1.CUSTOM_5 IN ( 'VLIK9035_POS_NOTE', 'VLIK9023_POS_COVERED_BOND' ) AND t1.CUSTOM_1 BETWEEN '20500000' AND '20599999' AND t1.LINE_ITEM NOT ='orphans' GROUP BY t1.CUSTOM_1, t1.CUSTOM_2, t1.LINE_ITEM, t1.CUSTOM_5; QUIT; </code></pre> <p>If I remove &quot;WORK.&quot; from the created table and the queried table nothing changes it works just as well as before, as far as I know.</p> <p>What does it mean when a is named WORK.?</p>
[ { "answer_id": 74389685, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 2, "selected": false, "text": "sameCol" }, { "answer_id": 74389693, "author": "Paul Stafford Allen", "author_id": 16730940, "author_profile": "https://Stackoverflow.com/users/16730940", "pm_score": 1, "selected": false, "text": "r <- left_join(dists, networkDistances, by = c(\"ID1\", \"ID2\"))\nr[r$sameCol != TRUE | is.na(r$sameCol), c(\"colony\", \"value\", \"networkDist\")] <- NA\n" }, { "answer_id": 74390084, "author": "Andre Wildberg", "author_id": 9462095, "author_profile": "https://Stackoverflow.com/users/9462095", "pm_score": 0, "selected": false, "text": "dists\n label1 label2 dist sameCol ID1 ID2\n1 193 194 0.7219847 NA N53 <NA>\n2 193 195 0.5996300 FALSE N53 N43\n3 193 196 0.2038451 FALSE N5 N45\n4 194 195 0.2190454 NA <NA> N43\n5 194 196 0.8894645 NA <NA> N45\n6 195 196 0.7910169 TRUE N38 N5\n7 195 196 0.7910169 FALSE N38 N5\n8 195 196 0.7910169 TRUE N36 N5\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13340047/" ]
74,389,369
<p>There is a <code>Char.IsControl()</code> method to <em>identify</em> such characters, but I want a way to convert them to &quot;normal&quot; characters. i.e. some way to visualise a string that contains such characters. Probably similar to what Notepad++ does.</p> <p>Obviously such a visualisation will be imperfect, and ambiguous ... but does it exist as a built in method?</p>
[ { "answer_id": 74389519, "author": "phuclv", "author_id": 995714, "author_profile": "https://Stackoverflow.com/users/995714", "pm_score": 2, "selected": false, "text": "controlChar" }, { "answer_id": 74389596, "author": "Lucian", "author_id": 856777, "author_profile": "https://Stackoverflow.com/users/856777", "pm_score": 0, "selected": false, "text": "var stringBuilder = new StringBuilder();\nforeach (var character in input)\n {\n if (character.IsControl())\n stringBuilder.Append(Convert.ToInt32(character).ToString(\"X4\"));\n }\n\n return stringBuilder.ToString();\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1662268/" ]
74,389,379
<p>For the problem, consider below two structures.</p> <pre><code>struct type1_A { int a; char b; char rsvd[10]; char c; int d; } struct type1_B { int d; char rsvd[12]; char c; char b; int a; } </code></pre> <p>I need to read fields <strong>a, b, c &amp; d</strong> from the structs. I will have a buffer address and that buffer will have one of the struct. A flag can tell what kind of struct it is.</p> <pre><code>if (flag == TYPE1_A) { a = ((struct type1_A*) (buffer))-&gt;a; } else if (flag == TYPE1_B) { a = ((struct type1_B*) (buffer))-&gt;a; } </code></pre> <p>But when there are many such reads, I dont want to keep on having if-else like above. Is there some way (hack) that this can be done without if-else. The field names will be same but at a different offset.</p>
[ { "answer_id": 74389519, "author": "phuclv", "author_id": 995714, "author_profile": "https://Stackoverflow.com/users/995714", "pm_score": 2, "selected": false, "text": "controlChar" }, { "answer_id": 74389596, "author": "Lucian", "author_id": 856777, "author_profile": "https://Stackoverflow.com/users/856777", "pm_score": 0, "selected": false, "text": "var stringBuilder = new StringBuilder();\nforeach (var character in input)\n {\n if (character.IsControl())\n stringBuilder.Append(Convert.ToInt32(character).ToString(\"X4\"));\n }\n\n return stringBuilder.ToString();\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1210665/" ]
74,389,381
<p>I'am trying to get the first character of each string using regex and BASH_REMATCH in shell script.</p> <p>My input text file contain :</p> <pre><code> config_text = STACK OVER FLOW </code></pre> <p>The strings <strong>STACK</strong> <strong>OVER</strong> <strong>FLOW</strong> must be uppercase like that.</p> <p>My output should be something like this :</p> <pre><code> SOF </code></pre> <p>My code for now is :</p> <pre><code> var = config_text values=$(grep $var test_file.txt | tr -s ' ' '\n' | cut -c 1) if [[ $values =~ [=(.*)]]; then echo $values fi </code></pre> <p>As you can see I'am using <strong>tr</strong> and <strong>cut</strong> but I'am looking to replace them with only <strong>BASH_REMATCH</strong> because these two commands have been reported in many links as not functional on MacOs.</p> <p>I tried something like this :</p> <pre><code> var = config_text values=$(grep $var test_file.txt) if [[ $values =~ [=(.*)(\b[a-zA-Z])]]; then echo $values fi </code></pre> <p>VALUES as I explained should be :</p> <pre><code> S O F </code></pre> <p>But it seems \b does not work on shell script. Anyone have an idea how to get my desired output with <strong>BASH_REMATCH</strong> ONLY. Thanks in advance for any help.</p>
[ { "answer_id": 74390388, "author": "Jetchisel", "author_id": 4452265, "author_profile": "https://Stackoverflow.com/users/4452265", "pm_score": 1, "selected": false, "text": "config" }, { "answer_id": 74390712, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 1, "selected": false, "text": "config_text=\"STACK OVER FLOW\"\nsed 's/\\([^[:space:]]\\)[^[:space:]]*/\\1/g' <<<\"$config_text\"\n" }, { "answer_id": 74391138, "author": "j_b", "author_id": 16482938, "author_profile": "https://Stackoverflow.com/users/16482938", "pm_score": 0, "selected": false, "text": "${parameter:offset:length}" }, { "answer_id": 74391857, "author": "Philippe", "author_id": 2125671, "author_profile": "https://Stackoverflow.com/users/2125671", "pm_score": 2, "selected": true, "text": "local input=\"STACK OVER FLOW\" pattern='([[:upper:]]+)([^[:upper:]]*)' result=\"\"\nwhile [[ $input =~ $pattern ]]; do\n result+=\"${BASH_REMATCH[1]::1}${BASH_REMATCH[2]}\" \n input=\"${input:${#BASH_REMATCH[0]}}\"\ndone\necho \"$result\"\n# Output: \"S O F\"\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11154545/" ]
74,389,413
<p>I am trying to align icons horizontally like this in a row, with <code>mainAxisAlignment: MainAxisAlignment.spaceEvenly</code> and <code>crossAxisAlignment: CrossAxisAlignment.center</code>.</p> <p>The result I am getting is something like this <a href="https://i.stack.imgur.com/eU79J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eU79J.png" alt="result I am getting" /></a></p> <p>But I am trying to get a result like this.</p> <p><a href="https://i.stack.imgur.com/S1xxt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S1xxt.png" alt="desired result" /></a></p> <p>my code:</p> <pre><code>Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ IconButton(onPressed: ()=&gt;{}, icon: Icon(Icons.home_sharp, color: Color(0xFFf1a40a), size: 40,)), IconButton(onPressed: ()=&gt;{}, icon: Icon(Icons.search_sharp, color: Color(0xFFe7e5d3), size: 40,)), IconButton(onPressed: ()=&gt;{}, icon: Icon(Icons.add_circle_outlined, color: Color(0xFFfad974), size: 60,)), IconButton(onPressed: ()=&gt;{}, icon: Icon(Icons.notifications, color: Color(0xFFe7e5d3), size: 40,)), IconButton(onPressed: ()=&gt;{}, icon: Icon(Icons.people_alt_sharp, color: Color(0xFFe7e5d3), size: 40,)), ], ) </code></pre> <p>Can someone help?</p>
[ { "answer_id": 74390388, "author": "Jetchisel", "author_id": 4452265, "author_profile": "https://Stackoverflow.com/users/4452265", "pm_score": 1, "selected": false, "text": "config" }, { "answer_id": 74390712, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 1, "selected": false, "text": "config_text=\"STACK OVER FLOW\"\nsed 's/\\([^[:space:]]\\)[^[:space:]]*/\\1/g' <<<\"$config_text\"\n" }, { "answer_id": 74391138, "author": "j_b", "author_id": 16482938, "author_profile": "https://Stackoverflow.com/users/16482938", "pm_score": 0, "selected": false, "text": "${parameter:offset:length}" }, { "answer_id": 74391857, "author": "Philippe", "author_id": 2125671, "author_profile": "https://Stackoverflow.com/users/2125671", "pm_score": 2, "selected": true, "text": "local input=\"STACK OVER FLOW\" pattern='([[:upper:]]+)([^[:upper:]]*)' result=\"\"\nwhile [[ $input =~ $pattern ]]; do\n result+=\"${BASH_REMATCH[1]::1}${BASH_REMATCH[2]}\" \n input=\"${input:${#BASH_REMATCH[0]}}\"\ndone\necho \"$result\"\n# Output: \"S O F\"\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14399746/" ]
74,389,428
<p>I get stuck with writing a dict of list to a .txt file.</p> <p>I have a dict of lict like this:</p> <pre><code>product_menu_list = {&quot;Shirt&quot;: [&quot;Red&quot;, &quot;Orange&quot;, &quot;Purple&quot;], &quot;Dress&quot;: [&quot;Blue&quot;, &quot;Yellow&quot;, &quot;Green&quot;]} </code></pre> <p>To write it into a .txt file, I wrote:</p> <pre><code>product_lines = product_menu_list with open('product_record.txt', 'w') as f: for line in product_lines: f.write(json.dumps(product_lines)) f.write('\n') </code></pre> <p>By writing the above code, I can just get:</p> <pre class="lang-none prettyprint-override"><code>{&quot;Shirt&quot;: [&quot;Red&quot;, &quot;Orange&quot;, &quot;Purple&quot;], &quot;Dress&quot;: [&quot;Blue&quot;, &quot;Yellow&quot;, &quot;Green&quot;]} </code></pre> <p>That's not the format I want.</p> <p>However, what I want is to write it line by line in the .txt file, like:</p> <pre class="lang-none prettyprint-override"><code>Shirt: Red Orange Purple Dress: Blue Yellow Green </code></pre> <p>How can I achieve the expected output?</p>
[ { "answer_id": 74390388, "author": "Jetchisel", "author_id": 4452265, "author_profile": "https://Stackoverflow.com/users/4452265", "pm_score": 1, "selected": false, "text": "config" }, { "answer_id": 74390712, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 1, "selected": false, "text": "config_text=\"STACK OVER FLOW\"\nsed 's/\\([^[:space:]]\\)[^[:space:]]*/\\1/g' <<<\"$config_text\"\n" }, { "answer_id": 74391138, "author": "j_b", "author_id": 16482938, "author_profile": "https://Stackoverflow.com/users/16482938", "pm_score": 0, "selected": false, "text": "${parameter:offset:length}" }, { "answer_id": 74391857, "author": "Philippe", "author_id": 2125671, "author_profile": "https://Stackoverflow.com/users/2125671", "pm_score": 2, "selected": true, "text": "local input=\"STACK OVER FLOW\" pattern='([[:upper:]]+)([^[:upper:]]*)' result=\"\"\nwhile [[ $input =~ $pattern ]]; do\n result+=\"${BASH_REMATCH[1]::1}${BASH_REMATCH[2]}\" \n input=\"${input:${#BASH_REMATCH[0]}}\"\ndone\necho \"$result\"\n# Output: \"S O F\"\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20138141/" ]
74,389,508
<p>I just want to know how Queries and Connections in Excel Workbooks are connected as objects. I noticed that I can use ThisWorkbook.Connections(&quot;Name of my connection&quot;).Refresh but that is not the same as the name used in my Queries (as I have commented out in my code).</p> <pre><code>Sub EditAllWorkbookFormuals(Order As String) For Each q In ThisWorkbook.Queries q.Formula = NewQuery(q.Formula, Order) 'q.Refresh 'ThisWorkbook.Connections(q.Name).Refresh ThisWorkbook.Connections(1).Refresh Next 'ThisWorkbook.RefreshAll End Sub </code></pre>
[ { "answer_id": 74390388, "author": "Jetchisel", "author_id": 4452265, "author_profile": "https://Stackoverflow.com/users/4452265", "pm_score": 1, "selected": false, "text": "config" }, { "answer_id": 74390712, "author": "tripleee", "author_id": 874188, "author_profile": "https://Stackoverflow.com/users/874188", "pm_score": 1, "selected": false, "text": "config_text=\"STACK OVER FLOW\"\nsed 's/\\([^[:space:]]\\)[^[:space:]]*/\\1/g' <<<\"$config_text\"\n" }, { "answer_id": 74391138, "author": "j_b", "author_id": 16482938, "author_profile": "https://Stackoverflow.com/users/16482938", "pm_score": 0, "selected": false, "text": "${parameter:offset:length}" }, { "answer_id": 74391857, "author": "Philippe", "author_id": 2125671, "author_profile": "https://Stackoverflow.com/users/2125671", "pm_score": 2, "selected": true, "text": "local input=\"STACK OVER FLOW\" pattern='([[:upper:]]+)([^[:upper:]]*)' result=\"\"\nwhile [[ $input =~ $pattern ]]; do\n result+=\"${BASH_REMATCH[1]::1}${BASH_REMATCH[2]}\" \n input=\"${input:${#BASH_REMATCH[0]}}\"\ndone\necho \"$result\"\n# Output: \"S O F\"\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20416519/" ]
74,389,528
<p>my data frame is:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">M1T1</th> <th style="text-align: center;">M1T2</th> <th style="text-align: right;">M1T3</th> <th style="text-align: left;">M2T1</th> <th style="text-align: center;">M2T2</th> <th style="text-align: right;">M2T3</th> <th style="text-align: left;">M3T1</th> <th style="text-align: center;">M3T2</th> <th style="text-align: right;">M3T3</th> <th style="text-align: right;">cntry_lan</th> <th style="text-align: right;">admdw</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">NA</td> <td style="text-align: center;">NA</td> <td style="text-align: right;">NA</td> <td style="text-align: left;">1</td> <td style="text-align: center;">2</td> <td style="text-align: right;">2</td> <td style="text-align: left;">1</td> <td style="text-align: center;">1</td> <td style="text-align: right;">2</td> <td style="text-align: right;">ATGER</td> <td style="text-align: right;">group1</td> </tr> <tr> <td style="text-align: left;">7</td> <td style="text-align: center;">6</td> <td style="text-align: right;">5</td> <td style="text-align: left;">NA</td> <td style="text-align: center;">NA</td> <td style="text-align: right;">NA</td> <td style="text-align: left;">6</td> <td style="text-align: center;">6</td> <td style="text-align: right;">5</td> <td style="text-align: right;">ATGER</td> <td style="text-align: right;">group3</td> </tr> <tr> <td style="text-align: left;">7</td> <td style="text-align: center;">5</td> <td style="text-align: right;">5</td> <td style="text-align: left;">NA</td> <td style="text-align: center;">NA</td> <td style="text-align: right;">NA</td> <td style="text-align: left;">7</td> <td style="text-align: center;">4</td> <td style="text-align: right;">4</td> <td style="text-align: right;">ATGER</td> <td style="text-align: right;">group2</td> </tr> </tbody> </table> </div> <p>My code is :</p> <pre><code>mtmm_data1 %&gt;% group_by(cntry_lan) %&gt;% group_by(admdw) summarise_at(vars(M1MT1, M1T2, M1T3, M2T1, M2T2, M2T3, M3T1, M3T2, M3T3), list(name = mean)) </code></pre> <p>The error I get:</p> <p>Error in UseMethod(&quot;tbl_vars&quot;) : no applicable method for 'tbl_vars' applied to an object of class &quot;c('quosures', 'list')&quot;</p> <p>Each countr_lan has three groups that are group1, group2 and group3. I would like to have one row for each country_lan and then have three groups for each country_lan having all the columns stable. Instead of creating new columns, I want to have the mean of the same columns M1T1-M3T3..</p>
[ { "answer_id": 74389840, "author": "NathanLVQ", "author_id": 20419201, "author_profile": "https://Stackoverflow.com/users/20419201", "pm_score": 2, "selected": true, "text": "aggregate" }, { "answer_id": 74389893, "author": "M.Viking", "author_id": 10276092, "author_profile": "https://Stackoverflow.com/users/10276092", "pm_score": 0, "selected": false, "text": "df<-data.frame(cntry_lan = c(\"ATGER\"),\n admdw = c(\"group1\", \"group2\", \"group3\"),\n M1T1 = c(NA,1,2),\n M1T2 = c(1,10,3),\n M1T3 = c(10,NA,1))\n\nlibrary(tidyverse)\n\ndf %>% \n rowwise() %>% \n mutate(mean = mean(c_across(starts_with(\"M\")), na.rm=T), .keep=\"unused\") %>% \n pivot_wider(names_from = admdw, values_from = mean)\n\n# cntry_lan group1 group2 group3\n# <chr> <dbl> <dbl> <dbl>\n#1 ATGER 5.5 5.5 2\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18049878/" ]
74,389,562
<p>I'm new to C++ and I've been doing bubbleSort, but when I want to show the numbers in the terminal, the leading number is a problem. Sorry for my bad english btw.</p> <p>where am i doing wrong?</p> <p>this is the code:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; void printArray(int *myArr, int lenght) { for (int i = 0; i &lt; lenght; ++i) { std::cout &lt;&lt; myArr[i] &lt;&lt; &quot;, &quot;; } } int bubbleSort(int *myArr, int lenght) { for (int i = 0; i &lt; lenght; ++i) { for (int j = 0; j &lt; lenght-1; ++j) { if (myArr[j] &gt; myArr[j+1]) { int temp = myArr[j]; myArr[j] = myArr[j+1]; myArr[j+1] = temp; } } } return *myArr; } int main() { int myArr[] = {10,14,13,19,15,12,16,18,17,11}; int newArr = bubbleSort(myArr, 8); printArray(&amp;newArr, 8); return 0; } </code></pre> <p>this is what i get: <code>10, 10, 12, 13, 14, 15, 16, 18, </code> there is no 19 and double 10s</p> <p>and is there any eaiser way to get lenght of array in function? Thank you...</p>
[ { "answer_id": 74389701, "author": "463035818_is_not_a_number", "author_id": 4117728, "author_profile": "https://Stackoverflow.com/users/4117728", "pm_score": 3, "selected": true, "text": "int bubbleSort(int *myArr, int lenght) {\n // ... not actually that important what happens here ...\n return *myArr;\n}\n" }, { "answer_id": 74390169, "author": "Ramesh Jangama", "author_id": 13978908, "author_profile": "https://Stackoverflow.com/users/13978908", "pm_score": 0, "selected": false, "text": "void bubbleSort(std::vector<int> & vec) {\n for (int i = 0; i < vec.size(); ++i) {\n ...\n }\n}\n\nbubbleSort(vec);\n\n" }, { "answer_id": 74393127, "author": "izzy and simple", "author_id": 20428689, "author_profile": "https://Stackoverflow.com/users/20428689", "pm_score": 1, "selected": false, "text": "#include <iostream>\n#include <vector>\n\nusing namespace std;\n\nvoid printArray(vector<int> arr) {\n for (auto & item : arr) \n {\n cout << item<<' ';\n }\n}\n\nvoid bubbleSort(vector<int> &arr) \n{\n bool swapp = true;\n while (swapp) {\n swapp = false;\n for (size_t i = 0; i < arr.size() - 1; i++) {\n if (arr[i] > arr[i + 1]) {\n arr[i] += arr[i + 1];\n arr[i + 1] = arr[i] - arr[i + 1];\n arr[i] -= arr[i + 1];\n swapp = true;\n }\n }\n }\n}\nvoid main() {\n vector<int> arr = { 10,14,13,19,15,12,16,18,17,11 };\n bubbleSort(arr);\n\n printArray(arr);\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16406821/" ]
74,389,571
<p>I'm trying to get the average employee salary for each department. I am expecting two rows because one department doesn't have any employees assigned to it.</p> <p>Can someone please tell me how to rectify this issue. Thanks in advance to all who answer and your expertise.</p> <p>Below is my test CASE and inaccurate result.</p> <pre><code> CREATE TABLE departments( department_id, department_name) AS SELECT 1, 'IT' FROM DUAL UNION ALL SELECT 3, 'Sales' FROM DUAL UNION ALL SELECT 2, 'DBA' FROM DUAL; CREATE TABLE employees (employee_id, first_name, last_name, hire_date, salary, department_id) AS SELECT 1, 'Lisa', 'Saladino', DATE '2001-04-03', 100000, 1 FROM DUAL UNION ALL SELECT 2, 'Abby', 'Abbott', DATE '2001-04-04', 50000, 1 FROM DUAL UNION ALL SELECT 3, 'Beth', 'Cooper', DATE '2001-04-05', 60000, 1 FROM DUAL UNION ALL SELECT 4, 'Carol', 'Orr', DATE '2001-04-06', 70000,1 FROM DUAL UNION ALL SELECT 5, 'Vicky', 'Palazzo', DATE '2001-04-07', 88000,2 FROM DUAL UNION ALL SELECT 6, 'Cheryl', 'Ford', DATE '2001-04-08', 110000,1 FROM DUAL UNION ALL SELECT 7, 'Leslee', 'Altman', DATE '2001-04-10', 66666, 1 FROM DUAL UNION ALL SELECT 8, 'Jill', 'Coralnick', DATE '2001-04-11', 190000, 2 FROM DUAL UNION ALL SELECT 9, 'Faith', 'Aaron', DATE '2001-04-17', 122000,2 FROM DUAL; SELECT d.department_id, d.department_name, round(avg(e.salary) over (partition by e.department_id)) avg_sal FROM departments d JOIN employees e ON (d.department_id = e.department_id) DEPARTMENT_ID DEPARTMENT_NAME AVG_SAL 1 IT 76111 1 IT 76111 1 IT 76111 1 IT 76111 1 IT 76111 1 IT 76111 2 DBA 133333 2 DBA 133333 2 DBA 133333 </code></pre>
[ { "answer_id": 74389701, "author": "463035818_is_not_a_number", "author_id": 4117728, "author_profile": "https://Stackoverflow.com/users/4117728", "pm_score": 3, "selected": true, "text": "int bubbleSort(int *myArr, int lenght) {\n // ... not actually that important what happens here ...\n return *myArr;\n}\n" }, { "answer_id": 74390169, "author": "Ramesh Jangama", "author_id": 13978908, "author_profile": "https://Stackoverflow.com/users/13978908", "pm_score": 0, "selected": false, "text": "void bubbleSort(std::vector<int> & vec) {\n for (int i = 0; i < vec.size(); ++i) {\n ...\n }\n}\n\nbubbleSort(vec);\n\n" }, { "answer_id": 74393127, "author": "izzy and simple", "author_id": 20428689, "author_profile": "https://Stackoverflow.com/users/20428689", "pm_score": 1, "selected": false, "text": "#include <iostream>\n#include <vector>\n\nusing namespace std;\n\nvoid printArray(vector<int> arr) {\n for (auto & item : arr) \n {\n cout << item<<' ';\n }\n}\n\nvoid bubbleSort(vector<int> &arr) \n{\n bool swapp = true;\n while (swapp) {\n swapp = false;\n for (size_t i = 0; i < arr.size() - 1; i++) {\n if (arr[i] > arr[i + 1]) {\n arr[i] += arr[i + 1];\n arr[i + 1] = arr[i] - arr[i + 1];\n arr[i] -= arr[i + 1];\n swapp = true;\n }\n }\n }\n}\nvoid main() {\n vector<int> arr = { 10,14,13,19,15,12,16,18,17,11 };\n bubbleSort(arr);\n\n printArray(arr);\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16771377/" ]
74,389,572
<p>I have the following case:</p> <pre><code>Test (2.00001) Test (2.000) Test 2.1 Test (2,0001) Test 2,000 Test 2,1000 test 2 </code></pre> <p>I try to use regex to find only the integers:</p> <ol> <li><code>2.000</code></li> <li><code>2,000</code></li> <li><code>2</code></li> </ol> <p>but not the other float numbers.<br /> I tried different things:</p> <pre><code>re.search('(?&lt;![0-9.])2(?![.,]?[1-9])(?=[.,]*[0]*)(?![1-9]),...) </code></pre> <p>but this returns true for:</p> <ol> <li><code>2.00001</code></li> <li><code>2.000</code></li> <li><code>2,000</code></li> <li><code>2,0001</code></li> <li><code>2</code></li> </ol> <p>What have I to do?</p> <p><strong>UPDATE</strong><br /> I have updated the question and it should also find an integer without any comma and point, too (<code>2</code>).</p>
[ { "answer_id": 74389605, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "import re\n\ntext = 'Test (2.00001) Test (2.000) Test 2.1 Test (2,0001) Test 2,000 Test 2,1000'\n\nre.findall(r'(\\d+[.,]0+)(?!\\d)', text)\n" }, { "answer_id": 74389779, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 0, "selected": false, "text": "is_integer()" }, { "answer_id": 74390317, "author": "RobertG", "author_id": 19925522, "author_profile": "https://Stackoverflow.com/users/19925522", "pm_score": 0, "selected": false, "text": "import re\n\ntext = 'Test (2.00001) Test (2.000) Test 2.1 Test (2,0001) Test 2,000 Test 2,1000 test 2'\nout_ints = []\nfor x in re.findall(r'([0-9.,]+)', text):\n possible_int = x.replace(',', '.')\n is_int = int(float(possible_int)) == float(possible_int)\n if is_int:\n out_ints.append(int(float(possible_int)))\n\nprint(out_ints)\n" }, { "answer_id": 74391061, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 1, "selected": false, "text": "re.findall(r'\\b(?<!\\d[.,])\\d+(?:[.,]0+)?\\b(?![,.]\\d)', text)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3446051/" ]
74,389,599
<p>I need to turn uppercase to lowercase, lowercase to uppercase and I need to add each number +5 modulo 10. It doesn't work so could you please help me? The sentence is &quot;Hello World, 521&quot; and the output should be &quot;hELLO wORLD, 076&quot;. I need to use a function definition.</p> <p>I tried this:</p> <pre><code>def fc1 (string): if string.upper == True: return string.lower else: return string.upper if string.isdigit == True: return ((string + 5 ) % 10) fc1 (&quot;Hello World, 521&quot;) </code></pre>
[ { "answer_id": 74389637, "author": "assume_irrational_is_rational", "author_id": 11622508, "author_profile": "https://Stackoverflow.com/users/11622508", "pm_score": 2, "selected": false, "text": "str.swapcase" }, { "answer_id": 74421353, "author": "Jimmy", "author_id": 20347481, "author_profile": "https://Stackoverflow.com/users/20347481", "pm_score": 0, "selected": false, "text": " def fce1 (string):\n for i in (string):\n if i.isupper():\n print (i.lower(), end=\"\")\n elif i.islower():\n print (i.upper(), end=\"\")\n elif i.isdigit():\n print ((int(i)+5)%10, end=\"\")\n else:\n print (i, end=\"\")\n\nfce1 (\"Ahoj Světe, 521\")\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20347481/" ]
74,389,603
<p>I understand in the code below that I am supposed to use [i,j,k] (or a single variable) to retrieve my return values. However, I have assigned two (only i and j), instead of three to the function. This gives the error &quot;ValueError: too many values to unpack (expected 2)&quot;. I am still trying to understand the error. Is the error not supposed to be &quot;ValueError: not enough values to unpack (expected 3)&quot; or perhaps because python indexes from 0, (expected 2)?</p> <pre><code>def fn(x,y): a = x*5 b = a*y h = b - 3 return a,b,h [i, j] = fn5(5,2) </code></pre>
[ { "answer_id": 74389653, "author": "oskros", "author_id": 9490769, "author_profile": "https://Stackoverflow.com/users/9490769", "pm_score": 1, "selected": false, "text": "fn" }, { "answer_id": 74389691, "author": "puf", "author_id": 6583203, "author_profile": "https://Stackoverflow.com/users/6583203", "pm_score": 0, "selected": false, "text": "def fn(x,y):\n a = x*5\n b = a*y\n h = b - 3\n return a,b,h\ni, j, k = fn(5,2)\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15502001/" ]
74,389,607
<p>I have a pandas dataframe with 1 row and values in columns by separated by categories</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>car &gt; audi &gt; a4</th> <th>car &gt; bmw &gt; 3er</th> <th>moto &gt; bmw &gt; gs</th> </tr> </thead> <tbody> <tr> <td>[item1, item2, item3]</td> <td>[item1, item4, item5]</td> <td>[item6]</td> </tr> </tbody> </table> </div> <p>and I would like to create structure something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>item</th> <th>category 1</th> <th>category 2</th> <th>category 3</th> </tr> </thead> <tbody> <tr> <td>item 1</td> <td>car</td> <td>audi</td> <td>a4</td> </tr> <tr> <td>item 1</td> <td>car</td> <td>bmw</td> <td>3er</td> </tr> <tr> <td>item 2</td> <td>car</td> <td>audi</td> <td>a4</td> </tr> <tr> <td>item 3</td> <td>car</td> <td>audi</td> <td>a4</td> </tr> <tr> <td>item 4</td> <td>car</td> <td>bmw</td> <td>3er</td> </tr> <tr> <td>item 5</td> <td>car</td> <td>bmw</td> <td>3er</td> </tr> <tr> <td>item 6</td> <td>moto</td> <td>bmw</td> <td>gs</td> </tr> </tbody> </table> </div> <p>What is the best solution?</p>
[ { "answer_id": 74389642, "author": "Will", "author_id": 12829151, "author_profile": "https://Stackoverflow.com/users/12829151", "pm_score": -1, "selected": false, "text": "explode" }, { "answer_id": 74389734, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 3, "selected": true, "text": "(df.set_axis(df.columns.str.split('\\s*>\\s*', expand=True), axis=1)\n .loc[0].explode()\n .reset_index(name='item')\n .rename(columns=lambda x: x.replace('level_', 'category'))\n)\n" }, { "answer_id": 74395258, "author": "sammywemmy", "author_id": 7175713, "author_profile": "https://Stackoverflow.com/users/7175713", "pm_score": 1, "selected": false, "text": "names_sep" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5423285/" ]
74,389,625
<p>I am wanting to only get the SourceEndpointConfigs from the sourceEndpoints retrieved from _vwSourceEndpoints. I am not sure how to modify my where clause to get the correct results. All help appreciated. Thanks!</p> <pre class="lang-cs prettyprint-override"><code>_vwSourceEndpoints = db.vwSourceEndpoints .Where(e =&gt; e.StudySourceSystemId == study.StudySourceSystemId &amp; e.ScheduleId == study.ScheduleId &amp; e.OrderNo == study.OrderNo &amp; e.Active == true ).ToList(); _vwSourceEndpointConfigs = db.SourceEndpointConfigs.Where( e =&gt; e.Active == true ).ToList(); var query3 = _vwSourceEndpointConfigs.Concat(_vwSourceEndpoints.OrderBy(x =&gt; x.OrderNo).ToList(); </code></pre> <p>I have come up with the below as an edit to my original code</p> <pre class="lang-cs prettyprint-override"><code>_vwSourceEndpoints = db.vwSourceEndpoints.Where( e =&gt; e.StudySourceSystemId == study.StudySourceSystemId &amp; e.ScheduleId == study.ScheduleId &amp; e.OrderNo == study.OrderNo &amp; e.Active == true).ToList(); _vwSourceEndpointConfigs = db.SourceEndpointConfigs.Where( e =&gt; _vwSourceEndpoints.All(x =&gt; x.StudySourceSystemId == study.StudySourceSystemId &amp; x.ScheduleId == study.ScheduleId &amp; x.OrderNo == study.OrderNo &amp; x.Active == true) ).ToList(); </code></pre>
[ { "answer_id": 74393092, "author": "adamctifacts", "author_id": 19216264, "author_profile": "https://Stackoverflow.com/users/19216264", "pm_score": 0, "selected": false, "text": "_vwSourceEndpoints = db.vwSourceEndpoints.Where(\n e => e.StudySourceSystemId == study.StudySourceSystemId\n & e.ScheduleId == study.ScheduleId\n & e.OrderNo == study.OrderNo\n & e.Active == true).ToList();\n\n _vwSourceEndpointConfigs = (from config in db.SourceEndpointConfigs.Where(c => c.Active == true)\n join ep in _vwSourceEndpoints\n on config.SourceEndpointId equals ep.SourceEndpointId\n select config).ToList();\n\n" }, { "answer_id": 74393305, "author": "WandererAboveTheSea", "author_id": 9680817, "author_profile": "https://Stackoverflow.com/users/9680817", "pm_score": 1, "selected": false, "text": "var query = context.vwSourceEndpoints\n .Where(e => e.StudySourceSystemId == study.StudySourceSystemId\n && e.ScheduleId == study.ScheduleId\n && e.OrderNo == study.OrderNo\n && e.Active == true\n ).Union(context.SourceEndpointConfigs.Where(e => e.Active == true);\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19216264/" ]
74,389,643
<p>Let's say I have a dataframe with 1000 rows. Is there an easy way of slicing the datframe in sucha way that the resulting datframe consisits of alternating N rows?</p> <p>For example, I want rows 1-100, 200-300, 400-500, ....and so on and skip 100 rows in between and create a new dataframe out of this.</p> <p>I can do this by storing each individial slice first into a new dataframe and then append at the end, but I was wondering if there a much simpler way to do this.</p>
[ { "answer_id": 74389759, "author": "Ric S", "author_id": 7465462, "author_profile": "https://Stackoverflow.com/users/7465462", "pm_score": 2, "selected": true, "text": "%" }, { "answer_id": 74389793, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 2, "selected": false, "text": "import numpy as np\nout = df[np.arange(len(df))%200<100]\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3370354/" ]
74,389,654
<p>I need to remove part of a URL with a regex. From the words: http or https to the word .com. And it can be several times in one string. Can anyone help me with this?</p> <p>For example a string: &quot;The request is:<a href="https://stackoverflow.com/questions%22">https://stackoverflow.com/questions&quot;</a> After the removal - &quot;The request is:/questions&quot;</p>
[ { "answer_id": 74392308, "author": "Shai Vashdy", "author_id": 14747878, "author_profile": "https://Stackoverflow.com/users/14747878", "pm_score": -1, "selected": false, "text": "re.sub()" }, { "answer_id": 74424058, "author": "Y.B.L", "author_id": 19323937, "author_profile": "https://Stackoverflow.com/users/19323937", "pm_score": 1, "selected": true, "text": "var regex = new Regex(@\"\\w+:\\/\\/[^\\/$]*\");\nregex.Replace(url, \"\");\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19323937/" ]
74,389,721
<p>I wrote this code and received an unexpected output than I thought.</p> <pre><code>def egg(): print(a) egg() # NameError: name 'a' is not defined **As excepted** egg.a = 50 egg() # NameError: name 'a' is not defined **Not as excepted** </code></pre> <p>My hope was that after setting <code>agg.a = 50</code> the next time I would call <code>agg()</code> <code>a</code> variable will be defined.</p> <p>Can someone please explain what am I missing? why <code>a</code> is not added to the function scope dynamically</p> <p>p.s. when I used <code>dir(egg)</code> I could see <code>a</code> was add the the function dict</p>
[ { "answer_id": 74389832, "author": "matszwecja", "author_id": 9296093, "author_profile": "https://Stackoverflow.com/users/9296093", "pm_score": 0, "selected": false, "text": "class Egg:\n def __init__(self, a):\n self.a = a\n def __call__(self):\n print(self.a)\n\negg = Egg(50)\n\negg() # 50\n\negg.a = 20\n\negg() # 20\n" }, { "answer_id": 74389878, "author": "Bhargav", "author_id": 15358800, "author_profile": "https://Stackoverflow.com/users/15358800", "pm_score": 2, "selected": false, "text": "def main():\n def egg():\n nonlocal a\n print(a)\n\n #egg() # NameError: name 'a' is not defined **As excepted**\n\n a = 50\n\n egg()\nmain()\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10738662/" ]
74,389,781
<p>I have a script which generates an S3 PreSigned URL and sends it in an email. The script works fine, but when the email is sent, it adds a new-line to the URL, which breaks it and makes it unusable in the email.</p> <p><strong>The only packages installed:</strong></p> <ul> <li>boto3</li> <li>Jinja2</li> </ul> <p><strong>The script:</strong></p> <pre class="lang-py prettyprint-override"><code>import boto3 from botocore.config import Config from jinja2 import Environment, FileSystemLoader from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import smtplib # AWS my_config = Config( region_name = 'eu-west-1' ) s3 = boto3.client('s3', config=my_config) bucket = &quot;name of bucket&quot; # Jinja2 loader = FileSystemLoader('templates') env = Environment(loader=loader) email_template = env.get_template('test_template.html') def create_presigned_url(bucket, object_name, expiration=259200): response = s3.generate_presigned_url('get_object', Params={'Bucket': bucket, 'Key': object_name}, ExpiresIn=expiration) return response def sendEmail(download_link): toEmail = 'me@email.com' msg = MIMEMultipart('alternative') title = 'Test email' sender = 'me@email.com' rendered_template = MIMEText(email_template.render({'download_link':download_link}), 'html') msg['Subject'] = title msg['From'] = sender msg['To'] = toEmail receivers = toEmail msg.attach(rendered_template) try: smtpObj = smtplib.SMTP('mail.server.com', 25) smtpObj.sendmail(sender, receivers, msg.as_string()) print (&quot;Successfully sent email&quot;) smtpObj.quit() except Exception as e: print (e, &quot;Error: unable to send email&quot;) if __name__ == &quot;__main__&quot;: selectedFile = 'file.txt' # Download link downloadURL = create_presigned_url(bucket, selectedFile) # print(downloadURL) # Send email sendEmail(downloadURL) </code></pre> <p><strong>Results</strong></p> <p>When I run the script, for some reason I get a newline somewhere inside of this long URL, which breaks the URL:</p> <p><a href="https://i.stack.imgur.com/pV8m8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pV8m8.png" alt="enter image description here" /></a></p> <p>Here's the source from Outlook:</p> <pre class="lang-html prettyprint-override"><code>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=us-ascii&quot;&gt;Download link: https://redacted/9%2FJOUw%3D&amp;amp;x-amz-security-token=IQoJb3JpZ2luX2VjEH0aCWV1LXdlc3QtMSJHMEUCIEBMYHD9wKhOfrR00jTv7RIcsRe3NbOU31QniJpEdps8AiEAi377qRmvQQXb5dXhRGJcXulFhRunGTSd0GRyGXHR2kMqzAQIdhAEGgwzNTgyODkxNTgxMTIiDH3bqAZMxVyKH3f6xyqpBL40WhPQMShoV8x1epn85Ml6qQ8Y1xdHe16xyoMWKqylbLGrndMFtYyOgs6LAlDvGJPrcF9xymGf8BqGsGHwCuWGdEcisxvwR%2FUoigjHBXP55fHpF%2FXnVupCRYDIVA5N%2BVOKW5%2BcljVN9KC3RKKvEeUncTGnXIaW5UHNAPiFSrgbbj9X%2FyBptkFmj5f4x2Zblm8crQS0rMTveCuoki3E06NO%2FKiDNiJQpF1vVphb%2F0spIR3CUxSx9HJHjvRBWTWQn9bmmT8rhp0lx%2Bzx9RLlpmE6hRRF6KBpNW%2B86y3EB%2BtMxVBuEhC5M1rCyjou6efK%2FA96wuwBN%2FmjD663vyZipiOGrj4yOFIMPklBu4L1SnfkxhZN8%2BNWXzwc%2B%2B5%2FNfL%2BVzyFpWS7TbGIM4A9TEvL3bPlgafvIl%2Fi24MOrN47UshpdpHGAjG20PBr0cbi75G7D%2B3UoSn%2Bzp0hZkAEACnwWtWtzEpVWbwatx%2FL1T8XF43o8OiKWqCfVxBjoZSc1itxRDOUqonYbCGY2Y0NlkXpvpHBZMcg7530dIFRBBxhTZo4RVXqkymTM4hEvDUw74R%2BDovr%2F%2BG5ji52Wpcng 954ESTpzMjOtuBXKcPtmEWTqx4au99ZP8lxbqKjq3BO%2FJLqrzTCPSEs6CTv7YbtzUqQ0r%2BkFyAU2RnpTTcYPJ5SD8ytlb4qUHb5RhEcn3bbJ5fsIRx%2B6q3LrhWkorDNKp5jh6oth1roRxXQM0swgN%2BzmwY6qQGnjWLAgUSUB9yf3heEdiFZo4DnC7ipW6BgsnkoeZJcPz5Ysx5PG4kzelCP89AsXQGD%2BtFqweusgWJVLo3dfyK3iLJ5myohn7mjSf1YVE%2B5CGlajc2HZl%2BoUOhI5gMMxpFXtpIL6jgTyY5r6ZwCKZ9g1afHO1kUF4VYir2M2BWYHTcB%2Bu8TANzoc15RJih8XmE%2FAWd%2FMQM7SQOQxsbmCiRSv5AeYMuok%2FSw&amp;amp;Expires=1668345190 </code></pre> <p>I tried:</p> <ul> <li>using <code>| safe</code> inside of my Jinja2 template.</li> <li>I tried using the href HTML tag, no dice.</li> </ul> <p>I don't know what else I can check and have no idea why it's happening. People mentioned this might be the cause: <a href="https://www.rfc-editor.org/rfc/rfc2822#section-2.1.1" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc2822#section-2.1.1</a></p>
[ { "answer_id": 74389832, "author": "matszwecja", "author_id": 9296093, "author_profile": "https://Stackoverflow.com/users/9296093", "pm_score": 0, "selected": false, "text": "class Egg:\n def __init__(self, a):\n self.a = a\n def __call__(self):\n print(self.a)\n\negg = Egg(50)\n\negg() # 50\n\negg.a = 20\n\negg() # 20\n" }, { "answer_id": 74389878, "author": "Bhargav", "author_id": 15358800, "author_profile": "https://Stackoverflow.com/users/15358800", "pm_score": 2, "selected": false, "text": "def main():\n def egg():\n nonlocal a\n print(a)\n\n #egg() # NameError: name 'a' is not defined **As excepted**\n\n a = 50\n\n egg()\nmain()\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5431283/" ]
74,389,794
<p>So i have a list of customers with name and id in a button and i will like to delete each customers by obviously targeting the id.</p> <pre><code>&lt;?php foreach ($customers as $customer) { echo '&lt;button id=&quot;btn&quot; onclick=&quot;showDelete('.$customer['id'].')&quot;&gt;'.$customer['name'].'&lt;/button&gt; &lt;button id=&quot;btn-delete&quot; value=&quot;'.$customer['id'].'&quot; style=&quot;display:none;&quot;&gt;Delete&lt;/button&gt; '; } &lt;script&gt; function showDelete(id) { let deleteId = id let btn = document.getElementById(&quot;btn-delete&quot;) let deleteValue = btn.value console.log(deleteValue) if ( deleteId === deleteValue ){ document.getElementById(&quot;btn-delete&quot;).style.display = &quot;block&quot;; } &lt;/script&gt; </code></pre> <p>Any time i trigger the button only the first <code>value</code> of the <code>delete</code> button shows</p> <p>How do i target each name and delete them using vanilla javascript??</p>
[ { "answer_id": 74389832, "author": "matszwecja", "author_id": 9296093, "author_profile": "https://Stackoverflow.com/users/9296093", "pm_score": 0, "selected": false, "text": "class Egg:\n def __init__(self, a):\n self.a = a\n def __call__(self):\n print(self.a)\n\negg = Egg(50)\n\negg() # 50\n\negg.a = 20\n\negg() # 20\n" }, { "answer_id": 74389878, "author": "Bhargav", "author_id": 15358800, "author_profile": "https://Stackoverflow.com/users/15358800", "pm_score": 2, "selected": false, "text": "def main():\n def egg():\n nonlocal a\n print(a)\n\n #egg() # NameError: name 'a' is not defined **As excepted**\n\n a = 50\n\n egg()\nmain()\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468912/" ]
74,389,834
<p>I'm trying to set each td as a different image that I have saved as imgn.gif. (n being image number, I have 13 images, img1.gif., img2.gif... img13.gif) I have a code that generates the table now I just can't figure out how to set a background image, preferably so that the n imgn.gif changes to the next index so the next td will have the next image.</p> <p>this is the code that I have for now. I assume I have to set something differently here: const cellText = document.createTextNode(2);, so it sets background-image instead?</p> <pre><code>function options () { const tbl = document.createElement(&quot;table&quot;); const tblBody = document.createElement(&quot;tbody&quot;); for (let i = 0; i &lt; 1; i++) { const row = document.createElement(&quot;tr&quot;); for (let j = 0; j &lt; 16; j++) { const cell = document.createElement(&quot;td&quot;); const cellText = document.createTextNode(2); cell.appendChild(cellText); row.appendChild(cell); } tblBody.appendChild(row); } tbl.appendChild(tblBody); document.body.appendChild(tbl); } </code></pre>
[ { "answer_id": 74389832, "author": "matszwecja", "author_id": 9296093, "author_profile": "https://Stackoverflow.com/users/9296093", "pm_score": 0, "selected": false, "text": "class Egg:\n def __init__(self, a):\n self.a = a\n def __call__(self):\n print(self.a)\n\negg = Egg(50)\n\negg() # 50\n\negg.a = 20\n\negg() # 20\n" }, { "answer_id": 74389878, "author": "Bhargav", "author_id": 15358800, "author_profile": "https://Stackoverflow.com/users/15358800", "pm_score": 2, "selected": false, "text": "def main():\n def egg():\n nonlocal a\n print(a)\n\n #egg() # NameError: name 'a' is not defined **As excepted**\n\n a = 50\n\n egg()\nmain()\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468889/" ]
74,389,848
<p>In python tutorial(<a href="https://docs.python.org/3/tutorial/introduction.html#strings" rel="nofollow noreferrer">https://docs.python.org/3/tutorial/introduction.html#strings</a>), slicing is explained as to think of the indices as pointing between characters, with the left edge of the first character numbered 0. Then the right edge of the last character of a string of n characters has index n, for example:</p> <p><a href="https://i.stack.imgur.com/kBfgk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kBfgk.png" alt="enter image description here" /></a></p> <p>Moving on it says - 'The slice from i to j consists of all characters between the edges labeled i and j, respectively.'</p> <p>However, when i try to print the following two cases it seems to miss the P.</p> <p>Case1: print(word[6:0:-1])--&gt; Outputs 'nohty'</p> <p>Case2: print(word[6:-6:-1])--&gt; Outputs 'nohty'</p> <p>Can anyone provide a possible explanation why it doesn't print 'nohtyP'? (P.S. - I know i can keep the end vacant to get the 'P'.)</p>
[ { "answer_id": 74389832, "author": "matszwecja", "author_id": 9296093, "author_profile": "https://Stackoverflow.com/users/9296093", "pm_score": 0, "selected": false, "text": "class Egg:\n def __init__(self, a):\n self.a = a\n def __call__(self):\n print(self.a)\n\negg = Egg(50)\n\negg() # 50\n\negg.a = 20\n\negg() # 20\n" }, { "answer_id": 74389878, "author": "Bhargav", "author_id": 15358800, "author_profile": "https://Stackoverflow.com/users/15358800", "pm_score": 2, "selected": false, "text": "def main():\n def egg():\n nonlocal a\n print(a)\n\n #egg() # NameError: name 'a' is not defined **As excepted**\n\n a = 50\n\n egg()\nmain()\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10288870/" ]
74,389,862
<p>I want to copy the string “Best School” into a new space in memory, which of these statements can I use to reserve enough space for it</p> <p>A. <code>malloc(sizeof(“Best School”))</code></p> <p>B. <code>malloc(strlen(“Best School”))</code></p> <p>C. <code>malloc(11)</code></p> <p>D. <code>malloc(12)</code></p> <p>E. <code>malloc(sizeof(“Best School”) + 1)</code></p> <p>F. <code>malloc(strlen(“Best School”) + 1)</code></p> <p>I am still very new to C programming language so I really am not too sure of which works well. But I will love for someone to show me which ones can be used and why they should be used.</p> <p>Thank you.</p>
[ { "answer_id": 74389948, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 2, "selected": true, "text": "sizeof" }, { "answer_id": 74390104, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "sizeof" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20418936/" ]
74,389,864
<p>I have built a Web API that is connected to a database for persons. I am now trying to call this Web API from a separate MVC-application which is supposed to have full CRUD. So far i have managed to do so with the Get and Post-methods to create a new person and see a list of the persons currently in the database.</p> <p>When trying to do a similar call for the Put-method, i get the following error: <a href="https://i.stack.imgur.com/OAEs4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OAEs4.png" alt="Error" /></a></p> <p>This is how my method UpdatePerson is written in my API-application:</p> <pre><code> [HttpPut] [Route(&quot;{id:guid}&quot;)] public async Task&lt;IActionResult&gt; UpdatePerson([FromRoute] Guid id, UpdatePersonRequest updatePersonRequest) { var person = await dbContext.Persons.FindAsync(id); if (person != null) { person.Name = updatePersonRequest.Name; person.Email = updatePersonRequest.Email; person.Phone = updatePersonRequest.Phone; person.Address = updatePersonRequest.Address; await dbContext.SaveChangesAsync(); return Ok(person); } </code></pre> <p>And this is how i am trying to consume the API in my separate MVC-project:</p> <pre><code> [HttpGet] public IActionResult Edit() { return View(); } [HttpPost] public async Task&lt;IActionResult&gt; Edit(PersonViewModel pvm) { HttpClient client = new(); StringContent sContent = new StringContent(JsonConvert.SerializeObject(pvm), Encoding.UTF8, &quot;application/json&quot;); HttpResponseMessage response = await client.PutAsync(&quot;https://localhost:7281/api/Persons/&quot;, sContent); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { return RedirectToAction(&quot;Get&quot;); } else { return NotFound(); } } </code></pre> <p>Everything is working fine when i try to update the database through the API-app so i am not really sure what is wrong with my request. I hope that someone here can spot the issue right away or at least help me out as i am quite a beginner with WEB APIs.</p> <p>I have mostly tried changing the URL in my MVC-project but the issue remains.</p>
[ { "answer_id": 74389948, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 2, "selected": true, "text": "sizeof" }, { "answer_id": 74390104, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "sizeof" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20203816/" ]
74,389,881
<p>I have created a partial view which will show the menu with unordered list. I want to add links to each li element. I have done my research and tried different ways like giving relative path, absolute path etc. but it does not open the view page. It shows 404 error in browser. Am I missing to add something in partial view which can then open the view page on clicking the li tag item.</p> <pre><code>&lt;li&gt;&lt;a href=&quot;~/Views/Powershell/PwrCmts.cshtml&quot;&gt;Powershell Comments&lt;/a&gt;&lt;/li&gt; </code></pre> <p>Any guidance would be greatly appreciated.</p>
[ { "answer_id": 74389948, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 2, "selected": true, "text": "sizeof" }, { "answer_id": 74390104, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "sizeof" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15287049/" ]
74,389,891
<p>I am new in React Native and i'm trying to develop a mobile app with Expo.</p> <p>I am trying to call a function of a component class in my App.tsx. I don't want that function is static because i need to access to my variable of my state which is in my constructor of my class.</p> <p>App.tsx</p> <pre><code>const App = () =&gt; { const [variable, setVariable] = useState(''); useEffect(() =&gt; { //doing some stuff }, []) Class1.method(variable); [...] } </code></pre> <p>Class1.tsx</p> <pre><code>class Class1 extends Component&lt;any, any&gt; { constructor(props: any){ super(props); this.state = { company_name: [], } } method(param: any) { Object.values(param).map(function(d: any, idx){ this.state.company_name = [...this.state.company_name, d]; }); } [...] </code></pre> <p>So the thing is that i am having an array in my App.tsx and i want to pass it to my Class1.</p> <p>Is that possible to do in that way or am i missing something ?</p> <p>Thanks in advance</p>
[ { "answer_id": 74389948, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 2, "selected": true, "text": "sizeof" }, { "answer_id": 74390104, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 0, "selected": false, "text": "sizeof" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9741308/" ]
74,389,925
<p>I am loading 10 items per page from API and storing the data in redux suppose I scroll 3 pages so in my redux there are 30 elements 10 elements on page 1 10 on page 2 10 on page 3. Now I go to the next screen and return to the pagination screen again. My page 1 is again called and in the redux, there is duplication of elements because page 1 elements are already in the redux, So, should I clear the redux before going to the next screen? So it again starts with page 1</p>
[ { "answer_id": 74390564, "author": "Gavara.Suneel", "author_id": 8988448, "author_profile": "https://Stackoverflow.com/users/8988448", "pm_score": 0, "selected": false, "text": "{lastSearchedPageIndex: 0, items: []}" }, { "answer_id": 74390588, "author": "Azzam Michel", "author_id": 14568922, "author_profile": "https://Stackoverflow.com/users/14568922", "pm_score": 1, "selected": false, "text": " return { \n ...state,\ndata:[...state.data,...data]\n page:data.length >0? state.page+1:state.page\n }\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9002158/" ]
74,389,960
<p>I'd like to access the last modified time column from the metadata of a BigQuery table that acts as a source. I want to create a generic test that checks if the last modified date of the source table is equal to today.</p> <p>In BigQuery you can access this data in this way:</p> <pre><code>SELECT last_modified_time FROM `project.dataset.__TABLES__` WHERE table_id = 'table_id' </code></pre> <p>My goal is to make the project.dataset dynamic depending on the model this test is applied to. Similarly, I'd like for table_id to be dynamic.</p> <p>Given that DBT mentions on their documentation that the dataset of BigQuery is similar in definition to 'schema', I tried this but it didn't work.</p> <pre><code>{% test last_modified_time(schema, model) %} SELECT last_modified_time FROM `{{ database }}.{{ schema }}.__TABLES__` WHERE table_id = {{ model }} {% endtest %} </code></pre> <p>What this does is it renders the project name for both database and schema. Also, model will (of course) render the project.dataset.table_id path while I only need the table_id.</p> <p>I'm fairly new to DBT but I couldn't find anything that resembles what I'm looking for.</p>
[ { "answer_id": 74390564, "author": "Gavara.Suneel", "author_id": 8988448, "author_profile": "https://Stackoverflow.com/users/8988448", "pm_score": 0, "selected": false, "text": "{lastSearchedPageIndex: 0, items: []}" }, { "answer_id": 74390588, "author": "Azzam Michel", "author_id": 14568922, "author_profile": "https://Stackoverflow.com/users/14568922", "pm_score": 1, "selected": false, "text": " return { \n ...state,\ndata:[...state.data,...data]\n page:data.length >0? state.page+1:state.page\n }\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11341655/" ]
74,389,968
<p>How can I convert Date.now to a string without using DateFormatter?</p>
[ { "answer_id": 74390564, "author": "Gavara.Suneel", "author_id": 8988448, "author_profile": "https://Stackoverflow.com/users/8988448", "pm_score": 0, "selected": false, "text": "{lastSearchedPageIndex: 0, items: []}" }, { "answer_id": 74390588, "author": "Azzam Michel", "author_id": 14568922, "author_profile": "https://Stackoverflow.com/users/14568922", "pm_score": 1, "selected": false, "text": " return { \n ...state,\ndata:[...state.data,...data]\n page:data.length >0? state.page+1:state.page\n }\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1229350/" ]
74,389,982
<p>i'm beginner and just learning abstract classes and interfaces but really struggeling to get it right.</p> <p><strong>MY Class structure.</strong></p> <ul> <li><strong>Abstract Class</strong> Vehicle</li> <li><strong>Class</strong> Car (extends Vehicle, implements ITuning)</li> <li><strong>Class</strong> Motorcycle (extending Vehicle)</li> <li><strong>Interface</strong> ITuning</li> </ul> <p>I want to have an abstract method <strong>doRace()</strong> that I can use in my Car class to compare the Car Objects (car.getHp()) and prints the winner. I try to implement a doRace(object o) into the Interface ITuning and a doRace(Car o) into my Car class but get the error. How can I implement that correctly ?</p> <blockquote> <p>The type Car must implement the inherited abstract method ITuning.doRace(Object)</p> </blockquote> <p>But if do chage it to Object, i can't use it in my Car class…</p> <pre><code>public interface ITuning { abstract void doRace(Object o1); } </code></pre> <pre><code>public Car extends Vehicle implements ITuning { public void doRace(Car o1){ if(this.getHp() &gt; o1.getHp()) }; } </code></pre> <p>Any Idea what i'm doing wrong? I assume its a comprehension error</p>
[ { "answer_id": 74390214, "author": "Chaosfire", "author_id": 17795888, "author_profile": "https://Stackoverflow.com/users/17795888", "pm_score": 2, "selected": false, "text": "ITuning" }, { "answer_id": 74390783, "author": "Marvin", "author_id": 4616087, "author_profile": "https://Stackoverflow.com/users/4616087", "pm_score": 2, "selected": true, "text": "ITuning" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74389982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18906827/" ]
74,390,003
<p>So Im supposed to write a program that does the following • Read an eight-digit integer entered by the user. If less or more then eight digits are entered prompt the user again for input Ive tried the following methods yet they dont work, what do I do. Either it accepts asdfghjk as an eight digit number or it crashes the entire loop</p> <pre><code>number= input(&quot;Enter an eight digit number&quot;) while True: if len(number)==8 and number.isnumeric(): continue; else: number=input(&quot;Invalid Entry, Type again:&quot;) </code></pre> <pre><code>number = int(input(&quot;Enter an eight digit number:&quot;)) while True: if number &lt; 10000000 or number &gt; 99999999: number = input(&quot;Invalid Entry, Type again:&quot;) else:      continue </code></pre>
[ { "answer_id": 74390088, "author": "Alan Biju", "author_id": 20468979, "author_profile": "https://Stackoverflow.com/users/20468979", "pm_score": 1, "selected": false, "text": "continue;" }, { "answer_id": 74390412, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 0, "selected": false, "text": "input()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469024/" ]
74,390,007
<p>I have an external endpoint which I call to get some Json response. This endpoint will initiate a session to a POS device, so the device will show the request details and ask the customer to enter his credit card to complete the payment, then when the customer finishes; the POS will call the endpoint and it will return the result back to my application.</p> <p>The problem here is that I need the operation to complete as described in this scenario (synchronously).</p> <p>When I do the call to this endpoint from postman; it waits a lot of time (until the POS receives the request and customer do his entries then returns the results back to endpoint and endpoint returns the results back to Postman) ... this is all works fine.</p> <p>The problem is when I do this from an ASP.NET Core app, the request is not waited for endpoint and the response is returned with <code>null</code> directly.</p> <p>I need something to wait for it.</p> <pre><code>using (var client = new HttpClient()) { client.DefaultRequestHeaders.Add(&quot;x-API-Key&quot;, &quot;ApiKey&quot;); client.DefaultRequestHeaders.Add(&quot;Connection&quot;, &quot;keep-alive&quot;); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(&quot;application/json&quot;)); var postTask = client.PostAsJsonAsync(new Uri(&quot;terminalEndpoint here&quot;), dto);//dto is the request payload postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { //Should hang after this line to wait for POS var terminalPaymentResponseDto = result.Content.ReadAsAsync&lt;InitiateTerminalPaymentResponseDto&gt;().Result; //Should hit this line after customer finishes with POS device return terminalPaymentResponseDto; } } </code></pre>
[ { "answer_id": 74390088, "author": "Alan Biju", "author_id": 20468979, "author_profile": "https://Stackoverflow.com/users/20468979", "pm_score": 1, "selected": false, "text": "continue;" }, { "answer_id": 74390412, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 0, "selected": false, "text": "input()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9984048/" ]
74,390,037
<p>I would like the execution of the event handler to depend on whether the property is set to true or false in applecation.yaml file. I have three yaml files (test, dev, prod) and I have set the settings in them:</p> <pre><code> for application-dev.yml page-cache: starting: false for application-test.yml page-cache: starting: true for application-prod.yml page-cache: starting: true </code></pre> <p>And I need not to write 'dev' or 'test' in condition myself, but to read true or false from yaml files. For example: <code>condition = &quot;@serviceEnabled == true&quot;</code> , does not work.</p> <pre class="lang-java prettyprint-override"><code>@Service public class ServiceImpl{ @Value(&quot;${page-cache.starting}&quot;) private Boolean serviceEnabled; /means that when running dev will be false and the method will not run and this code is working @EventListener( value = ApplicationReadyEvent.class, condition = &quot;@environment.getActiveProfiles()[0] != 'dev'&quot;) public void updateCacheAfterStartup() { log.info(&quot;Info add starting...&quot;); someService.getInfo(); } </code></pre> <p>I tried to do as in this article, but it doesn't work for me .</p> <p><a href="https://stackoverflow.com/questions/50723383/evaluate-property-from-properties-file-in-springs-eventlistenercondition">Evaluate property from properties file in Spring&#39;s @EventListener(condition = &quot;...&quot;)</a></p> <p>I also tried the same option</p> <pre><code>@Service public class ServiceImpl{ // @Lazy private final ServiceImpl serviceImpl @Value(&quot;${page-cache.starting}&quot;) private Boolean serviceEnabled; public Boolean isServiceEnabled() { return this.serviceEnabled; } public Boolean getServiceEnabled() { return serviceEnabled; } @EventListener( value = ApplicationReadyEvent.class, condition = &quot;@ServiceImpl.serviceEnabled&quot;) public void updateCacheAfterStartup() { log.info(&quot;Info add starting...&quot;); someService.getInfo(); } </code></pre>
[ { "answer_id": 74390088, "author": "Alan Biju", "author_id": 20468979, "author_profile": "https://Stackoverflow.com/users/20468979", "pm_score": 1, "selected": false, "text": "continue;" }, { "answer_id": 74390412, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 0, "selected": false, "text": "input()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20468872/" ]
74,390,106
<p>I'm learning react bootstrap, I wrote in the terminal npm install react-bootstrap bootstrap. and I got this code: But it doesn't show it and I don't get any errors. What am I doing wrong?</p> <pre><code>import {Container, Nav} from &quot;react-bootstrap&quot;; const Navbar = () =&gt; { return( &lt;Navbar bg=&quot;light&quot; expand=&quot;lg&quot;&gt; &lt;Container&gt; &lt;Navbar.Brand href=&quot;#home&quot;&gt;React-Bootstrap&lt;/Navbar.Brand&gt; &lt;Navbar.Toggle aria-controls=&quot;basic-navbar-nav&quot; /&gt; &lt;Navbar.Collapse id=&quot;basic-navbar-nav&quot;&gt; &lt;Nav className=&quot;me-auto&quot;&gt; &lt;Nav.Link href=&quot;#home&quot;&gt;Home&lt;/Nav.Link&gt; &lt;Nav.Link href=&quot;#link&quot;&gt;Link&lt;/Nav.Link&gt; &lt;/Nav&gt; &lt;/Navbar.Collapse&gt; &lt;/Container&gt; &lt;/Navbar&gt; ) } export default Navbar </code></pre> <p>I don't get any errors, so I don't know what I did wrong.</p>
[ { "answer_id": 74390088, "author": "Alan Biju", "author_id": 20468979, "author_profile": "https://Stackoverflow.com/users/20468979", "pm_score": 1, "selected": false, "text": "continue;" }, { "answer_id": 74390412, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 0, "selected": false, "text": "input()" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17716431/" ]
74,390,114
<p>I am getting a name error not defined error when entering bond into the program.</p> <p>If anyone could shed some light onto where I have gone wrong that would be great.</p> <pre><code>elif greeting == &quot;Bond&quot;: house_value = int (input('''Please enter the value of the house: ''')) monthly_rate=float(input('''Enter the percentage of your interest rate ''')) / 100 /12 monthly_repay=int(input('''Please enter the number of months you plan to take to repay the bond''')) x = (monthly_rate * house_value)/(1 - (1+monthly_rate)**(-monthly_repay)) print(f&quot;The monthly repayment is {x:.2f}&quot;) if y == 'Simple': compound = investment* math.pow((1+rate),years) print(f&quot;The total amount of interest you will earn on your investment will be {compound:.2f} &quot;) </code></pre>
[ { "answer_id": 74390157, "author": "Axeltherabbit", "author_id": 8340761, "author_profile": "https://Stackoverflow.com/users/8340761", "pm_score": 3, "selected": false, "text": "elif greeting == \"Bond\":" }, { "answer_id": 74390690, "author": "ago", "author_id": 20422485, "author_profile": "https://Stackoverflow.com/users/20422485", "pm_score": 0, "selected": false, "text": "if greeting == investment:\n\n...\n\n if y == simple:\n\n ...\n\n elif y == compound:\n\n ...\n\n elif greeting == bond:\n\n...\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469070/" ]
74,390,141
<p>Hi guys I need some help regarding on the script that I'm doing.</p> <p>I've created a temp table to get the compared values from table1 and table2</p> <pre><code>CREATE TABLE tmp_table1 AS SELECT a.Date, a.Id, b.Customer_Id, a.Name, a.Values FROM table2 a, table1 b WHERE (a.Name like '%Red%' OR a.Name like '%Blue%') AND a.Date = b.Date AND a.Values != b.Values AND a.Customer_Id = b.Customer_Id </code></pre> <p>Now I would like to update the values from table1 while comparing the values to the temp table using the Customer_Id, Name and Values column. So it should be compared first before adding the column Values to the table1.</p> <pre><code>UPDATE table1 SET Values = REPLACE(VALUES, '=N', '=N#10-NOV-2022') </code></pre> <p>Sample Data:</p> <ul> <li>Table1</li> </ul> <pre><code>Values = 'ANS1=N, ANS2=Y, ANS3=N' </code></pre> <ul> <li>TempTable</li> </ul> <pre><code>Values = 'ANS1=Y, ANS2=N, ANS3=N' </code></pre> <p>The output should be</p> <ul> <li>Table1</li> </ul> <pre><code>Values = 'ANS1=Y, ANS2=N#10-NOV-2022, ANS3=N' </code></pre> <p>I tried to do it by using this solution but I think I'm missing something.</p> <pre><code>UPDATE table1 SET Values = REPLACE(Values, '=N', '=N#DATE') FROM (SELECT b.Values FROM table1 a, tempTable b WHERE a.Customer_Id = b.Customer_Id AND a.Values != b.Values) </code></pre> <p>The date after '=N' is just a hardcoded date.</p> <p>Do you have any idea regarding on this.</p>
[ { "answer_id": 74390157, "author": "Axeltherabbit", "author_id": 8340761, "author_profile": "https://Stackoverflow.com/users/8340761", "pm_score": 3, "selected": false, "text": "elif greeting == \"Bond\":" }, { "answer_id": 74390690, "author": "ago", "author_id": 20422485, "author_profile": "https://Stackoverflow.com/users/20422485", "pm_score": 0, "selected": false, "text": "if greeting == investment:\n\n...\n\n if y == simple:\n\n ...\n\n elif y == compound:\n\n ...\n\n elif greeting == bond:\n\n...\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469002/" ]
74,390,163
<p>I'm a new beginner in swiftUI and I'm trying to deal with a Class that use CoreLocation to do some places locations comparison. But I've add my structured array of place in my Class and I've got an error with the <code>override init()</code>.</p> <p>My class :</p> <pre><code>import Foundation import CoreLocation import Combine import SwiftUI class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { private let locationManager = CLLocationManager() @ObservedObject var placeLibrary: PlaceLibrary @Published var locationStatus: CLAuthorizationStatus? @Published var lastLocation: CLLocation? @Published var distanceFromNearest: Double = 0.0 @Published var nearestObject:String = &quot;&quot; override init() { placeLibrary.testPlace = placeLibrary.testPlace super.init() // HERE I GET MY ERROR locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() self.placeLibrary = placeLibrary } var statusString: String { guard let status = locationStatus else { return &quot;unknown&quot; } switch status { case .notDetermined: return &quot;notDetermined&quot; case .authorizedWhenInUse: return &quot;authorizedWhenInUse&quot; case .authorizedAlways: return &quot;authorizedAlways&quot; case .restricted: return &quot;restricted&quot; case .denied: return &quot;denied&quot; default: return &quot;unknown&quot; } } func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { locationStatus = status print(#function, statusString) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard let location = locations.last else { return } lastLocation = location for (idx, readOnlyPlace) in placeLibrary.testPlace.enumerated() { // Calculate stuff let currentLocation = CLLocation(latitude: (self.lastLocation?.coordinate.latitude) ?? 0.0, longitude: (self.lastLocation?.coordinate.longitude) ?? 0.0) let comparedLocation = CLLocation(latitude: readOnlyPlace.lat, longitude: readOnlyPlace.long) // Update struct placeLibrary.testPlace[idx].proximity = currentLocation.distance(from: comparedLocation) } placeLibrary.testPlace = placeLibrary.testPlace.sorted(by: { $0.proximity &lt; $1.proximity }) print(placeLibrary.testPlace) } } </code></pre> <p>The error result here is : <code>Property 'self.placeLibrary' not initialized at super.init call</code></p> <p>After looking on internet I understand that I need to define all my variable used by my Class into the Init. That's why I add this line without any success : <code>self.placeLibrary = placeLibrary</code> even if there is before or after the <code>super.init()</code> line...</p> <p>So I think there something I don't understand ...</p> <p>My Place library :</p> <pre><code>class PlaceLibrary: ObservableObject{ @Published var testPlace = [ Place(lat: 46.1810, long: 6.2304, Name: &quot;Place 1&quot;, proximity: 0.0), Place(lat: 46.1531, long: 6.2951, Name: &quot;Place 2&quot;, proximity: 0.0), Place(lat: 46.1207, long: 6.3302, Name: &quot;Place 3&quot;, proximity: 0.0) ] } </code></pre> <p>My Place structure :</p> <pre><code>struct Place: Identifiable{ let id = UUID().uuidString var lat: Double var long: Double var Name: String var proximity: Double init (lat: Double, long: Double, Name: String, proximity: Double){ self.lat = lat self.long = long self.Name = Name self.proximity = proximity } init(config: NewPlaceConfig){ self.lat = config.lat self.long = config.long self.Name = config.Name self.proximity = config.proximity } } </code></pre> <p>And finally my NewPlaceConfig</p> <pre><code>struct NewPlaceConfig{ var lat: Double var long: Double var Name: String var proximity: Double } </code></pre>
[ { "answer_id": 74390311, "author": "Allan Garcia", "author_id": 1636456, "author_profile": "https://Stackoverflow.com/users/1636456", "pm_score": 0, "selected": false, "text": "Property 'self.placeLibrary' not initialized at super.init call" }, { "answer_id": 74390703, "author": "Cheezzhead", "author_id": 2542661, "author_profile": "https://Stackoverflow.com/users/2542661", "pm_score": 2, "selected": true, "text": "placeLibrary" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10582757/" ]
74,390,165
<p>I 'm trying to parse data from website using beautifulsoap in python and finally I pulled data from website so I want to save data in json file but it saves the data as follows according to the code I wrote</p> <p><strong>json file</strong></p> <pre><code>[ { &quot;collocation&quot;: &quot;\nabove average&quot;, &quot;meaning&quot;: &quot;more than average, esp. in amount, age, height, weight etc. &quot; }, { &quot;collocation&quot;: &quot;\nabsolutely necessary&quot;, &quot;meaning&quot;: &quot;totally or completely necessary&quot; }, { &quot;collocation&quot;: &quot;\nabuse drugs&quot;, &quot;meaning&quot;: &quot;to use drugs in a way that's harmful to yourself or others&quot; }, { &quot;collocation&quot;: &quot;\nabuse of power&quot;, &quot;meaning&quot;: &quot;the harmful or unethical use of power&quot; }, { &quot;collocation&quot;: &quot;\naccept (a) defeat&quot;, &quot;meaning&quot;: &quot;to accept the fact that you didn't win a game, match, contest, election, etc.&quot; }, </code></pre> <p><strong>my code:</strong></p> <pre><code>import requests from bs4 import BeautifulSoup from selenium import webdriver import pandas as pd import json url = &quot;https://www.englishclub.com/ref/Collocations/&quot; mylist = [ &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E&quot;, &quot;F&quot;, &quot;G&quot;, &quot;H&quot;, &quot;I&quot;, &quot;J&quot;, &quot;K&quot;, &quot;L&quot;, &quot;M&quot;, &quot;N&quot;, &quot;O&quot;, &quot;P&quot;, &quot;Q&quot;, &quot;R&quot;, &quot;S&quot;, &quot;T&quot;, &quot;U&quot;, &quot;V&quot;, &quot;W&quot; ] list = [] for i in range(23): result = requests.get(url+mylist[i]+&quot;/&quot;, headers=headers) doc = BeautifulSoup(result.text, &quot;html.parser&quot;) collocations = doc.find_all(class_=&quot;linklisting&quot;) for tag in collocations: case = { &quot;collocation&quot;: tag.a.string, &quot;meaning&quot;: tag.div.string } list.append(case) with open('data.json', 'w', encoding='utf-8') as f: json.dump(list, f, ensure_ascii=False, indent=4) </code></pre> <p>but for example, I want to have a list for each letter, for example, one list for A and one more list for B so that I can easily find which one starts with which letter and use it. How can I do that. And as you can see in the json file there is always <code>\</code> at the beginning of the collocation how can I remove it?</p>
[ { "answer_id": 74390374, "author": "Mustafa KÜÇÜKDEMİRCİ", "author_id": 15833253, "author_profile": "https://Stackoverflow.com/users/15833253", "pm_score": 2, "selected": true, "text": "import requests\nfrom bs4 import BeautifulSoup\nimport pandas as pd\nimport json\n\n\nurl = \"https://www.englishclub.com/ref/Collocations/\"\n\nmylist = [\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"I\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"O\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\"\n]\n\n#you can use dictionary instead list. suits your needs better\nlist = {}\n\n#just for quick testing, i set range to 4\nfor i in range(4):\n list[mylist[i]] = [] #make an empty list for your collocations\n\n result = requests.get(url+mylist[i]+\"/\")\n doc = BeautifulSoup(result.text, \"html.parser\")\n collocations = doc.find_all(class_=\"linklisting\")\n\n for tag in collocations:\n \n case = {\n \"collocation\": tag.a.string.replace(\"\\n\",\"\"),#replace \\n indentations\n \"meaning\": tag.div.string\n }\n list[mylist[i]].append(case)#add collocation to related list\n\n\nwith open('data.json', 'w', encoding='utf-8') as f:\n\n json.dump(list, f, ensure_ascii=False, indent=4)\n" }, { "answer_id": 74390383, "author": "Jack Fleeting", "author_id": 9448090, "author_profile": "https://Stackoverflow.com/users/9448090", "pm_score": 0, "selected": false, "text": "doc" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18002913/" ]
74,390,188
<p>I have an ActiveRecord request:</p> <pre><code>Post.all.select { |p| Date.today &lt; p.created_at.weeks_since(2) } </code></pre> <p>And I want to be able to see what SQL request this produces using <code>.to_sql</code></p> <p>The error I get is: <code>NoMethodError: undefined method 'to_sql'</code></p> <p>TIA!</p>
[ { "answer_id": 74390364, "author": "53c", "author_id": 10630142, "author_profile": "https://Stackoverflow.com/users/10630142", "pm_score": 0, "selected": false, "text": "to_sql" }, { "answer_id": 74408407, "author": "engineersmnky", "author_id": 1978251, "author_profile": "https://Stackoverflow.com/users/1978251", "pm_score": 2, "selected": true, "text": "select" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17767334/" ]
74,390,204
<p>I have the following table</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Father</th> <th>Son</th> <th>Year</th> </tr> </thead> <tbody> <tr> <td>James</td> <td>Harry</td> <td>1999</td> </tr> <tr> <td>James</td> <td>Alfi</td> <td>2001</td> </tr> <tr> <td>Corey</td> <td>Kyle</td> <td>2003</td> </tr> </tbody> </table> </div> <p>I would like to add a fourth column that makes the table look like below. It's supposed to show which child of each father was born first, second, third, and so on. How can I do that?</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Father</th> <th>Son</th> <th>Year</th> <th>Child</th> </tr> </thead> <tbody> <tr> <td>James</td> <td>Harry</td> <td>1999</td> <td>1</td> </tr> <tr> <td>James</td> <td>Alfi</td> <td>2001</td> <td>2</td> </tr> <tr> <td>Corey</td> <td>Kyle</td> <td>2003</td> <td>1</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74390420, "author": "Dmitri Chubarov", "author_id": 1328439, "author_profile": "https://Stackoverflow.com/users/1328439", "pm_score": 0, "selected": false, "text": "groupby" }, { "answer_id": 74390613, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 1, "selected": false, "text": "# groupby Father and take a cumcount, offsetted by 1\ndf['Child']=df.groupby(['Father'])['Son'].cumcount()+1\ndf\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20346110/" ]
74,390,216
<p>If the mouse is about 20px close to the button, I want that the button should be clickable. I tried increasing the width of the button by 20px and making the opacity 0.1 so the big size won't show. Then in the <code>button:hover</code> rule I made the opacity 1.</p> <p>I did the above cause I don't really know how go about it.</p> <p><a href="https://i.stack.imgur.com/d349p.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d349p.jpg" alt="the image depicts what I am trying to achieve." /></a></p>
[ { "answer_id": 74390420, "author": "Dmitri Chubarov", "author_id": 1328439, "author_profile": "https://Stackoverflow.com/users/1328439", "pm_score": 0, "selected": false, "text": "groupby" }, { "answer_id": 74390613, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 1, "selected": false, "text": "# groupby Father and take a cumcount, offsetted by 1\ndf['Child']=df.groupby(['Father'])['Son'].cumcount()+1\ndf\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19519711/" ]
74,390,218
<p>I want add span in li's. I add spans but they become visible after all of them created.But I want them to be visible right after created</p> <pre><code>h.appendChild(node) console.log(node) </code></pre> <p>when I do that an empty line comes to console but all nodes created that turn this</p> <pre><code>&lt;span class=&quot;l_Right f_12px f_Bold c_Gray&quot;&gt;…&lt;/span&gt; </code></pre> <p>I want they comes right after created</p>
[ { "answer_id": 74396558, "author": "Norio Yamamoto", "author_id": 20074043, "author_profile": "https://Stackoverflow.com/users/20074043", "pm_score": -1, "selected": false, "text": "<!DOCTYPE html>\n<html>\n\n<head>\n <style type=\"text/css\">\n * {\n font-size: xx-large;\n }\n </style>\n</head>\n\n<body>\n <input type=\"button\" id=\"button\" value=\"button\"><br>\n <input type=\"text\" id=\"delay\" value=\"1000\">msec\n <ui id=\"ui\">\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n <li>hoge&nbsp;</li>\n </ui>\n\n <script>\n const elmButton = document.getElementById(\"button\");\n const elmDelay = document.getElementById(\"delay\");\n const elmUi = document.getElementById(\"ui\");\n\n elmButton.onclick = async () => {\n const delay = elmDelay.value;\n for (const li of elmUi.children) {\n const span = document.createElement(\"span\");\n span.innerText = \"hogehoge\";\n li.appendChild(span);\n await new Promise(r => setTimeout(r, delay));\n }\n }\n\n </script>\n</body>\n\n</html>\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469130/" ]
74,390,223
<p>So, imagine I have a (dumb) function like this:</p> <pre class="lang-js prettyprint-override"><code>function doSomething(input: number|string): boolean { if (input === 42 || input === '42') { return true; } else { return false; } } </code></pre> <p>Why am I allowed to call <code>array.some()</code> like this:</p> <pre class="lang-js prettyprint-override"><code>function doSomethingWithArray(input: number[]|string[]): boolean { return input.some(i =&gt; doSomething(i)); } </code></pre> <p>But not <code>array.every()</code> like this:</p> <pre class="lang-js prettyprint-override"><code>function doEverythingWithArray(input: number[]|string[]): boolean { return input.every(i =&gt; doSomething(i)); } </code></pre> <p>Which gives me this error:</p> <blockquote> <p>This expression is not callable. Each member of the union type '{ (predicate: (value: number, index: number, array: number[]) =&gt; value is S, thisArg?: any): this is S[]; (predicate: (value: number, index: number, array: number[]) =&gt; unknown, thisArg?: any): boolean; } | { ...; }' has signatures, but none of those signatures are compatible with each other.</p> </blockquote> <p>I don't understand the difference. In my mind either both should work, or neither. What am I missing?</p> <p>Note that <code>doSomething()</code> accepts <code>number|string</code> as its argument, so it should work with every element of <code>number[]|array[]</code>, like it does for <code>array.some()</code>, shouldn't it?</p>
[ { "answer_id": 74390765, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "every()" }, { "answer_id": 74391020, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 1, "selected": false, "text": "every" }, { "answer_id": 74398142, "author": "jcalz", "author_id": 2887218, "author_profile": "https://Stackoverflow.com/users/2887218", "pm_score": 3, "selected": true, "text": "// Before TS3.3:\ndeclare const arr: string[] | number[];\narr.some(() => true); // error\narr.map(() => 1); // error\narr.every(() => true); // error\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1934772/" ]
74,390,232
<p>I want to hook a variable called <code>test</code> using an anonymous function.</p> <pre class="lang-js prettyprint-override"><code>!function() { let test = true; return !test // it writes true to console but i need to write false }() </code></pre> <p>I except that code will show in console <code>false</code> instead of <code>true</code>.</p>
[ { "answer_id": 74390765, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "every()" }, { "answer_id": 74391020, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 1, "selected": false, "text": "every" }, { "answer_id": 74398142, "author": "jcalz", "author_id": 2887218, "author_profile": "https://Stackoverflow.com/users/2887218", "pm_score": 3, "selected": true, "text": "// Before TS3.3:\ndeclare const arr: string[] | number[];\narr.some(() => true); // error\narr.map(() => 1); // error\narr.every(() => true); // error\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469108/" ]
74,390,246
<p>I am learning how to use the .get() for tkinter, and trying to write this basic GUI that can store, process, and display data depending on a user input.</p> <p>Now (I am fairly new to this, so I am probably wrong) to my knowledge, I need to use the .get() and store it into a variable for future uses.</p> <p>Now here are my codes, but when I run the code, it kept saying I did not define my variable in the function I defined.</p> <p>I wrote in Pycharm, the variable I wrote in the first line of the function just keep turning grey.</p> <p>Why is this happening, am I missing something important?</p> <p>Sidenote:</p> <p>I have done some research and saw some result regarding using the following method:</p> <ol> <li>StringVar()</li> <li>fstring, f&quot;{}&quot;</li> </ol> <p>but I still can't figure out how that works and how it is affecting my code that Python is not accepting my variable.</p> <pre class="lang-py prettyprint-override"><code> Import tkinter as tk def event(): expEntry = entry.get() window = tk.Tk() entry = tk.Entry(window) button = tk.Button(window,commnad=event()) expEntry = tk.Label(window,text = expEntry) entry.pack() button.pack() expEntry.pack() window.mainloop() </code></pre>
[ { "answer_id": 74390765, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "every()" }, { "answer_id": 74391020, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 1, "selected": false, "text": "every" }, { "answer_id": 74398142, "author": "jcalz", "author_id": 2887218, "author_profile": "https://Stackoverflow.com/users/2887218", "pm_score": 3, "selected": true, "text": "// Before TS3.3:\ndeclare const arr: string[] | number[];\narr.some(() => true); // error\narr.map(() => 1); // error\narr.every(() => true); // error\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469101/" ]
74,390,263
<p>Problem appeared just today - previously it was working fine. Suddenly getting the error:</p> <pre><code>##[error]System.ArgumentNullException: Value cannot be null. (Parameter ‘input’) at System.Text.RegularExpressions.Regex.Replace(String input, String replacement) at Microsoft.VisualStudio.Services.Agent.Util.StringUtil.DeactivateVsoCommands(String input) at Microsoft.VisualStudio.Services.Agent.Worker.WorkerUtilities.DeactivateVsoCommandsFromJobMessageVariables(AgentJobRequestMessage message) at Microsoft.VisualStudio.Services.Agent.Worker.Worker.RunAsync(String pipeIn, String pipeOut) at Microsoft.VisualStudio.Services.Agent.Worker.Program.MainAsync(IHostContext context, String[] args) Error reported in diagnostic logs. Please examine the log for more details. - /home/vsts/agents/2.213.1/_diag/Worker_20221110-110312-utc.log Pool: Azure Pipelines Image: ubuntu-latest Queued: Today at 13:00 [manage parallel jobs] The agent request is already running or has already completed. </code></pre> <p>The stage seems waiting for the agent and after that fails with above message.</p> <p>After cancelling the pipeline and restarting the stage - the same error. What is the problem? What would be temporary workaround?</p> <p>Our pipelines are defined with yaml. I have no access to the log indicated above so can not provide more details from there.</p> <p>Regards,</p> <p>Roman.</p> <p>UPDATE 14/11/2022: After applying patch 2.213.2 to MS hosted agents Microsoft has resolved the issue</p>
[ { "answer_id": 74390765, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "every()" }, { "answer_id": 74391020, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 1, "selected": false, "text": "every" }, { "answer_id": 74398142, "author": "jcalz", "author_id": 2887218, "author_profile": "https://Stackoverflow.com/users/2887218", "pm_score": 3, "selected": true, "text": "// Before TS3.3:\ndeclare const arr: string[] | number[];\narr.some(() => true); // error\narr.map(() => 1); // error\narr.every(() => true); // error\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403412/" ]
74,390,270
<p>I loop trough an eloquent Collection and I want to add the data to another Collection called &quot;$tagCollection&quot;. If an entry with the same tag_id already exists I only want to increase the rating-column for the existing entry. At the moment it looks like this. Has anyone an Idea?</p> <pre><code>$tagCollection = collect(); $entries-&gt;each(function($entry) use($tagCollection){ $tagId = $entry-&gt;tag_id; //something like this if($tagCollection-&gt;contains('tag_id', $tagId)){ $tagCollection-&gt;update ('rating' =&gt; $oldRating + 0.5) } else{ $tagCollection-&gt;push(array( 'tag_id' =&gt; $tagId, 'rating' =&gt; 0.35 )); } }); </code></pre> <p>I also tried to use -&gt;pull() to remove the Item out of the Collection and then push it again with the new rating but I also do not know how</p>
[ { "answer_id": 74390579, "author": "N69S", "author_id": 4369919, "author_profile": "https://Stackoverflow.com/users/4369919", "pm_score": 0, "selected": false, "text": "$entries" }, { "answer_id": 74391871, "author": "Ross_102", "author_id": 3657308, "author_profile": "https://Stackoverflow.com/users/3657308", "pm_score": 2, "selected": true, "text": "$tagArray = [];\n$entries->each(function ($entry) use (&$tagArray) {\n if (isset($tagArray[$entry['tag_id']])) {\n $tagArray[$entry['tag_id']] += 0.5;\n } else {\n $tagArray[$entry['tag_id']] = 0.35;\n }\n});\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9739643/" ]
74,390,272
<p>I have a CSV file with company data with 22 rows and 6500 columns. The columns have the same names and I should get the columns with the same names stacked into individual columns according to their headers.</p> <p>I have now the data in one df like this:</p> <pre><code>Y C Y C Y C 1. a 1. b. 1. c. 2. a. 2. b. 2. c. </code></pre> <p>and I need to get it like this:</p> <pre><code>Y C 1. a. 2. a. 1. b. 2. b. 1. c. 2. c. </code></pre>
[ { "answer_id": 74390579, "author": "N69S", "author_id": 4369919, "author_profile": "https://Stackoverflow.com/users/4369919", "pm_score": 0, "selected": false, "text": "$entries" }, { "answer_id": 74391871, "author": "Ross_102", "author_id": 3657308, "author_profile": "https://Stackoverflow.com/users/3657308", "pm_score": 2, "selected": true, "text": "$tagArray = [];\n$entries->each(function ($entry) use (&$tagArray) {\n if (isset($tagArray[$entry['tag_id']])) {\n $tagArray[$entry['tag_id']] += 0.5;\n } else {\n $tagArray[$entry['tag_id']] = 0.35;\n }\n});\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20441021/" ]
74,390,322
<p>I am trying to run a Hello World application with Spring Boot on IntelliJ IDEA. I have the following code:</p> <pre><code>package com.example.springbootexample; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class SpringBootExampleApplication { public static void main(String[] args) { SpringApplication.run(SpringBootExampleApplication.class, args); } } </code></pre> <p>After building and running the code I get the following error message:</p> <pre><code>*************************** APPLICATION FAILED TO START *************************** Description: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. Process finished with exit code 1 </code></pre> <p>Trying to identify the process that uses the port <code>8080</code> I run <code>lsof -i :8080</code>, but I get a blank output. What could the problem be?</p>
[ { "answer_id": 74390579, "author": "N69S", "author_id": 4369919, "author_profile": "https://Stackoverflow.com/users/4369919", "pm_score": 0, "selected": false, "text": "$entries" }, { "answer_id": 74391871, "author": "Ross_102", "author_id": 3657308, "author_profile": "https://Stackoverflow.com/users/3657308", "pm_score": 2, "selected": true, "text": "$tagArray = [];\n$entries->each(function ($entry) use (&$tagArray) {\n if (isset($tagArray[$entry['tag_id']])) {\n $tagArray[$entry['tag_id']] += 0.5;\n } else {\n $tagArray[$entry['tag_id']] = 0.35;\n }\n});\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5559342/" ]
74,390,338
<p>We have a Grafana Service with two Grafana PODs in our Kubernetes Cluster. Everytime an alert is triggered both instances will fire the alert.</p> <p>To prevent this from happening, we tried activating the HA alerting, which basically consists of the following configuration:</p> <pre><code>[unified_alerting] enabled = true ha_listen_address = ${POD_IP}:9094 ha_peers = ${POD_IP}:9094 </code></pre> <p>Since every POD only knows it's own IP address <code>${POD_IP}</code>, we are not able to set the ha_peers value correctly to contain all instances (like described in the Grafana documentation). Therefore we still get duplicate alerts.</p> <p>Also, if one instance is terminated and another will start, I'm not quite sure how the ha_peers of the remaining active POD will be updated.</p> <p>We'd like to avoid using work-arouds like fixed IPs because this would go against Kubernetes practices.</p> <p>Does anyone one know how to circumvent or solve this problem?</p>
[ { "answer_id": 74392620, "author": "Jan Garaj", "author_id": 3348604, "author_profile": "https://Stackoverflow.com/users/3348604", "pm_score": 1, "selected": false, "text": " unified_alerting:\n enabled: true\n ha_peers: {{ Name }}-headless:9094\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6380489/" ]
74,390,340
<p>I want to display numbers in grid which should auto adjust (rows and columns) based on screen size (Mobile, Tablet, PC)</p> <p>May I know which classes to apply ? Since I have no idea which one to use to make it responsive grid.</p> <p>I tried many classes none worked.</p> <p>Please find the tailwind code here, <a href="https://play.tailwindcss.com/zPTf9qz6vm" rel="nofollow noreferrer">https://play.tailwindcss.com/zPTf9qz6vm</a></p> <pre><code>&lt;div class=&quot;grid grid-flow-col gap-2&quot;&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;03&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;div&gt;04&lt;/div&gt; &lt;div&gt;05&lt;/div&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74392620, "author": "Jan Garaj", "author_id": 3348604, "author_profile": "https://Stackoverflow.com/users/3348604", "pm_score": 1, "selected": false, "text": " unified_alerting:\n enabled: true\n ha_peers: {{ Name }}-headless:9094\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4968403/" ]
74,390,363
<p>In regular <code>JavaScript</code>, one can write a <code>for loop</code> using the for...of syntax. Is this possible with <code>observablehq</code>?</p> <pre><code>const array1 = [1, 2, 3]; for (const element of array1) { console.log(element); } </code></pre>
[ { "answer_id": 74390566, "author": "Gerardo Furtado", "author_id": 5768908, "author_profile": "https://Stackoverflow.com/users/5768908", "pm_score": 1, "selected": false, "text": "const" }, { "answer_id": 74391399, "author": "mbostock", "author_id": 365814, "author_profile": "https://Stackoverflow.com/users/365814", "pm_score": 3, "selected": true, "text": "array1 = {\n const array = [1, 2, 3];\n\n for (const element of array) {\n console.log(element);\n }\n\n return array;\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12347708/" ]
74,390,365
<p>I would like to obtain a cumulative sum through years and for each entity.</p> <p>Here below an example, and what I have tried so far:</p> <pre class="lang-r prettyprint-override"><code>data&lt;-data.frame(id=c(&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;b&quot;,&quot;a&quot;,&quot;b&quot;,&quot;b&quot;),cars=c(1,1,1,1,1,1,1),year=c(2001,2001,2002,2003,2003,2003,2004)) </code></pre> <h1>I have tried :</h1> <pre class="lang-r prettyprint-override"><code>library(tidyverse) library(stringr) library(dplyr) library(tidyr) data %&gt;% group_by(id,year) %&gt;% mutate(csum = (cumsum(cars))) %&gt;% top_n(1, csum) id cars year csum &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; 1 a 1 2001 2 2 a 1 2002 1 3 a 1 2003 1 4 b 1 2003 2 5 b 1 2004 1 </code></pre> <p>This is what I would like:</p> <pre class="lang-r prettyprint-override"><code> id cars year csum &lt;chr&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; 1 a 1 2001 2 2 a 1 2002 3 3 a 1 2003 4 4 b 1 2003 2 5 b 1 2004 3 </code></pre> <p>Thank you very much.</p>
[ { "answer_id": 74390478, "author": "Juan C", "author_id": 9462829, "author_profile": "https://Stackoverflow.com/users/9462829", "pm_score": 1, "selected": false, "text": "data %>% group_by(id, year) %>% summarise(sum_cars = sum(cars)) %>% \ngroup_by(id) %>% mutate(csum_cars = cumsum(sum_cars), .keep = 'unused')\n" }, { "answer_id": 74390518, "author": "Abdur Rohman", "author_id": 14812170, "author_profile": "https://Stackoverflow.com/users/14812170", "pm_score": 2, "selected": false, "text": "dat %>% group_by(id) %>% count(cars,year) %>%\nmutate(csum = cumsum(n)) %>% select(-c(cars,n))\n# A tibble: 5 × 3\n# Groups: id [2]\n id year csum\n <chr> <dbl> <int>\n1 a 2001 2\n2 a 2002 3\n3 a 2003 4\n4 b 2003 2\n5 b 2004 3\n" }, { "answer_id": 74390607, "author": "NathanLVQ", "author_id": 20419201, "author_profile": "https://Stackoverflow.com/users/20419201", "pm_score": 2, "selected": true, "text": "aggregate" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16495989/" ]
74,390,370
<p>I am pretty new to Javascript. I am trying to get the sum of the grades of the 3 student properties i have declared. The problem is that i dont understand why it says undefined on my &quot;grade&quot; value. Also if there is any other easier way to find the values of the grades of each student other than writing it like:</p> <p>classroom.student1.grade + classroom.student2.grade + classroom.student3.grade</p> <p>Thank you in advance!</p> <pre><code>let classroom = { numberOfChairs: 20, numberofTables: 10, student1: [ {fullName: &quot;&quot;, age: &quot;&quot;, grade:8, electronics: { brand:&quot;&quot;, model:&quot;&quot;, batteryCapacity:&quot;&quot; }} ], student2: [ {fullName: &quot;&quot;, age: &quot;&quot;, grade:8, electronics: { brand:&quot;&quot;, model:&quot;&quot;, batteryCapacity:&quot;&quot; }} ], student3:[ {fullName: &quot;&quot;, age: &quot;&quot;, grade: 8, electronics: { brand:&quot;&quot;, model:&quot;&quot;, batteryCapacity:&quot;&quot; }} ], teachers: [ {fullName:&quot;&quot;, yearsOfExperience:&quot;&quot;, salary:&quot;&quot;} ], }; function getGrades() { grades = classroom.student1.grade + classroom.student2.grade + classroom.student3.grade console.log(grades) } getGrades(); </code></pre> <p>`</p> <p>I am trying to find out why it says that my value of the students is &quot;undefined&quot; and what i shall write differently for it to find the value.</p>
[ { "answer_id": 74390418, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "classroom.student1.grade\n" }, { "answer_id": 74390461, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": true, "text": "let classroom = {\nnumberOfChairs: 20,\nnumberofTables: 10,\nstudent1: {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent2:\n {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent3:\n {fullName: \"\", \n age: \"\", \n grade: 8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nteachers: [\n {fullName:\"\", yearsOfExperience:\"\", salary:\"\"}\n],\n};\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20109299/" ]
74,390,382
<p>I am making a memory game and when I press a card it's supposed to &quot;flip&quot;. (Simple deck of cards ace-9) I've added the code below to a function &quot;addAcard&quot; but I have to convert my string into a sprite to be able to call it in the assets where I have stored pictures of all of my cards. The rank is the inparameter in the function, 0-9 as the cards expected values. Summary of the problem is that the sprite s1 stays empty.</p> <pre><code> c.name = &quot;&quot;+rank; string nameOfCard = &quot;&quot;; string cardNumber = &quot;&quot;; if(rank == 0) cardNumber = &quot;ace&quot;; else cardNumber = &quot;&quot; + (rank+1); nameOfCard = cardNumber + &quot;_Of_Hearts&quot;; Sprite s1 = (Sprite)(Resources.Load&lt;Sprite&gt;(nameOfCard)); print (&quot;s1:&quot; + s1); GameObject.Find(&quot;&quot;+rank).GetComponent&lt;tile&gt; ().setOriginalSprite (s1); </code></pre> <p>I've tried looking around as it may been a typo I can't find or the row where I create s1 itself doesn't work anymore since the guides I'm watching could be done on different versions of Unity. I'm on 2021.3.8f1. Both the nameOfCard and cardNumber creates the expected results.</p>
[ { "answer_id": 74390418, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "classroom.student1.grade\n" }, { "answer_id": 74390461, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": true, "text": "let classroom = {\nnumberOfChairs: 20,\nnumberofTables: 10,\nstudent1: {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent2:\n {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent3:\n {fullName: \"\", \n age: \"\", \n grade: 8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nteachers: [\n {fullName:\"\", yearsOfExperience:\"\", salary:\"\"}\n],\n};\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20113184/" ]
74,390,430
<p>I try to send an email in c# with <strong>System.Net.Mail</strong></p> <pre><code>string MsgBody = string.Format(@&quot;Votre espace Cloud a été créé sur Patrimoine Click.&lt;br&gt;Vous pouvez vous y connecter en cliquant &lt;a href=&quot;&quot;https://patrimoine-click.netexplorer.pro&quot;&quot;&gt;ici&lt;/a&gt;&lt;br&gt;&lt;br&gt;Votre identifiant est : &lt;strong&gt;{0}&lt;/strong&gt;&lt;br&gt;Votre mot de passe par défaut est : &lt;strong&gt;{1}&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Nous vous invitons à le changer à la première connexion.&lt;br&gt;&lt;br&gt;L'équipe PatrimoineClick&quot;, user.Email, string.Concat(user.FirstName, user.LastName, &quot;_PATRIMOINECLICK&quot;)); MailRequest m = new() { Subject = &quot;Patrimoine Click : votre espace Cloud a été créé.&quot;, ToEmail = user.Email, Body = MsgBody, }; string MsgErreur = _traitement.EnvoieMail(m); </code></pre> <p>The problem is the href in the MsgBody.</p> <pre><code>&lt;a href=&quot;&quot;https://patrimoine-click.netexplorer.pro&quot;&quot;&gt;ici&lt;/a&gt; </code></pre> <p>When I put it, the message is not sent but there's no error. When I remove it, the message is sent correctly.</p> <p>I think there's a problem with quotes.</p> <p>Any idea ?</p> <p>Thanks,</p>
[ { "answer_id": 74390418, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "classroom.student1.grade\n" }, { "answer_id": 74390461, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": true, "text": "let classroom = {\nnumberOfChairs: 20,\nnumberofTables: 10,\nstudent1: {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent2:\n {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent3:\n {fullName: \"\", \n age: \"\", \n grade: 8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nteachers: [\n {fullName:\"\", yearsOfExperience:\"\", salary:\"\"}\n],\n};\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642324/" ]
74,390,435
<p>I have an abstract class BaseEntity which contains fields I want to share with multiple objects inside my project.</p> <pre><code> @MappedSuperclass @AllArgsConstructor @NoArgsConstructor @Data public abstract class BaseEntity { @Id @Column(name = &quot;objectId&quot;, insertable = false, updatable = false) @GeneratedValue(strategy = GenerationType.AUTO) private long objectId; @Column(name = &quot;createdDate&quot;, updatable = false/*, columnDefinition=&quot;TIMESTAMP DEFAULT CURRENT_TIMESTAMP&quot;*/) @CreationTimestamp private Date createdDate; @Column(name = &quot;updatedDate&quot;/*, columnDefinition=&quot;TIMESTAMP DEFAULT CURRENT_TIMESTAMP&quot;*/) @UpdateTimestamp private Date updatedDate; @Column(name = &quot;active&quot;, columnDefinition = &quot;boolean default false&quot;) private boolean active; } </code></pre> <p>I've multiple entities that are inherited from this class</p> <p>For my example let's take two of them:</p> <ol> <li>User</li> <li>Contact</li> </ol> <p>While saving a <code>User</code> object on the DB I can see the <code>objectId</code> field is getting incremented, but as well for another object such as <code>Contact</code></p> <p>For example:</p> <p>I created an instance of User and saved it on DB, After persisting I can see my <code>User.objectId = 1</code>.</p> <p>After that I created an instance of Contact and saved it on DB, After persisting I can see my <code>Contact.objectId = 2</code></p> <p>How can I make the field <code>objectId</code> increment separately for each Entity?</p> <p>Thanks.</p>
[ { "answer_id": 74390418, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "classroom.student1.grade\n" }, { "answer_id": 74390461, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": true, "text": "let classroom = {\nnumberOfChairs: 20,\nnumberofTables: 10,\nstudent1: {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent2:\n {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent3:\n {fullName: \"\", \n age: \"\", \n grade: 8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nteachers: [\n {fullName:\"\", yearsOfExperience:\"\", salary:\"\"}\n],\n};\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6356090/" ]
74,390,439
<pre><code> public static void main(String args[]){ extract(&quot;e:\\&quot;); } public static void extract(String p){ File f=new File(p); File l[]=f.listFiles(); int counter = 0; for(File x:l){ if(x.isDirectory()) extract(x.getPath()); else if(x.getName().endsWith(&quot;.mp3&quot;))){ counter = counter + 1; } } // I want to count and return value at last } </code></pre> <p>Using this method(above), resets the counter every time when for loop ends. So here, I want to count even when the for loop ends so that I can keep track of the number of <code>.mp3</code> files.</p> <p>I want to count and return value at last.</p>
[ { "answer_id": 74390418, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "classroom.student1.grade\n" }, { "answer_id": 74390461, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": true, "text": "let classroom = {\nnumberOfChairs: 20,\nnumberofTables: 10,\nstudent1: {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent2:\n {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent3:\n {fullName: \"\", \n age: \"\", \n grade: 8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nteachers: [\n {fullName:\"\", yearsOfExperience:\"\", salary:\"\"}\n],\n};\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15816577/" ]
74,390,440
<p>my code is in <a href="https://codepen.io/tutsplus/pen/XWZqGgX" rel="nofollow noreferrer">codepen</a> how can i add breakline / new line between title and table ?</p> <pre><code> &lt;li class=&quot;slide&quot;&gt; &lt;H1&gt;TITLE&lt;/H1&gt; &lt;br /&gt; &lt;table border=1&gt; &lt;tr&gt; &lt;td&gt;qdf&lt;/td&gt; &lt;td&gt;qdf&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/li&gt; </code></pre> <p>and css:</p> <pre><code>.slide { width: 100%; height: 100%; flex: 1 0 100%; display: flex; justify-content: center; align-items: center; } </code></pre>
[ { "answer_id": 74390418, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "classroom.student1.grade\n" }, { "answer_id": 74390461, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 1, "selected": true, "text": "let classroom = {\nnumberOfChairs: 20,\nnumberofTables: 10,\nstudent1: {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent2:\n {fullName: \"\", \n age: \"\", \n grade:8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nstudent3:\n {fullName: \"\", \n age: \"\", \n grade: 8,\n electronics: {\n brand:\"\", \n model:\"\",\n batteryCapacity:\"\"\n }},\nteachers: [\n {fullName:\"\", yearsOfExperience:\"\", salary:\"\"}\n],\n};\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/609511/" ]
74,390,441
<p>Seemingly similar to <a href="https://stackoverflow.com/questions/13674031/how-to-get-the-top-10-values-in-postgresql">How to get the top 10 values in postgresql?</a>, yet somehow very different.</p> <p>We'll set it up similar to that question:</p> <p>I have a postgresql table: <code>Scores(score integer)</code>.</p> <p>How would I get the highest 99% of the scores? We cannot say that we know beforehand how many rows there are, so we can't use the same limit to an integer trick. SQL Server has an easy <code>SELECT TOP</code> syntax -- is there anything similarly simple in the postgresql world?</p>
[ { "answer_id": 74390618, "author": "a_horse_with_no_name", "author_id": 330315, "author_profile": "https://Stackoverflow.com/users/330315", "pm_score": 3, "selected": true, "text": "percent_rank()" }, { "answer_id": 74390622, "author": "Haleemur Ali", "author_id": 2570261, "author_profile": "https://Stackoverflow.com/users/2570261", "pm_score": 1, "selected": false, "text": "-- following query generates 1000 rows with random \n-- scores and selects the 99th percentile using the ntile function.\n-- because the chance of the same random value appearing twice is extremely\n-- small, the result should in most cases yield 10 rows.\nwith scores as (\n select\n id\n , random() score\n from generate_series(1, 1000) id\n )\n, percentiles AS (\n select \n *\n , ntile(100) over (order by score) tile\n from scores\n)\nselect \n id\n, score\nfrom percentiles \nwhere tile > 99\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2595659/" ]
74,390,468
<p>I'm having this strange error (sometimes works sometimes does not):</p> <blockquote> <p>no such element: Unable to locate element: {&quot;method&quot;:&quot;xpath&quot;,&quot;selector&quot;:&quot;//*[@id=&quot;card-id-oidc-i&quot;]/a&quot;}</p> </blockquote> <p>My button has this:</p> <pre><code>&lt;a href=&quot;/auth/realms/Global-Realm/broker/id-oidc-i/login?client_id=web&amp;amp;tab_id=Doz54nelUC0&amp;amp;session_code=gwAePmGfpQ2hBLommJO7Rswc1gNkB90Ctc4&quot;&gt; &lt;div style=&quot;width:100%;height: 40px;&quot;&gt; &lt;span class=&quot;arrow arrow-bar is-right&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;image&quot; style=&quot;background-repeat: no-repeat;margin:auto; width:115px;height:120px&quot;&gt;&lt;/div&gt; &lt;div style=&quot;margin-top: 10px;min-width:170px&quot;&gt; &lt;h4 style=&quot;text-align:center;&quot;&gt;&lt;b&gt;log in&lt;/b&gt;&lt;/h4&gt; &lt;/div&gt; &lt;/a&gt; </code></pre> <p>It's XPATH is:</p> <pre><code>//*[@id=&quot;card-id-oidc-i&quot;]/a </code></pre> <p>I did this:</p> <pre><code>driver.findElement(By.xpath(&quot;//*[@id=\&quot;card-id-oidc-i\&quot;]/a&quot;)).click(); </code></pre> <p>It is strange because sometimes works just fine but sometimes it fails.</p> <p>Why?</p>
[ { "answer_id": 74390561, "author": "Prophet", "author_id": 3485434, "author_profile": "https://Stackoverflow.com/users/3485434", "pm_score": 3, "selected": true, "text": "WebDriverWait wait = new WebDriverWait(driver, 30); \nwait.until(ExpectedConditions.elementToBeClickable(By.xpath(\"//*[@id='card-id-oidc-i']/a\"))).click();\n" }, { "answer_id": 74390642, "author": "Saidamir", "author_id": 15148870, "author_profile": "https://Stackoverflow.com/users/15148870", "pm_score": 1, "selected": false, "text": "NoSuchElementException" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14012751/" ]
74,390,498
<p>How can I take words from STDIN, then put them into an array I can sort later? this is the code I have for taking in STDIN.</p> <pre><code>printf(&quot;Please enter words to sort:\n&quot;); char *line = NULL; size_t len = 0; ssize_t lineSize = 0; lineSize = getline(&amp;line, &amp;len, stdin); printf(&quot;You entered: %swhich has %zu chars.\n&quot;, line, lineSize - 1); free(line); return 0; </code></pre>
[ { "answer_id": 74392974, "author": "Andreas Wenzel", "author_id": 12149471, "author_profile": "https://Stackoverflow.com/users/12149471", "pm_score": 1, "selected": false, "text": "char *" }, { "answer_id": 74393817, "author": "chux - Reinstate Monica", "author_id": 2410359, "author_profile": "https://Stackoverflow.com/users/2410359", "pm_score": 0, "selected": false, "text": "WORDS_MAX" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20352716/" ]
74,390,551
<p>On <code>example.com</code> I have an iframe which loads <code>anotherexample.com</code>. The problem I am having though is if I load <code>anotherexample.com</code> directly (outside of the iframe) the localStorage isn't shared with the iframed <code>anotherexample.com</code>.</p> <p>Is this possible to achieve?</p> <p>An example of the issue can be seen by visiting <a href="https://eskimo.dev/localstorage/" rel="nofollow noreferrer">https://eskimo.dev/localstorage/</a>, then visiting <a href="https://eskimo.ooo/localstorage/iframe" rel="nofollow noreferrer">https://eskimo.ooo/localstorage/iframe</a> which iframes the first link. The iframe isn't using the localStorage from the previous.</p>
[ { "answer_id": 74547039, "author": "L.Raudel", "author_id": 16340303, "author_profile": "https://Stackoverflow.com/users/16340303", "pm_score": -1, "selected": false, "text": "/iframe" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9248335/" ]
74,390,581
<p>I am trying to install erlang 25 (and elixir 1.13) on my ubuntu VM, but the default version installed by apt is erlang 24. I've tried both :</p> <pre><code>sudo wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb &amp;&amp; sudo dpkg -i erlang-solutions_1.0_all.d sudo apt update </code></pre> <p>and</p> <pre><code>sudo wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb &amp;&amp; sudo dpkg -i erlang-solutions_2.0_all.d sudo apt update </code></pre> <p>but in both case, running <code>apt-cache policy esl-erlang</code> didn't show the desired version. I have recently installed erlang 25 on a identical vm, and I don't remember struggling at all, so I'm guessing there's a simple way of doing it that I just forgot ?</p> <p>I hope you can help me, thank you !</p>
[ { "answer_id": 74402692, "author": "Kiko Fernandez", "author_id": 470655, "author_profile": "https://Stackoverflow.com/users/470655", "pm_score": 1, "selected": false, "text": "apt-get install erlang\n" }, { "answer_id": 74491267, "author": "JNLK", "author_id": 1348270, "author_profile": "https://Stackoverflow.com/users/1348270", "pm_score": 0, "selected": false, "text": " $ git clone https://github.com/robisonsantos/evm /tmp/evm/\n $ cd /tmp/evm/\n $ /tmp/evm/install\n $ echo 'source ~/.evm/scripts/evm' >> ~/.bashrc\n $ bash\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18446325/" ]
74,390,625
<p>I have the following code below.</p> <p>I am trying to carry out a mapping where the value 0 in the dataframe column 'caffeine' is replaced by 'no' and any other value aside 0 is replaced by 'yes'.</p> <p>However, the following command, the values that are not 0 are replaced with 'NaN' rather than 'yes'.</p> <p>Would be so grateful for a helping hand!</p> <pre><code>newerdf = newdf.copy() newerdf['caffeine'].max() newerdf['caffeine'] = newerdf['caffeine'].map({0:'no',(1,2,3,4,5,6,7,8,9,10):'yes'}) newerdf.groupby(['caffeine'])['distance'].mean() </code></pre> <pre><code>newdf['caffeine'] 0 0.0 1 3.0 2 1.0 3 2.0 5 1.0 ... 911 1.0 912 1.0 913 2.0 914 1.0 915 2.0 </code></pre> <pre><code>newerdf['caffeine']: 0 no 1 NaN 2 NaN 3 NaN 5 NaN ... 911 NaN 912 NaN 913 NaN 914 NaN 915 NaN </code></pre>
[ { "answer_id": 74390704, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 1, "selected": false, "text": "newerdf['caffeine'] = np.where(newerdf['caffeine'] == 0,'no','yes')\n" }, { "answer_id": 74390715, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 2, "selected": false, "text": "# check value of caffeine, if it zero, then map the boolean result to Yes, No\ndf['caffeine']=df['caffeine'].eq(0).map({True:'no', False:'yes'})\n" }, { "answer_id": 74390735, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 1, "selected": false, "text": "map" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12985497/" ]
74,390,627
<p>working on Python script. I get a result that is list:</p> <p><code>a = [{'S_RAF': {'C_C106': {'D_1103': 'AVE', 'D_1104': '3-AB3242'}}}, {'S_RAF': {'C_C106': {'D_1103': 'OI', 'D_1104': '31503302130'}}}, {'S_RAF': {'C_C106': {'D_1103': 'PQ', 'D_1104': 'IBAN3102495934895'}}}]</code></p> <p>And I would like to get the value of Key: D_1104, when the value for key D_1103 is PQ.</p> <p>what would be best way in python to get the value of this key in element S_RAF/C_C106/{D_1103=PQ}. function should return: IBAN3102495934895.</p> <p>Thanks</p> <p>I tried:</p> <p><code>a[2]['C_C106']['D_1104'] </code></p> <p>but is not correct.</p>
[ { "answer_id": 74390704, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 1, "selected": false, "text": "newerdf['caffeine'] = np.where(newerdf['caffeine'] == 0,'no','yes')\n" }, { "answer_id": 74390715, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 2, "selected": false, "text": "# check value of caffeine, if it zero, then map the boolean result to Yes, No\ndf['caffeine']=df['caffeine'].eq(0).map({True:'no', False:'yes'})\n" }, { "answer_id": 74390735, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 1, "selected": false, "text": "map" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469396/" ]
74,390,669
<p>When you run the C code below, you get a different results almost everytime(None of them are altogether correct).</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main() { int i,j; int s[10][4]={{202201,90,13,21},{202202,32,24,12},{202203,23,53,76},{202204,21,43,64},{202205,12,45,89},{202206,98,99,100},{202207,12,0,0},{202208,0,0,0},{202209,98,12,34},{202210,23,65,34}}; int ave[10],sum[10]; printf(&quot;No. MA EN CN\n&quot;); for(i=0;i&lt;10;i++) { for(j=0;j&lt;4;j++) printf(&quot;%4d&quot;,s[i][j]); printf(&quot;\n&quot;); } for(i=0;i&lt;10;i++) { for(j=1;j&lt;4;j++) sum[i]=s[i][j]+sum[i]; printf(&quot;%d\n&quot;,sum[i]); } return 0; } </code></pre> <p>What's happening? What's the mechanics behind it? How can I fix it?</p>
[ { "answer_id": 74390704, "author": "Celius Stingher", "author_id": 11897007, "author_profile": "https://Stackoverflow.com/users/11897007", "pm_score": 1, "selected": false, "text": "newerdf['caffeine'] = np.where(newerdf['caffeine'] == 0,'no','yes')\n" }, { "answer_id": 74390715, "author": "Naveed", "author_id": 3494754, "author_profile": "https://Stackoverflow.com/users/3494754", "pm_score": 2, "selected": false, "text": "# check value of caffeine, if it zero, then map the boolean result to Yes, No\ndf['caffeine']=df['caffeine'].eq(0).map({True:'no', False:'yes'})\n" }, { "answer_id": 74390735, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 1, "selected": false, "text": "map" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469441/" ]
74,390,692
<p>I need copy pdf files between Source and Destination server, but pdf files are stored on Source server only as shortcuts to web address (FileName.pdf.url files).</p> <p>Network source/destination shares mapped as disk D: and E:</p> <pre><code>Copy-Item -Path D:\FileName.pdf.url -Destination E:\FileName.pdf </code></pre> <p>copy only .url shortcut, I need copy pdf file.</p> <p>When I open properties of file by Windows explorer in 'Web Content' tab visible is URL address. For example <a href="https://ServerName.int:11443/AFUWeb/RetrieveDocument.do?r=ieXZcv-OHZHB465.pdf" rel="nofollow noreferrer">https://ServerName.int:11443/AFUWeb/RetrieveDocument.do?r=ieXZcv-OHZHB465.pdf</a>.</p> <p>powershell 5.1 w2k12</p> <p><strong>How received URL info from powershell level.</strong></p> <p>Get-ChildItem, Get-ItemProperty doesn't received this information for .url files</p> <p>I found out how download pdf file from remote server, but need pdf web address to provide URL address as variable for 'DownloadFile' as below</p> <pre><code>$NewFile = New-Object System.Net.WebClient $NewFile.DownloadFile(&quot;**https://ServerName.int:11443/AFUWeb/RetrieveDocument.do?r=ieXZcv-OHZHB465.pdf**&quot;,&quot;C:\Temp\test.pdf&quot;) </code></pre> <pre><code>$NewFile = New-Object System.Net.WebClient $NewFile.DownloadFile(&quot;**$URLVariable**&quot;,&quot;C:\Temp\FileName.pdf&quot;) </code></pre>
[ { "answer_id": 74391710, "author": "mklement0", "author_id": 45375, "author_profile": "https://Stackoverflow.com/users/45375", "pm_score": 1, "selected": false, "text": "WScript.Shell" }, { "answer_id": 74391896, "author": "Vinc", "author_id": 13712249, "author_profile": "https://Stackoverflow.com/users/13712249", "pm_score": 0, "selected": false, "text": "# Get all .url files\n$Source = \"D:\\\"\n$UrlFiles = Get-ChildItem -File -Path $Source -Filter \"*.url*\"\n\n# Get file content, extract URL from each file and download it\nforeach ($UrlFile in $UrlFiles) {\n $Content = Get-Content $UrlFile.FullName -Raw\n $URL = [regex]::Match($Content,\"(?<=\\=).*\").Value\n $SaveTo = \"E:\\$($UrlFile.BaseName)\"\n\n $NewFile = New-Object System.Net.WebClient\n $NewFile.DownloadFile($URL,$SaveTo)\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1952168/" ]
74,390,705
<p>In Android I often want to navigate is response to state change from a ViewModel. (for example, successful authentication triggers navigation to the user's home screen.)</p> <p>Is the best practice to trigger navigation from within the ViewModel? Is there an intentional mechanism to trigger navigation within a composable in response to a ViewModel state change?</p> <p>With Jetpack Compose the process for handling this use case is not obvious. If I try something like the following example navigation will occur, but the destination I navigate to will not behave correctly. I believe this is because the original composable function was not allowed to finish before navigation was invoked.</p> <pre><code>// Does not behave correctly. @Composable fun AuthScreen() { val screenState = viewModel.screenState.observeAsState() if(screenState.value is ScreenState.UserAuthenticated){ navController.navigate(&quot;/gameScreen&quot;) } else { LoginScreen() } } </code></pre> <p>I do observe the correct behavior if I use LauncedEffect as follows:</p> <pre><code>// Does behave correctly. @Composable fun AuthScreen() { val screenState = viewModel.screenState.observeAsState() if(screenState.value is ScreenState.UserAuthenticated){ LaunchedEffect(key1 = &quot;test&quot;) { navController.navigate(&quot;$/gameScreen&quot;) } } else { LoginScreen() } } </code></pre> <p>Is this correct? The documentation for LaunchedEffect states the following, but the meaning is not 100% clear to me:</p> <blockquote> <p>When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext. The coroutine will be cancelled and re-launched when LaunchedEffect is recomposed with a different key1, key2 or key3. The coroutine will be cancelled when the LaunchedEffect leaves the composition.</p> </blockquote>
[ { "answer_id": 74391028, "author": "z.y", "author_id": 19023745, "author_profile": "https://Stackoverflow.com/users/19023745", "pm_score": 2, "selected": false, "text": "// Does not behave correctly.\n@Composable fun AuthScreen() {\n val screenState = viewModel.screenState.observeAsState()\n if(screenState.value is ScreenState.UserAuthenticated){\n navController.navigate(\"/gameScreen\")\n } else {\n LoginScreen()\n }\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647098/" ]
74,390,729
<p>I am a linguist by trade and use Perl to help me organize my data so I am not at all proficient and my solutions are not very streamlined :) My problem today, is that I want to tag all occurrences of the items in a wordlist in a corpus of example sentences.</p> <p>I wrote a (sloppy) script for another experiment but it only identifies the first word from the list that it finds and then moves to the next. I need it to find all words in all sentences and on top of that, assign a tag in the second column of the wordlist. My head just cannot get around how to do this. Help!</p> <p>So say my wordlist looks like this (a tab delimited .txt file with 1 column for the word and 1 for the tag to be assigned, each word and tag on one line):</p> <pre><code>boy (\t) ID01 sleep (\t) ID02 dog (\t) ID03 hungry (\t) ID04 home (\t) ID05 </code></pre> <p>The original corpus would just be a tokenised .txt with one sentence per line, eg:</p> <pre><code>The boy and his dog met a hungry lion . They needed to catch up on sleep after the dog and the boy came home . </code></pre> <p>I ideally want output like the following:</p> <p>(1) A tagged corpus in the format:</p> <pre><code>The boy [ID01] and his dog [ID03] met a hungry [ID04] lion . They needed to catch up on sleep [ID02] after the dog [ID03] and the boy [ID01] came home [ID05]. </code></pre> <p>(2) A list of the words with their tags that were not found in the corpus at all. I previously just printed the words to a .txt and this worked fine.</p> <p>I hope this makes sense! Here is what I have used previously to find sentences containing the words. This code is based on a much simpler word list without the ID tags and I was just looking for any matches to see if my corpus at least contained some examples. How can I best adapt it? This took me ages to write but I am learning!</p> <p>Thank you!</p> <pre><code>use strict; use warnings; my %words; my %print; open (IN2, &quot;&lt;LemmasFromTagset.MG.2022-10-17.txt&quot;); #the wordlist while (my $s = &lt;IN2&gt;) { chomp $s; my $lcs = lc $s; $words{$lcs} = 1; } close(IN2); open (OUT, &quot;&gt;TaggedSentences.txt&quot;); #the final output with tagged sentences open (OUT2, &quot;&gt;NotFound.txt&quot;); #words for which there are no sentences foreach my $word (sort keys (%words)) { open (IN,&quot;&lt;all-sentences_cleaned.tagged.desentensised.txt&quot;); #the corpus print $word.&quot;\n&quot;; my $count = 0; while(my $s = &lt;IN&gt;) { chomp $s; my $lcs = lc $s; if ($lcs =~ /^(.*)(\W+)($word)(\W+)(.*)$/) { print OUT $word.&quot;\t&quot;.$s.&quot;\n&quot;; $count ++; } elsif ($lcs =~ /^($word)(\W+)(.*)$/) { print OUT $word.&quot;\t&quot;.$s.&quot;\n&quot;; $count ++; } } if ($count == 0) { print OUT2 $word.&quot;\n&quot;; } close(IN); } close(OUT); close (OUT2); </code></pre>
[ { "answer_id": 74391100, "author": "TLP", "author_id": 725418, "author_profile": "https://Stackoverflow.com/users/725418", "pm_score": 2, "selected": false, "text": "%words" }, { "answer_id": 74391547, "author": "pilcrow", "author_id": 132382, "author_profile": "https://Stackoverflow.com/users/132382", "pm_score": 2, "selected": false, "text": "my %words2ids; # will be { \"sleep\" => \"ID02\", \"boy\" => \"ID01\", ...}\n\nopen(my $lemmas, \"...\") or die;\nwhile (my $line = <$lemmas>) {\n chomp($line);\n my ($word, $id) = split \"\\t\", $line;\n $words2ids{ lc($word) } = $id; # note: lc($word)\n}\n" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20469177/" ]
74,390,730
<p>I have a list of strings in example:</p> <pre><code>['xxx', 'xxxyy', 'ccccy'] </code></pre> <p>and a normal string i.e. <code>String example1 = &quot;xxxyyy&quot;</code></p> <p>And I want to check if any of the strings in my list matches start of my example1 I dont need to know which strings match but only if example1 starts with any of the strings in the list.</p>
[ { "answer_id": 74390824, "author": "Rono", "author_id": 2292457, "author_profile": "https://Stackoverflow.com/users/2292457", "pm_score": 3, "selected": true, "text": "if (yourArray.Any(a => example1.StartsWith(a))\n" }, { "answer_id": 74392129, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 0, "selected": false, "text": "foreach" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9441773/" ]
74,390,732
<p>I have an array of objects that contains children, There will not always be children, sometimes there will be grandchildren How can I go through it in JAVA SCRIPT and print it?</p> <pre><code>[ { &quot;id&quot;: &quot;1&quot;, &quot;name&quot;: &quot;sara&quot;, &quot;children&quot;: [ { &quot;id&quot;: &quot;2&quot;, &quot;name&quot;: &quot;dian&quot; }, { &quot;id&quot;: &quot;3&quot;, &quot;name&quot;: &quot;michael&quot;, &quot;children&quot;: [ { &quot;id&quot;: &quot;4&quot;, &quot;name&quot;: &quot;dkny&quot; }, { &quot;id&quot;: &quot;5&quot;, &quot;name&quot;: &quot;Anne&quot; } ] } ] }, { &quot;id&quot;: &quot;6&quot;, &quot;name&quot;: &quot;Tommy&quot; }, { &quot;id&quot;: &quot;7&quot;, &quot;name&quot;: &quot;danken&quot;, &quot;children&quot;: [ { &quot;id&quot;: &quot;8&quot;, &quot;name&quot;: &quot;biria&quot; } ] } ] </code></pre> <p>I tried to go through the for loop on the children, Only it does not pass on to the grandchildren and great-grandchildren</p>
[ { "answer_id": 74390824, "author": "Rono", "author_id": 2292457, "author_profile": "https://Stackoverflow.com/users/2292457", "pm_score": 3, "selected": true, "text": "if (yourArray.Any(a => example1.StartsWith(a))\n" }, { "answer_id": 74392129, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 0, "selected": false, "text": "foreach" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17125497/" ]
74,390,737
<p>With loop or other, I can't see how to use the replace or inline module to achieve that.</p> <p>The orinal file contains this line</p> <pre><code>goals first_goal + second_goal </code></pre> <p>I <strong>only</strong> want to modify the line starting with <code>goals</code> (with leading spaces or not)<br /> With these possible values : A, B, C, D, E, F</p> <p>For example</p> <pre><code>goals C + F </code></pre> <p>My role needs to replace this line with these correspondances (the first letter matching is just to simplify my example) :</p> <pre><code>A -&gt; always B -&gt; back C -&gt; car D -&gt; dance E -&gt; even F -&gt; fast </code></pre> <p>So, for this example, the converted file will contains the line :</p> <pre><code>goals car + fast </code></pre> <p>(option+ if possible : several single letters can lead to the same value, e.g. <code>A -&gt; always , V -&gt; always, Z -&gt; always</code>)</p> <p>Here things are voluntarily limited, I have many more value possibles.<br /> What would be the best way to do this ? Thank you.</p>
[ { "answer_id": 74390824, "author": "Rono", "author_id": 2292457, "author_profile": "https://Stackoverflow.com/users/2292457", "pm_score": 3, "selected": true, "text": "if (yourArray.Any(a => example1.StartsWith(a))\n" }, { "answer_id": 74392129, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 0, "selected": false, "text": "foreach" } ]
2022/11/10
[ "https://Stackoverflow.com/questions/74390737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13575132/" ]