qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,141,773
<pre class="lang-py prettyprint-override"><code>x = input(&quot;Test: &quot;) if x == &quot;test: &quot; + 1: print(&quot;test&quot;) </code></pre> <p>I'm simply trying to make this input system with an if statement work, and Google and VS are hating me and I cannot do it.</p>
[ { "answer_id": 74229575, "author": "codeye", "author_id": 4786776, "author_profile": "https://Stackoverflow.com/users/4786776", "pm_score": 3, "selected": true, "text": "https://xyzsolutions.sharepoint.com/sites/2021/Shared Documents/General/xyzfolder/xyzppt.pptx?&web=1&nav=eyJzSWQiOjI1O...
2022/10/20
[ "https://Stackoverflow.com/questions/74141773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292770/" ]
74,141,792
<p>I created a <code>theme.ts</code> where I'm deteting the site &quot;brand&quot; by the hostname (based in the <a href="https://github.com/viandwi24/nuxt3-awesome-starter/blob/main/utils/theme.ts" rel="nofollow noreferrer">awesome starter nuxt3 repository</a> versoin) like so:</p> <p><strong>utils/theme.ts</strong></p> <pre><code>export type IThemeSettingOptions = 'light' | 'system' | 'foo' | 'bar' export type ITheme = 'light' | 'foo' | 'bar' export const availableThemes: { key: IThemeSettingOptions text: string }[] = [ { key: 'light', text: 'Light' }, { key: 'system', text: 'System' }, { key: 'foo', text: 'Foo' }, { key: 'bar', text: 'Bar' }, ] export function ThemeManager() { // composable const themeUserSetting = useCookie&lt;IThemeSettingOptions&gt;('theme') // methods const getUserSetting = (): IThemeSettingOptions =&gt; { return themeUserSetting.value || 'system' } const getSiteTheme = (): ITheme =&gt; { try { const host = location.hostname const sites = { 'foo.whitelabel.com': 'foo', 'bar.whitelabel.com': 'bar' } if (sites[host]) { return sites[host] } } catch (e) { return 'light' // This means generic styles, no customizable brand } } // state const themeSetting = useState&lt;IThemeSettingOptions&gt;('theme.setting', () =&gt; getSiteTheme() ) const themeCurrent = useState&lt;ITheme&gt;('theme.current', () =&gt; process.client ? getSiteTheme() : 'light' ) // init theme const init = () =&gt; { themeSetting.value = getSiteTheme() } // lifecycle onBeforeMount(() =&gt; init()) onMounted(() =&gt; { themeCurrent.value = getSiteTheme() }) return { themeSetting, themeCurrent, getUserSetting, getSiteTheme } } </code></pre> <p>I know of this <a href="https://color-mode.nuxtjs.org/" rel="nofollow noreferrer">color mode</a> that nuxt offers. But As I'm using <a href="https://windicss.org/" rel="nofollow noreferrer">windicss</a> I would like to have a different config file/object for every theme/brand.</p> <p>I tried like this in the <code>windi.config.ts</code></p> <pre><code>import { defineConfig } from 'windicss/helpers'; import type { Plugin } from 'windicss/types/interfaces'; import { ThemeManager } from './utils/theme'; console.log(ThemeManager().themeCurrent) // etc.. </code></pre> <p>But this won't log anything in the console</p> <p>is this posible? if not, a similar workaround? (perhaps with tailwindcss)</p> <p>I want to do this so the <code>primary</code> color is different for <code>foo</code> than for <code>bar</code> brand, lets say something like this:</p> <p><strong>windi.config.ts</strong></p> <pre><code>const MyThemes = { light: { colors: { green: { DEFAULT: '#3BA670' }, blue: { DEFAULT: '#0096F0' } } }, foo: { colors: { green: { DEFAULT: '#3BA675' }, blue: { DEFAULT: '#0096F5' } } }, bar: { colors: { green: { DEFAULT: '#3BA67F' }, blue: { DEFAULT: '#0096FF' } } } } const MyTheme = MyThemes['foo'] // or 'bar' or 'light' export default defineConfig({ // etc.. theme: { extend: { colors: { primary: MyTheme.colors.green, // etc.. } }, } // etc.. }) </code></pre>
[ { "answer_id": 74229575, "author": "codeye", "author_id": 4786776, "author_profile": "https://Stackoverflow.com/users/4786776", "pm_score": 3, "selected": true, "text": "https://xyzsolutions.sharepoint.com/sites/2021/Shared Documents/General/xyzfolder/xyzppt.pptx?&web=1&nav=eyJzSWQiOjI1O...
2022/10/20
[ "https://Stackoverflow.com/questions/74141792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/533941/" ]
74,141,815
<p>I am currently working on rewriting the backend of a PHP Symfony application with Spring boot. I cannot touch the front-end code, and have to modify my backend to work in accordance with existing request structure. However, I am currently stuck with something that i need some help with</p> <p>some examples of an endpoint looks as below</p> <pre><code>/app/api/incidents?customSearch=Some reason&amp;dt=month&amp;order[timeStart]=desc /app/api/incidents?customSearch=Some reason&amp;dt=month&amp;order[timeResolved]=desc </code></pre> <p>How can I map these endpoints to my RestController as a Map ? as per latest tomcat configuration square brackets are not valid and hence unsupported, throwing a 400 error. Adding a configuration for tomcat to support these characters, resolves the issue. But how can I map the above request params into an order hashmap ? There are other parameters that needs to be mapped as well e.g. timeStart</p> <pre><code>/app/api/incidents?timeStart[after]=2022-10-11 00:00:00&amp;timeStart[before]=2022-10-13 23:59:59&amp;dt=range&amp;order[incidentSeverity.orderBy]=desc </code></pre> <p>based on these values, the corresponding query needs to be formed.</p> <pre><code> @GetMapping public ResponseEntity&lt;String&gt; test(@RequestParam(name = &quot;order&quot;) Map&lt;String, String&gt; order) { log.info(&quot;order : &quot; + order); return ResponseEntity.ok(&quot;Hello&quot;); } </code></pre> <p>But order is mapped to null</p> <p>Can anyone please help me with this. I have already wasted way more time than I should have.</p>
[ { "answer_id": 74229575, "author": "codeye", "author_id": 4786776, "author_profile": "https://Stackoverflow.com/users/4786776", "pm_score": 3, "selected": true, "text": "https://xyzsolutions.sharepoint.com/sites/2021/Shared Documents/General/xyzfolder/xyzppt.pptx?&web=1&nav=eyJzSWQiOjI1O...
2022/10/20
[ "https://Stackoverflow.com/questions/74141815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1494625/" ]
74,141,833
<p>I have a canvas with some styling applied. There is a single letter centered in the canvas. Please take a look at the code below. As the title suggest, I am trying to change the letter by pressing a key. For example:</p> <p><strong>Letter A centered in canvas: I press the g - key, it changes to the letter g (Uppercase included)</strong></p> <p>As to my knowledge, I might have to use the method &quot;<strong>keyup</strong>&quot; with a &quot;document.addEventListener&quot;. Currently I am going through a course on learning JS, but I have noticed a strong reliance on certain libraries in the course, which I frankly dislike. I am not trashing the benefits, but I would prefer building a base with pure JS before using certain libraries I hardly understand. Some guidance would be appreciated.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { background-color: #000000; } canvas { padding: 0; margin: auto; display: block; position: absolute; top: 0; bottom: 0; left: 0; right: 0; background-color: #111416; border: 10px solid #a60000; border-style: double; box-shadow: 0 0 20px 5px #a60000; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;title&gt;Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;link rel="stylesheet" href="canvas.css"&gt; &lt;canvas id="myCanvas" width="800" height="800"&gt;&lt;/canvas&gt; &lt;script&gt; // Get id from the canvas element var canvas = document.getElementById("myCanvas"); // Provide 2D rendering context for the drawing surface of canvas var context = canvas.getContext("2d"); // Get width and height of the canvas element var canvW = document.getElementById("myCanvas").width; var canvH = document.getElementById("myCanvas").height; let text = "f"; context.fillStyle = "#a60000"; context.font = "700px serif"; // Measure the size of the letter and the specific font // Always centers the letter regardless of size // Display size of letter const metrics = context.measureText(text); const mx = metrics.actualBoundingBoxLeft * -1; const my = metrics.actualBoundingBoxAscent * -1; const mw = metrics.actualBoundingBoxLeft + metrics.actualBoundingBoxRight; const mh = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent; const x = (canvW -mw) *0.5 - mx; const y = (canvH - mh) *0.5 - my; context.save(); context.translate(x, y); context.beginPath(); context.rect(mx, my, mw, mh); context.stroke(); context.fillText(text, 0, 0); context.restore(); const onKeyUp = (e) =&gt; { text = e.key.toUpperCase(); manager.render(); }; document.addEventListener("keyup", onKeyUp); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74229575, "author": "codeye", "author_id": 4786776, "author_profile": "https://Stackoverflow.com/users/4786776", "pm_score": 3, "selected": true, "text": "https://xyzsolutions.sharepoint.com/sites/2021/Shared Documents/General/xyzfolder/xyzppt.pptx?&web=1&nav=eyJzSWQiOjI1O...
2022/10/20
[ "https://Stackoverflow.com/questions/74141833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17292443/" ]
74,141,841
<p><strong>Background</strong></p> <p>The data set is given below for reproducibility</p> <pre><code>data &lt;- structure(list(rest1 = c(1, 1, 0, 1, 1, 1, 0, 1, 0, 1), rest2 = c(1, 0, 1, 0, 0, 1, 1, 0, 0, 0), rest3 = c(1, 0, 0, 0, 0, 1, 0, 1, 0, 0), rest4 = c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0), rest5 = c(1, 1, 0, 0, 0, 1, 0, 1, 0, 1), rest6 = c(0, 0, 1, 0, 0, 0, 1, 0, 1, 0)), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -10L)) </code></pre> <p>The output is given below:</p> <pre><code>A tibble: 10 x 6 rest1 rest2 rest3 rest4 rest5 rest6 &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; 1 1 1 1 1 1 0 2 1 0 0 0 1 0 3 0 1 0 0 0 1 4 1 0 0 0 0 0 5 1 0 0 0 0 0 6 1 1 1 1 1 0 7 0 1 0 0 0 1 8 1 0 1 0 1 0 9 0 0 0 0 0 1 10 1 0 0 0 1 0 </code></pre> <p><strong>My question</strong></p> <p>Based on the values of column sleep 6, there needs to be changes made. Given the variable <code>rest6</code> is equal to 1, the other variables <code>rest1-rest5</code> need to be changed to 0. Here, variables 3 and 7 need to be fixed.</p> <p>The <em>desired</em> output is below:</p> <pre><code> rest1 rest2 rest3 rest4 rest5 rest6 &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; 1 1 1 1 1 1 0 2 1 0 0 0 1 0 3 0 0 0 0 0 1 4 1 0 0 0 0 0 5 1 0 0 0 0 0 6 1 1 1 1 1 0 7 0 0 0 0 0 1 8 1 0 1 0 1 0 9 0 0 0 0 0 1 10 1 0 0 0 1 0 </code></pre> <p><strong>Previous Attempts</strong></p> <p>I have attempted to do so using my basic knowledge of <em>R</em>. My logic is if <code>rest6</code> is equal to 1 and the observations are equal to 1, then set to 0, else we return the original value. However, this has not worked and I am a little unsure/not as proficient in <em>R</em> as of deliberate.</p> <pre><code>data &lt;- ifelse(data$rest6 == 1 &amp; data[,c(2:5) == 1], 0, data[,c(2:6)]) </code></pre> <p>Another attempt I have tried to use a <code>function()</code> to identify where to place the values.</p> <p>Thank you for your help.</p>
[ { "answer_id": 74141891, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 2, "selected": false, "text": "tidyverse" }, { "answer_id": 74141907, "author": "jpsmith", "author_id": 12109788, "author_profile...
2022/10/20
[ "https://Stackoverflow.com/questions/74141841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20282737/" ]
74,141,871
<p>I'm using flask to develop my application with multiple routes. Running my application on my local machine with a single &quot;thread&quot;, it works very well. When I deploy it the problem occurs. The following snippet represents the situation:</p> <pre><code>object_a = None @app.route(/route_a) def route_a(): global object_a object_a = do_something() return render_template(&quot;route_a.html&quot;) @app.route(/route_b) def route_b(): global object_a object_a.get_something return render_template(&quot;route_b.html&quot;) </code></pre> <p>In this example, I used a global variable that is accessible through the routes functions. With a single worker/thread, this approach worked, but when I use gunicorn with 3 workers, e.g., the application crashes because the object accessed is empty. My main hypothesis is that work shifts during the process. Is there a proper way to handle this behavior?</p> <p>EDIT 1:</p> <p>The following command are executed for gunicor:</p> <pre><code>gunicorn --workers 3 --timeout 180 --bind </code></pre>
[ { "answer_id": 74141891, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 2, "selected": false, "text": "tidyverse" }, { "answer_id": 74141907, "author": "jpsmith", "author_id": 12109788, "author_profile...
2022/10/20
[ "https://Stackoverflow.com/questions/74141871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5117173/" ]
74,141,885
<p>Source image:</p> <p><a href="https://i.stack.imgur.com/kVX89.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kVX89.png" alt="SOURCE" /></a></p> <p>My Code:</p> <pre><code>$mgck_wnd = new Imagick(); $mgck_wnd-&gt;readImageBlob($file); // 1 cmyk2rgb $img_colspc = $mgck_wnd-&gt;getImageColorspace(); if ($img_colspc != imagick::COLORSPACE_RGB &amp;&amp; $img_colspc != imagick::COLORSPACE_GRAY) { $profiles = $mgck_wnd-&gt;getImageProfiles('*', false); // get profiles $has_icc_profile = (array_search('icc', $profiles) !== false); // we're interested if ICC if ($has_icc_profile === false) { // image does not have CMYK ICC profile, we add one $icc_cmyk = file_get_contents('icc/Generic CMYK Profile.icc'); $mgck_wnd-&gt;profileImage('icc', $icc_cmyk); } // Then we need to add RGB profile $icc_rgb = file_get_contents('icc/Generic RGB Profile.icc'); $mgck_wnd-&gt;profileImage('icc', $icc_rgb); $mgck_wnd-&gt;setImageColorspace(imagick::COLORSPACE_RGB); } // 2 to300dpi $img_units = $mgck_wnd-&gt;getImageUnits(); switch ($img_units) { case imagick::RESOLUTION_UNDEFINED: $units= 'undefined'; break; case imagick::RESOLUTION_PIXELSPERINCH: $units= 'PPI'; break; case imagick::RESOLUTION_PIXELSPERCENTIMETER: $units= 'PPcm'; break; } list($x_res, $y_res) = $mgck_wnd-&gt;getImageResolution(); if ($x_res == 300 &amp;&amp; $y_res == 300 &amp;&amp; $img_units == imagick::RESOLUTION_PIXELSPERINCH) { return null; } $mgck_wnd-&gt;setResolution(300, 300); $mgck_wnd-&gt;setImageUnits(imagick::RESOLUTION_PIXELSPERINCH); // 3 tiff2jpg $img_colspc = $mgck_wnd-&gt;getImageColorspace(); if ($img_colspc == imagick::COLORSPACE_RGB) { $mgck_wnd-&gt;setImageColorspace(imagick::COLORSPACE_RGB); } $mgck_wnd-&gt;setCompression(Imagick::COMPRESSION_JPEG); $mgck_wnd-&gt;setCompressionQuality(85); $mgck_wnd-&gt;setImageFormat('jpeg'); return $mgck_wnd; </code></pre> <p>Result image:</p> <p><a href="https://i.stack.imgur.com/0r6Jx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0r6Jx.png" alt="RESULT" /></a></p> <p>How to fix it?</p> <p>Tiff Image Example from <a href="https://file-examples.com/wp-content/uploads/2017/10/file_example_TIFF_1MB.tiff" rel="nofollow noreferrer">https://file-examples.com/wp-content/uploads/2017/10/file_example_TIFF_1MB.tiff</a> Color Profiles from <a href="https://github.com/gopalkoduri/DLIdownloader/tree/master/libs/tiff2pdf" rel="nofollow noreferrer">https://github.com/gopalkoduri/DLIdownloader/tree/master/libs/tiff2pdf</a></p>
[ { "answer_id": 74147546, "author": "fmw42", "author_id": 7355741, "author_profile": "https://Stackoverflow.com/users/7355741", "pm_score": 1, "selected": false, "text": "convert file_example_TIFF_1MB.tiff -density 300 file_example_TIFF_1MB.jpg\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74141885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/801230/" ]
74,141,926
<p>I am trying to delete the contents of a column but would like to keep the column.</p> <p>For instance I have a table like.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Numbers1</th> <th>Numbers2</th> <th>Numbers3</th> <th>Numbers4</th> <th>Numbers5</th> </tr> </thead> <tbody> <tr> <td>five</td> <td>four</td> <td>three</td> <td>two</td> <td>two</td> </tr> <tr> <td>six</td> <td>seven</td> <td>eight</td> <td>nine</td> <td>ten</td> </tr> <tr> <td>nine</td> <td>seven</td> <td>four</td> <td>two</td> <td>two</td> </tr> <tr> <td>seven</td> <td>six</td> <td>five</td> <td>three</td> <td>one</td> </tr> </tbody> </table> </div> <p>I would like to remove all the contents of column b but I want to keep column Numbers2</p> <p>the desired output be like</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Numbers1</th> <th>Numbers2</th> <th>Numbers3</th> <th>Numbers4</th> <th>Numbers5</th> </tr> </thead> <tbody> <tr> <td>five</td> <td></td> <td>three</td> <td>two</td> <td>two</td> </tr> <tr> <td>six</td> <td></td> <td>eight</td> <td>nine</td> <td>ten</td> </tr> <tr> <td>nine</td> <td></td> <td>four</td> <td>two</td> <td>two</td> </tr> <tr> <td>seven</td> <td></td> <td>five</td> <td>three</td> <td>one</td> </tr> </tbody> </table> </div> <p>kindly help Thankyou</p>
[ { "answer_id": 74141949, "author": "Bushmaster", "author_id": 15415267, "author_profile": "https://Stackoverflow.com/users/15415267", "pm_score": 1, "selected": false, "text": "df['Numbers2']='' #empty string\n\ndf['Numbers2']=np.nan #nan\n" }, { "answer_id": 74141953, "auth...
2022/10/20
[ "https://Stackoverflow.com/questions/74141926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13801476/" ]
74,141,931
<p>Is there a method to early return if I get a <code>None</code> from a method? Example:</p> <pre class="lang-rust prettyprint-override"><code>pub async fn found_player(id: &amp;str) -&gt; Result&lt;Option&lt;Player&gt;&gt; { let player = repo // player here is Option&lt;Player&gt; .player_by_id(id) .await?; // I would like to use here a magic method to return here immediately if is None with `Ok(None)` if player.is_none() { return Ok(None); } // Do some stuff here but WITHOUT using player.unwrap(). I would like to have it already unwrapped since is not None Ok(Some(player)) } </code></pre> <p>I tried things like <code>Ok_or()</code> but I think they are now what I need. How can I do?</p> <p>I don't wanna use <code>match</code> or <code>if else</code> because I need to be as less verbose I can.</p>
[ { "answer_id": 74143179, "author": "NovaDenizen", "author_id": 1134885, "author_profile": "https://Stackoverflow.com/users/1134885", "pm_score": -1, "selected": false, "text": "pub async fn found_player(id: &str) -> Result<Option<Player>> {\n Ok(repo // player here is Option<Player>\n...
2022/10/20
[ "https://Stackoverflow.com/questions/74141931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10088259/" ]
74,142,013
<p>I am in middle of optimising my react app bundle. Current size is 1.4MB. Implemented Lazy loading in routers. While running the app at localhost, i can see lazy loading working well in Network tab of browser, I see first initial chunk loads and render's in the browser then rest of the 1.4MB comes. Problem comes when i create a production bundle and deploy it to server, there entire 1.4MB loads and then can see rendering.</p> <p>Is there something missing during production bundle creation? How to check if lazy loading is working from server?</p> <p>Webpack.config.js</p> <pre><code>const path = require('path'); const { resolve } = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); var CompressionPlugin = require('compression-webpack-plugin'); process.env.BABEL_ENV = 'production'; process.env.NODE_ENV = 'production'; module.exports = { devtool: 'cheap-module-source-map', entry: './src/index.jsx', resolve: { fallback: { crypto: false }, extensions: ['.js', '.jsx', '.json', '.wasm'], enforceExtension: false, alias: { process: resolve('node_modules/process') } }, devServer: { historyApiFallback: true, }, output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), publicPath: '/' }, module: { rules: [ { test: /\.js$|jsx/, loader: 'babel-loader', exclude: /node_modules[/\\\\](?!(mesh-component-library|mesh-icon-library)[/\\\\]).*/ }, { test: /\.css$/, use: [ { loader: 'style-loader' }, { loader: 'css-loader' } ] }, { test: /\.sass$/, use: [ { loader: 'style-loader' }, { loader: 'sass-loader' } ] }, { test: /\.(png|jp(e*)g|svg|gif)$/, use: [ { loader: 'file-loader', options: { name: 'images/[hash]-[name].[ext]' } } ] } ] }, plugins: [ new webpack.ProvidePlugin({ process: 'process/browser' }), new HtmlWebpackPlugin({ template: './public/index.html' }), new MiniCssExtractPlugin({ filename: 'styles.css' }), new webpack.EnvironmentPlugin({ NODE_ENV: process.env.BABEL_ENV, BABEL_ENV: process.env.NODE_ENV }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }), new CompressionPlugin({ algorithm: &quot;gzip&quot;, threshold: 10240, minRatio: 0.8 }) ] }; </code></pre> <p>Package.json</p> <pre><code>&quot;scripts&quot;: { &quot;test&quot;: &quot;jest --watchAll=false --coverage&quot;, &quot;testWithResults&quot;: &quot;jest --json --outputFile=./testResults.json&quot;, &quot;start&quot;: &quot;webpack-dev-server --mode development --config webpack.config.js --open --port 4000&quot;, &quot;build&quot;: &quot;webpack --mode production --config webpack.config.js&quot;, &quot;eslint&quot;: &quot;eslint src/**/*.js*&quot; }, </code></pre>
[ { "answer_id": 74296607, "author": "Benjamin", "author_id": 1830563, "author_profile": "https://Stackoverflow.com/users/1830563", "pm_score": 2, "selected": false, "text": "optimization: {\n splitChunks: {\n chunks: 'all',\n }\n}\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74142013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5288074/" ]
74,142,020
<p>I'm working on a project for my internet programming class and I'm not quite sure where I made my mistake here. I had this project at least running and able to test locally up until last night when I switched to using hooks (or trying to anyway). When I run <code>npm start</code> this is what logs into the console on Firefox.</p> <pre><code>Uncaught TypeError: this is undefined App App.js:67 React 11 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 App.js:67 App App.js:67 React 11 performConcurrentWorkOnRoot self-hosted:1406 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 (Async: EventHandlerNonNull) js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 </code></pre> <p>I had not changed any of my import statements, I had only added <code>useState</code>. VSCode shows me no errors in my code, so I believe something is out of place, but that's why I'm here to ask.</p> <pre><code>//import logo from './logo.svg'; import './App.css'; import './form.css'; import React, { useState } from 'react'; function App(){ const [showText, setShowText] = useState(0); const radioHandler = (showText) =&gt; { setShowText(showText); }; // constructor = (props) =&gt; { // super(props); // this.state = { // status: 0 // }; // handleInputChange = handleInputChange.bind(this); // handleSubmit = handleSubmit.bind(this); // } const handleInputChange = (event, value) =&gt; { console.log(value); } const handleSubmit = (event) =&gt; { event.preventDefault(); } return ( &lt;div className=&quot;form_css&quot;&gt; &lt;form onSubmit={handleSubmit}&gt; &lt;div className=&quot;general_info_container&quot;&gt; &lt;div className=&quot;name_container&quot;&gt; &lt;label className=&quot;f_name&quot;&gt;First Name:&lt;/label&gt; &lt;input name=&quot;f_name&quot; type=&quot;text&quot; value={this.state.f_name} onChange={handleInputChange} placeholder=&quot;Please enter your first name&quot; /&gt; &lt;label className=&quot;m_name&quot;&gt;Middle Initial:&lt;/label&gt; &lt;input name=&quot;m_name&quot; type=&quot;text&quot; value={this.state.m_name} onChange={handleInputChange} placeholder=&quot;Please enter your middle initial&quot; /&gt; &lt;label className=&quot;l_name&quot;&gt;Last Name:&lt;/label&gt; &lt;input name=&quot;l_name&quot; type=&quot;text&quot; value={this.state.l_name} onChange={handleInputChange} placeholder=&quot;Please enter your last name&quot; /&gt; &lt;/div&gt; &lt;div className=&quot;address_container&quot;&gt; &lt;label&gt;Street:&lt;/label&gt; &lt;input className=&quot;street&quot; type=&quot;text&quot; value={this.state.street} onChange={handleInputChange} placeholder=&quot;123 Main Street&quot; /&gt; &lt;label&gt;City:&lt;/label&gt; &lt;input className=&quot;city&quot; type=&quot;text&quot; value={this.state.city} onChange={handleInputChange} placeholder=&quot;City Name&quot; /&gt; &lt;label&gt;State:&lt;/label&gt; &lt;input className=&quot;state&quot; type=&quot;text&quot; value={this.state.state} onChange={handleInputChange} placeholder=&quot;New York&quot; /&gt; &lt;label&gt;Zip Code:&lt;/label&gt; &lt;input className=&quot;zip_code&quot; type=&quot;number&quot; value={this.state.zip_code} onChange={handleInputChange} placeholder=&quot;12345&quot; /&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt; Have you exercised regularly within the past six (6) months? &lt;/label&gt; &lt;input className=&quot;exr_yes&quot; type=&quot;radio&quot; value=&quot;true&quot; onChange={handleInputChange} /&gt; &lt;input className=&quot;exr_no&quot; type=&quot;radio&quot; value=&quot;false&quot; onChange={handleInputChange} /&gt; &lt;br&gt;&lt;/br&gt; {/* Testing radio button hide/show */} &lt;label&gt;Do you have any chonic medical conditions? TEST TEST TEST TEST TEST TEST&lt;/label&gt; &lt;input className=&quot;chronic_yes&quot; type=&quot;radio&quot; value=&quot;true&quot; checked={showText === 1} onClick={(e) =&gt; radioHandler(1)} /&gt; &lt;input className=&quot;chronic_no&quot; type=&quot;radio&quot; value=&quot;false&quot; checked={showText === 2} onClick={(e) =&gt; radioHandler(2)} /&gt; {showText === 1 &amp;&amp; &lt;div&gt; &lt;p&gt;Test showing&lt;/p&gt; &lt;/div&gt;} {showText === 2 &amp; &lt;p&gt;&lt;/p&gt;} &lt;div&gt; &lt;label&gt;Please enter any chronic conditions you have below:&lt;/label&gt; &lt;input className=&quot;chronic_medical&quot; type=&quot;text&quot; value={this.state.chronic_show} onChange={handleInputChange} /&gt; &lt;/div&gt; {/* Testing radio button hide/show {/* Testing radio button hide/show */} &lt;label&gt;Are you currently taking any medication?&lt;/label&gt; &lt;input className=&quot;meds_yes&quot; type=&quot;radio&quot; value=&quot;chronic&quot; onClick={(e) =&gt; radioHandler(1)} /&gt; &lt;input className=&quot;meds_no&quot; type=&quot;radio&quot; value=&quot;chronic&quot; onClick={(e) =&gt; radioHandler(2)} /&gt; &lt;div id=&quot;meds_show&quot;&gt; &lt;label&gt;Please list any medications you take below:&lt;/label&gt; &lt;input className=&quot;meds_show&quot; type=&quot;text&quot; value={this.state.meds_show} onChange={handleInputChange} /&gt; &lt;/div&gt; {/* Testing radio button hide/show */} {/* Testing radio button hide/show */} &lt;label&gt;Do you, or have you had, any injuries?&lt;/label&gt; &lt;input className=&quot;injury_yes&quot; type=&quot;radio&quot; value=&quot;ture&quot; onChange={handleInputChange} /&gt; &lt;input className=&quot;injnury_no&quot; type=&quot;radio&quot; value=&quot;false&quot; onChange={handleInputChange} /&gt; &lt;div id=&quot;injury_show&quot;&gt; &lt;label&gt; Please enter any injuries you have had in the past below: &lt;/label&gt; &lt;input className=&quot;injury_show&quot; type=&quot;text&quot; value={this.state.injury_show} onChange={handleInputChange} /&gt; &lt;/div&gt; {/* Testing radio button hide/show */} &lt;label&gt; Has a doctor ever suggested you only participate in medically supervised exercise? &lt;/label&gt; &lt;input className=&quot;supexr_yes&quot; type=&quot;radio&quot; value={this.state.supexr_yes} onChange={handleInputChange} /&gt; &lt;input className=&quot;supexr_no&quot; type=&quot;radio&quot; value={this.state.supexr_no} onChange={handleInputChange} /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; ); } export default App; </code></pre> <p>And please, if you have any tips for a beginner they would be much appreciated!</p>
[ { "answer_id": 74296607, "author": "Benjamin", "author_id": 1830563, "author_profile": "https://Stackoverflow.com/users/1830563", "pm_score": 2, "selected": false, "text": "optimization: {\n splitChunks: {\n chunks: 'all',\n }\n}\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74142020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18193192/" ]
74,142,047
<p>I have been researching about this topic for the past 3 days, but I seem to not understand how to handle quaternions correctly.</p> <p>I have a variable <em>pose</em> with a rotation property of the type &quot;quaternion&quot; that results in the euler angles (1, 2, 3). I want to modify this variable <em>pose</em>, so that it would result in the euler angles (-1, 2, 3).</p> <p>My current attempt looks like this:</p> <p><code>initialGameObject.rotation = pose.rot</code> -&gt; results in a rotation of (1, 2, 3)</p> <p><code>otherGameObject.rotation = Quaternion.Euler(pose.rot.eulerAngles.x * -1f, pose.rot.eulerAngles.y, pose.rot.eulerAngles.z)</code> -&gt; I want that to result in a rotation of (-1, 2, 3), but it doesn't work</p> <p>I would be so thankful if somebody could help me with that problem!</p>
[ { "answer_id": 74296607, "author": "Benjamin", "author_id": 1830563, "author_profile": "https://Stackoverflow.com/users/1830563", "pm_score": 2, "selected": false, "text": "optimization: {\n splitChunks: {\n chunks: 'all',\n }\n}\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74142047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15032514/" ]
74,142,050
<p>I know that in Apache Iceberg I can set limits on number and age of snapshots, and that &quot;deleting&quot; data from the table does not result in underlying data removal, it simply masks or deletes tracking information.</p> <p>I would like to actually delete the underlying files on delete, however. I know this will make time-travel inconsistent, but it is still a business requirement.</p> <p><a href="https://iceberg.apache.org/docs/latest/configuration/" rel="nofollow noreferrer">https://iceberg.apache.org/docs/latest/configuration/</a></p> <p>As best as I can tell, I'll have to track and manage the physical life-cycle every file independently. Am I missing something?</p>
[ { "answer_id": 74296607, "author": "Benjamin", "author_id": 1830563, "author_profile": "https://Stackoverflow.com/users/1830563", "pm_score": 2, "selected": false, "text": "optimization: {\n splitChunks: {\n chunks: 'all',\n }\n}\n" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74142050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1176806/" ]
74,142,068
<p>I would like to know if there is a way in r to return a value for the number of times where a series of data exceeds a certain value for a number of consecutive days.</p> <p><strong>e.g. How many times in a year was x greater than 10 for at least 30 consecutive days?</strong></p> <p>I know that you can find how many instances x was greater than a certain value over the whole year, but I'm not sure how to test for instances that are consecutive.</p> <p>Where <code>Data</code> is a data.frame with Date, Year, and Value columns with daily data from 2010-2020:</p> <pre><code>Data %&gt;% group_by(Year) %&gt;% filter(Value &gt;= 10) %&gt;% summarize(exceedances = n()) </code></pre> <p>Here is an example of daily data from 2018-2021 with random values from 0-25:</p> <pre><code>library(tidyverse) library(dplyr) library(lubridate) value = sample(0:25, 1461, replace=T) date = seq(as.Date(&quot;2018-01-01&quot;), as.Date(&quot;2021-12-31&quot;), by = &quot;1 day&quot;) dat = data.frame(date = date, year = year(date), value = value) dat %&gt;% group_by(year) %&gt;% filter(value &gt;= 10) %&gt;% summarize(exceedances = n()) </code></pre> <p>The output:</p> <pre><code># A tibble: 4 x 2 year exceedances &lt;dbl&gt; &lt;int&gt; 1 2018 216 2 2019 247 3 2020 229 4 2021 217 </code></pre> <p>Desired output (n of &gt;= 30 consecutive exceedances is a guess):</p> <pre><code># A tibble: 4 x 2 year n_exceedances_30_consec &lt;dbl&gt; &lt;int&gt; 1 2018 1 2 2019 0 3 2020 2 4 2021 0 </code></pre> <p>The trick with this is that if there are 40 consecutive exceedances, I need that to show as 1 instance only, not 10 instances where the previous 30 days were &gt;= 10.</p>
[ { "answer_id": 74142277, "author": "bdbmax", "author_id": 20264307, "author_profile": "https://Stackoverflow.com/users/20264307", "pm_score": 2, "selected": false, "text": "slider::slide_dbl" }, { "answer_id": 74142916, "author": "Ottie", "author_id": 17732851, "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74142068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18805611/" ]
74,142,070
<p>How do I add a <code>term</code> to a <code>listItem</code> in Microsoft Graph API?</p> <p>For simple String types (ProductSegment in the example) I do the following:</p> <pre><code>PATCH https://graph.microsoft.com/v1.0/sites/{{sharepoint_site_id}}/lists/{{sharepoint_list_id}}/items/{{num}}/fields { &quot;DisplayedName&quot;: &quot;asdasfsvsvdvsdbvdfb&quot;, &quot;DocumentType&quot;: &quot;FLYER&quot;, &quot;ProductSegment&quot;: [&quot;SEG1&quot;], &quot;TEST_x0020_2_x0020_ProductSegment&quot;: [{ &quot;TermGuid&quot;: &quot;c252c37d-1fa3-4860-8d3e-ff2cdde1f673&quot; }], &quot;Active&quot;: true, &quot;ProductSegment@odata.type&quot;: &quot;Collection(Edm.String)&quot;, &quot;TEST_x0020_2_x0020_ProductSegment@odata.type&quot;: &quot;Collection(Edm.Term)&quot; } </code></pre> <p>Obviously it won't work for <code>TEST_x0020_2_x0020_ProductSegment</code>. But I just cannot find any hints in the <a href="https://learn.microsoft.com/en-us/graph/api/resources/listitem?view=graph-rest-1.0" rel="nofollow noreferrer">documentation</a>.</p> <hr /> <p>I got one step closer thanks to the duplicated issue. First I found the <code>name</code> (not the <code>id</code>) of the hidden field <code>TEST 2 ProductSegment_0</code> (notice the <code>_0</code> suffix). Then assembled the <code>term</code> value to send: <code>-1;#MyLabel|c352c37d-1fa3-4860-8d3e-ff2cdde1f673</code>.</p> <pre><code>PATCH https://graph.microsoft.com/v1.0/sites/{{sharepoint_site_id}}/lists/{{sharepoint_list_id}}/items/{{num}}/fields { &quot;DisplayedName&quot;: &quot;asdasfsvsvdvsdbvdfb&quot;, &quot;DocumentType&quot;: &quot;FLYER&quot;, &quot;ProductSegment&quot;: [&quot;SEG1&quot;], &quot;i9da5ea20ec548bfb2097f0aefe49df8&quot;: &quot;-1;#MyLabel|c352c37d-1fa3-4860-8d3e-ff2cdde1f673&quot;, &quot;Active&quot;: true, &quot;ProductSegment@odata.type&quot;: &quot;Collection(Edm.String)&quot; } </code></pre> <p>and so I can add <em>one</em> item. I would need to add multiple, so I wanted to add the values to an array and set the field type (<code>i9da5ea20ec548bfb2097f0aefe49df8@odata.type</code>) to <code>Collection(Edm.String)</code>.</p> <p>Now I get an error with the code <code>generalException</code> as opposed to an <code>invalidRequest</code>.</p>
[ { "answer_id": 74142277, "author": "bdbmax", "author_id": 20264307, "author_profile": "https://Stackoverflow.com/users/20264307", "pm_score": 2, "selected": false, "text": "slider::slide_dbl" }, { "answer_id": 74142916, "author": "Ottie", "author_id": 17732851, "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74142070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/427321/" ]
74,142,082
<p>I am new to formulas on NetSuite Saved Searches but need some help. I want to use the ship date and deduct 7 working days from it</p>
[ { "answer_id": 74142277, "author": "bdbmax", "author_id": 20264307, "author_profile": "https://Stackoverflow.com/users/20264307", "pm_score": 2, "selected": false, "text": "slider::slide_dbl" }, { "answer_id": 74142916, "author": "Ottie", "author_id": 17732851, "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74142082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292854/" ]
74,142,092
<p>In Jetpack Compose, once the user places a finger down on a screen and moves it, I want to be notified of the finger position.</p> <p>How can I track the finger movement?</p>
[ { "answer_id": 74142277, "author": "bdbmax", "author_id": 20264307, "author_profile": "https://Stackoverflow.com/users/20264307", "pm_score": 2, "selected": false, "text": "slider::slide_dbl" }, { "answer_id": 74142916, "author": "Ottie", "author_id": 17732851, "autho...
2022/10/20
[ "https://Stackoverflow.com/questions/74142092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647098/" ]
74,142,120
<p>I am trying to translate a T-SQL Query to PostgreSQL and one part of the query contains the string function CHARINDEX () which I am not able to translate to PgSQL.</p> <p>Here is the part of the query with the string function:</p> <pre class="lang-sql prettyprint-override"><code>SELECT REPLACE(REPLACE(SUBSTRING( PARAMETRI ,CHARINDEX('=',PARAMETRI, PATINDEX('%ACCOUNTFILTERFST=%', PARAMETRI) ) +1 ,CHARINDEX( CHAR(13)||CHAR(10) ,PARAMETRI ,PATINDEX('%ACCOUNTFILTERFST=%', PARAMETRI) ) -CHARINDEX('=',PARAMETRI, PATINDEX('%ACCOUNTFILTERFST=%', PARAMETRI) ) ),CHAR(13), ''), CHAR(10), '') AS SELECTED FROM dbo.XYZ </code></pre> <p>CHARINDEX('=',PARAMETRI, PATINDEX('%ACCOUNTFILTERFST=%', PARAMETRI) '=' lokup this sign in column PARAMETRI and start at position whatever PATINDEX outputs as a result.</p> <hr /> <p>Edit: 21.10.2022</p> <pre class="lang-sql prettyprint-override"><code>SELECT * FROM DBO.YYY WHERE COD_SCHEMA IN ( SELECT --TRIM(CHAR(13)+ CHAR(10) + ' ' FROM VALUE) RTRIM(LTRIM(value)) FROM --STRING_SPLIT fn_split_string ( --(SELECT STRING_AGG(SELECTED, ',') FROM (SELECT REPLACE(REPLACE(SUBSTRING( PARAMETRI ,CHARINDEX('=',PARAMETRI, PATINDEX('%ACCOUNTFILTERFST=%', PARAMETRI) ) +1 ,CHARINDEX( CHAR(13)+CHAR(10) ,PARAMETRI ,PATINDEX('%ACCOUNTFILTERFST=%', PARAMETRI) ) -CHARINDEX('=',PARAMETRI, PATINDEX('%ACCOUNTFILTERFST=%', PARAMETRI) ) ),CHAR(13), ''), CHAR(10), '') AS SELECTED FROM DBO.XXX WHERE TIPO_DIMENSIONE = 'CONTO' AND COD_CUBO = 'XPlus' --) T ) , ',' ) ) </code></pre> <pre class="lang-none prettyprint-override"><code>dbo.XXX +----------+-----------------+--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | COD_CUBO | TIPO_DIMENSIONE | COD_DIMENSIONE | PARAMETRI | +----------+-----------------+--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | XPlus | AZI | 8A8A81847FB7210E017FB73E244334 | #Fri Sep 23 09:10:04 UTC 2022 filtro=010 entityCTPCodeAttr=CTP All Entities Code hierarchyAttr=All Entities Hierarchy codeAttr=All Entities Code entityCTPDim=CTP All Entities entitySegmentHierarchyAttr=CTP for Segment All Entities Hierarchy entityCTPFlag=1 entitySegmentDescriptionAttr=CTP for Segment All Entities Description entitySegmentCodeAttr=CTP for Segment All Entities Code entityCTPDescriptionAttr=CTP All Entities Description entitySegmentFlag=1 nameDim=All Entities entityCTPHierarchyAttr=CTP All Entities Hierarchy entitySegmentDim=CTP for Segment All Entities descriptionAttr=All Entities Description entityFlag=0 | +----------+-----------------+--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ </code></pre> <pre class="lang-none prettyprint-override"><code>dbo.YYY +------------+----------+------------------------------------+-----------------------------------+------------+------------+--------+-----------+-----------------------+-------------+---------------+-----------+----------------+-------------+---------+------------------+--------+-------------------+-------------------------+--------------+------------+------------+------------+------------+------------+------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+ | COD_SCHEMA | COD_VOCE | DESC_VOCE0 | DESC_VOCE1 | DESC_VOCE2 | DESC_VOCE3 | FORMAT | TIPO_VOCE | FORMULA_VOCE | ORDINAMENTO | FLAG_NOREPORT | NAME_XBRL | TIPO_VOCE_XBRL | PROVENIENZA | USERUPD | DATEUPD | CLASSE | FLAG_CAMBIA_SEGNO | FLAG_FORZA_FORMULA_CUBO | FORMULA_CUBO | DESC_VOCE4 | DESC_VOCE5 | DESC_VOCE6 | DESC_VOCE7 | DESC_VOCE8 | DESC_VOCE9 | DESC_VOCE10 | DESC_VOCE11 | DESC_VOCE12 | DESC_VOCE13 | DESC_VOCE14 | DESC_VOCE15 | DESC_VOCE16 | DESC_VOCE17 | DESC_VOCE18 | DESC_VOCE19 | DESC_VOCE20 | DESC_VOCE21 | DESC_VOCE22 | DESC_VOCE23 | DESC_VOCE24 | +------------+----------+------------------------------------+-----------------------------------+------------+------------+--------+-----------+-----------------------+-------------+---------------+-----------+----------------+-------------+---------+------------------+--------+-------------------+-------------------------+--------------+------------+------------+------------+------------+------------+------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+ | 10 | 10 | Sales Revenue | Sales Revenue | NULL | NULL | 0 | A | NULL | 10 | 0 | NULL | I | INPUT_WEB | TNA | 12.03.2017 18:54 | R | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 15 | 10 | Sales Revenue | Sales Revenue | NULL | NULL | 0 | A | NULL | 10 | 0 | NULL | I | INPUT_WEB | CCH | 23.08.2018 14:41 | R | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 20 | 10 | ASSETS | ASSETS | NULL | NULL | 2 | D | NULL | 10 | 0 | NULL | I | INPUT_WEB | Sam | 21.09.2016 21:23 | A | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 30 | RF001 | CASH FLOWS FROM OPERATING ACTIVITY | NULL | NULL | NULL | 9 | D | NULL | RF001 | 0 | NULL | I | INPUT_WEB | DOM | 19.04.2017 01:28 | N | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 40 | 10010 | Beginning Cash Balance | NULL | NULL | NULL | 2 | A | NULL | 10010 | 0 | NULL | I | INPUT_WEB | TNA | 06.05.2017 00:14 | N | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 50 | 70 | Debt to Equity | NULL | NULL | NULL | NULL | F | {V,,'155'}/{V,,'150'} | 70 | 0 | NULL | I | INPUT_WEB | CHARLIE | 19.04.2017 03:09 | N | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 55 | 35 | Wages &amp; Salary | Wages &amp; Salary | NULL | NULL | 0 | A | NULL | 0 | 0 | NULL | I | INPUT_WEB | CCH | 31.07.2020 15:20 | N | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 60 | 55 | General &amp; Administrative Expenses | General &amp; Administrative Expenses | NULL | NULL | 0 | A | NULL | 0 | 0 | NULL | I | INPUT_WEB | CCH | 31.07.2020 15:22 | N | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | | 65 | 10 | Net Sales | NULL | NULL | NULL | 0 | F | {V,'010','020'} | 0 | 0 | NULL | I | INPUT_WEB | CCH | 31.07.2020 15:33 | N | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | +------------+----------+------------------------------------+-----------------------------------+------------+------------+--------+-----------+-----------------------+-------------+---------------+-----------+----------------+-------------+---------+------------------+--------+-------------------+-------------------------+--------------+------------+------------+------------+------------+------------+------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+ </code></pre> <p>Output Table:</p> <pre class="lang-none prettyprint-override"><code>+------------+----------+---------------+---------------+------------+------------+--------+-----------+--------------+-------------+---------------+-----------+----------------+-------------+---------+------------------+--------+-------------------+-------------------------+--------------+------------+------------+------------+------------+------------+------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+ | COD_SCHEMA | COD_VOCE | DESC_VOCE0 | DESC_VOCE1 | DESC_VOCE2 | DESC_VOCE3 | FORMAT | TIPO_VOCE | FORMULA_VOCE | ORDINAMENTO | FLAG_NOREPORT | NAME_XBRL | TIPO_VOCE_XBRL | PROVENIENZA | USERUPD | DATEUPD | CLASSE | FLAG_CAMBIA_SEGNO | FLAG_FORZA_FORMULA_CUBO | FORMULA_CUBO | DESC_VOCE4 | DESC_VOCE5 | DESC_VOCE6 | DESC_VOCE7 | DESC_VOCE8 | DESC_VOCE9 | DESC_VOCE10 | DESC_VOCE11 | DESC_VOCE12 | DESC_VOCE13 | DESC_VOCE14 | DESC_VOCE15 | DESC_VOCE16 | DESC_VOCE17 | DESC_VOCE18 | DESC_VOCE19 | DESC_VOCE20 | DESC_VOCE21 | DESC_VOCE22 | DESC_VOCE23 | DESC_VOCE24 | +------------+----------+---------------+---------------+------------+------------+--------+-----------+--------------+-------------+---------------+-----------+----------------+-------------+---------+------------------+--------+-------------------+-------------------------+--------------+------------+------------+------------+------------+------------+------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+ | 10 | 10 | Sales Revenue | Sales Revenue | NULL | NULL | 0 | A | NULL | 10 | 0 | NULL | I | INPUT_WEB | TNA | 12.03.2017 18:54 | R | 0 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | +------------+----------+---------------+---------------+------------+------------+--------+-----------+--------------+-------------+---------------+-----------+----------------+-------------+---------+------------------+--------+-------------------+-------------------------+--------------+------------+------------+------------+------------+------------+------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+-------------+ </code></pre> <p>The Function POSITION would be the one suitable if one goes by the logic of the function, but I am stuck with it because I am not able to pass it an starting position argument.</p>
[ { "answer_id": 74143046, "author": "Ramin Faracov", "author_id": 17296084, "author_profile": "https://Stackoverflow.com/users/17296084", "pm_score": -1, "selected": false, "text": "CHARINDEX" }, { "answer_id": 74146256, "author": "Naomi A.", "author_id": 20295448, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74142120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913339/" ]
74,142,183
<p>With a list like: <code>'apple,and,as'</code> All the words start with the same letter. If this is the case, I would like to return true and if not return false. How can I do that? A is just the example!! I need to check if the words begin in every random same letter</p> <p>I'm a Beginner.</p>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292990/" ]
74,142,187
<p>I have an application build using Svelte (v3), Routify (v2) and Vite (v3). Home page of application comprises of various sections and each section comprises of multiple components. Hence when this page loads, it makes network request to 50+ components resulting into network waterfall hell!</p> <p>Is there any mechanism to bundle the components into modules (like feature modules) and load them instead? Example, I can bundle multiple header related components into one header-module and make 1 network request instead of many!</p> <p><a href="https://i.stack.imgur.com/5tURG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5tURG.png" alt="enter image description here" /></a></p> <p><strong>routify.config.js</strong></p> <pre class="lang-js prettyprint-override"><code>module.exports = { routifyDir: '.routify', dynamicImports: true, extensions: ['svelte'] } </code></pre> <p><strong>vite.config.js</strong></p> <pre class="lang-js prettyprint-override"><code>export default defineConfig({ server: { port: 5000, }, plugins: [ svelte({ preprocess: [preprocess()], }), ], }); </code></pre> <p><a href="https://github.com/aakash14goplani/Svelte-Modular-Bundling" rel="nofollow noreferrer">Ref. to code in GitHub Repo</a></p>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3411606/" ]
74,142,202
<p>im having real trouble to complete an FullStackOpen exersice, it requires to render some data to the page. Give the next code, i have to render the number of <code>Parts</code> that each <code>Course</code> has, and also so reduce the number of <code>Parts/Exersices</code> to render the total of exersices por each Course.</p> <p>I am not being able to reach the inside of the Parts array of objects</p> <pre><code> { name: &quot;Half Stack application development&quot;, id: 1, parts: [ { name: &quot;Fundamentals of React&quot;, exercises: 10, id: 1, }, { name: &quot;Using props to pass data&quot;, exercises: 7, id: 2, }, { name: &quot;State of a component&quot;, exercises: 14, id: 3, }, { name: &quot;Redux&quot;, exercises: 11, id: 4, }, ], }, { name: &quot;Node.js&quot;, id: 2, parts: [ { name: &quot;Routing&quot;, exercises: 3, id: 1, }, { name: &quot;Middlewares&quot;, exercises: 7, id: 2, }, ], }, ];``` </code></pre>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292968/" ]
74,142,209
<p>The <a href="https://image.nuxtjs.org/components/nuxt-img#usage" rel="nofollow noreferrer">documentation</a> mentions that I can use <code>&lt;nuxt-img/&gt;</code> like I'm using the HTML's <code>&lt;img&gt;</code> tag however this is not the case.<br /> I have made this example to demonstrate that <code>&lt;img&gt;</code> tag is working just fine while <code>&lt;nuxt-img/&gt;</code> is not displaying the image.</p> <p>This is the code:</p> <pre class="lang-html prettyprint-override"><code>&lt;template&gt; &lt;main&gt; &lt;pre&gt;{{ pokemon.sprites.front_shiny }}&lt;/pre&gt; &lt;h1&gt;Normal Image Tag&lt;/h1&gt; &lt;img class=&quot;normal-img-tag&quot; :src=&quot;`${pokemon.sprites.front_shiny}`&quot; /&gt; &lt;h1&gt;Nuxt Image Tag&lt;/h1&gt; &lt;nuxt-img class=&quot;nuxt-img-tag&quot; placeholder=&quot;/images/lazy.jpg&quot; :src=&quot;`${pokemon.sprites.front_shiny}`&quot; /&gt; &lt;/main&gt; &lt;/template&gt; &lt;script&gt; export default { data: () =&gt; ({ pokemon: {}, }), async fetch() { this.pokemon = await this.$axios.$get( &quot;https://pokeapi.co/api/v2/pokemon/charizard&quot; ); }, }; &lt;/script&gt; </code></pre> <p><code>nuxt.config.js</code></p> <pre class="lang-js prettyprint-override"><code>export default { target: 'static', head: { title: 'nuxt-img', htmlAttrs: { lang: 'en' }, meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, { hid: 'description', name: 'description', content: '' }, { name: 'format-detection', content: 'telephone=no' } ], link: [ { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } ] }, modules: [ '@nuxtjs/axios', '@nuxt/image', ], image: { domains: ['localhost'] }, axios: { baseURL: '/', }, } </code></pre> <p><code>package.json</code></p> <pre class="lang-json prettyprint-override"><code>{ &quot;name&quot;: &quot;nuxt-img&quot;, &quot;version&quot;: &quot;1.0.0&quot;, &quot;private&quot;: true, &quot;scripts&quot;: { &quot;dev&quot;: &quot;nuxt&quot;, &quot;build&quot;: &quot;nuxt build&quot;, &quot;start&quot;: &quot;nuxt start&quot;, &quot;generate&quot;: &quot;nuxt generate&quot; }, &quot;dependencies&quot;: { &quot;@nuxtjs/axios&quot;: &quot;^5.13.6&quot;, &quot;core-js&quot;: &quot;^3.25.3&quot;, &quot;nuxt&quot;: &quot;^2.15.8&quot;, &quot;vue&quot;: &quot;^2.7.10&quot;, &quot;vue-server-renderer&quot;: &quot;^2.7.10&quot;, &quot;vue-template-compiler&quot;: &quot;^2.7.10&quot; }, &quot;devDependencies&quot;: { &quot;@nuxt/image&quot;: &quot;^0.7.1&quot; } } </code></pre> <p>Here is a screenshot</p> <p><img src="https://i.imgur.com/nHjaFcX.png" alt="" /></p> <p>that showns that <code>Image</code> is the lazy load image specified inside <code>nuxt-img</code> so nuxt-image is actually working but <code>:src</code> is not.</p> <p><strong>UPDATE</strong> I have added :</p> <pre class="lang-js prettyprint-override"><code>image: { domains: ['https://raw.githubusercontent.com'], } </code></pre> <p>to my <code>nuxt.config.js</code> as @kissu mentioned but I get this error on console :</p> <pre><code>GET http://localhost:3000/_ipx/_/https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/6.png 500 (IPX Error (500)) </code></pre> <p>and in terminal this error :</p> <pre><code>ERROR Not supported 11:21:15 at getExport (node_modules\ohmyfetch\cjs\node.cjs:1:54) at Object.fetch (node_modules\ohmyfetch\cjs\node.cjs:2:47) at Object.http (node_modules\ipx\dist\shared\ipx.eadce322.cjs:142:38) at node_modules\ipx\dist\shared\ipx.eadce322.cjs:445:33 at Object.src (node_modules\ipx\dist\shared\ipx.eadce322.cjs:69:25) at _handleRequest (node_modules\ipx\dist\shared\ipx.eadce322.cjs:521:25) at handleRequest (node_modules\ipx\dist\shared\ipx.eadce322.cjs:549:10) at IPXMiddleware (node_modules\ipx\dist\shared\ipx.eadce322.cjs:565:12) at call (node_modules\connect\index.js:239:7) at next (node_modules\connect\index.js:183:5) at next (node_modules\connect\index.js:161:14) at WebpackBundler.middleware (node_modules\@nuxt\webpack\dist\webpack.js:2194:5) </code></pre> <p><strong>PROJECT REPO ON GITHUB :</strong></p> <p><a href="https://github.com/abdurrahmanseyidoglu/nuxt-img-test" rel="nofollow noreferrer">https://github.com/abdurrahmanseyidoglu/nuxt-img-test</a></p> <p>Am I doing something wrong or it actually does not work this way?</p>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11170736/" ]
74,142,218
<p>I have the following code:</p> <pre><code> long_word: ISubscription['long_word']; </code></pre> <p>This is what I normally do:</p> <pre><code>shift v :s/long_word/new_word/g </code></pre> <p>It's tedious to have to type the word I'm trying to replace. So sometimes I just do</p> <pre><code>ciw new_word esc $ hhhh . </code></pre> <p>which feels inefficient.</p> <p>Is there a way to do something like <code>ciw</code> but on the whole line?</p>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1555312/" ]
74,142,243
<p>I have the following JSON file:</p> <pre><code>{&quot;xx&quot;:1,&quot;bb&quot;:2,&quot;cc&quot;:3} </code></pre> <p>I want to add a column to a data frame by using the value from the JSON</p> <p>My data frame</p> <pre><code>df = pd.DataFrame([{&quot;region&quot;: &quot;xx&quot;}, {&quot;region&quot;: &quot;xx&quot;}, {&quot;region&quot;: &quot;cc&quot;}]) </code></pre> <p>So, using the column region, I want to add a column with the value of the column region on the data frame, in this case, the data frame will be something like this</p> <pre><code>[{&quot;region&quot;: &quot;xx&quot;, &quot;value&quot;: 1}, {&quot;region&quot;: &quot;xx&quot;, &quot;value&quot;: 1}, {&quot;region&quot;: &quot;cc&quot;, &quot;value&quot;: 3}] </code></pre>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832490/" ]
74,142,244
<p>I'm trying to query a dataset about user status changes. and I want to find out the time it takes for the status to change, and the steps in between(number of rows).</p> <p>Example data:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>user_id</th> <th>Status</th> <th>date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>a</td> <td>2001-01-01</td> </tr> <tr> <td>1</td> <td>a</td> <td>2001-01-08</td> </tr> <tr> <td>1</td> <td>b</td> <td>2001-01-15</td> </tr> <tr> <td>1</td> <td>b</td> <td>2001-01-28</td> </tr> <tr> <td>1</td> <td>a</td> <td>2001-01-31</td> </tr> <tr> <td>1</td> <td>b</td> <td>2001-02-01</td> </tr> <tr> <td>2</td> <td>a</td> <td>2001-01-08</td> </tr> <tr> <td>2</td> <td>a</td> <td>2001-01-18</td> </tr> <tr> <td>2</td> <td>a</td> <td>2001-01-28</td> </tr> <tr> <td>3</td> <td>b</td> <td>2001-03-08</td> </tr> <tr> <td>3</td> <td>b</td> <td>2001-03-18</td> </tr> <tr> <td>3</td> <td>b</td> <td>2001-03-19</td> </tr> <tr> <td>3</td> <td>a</td> <td>2001-03-20</td> </tr> </tbody> </table> </div> <p>Desired output:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>user_id</th> <th>From</th> <th>to</th> <th>days in between</th> <th>Steps in between</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>a</td> <td>b</td> <td>14</td> <td>2</td> </tr> <tr> <td>1</td> <td>b</td> <td>a</td> <td>16</td> <td>2</td> </tr> <tr> <td>1</td> <td>a</td> <td>b</td> <td>1</td> <td>1</td> </tr> <tr> <td>3</td> <td>b</td> <td>a</td> <td>12</td> <td>3</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4315761/" ]
74,142,250
<p>I have a file allocation.js which defines <code>class Allocation {...}</code>. I have another file, test.js, which has <code>require('./allocation.js')</code> and on the next line <code>a = new Allocation;</code> which generates <code>ReferenceError: Allocation is not defined</code>. If I paste the contents of allocation.js into test.js where the <code>require</code> is and comment out the <code>require</code>, the code works fine. Is it possible to separate class definitions out into other files and if so, what am I doing wrong?</p>
[ { "answer_id": 74142289, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "'a'" }, { "answer_id": 74142554, "author": "ysethi92", "author_id": 9850897, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108913/" ]
74,142,271
<p>I have an array with correct order line:</p> <pre><code>let arr1 = ['name', 'age', 'occupation', 'address'] </code></pre> <p>and I have an another array which is coming from the backend with unsorted format</p> <pre><code>let arr2 = [{'age': 20, 'address': '', 'occupation': 'student', 'name': 'student name1'}, {'age': 21, 'address': '', 'occupation': 'student', 'name': 'student name2'}, {'age': 22, 'address': '', 'occupation': 'student', 'name': 'student name3'}] </code></pre> <p>So I need this <strong>arr2</strong> objects keys to be sorted the way <strong>arr1</strong> keys index positions.</p> <p>Final output needed:</p> <pre><code>let arr2Sorted = [{ 'name': 'student name1', 'age': 20, 'occupation': 'student', 'address': ''}, { 'name': 'student name2', 'age': 21, 'occupation': 'student', 'address': ''}, { 'name': 'student name3', 'age': 22, 'occupation': 'student', 'address': ''}] </code></pre> <p>What I tried:</p> <pre><code>const arrayMap = arr2.reduce( (accumulator, currentValue) =&gt; ({ ...accumulator, [currentValue]: currentValue, }), {}, ); const result = arr1.map((key) =&gt; arrayMap[key]); </code></pre>
[ { "answer_id": 74142450, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 3, "selected": true, "text": "let arr1 = ['name', 'age', 'occupation', 'address'];\nlet arr2 = [{'age': 20, 'address': '', 'occupation': 'stud...
2022/10/20
[ "https://Stackoverflow.com/questions/74142271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11096643/" ]
74,142,273
<p>I'm trying to get the price for this item, <a href="https://www.midwayusa.com/product/1009418514?pid=418514" rel="nofollow noreferrer">https://www.midwayusa.com/product/1009418514?pid=418514</a>. I found that the price is only ever found in the source under a script which has tons of information (Lines 155-157 of view-source:<a href="https://www.midwayusa.com/product/1009418514?pid=418514" rel="nofollow noreferrer">https://www.midwayusa.com/product/1009418514?pid=418514</a>). How would I go about extracting just that price data of 39.99 and importing it into my google sheets? I currently have everything under //script imported but how would I go about narrowing it down? <code>=IMPORTXML(&quot;https://www.midwayusa.com/product/1009418514?pid=418514&quot;,&quot;//script&quot;)</code></p>
[ { "answer_id": 74142450, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 3, "selected": true, "text": "let arr1 = ['name', 'age', 'occupation', 'address'];\nlet arr2 = [{'age': 20, 'address': '', 'occupation': 'stud...
2022/10/20
[ "https://Stackoverflow.com/questions/74142273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20292987/" ]
74,142,283
<p>I would like to know how to apply a <code>setTimeout</code> to my request response with await fetch. My code sends each response to a DIV in HTML, and I would like to know how to make it take 5 seconds for each response to appear.</p> <p><strong>I tried this but I couldn't do it.</strong></p> <pre><code>const envSoli = async () =&gt; { try { const controller = new AbortController(); const signal = controller.signal; const timeId = setTimeout(() =&gt; { controller.abort(); }, 20 * 1000); // 20 sec let peticion = await fetch(&quot;data.php&quot;, { method: &quot;POST&quot;, body: &quot;ajax=1&amp;do=check&amp;lista=&quot; + encodeURIComponent(leray[chenille]), headers: { &quot;Content-type&quot;: &quot;application/x-www-form-urlencoded&quot; }, cache: &quot;no-cache&quot;, signal: signal, }); clearTimeout(timeId); const oreen = await peticion.json(); const takeAMoment = setTimeout(() =&gt; { switch (oreen.enviando) { case -1: chenille++; document.getElementById(&quot;div1&quot;).append(oreen.cat + &quot;&lt;br /&gt;&quot;); updateProgress(chenille, leray.length); tvmit_wrongUp(); break; case 1: chenille++; document.getElementById(&quot;div1&quot;).append(oreen.dog + &quot;&lt;br /&gt;&quot;); updateProgress(chenille, leray.length); tvmit_wrongUp(); break; case 2: chenille++; document.getElementById(&quot;div2&quot;).append(oreen.sky + &quot;&lt;br /&gt;&quot;); nieva++; updateProgress(chenille, leray.length); tvmit_dieUp(); break; case 3: chenille++; document.getElementById(&quot;div3&quot;).append(oreen.water + &quot;&lt;br /&gt;&quot;); tvmit_liveUp(); updateProgress(chenille, leray.length); break; } OKTY(leray, chenille, aarsh, nieva); return true; }, 5 * 1000); clearTimeout(takeAMoment); } catch (error) { console.log(error); Swal.fire({ text: translate(&quot;text2&quot;), icon: &quot;question&quot;, buttonsStyling: false, confirmButtonText: translate(&quot;confirmbtn&quot;), allowOutsideClick: false, allowEscapeKey: false, customClass: { confirmButton: &quot;btn btn-primary&quot;, }, //refresh again on button click }).then(function () { location.reload(); }); } }; envSoli(); </code></pre> <h2>WORKING ORIGINAL CODE:</h2> <pre><code>const envSoli = async () =&gt; { try { const controller = new AbortController(); const signal = controller.signal; const timeId = setTimeout(() =&gt; { controller.abort(); }, 20 * 1000); let peticion = await fetch(&quot;data.php&quot;, { method: &quot;POST&quot;, body: &quot;ajax=1&amp;do=check&amp;lista=&quot; + encodeURIComponent(leray[chenille]), headers: { &quot;Content-type&quot;: &quot;application/x-www-form-urlencoded&quot; }, cache: &quot;no-cache&quot;, signal: signal, }); clearTimeout(timeId); let oreen = await peticion.json(); switch (oreen.enviando) { case -1: chenille++; document.getElementById(&quot;div1&quot;).append(oreen.cat + &quot;&lt;br /&gt;&quot;); updateProgress(chenille, leray.length); tvmit_wrongUp(); break; case 1: chenille++; document.getElementById(&quot;div1&quot;).append(oreen.dog + &quot;&lt;br /&gt;&quot;); updateProgress(chenille, leray.length); tvmit_wrongUp(); break; case 2: chenille++; document.getElementById(&quot;div2&quot;).append(oreen.sky + &quot;&lt;br /&gt;&quot;); nieva++; updateProgress(chenille, leray.length); tvmit_dieUp(); break; case 3: chenille++; document.getElementById(&quot;div3&quot;).append(oreen.water + &quot;&lt;br /&gt;&quot;); tvmit_liveUp(); updateProgress(chenille, leray.length); break; } OKTY(leray, chenille, aarsh, nieva); return true; } catch (error) { console.log(error); Swal.fire({ text: translate(&quot;text2&quot;), icon: &quot;question&quot;, buttonsStyling: false, confirmButtonText: translate(&quot;confirmbtn&quot;), allowOutsideClick: false, allowEscapeKey: false, customClass: { confirmButton: &quot;btn btn-primary&quot;, }, //refresh again on button click }).then(function () { location.reload(); }); } }; envSoli(); </code></pre>
[ { "answer_id": 74142450, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 3, "selected": true, "text": "let arr1 = ['name', 'age', 'occupation', 'address'];\nlet arr2 = [{'age': 20, 'address': '', 'occupation': 'stud...
2022/10/20
[ "https://Stackoverflow.com/questions/74142283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19856237/" ]
74,142,308
<p>When I want to run node-red, It started to show the error that the Error loading settings file.</p> <pre><code>Error loading settings file: \Users\&lt;User-Name&gt;\.node-red\settings.js </code></pre>
[ { "answer_id": 74142450, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 3, "selected": true, "text": "let arr1 = ['name', 'age', 'occupation', 'address'];\nlet arr2 = [{'age': 20, 'address': '', 'occupation': 'stud...
2022/10/20
[ "https://Stackoverflow.com/questions/74142308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18387703/" ]
74,142,312
<p>I'm absolutely new to php/laravel world so sorry if my question is simple.</p> <p>Language: php with laravel.</p> <p>What : I want to get all objects who contain the name of the users.</p> <pre><code>//Exemple of my users Array ($users = [&quot;name1&quot;, &quot;name2&quot;,&quot;name4&quot;]) //Forms is an array who contain multiple object, each object have a reference to a user Name. $Forms = [{_id: 1, title : &quot;title1&quot;, userName : &quot;name1&quot; }, {_id: 2, title : &quot;title2&quot;, userName : &quot;name2&quot; }, {_id: 3, title : &quot;title3&quot;, userName : &quot;name3&quot; }, {_id: 4, title : &quot;title4&quot;, userName : &quot;name4&quot; },{_id: 5, title : &quot;title5&quot;, userName : &quot;name1&quot; }] //here i want to get form with name1, name2 and name4 foreach ($users as $user) { $allForm = Forms::where('userName ', $user)-&gt;get(); }; </code></pre> <p>Problematic: I only received 2 objects (objects from the first user of my array).</p> <p>Exemple: here i want to get every forms who contain &quot;name1&quot;, &quot;name2&quot;,&quot;name4&quot; but i will received only every forms with &quot;name1&quot;.</p>
[ { "answer_id": 74142450, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 3, "selected": true, "text": "let arr1 = ['name', 'age', 'occupation', 'address'];\nlet arr2 = [{'age': 20, 'address': '', 'occupation': 'stud...
2022/10/20
[ "https://Stackoverflow.com/questions/74142312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19389219/" ]
74,142,326
<p>I am new to programming. This is a C language program.</p> <pre><code>#define _CRT_SECURE_NO_WARNINGS 1 #include&lt;stdio.h&gt; #include&lt;stdbool.h&gt; #define ture 1 #define false 0 void add(int m, int* arr,int n) { if (n == 32) return; arr[n] += m; if ( arr[n] &gt; 1) { arr[n] = 0; add(m, arr, ++n); } return; } int main(void) { int T,n,r,m,i,j,k; bool check = ture; scanf(&quot;%d&quot;, &amp;T); while (T--) { scanf(&quot;%d%d&quot;, &amp;n, &amp;r); switch (r) { case 10: printf(&quot;%d&quot;, n); break; case 2: int arr2[32] = { 0 }; if (n &gt; 0) { for (i = 0; i &lt; 32 ; i++) { arr2[i] = n % 2; n = n / 2; } for (j = 31; j &gt;= 0; j--) { if (arr2[j] == 0 &amp;&amp; check == ture) continue; else { check = false; printf(&quot;%d&quot;, arr2[j]); } } } else if (n == 0)printf(&quot;%d&quot;, 0); else if (n &lt; 0) { n = -n; for (i = 0; i &lt; 32; i++) { arr2[i] = n % 2; n = n / 2; } for (k = 0; k &lt; 32; k++) { arr2[k] = !arr2[k]; } add(1, arr2, 0); for (j = 31; j &gt;= 0; j--) { if (arr2[j] == 0 &amp;&amp; check == ture) continue; else { check = false; printf(&quot;%d&quot;, arr2[j]); } } break; } case 8: int arr8[11] = { 0 }; if (n &gt; 0) { for (i = 0; i &lt; 11; i++) { arr8[i] = n % 8; n = n / 8; } for (j = 10; j &gt;= 0; j--) { if (arr8[j] == 0 &amp;&amp; check == ture) continue; else { check = false; printf(&quot;%d&quot;, arr8[j]); } } } } } return 0; } </code></pre> <p>When I run the program in VS2022.There is a bug. <em><strong>Error C2360 Initialization of &quot;arr2&quot; is skipped by &quot;case&quot; tag Project5 C:\code\C\C_Single\Project5\Project5\test.cpp 74</strong></em> I don't understand why this is happening. In my opinion,when I select the contents of case8, I don't need the contents of case2, certainly,including the declaration of arr2.But obviously the compiler doesn't think that way. So I turn to google for help. However,google tells me something like this. Your search - Error C2360 Initialization of &quot;arr2&quot; is skipped by &quot;case&quot; tag - did not match any documents.</p> <p>Suggestions:</p> <p>Make sure that all words are spelled correctly. Try different keywords. Try more general keywords. Try fewer keywords. So I want to get help in stackoverflow.Can anyone help me?</p>
[ { "answer_id": 74142450, "author": "Andrew Parks", "author_id": 5898421, "author_profile": "https://Stackoverflow.com/users/5898421", "pm_score": 3, "selected": true, "text": "let arr1 = ['name', 'age', 'occupation', 'address'];\nlet arr2 = [{'age': 20, 'address': '', 'occupation': 'stud...
2022/10/20
[ "https://Stackoverflow.com/questions/74142326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19491735/" ]
74,142,401
<p>I know I have to use nonReentrant modifier for this method, but I also know it's wont work can someone tell me what should I do to create a mechanism something like this with safe pattern?</p> <pre><code>function swapTokenToEvolve(uint256 _tokenAmount, uint256 _stageIndex) public checkStageTime(_stageIndex) checkRemainingAmount(_tokenAmount, _stageIndex) nonReentrant returns (bool) { // get token price from stage ; uint256 tokenPrice = salesStages[_stageIndex].price; // how many tokens user will get; uint256 stableTokenAmount = multiply(_tokenAmount, tokenPrice, decimal); // transfer token from buyer to seller; require( IERC20(currencyToken).transferFrom( owner(), _msgSender(), _tokenAmount ) ); // transfer token from seller to user; require( IERC20(token).transferFrom(_msgSender(), owner(), stableTokenAmount) ); salesStages[_stageIndex].liquidity = salesStages[_stageIndex] .liquidity .sub(_tokenAmount); return true; } </code></pre>
[ { "answer_id": 74144862, "author": "tinom9", "author_id": 15756325, "author_profile": "https://Stackoverflow.com/users/15756325", "pm_score": 0, "selected": false, "text": "transferFrom" }, { "answer_id": 74204303, "author": "Payam Safaei", "author_id": 19630855, "aut...
2022/10/20
[ "https://Stackoverflow.com/questions/74142401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11404554/" ]
74,142,411
<p>I am trying to select a dropdown box. The code from the page is:</p> <pre><code>&lt;span class=&quot;sui-dropdown&quot; tabindex=&quot;0&quot; style=&quot;width: 150px;&quot;&gt; &lt;select class=&quot;dropdown-soberanos-plazo&quot; style=&quot;display: none;&quot;&gt; &lt;option value=&quot;CI&quot;&gt;CI&lt;/option&gt;&lt;option value=&quot;24hs&quot;&gt;24hs&lt;/option&gt; &lt;option value=&quot;48hs&quot;&gt;48hs&lt;/option&gt; &lt;/select&gt; &lt;span class=&quot;sui-input sui-unselectable&quot; unselectable=&quot;on&quot;&gt;48hs&lt;/span&gt; &lt;span class=&quot;sui-caret-container sui-unselectable&quot; unselectable=&quot;on&quot;&gt; &lt;span class=&quot;sui-caret sui-unselectable&quot; unselectable=&quot;on&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt; </code></pre> <p>I tried the next code, but i am not even able to select the dropdown.</p> <pre><code>from selenium.webdriver.support.select import Select driver.find_elements(By.XPATH,'//*[@id=&quot;soberanos&quot;]/div/div[3]/span') Out[176]: [&lt;selenium.webdriver.remote.webelement.WebElement (session=&quot;f181c2e9094dce7159f3b24212735c16&quot;, element=&quot;8846fda9-7cbe-4b20-ae8c-6b6071f7a18f&quot;)&gt;] Select(driver.find_elements(By.XPATH,'//*[@id=&quot;soberanos&quot;]/div/div[3]')) Traceback (most recent call last): File &quot;C:\Users\XXXXXXX\AppData\Local\Temp\ipykernel_22996\2906900798.py&quot;, line 1, in &lt;cell line: 1&gt; Select(driver.find_elements(By.XPATH,'//*[@id=&quot;soberanos&quot;]/div/div[3]')) File &quot;C:\Users\XXXXXX\Desktop\Selenium\lib\site-packages\selenium\webdriver\support\select.py&quot;, line 36, in __init__ if webelement.tag_name.lower() != &quot;select&quot;: AttributeError: 'list' object has no attribute 'tag_name' </code></pre> <p>and</p> <pre><code> from selenium.webdriver.support.ui import Select </code></pre> <p>with no success :(</p> <p>I tried with diferents XPATH, same result.</p> <pre><code>Select(driver.find_elements(By.XPATH,'//*[@id=&quot;soberanos&quot;]/div/div[3]/span/select')) Traceback (most recent call last): File &quot;C:\Users\ltaboada\AppData\Local\Temp\ipykernel_22996\1364519513.py&quot;, line 1, in &lt;cell line: 1&gt; Select(driver.find_elements(By.XPATH,'//*[@id=&quot;soberanos&quot;]/div/div[3]/span/select')) File &quot;C:\Users\ltaboada\Desktop\Selenium\lib\site-packages\selenium\webdriver\support\select.py&quot;, line 36, in __init__ if webelement.tag_name.lower() != &quot;select&quot;: AttributeError: 'list' object has no attribute 'tag_name' </code></pre> <p>So.... any advice? thanks!!! <a href="https://i.stack.imgur.com/tSq77.png" rel="nofollow noreferrer">dropdown Image</a></p>
[ { "answer_id": 74144862, "author": "tinom9", "author_id": 15756325, "author_profile": "https://Stackoverflow.com/users/15756325", "pm_score": 0, "selected": false, "text": "transferFrom" }, { "answer_id": 74204303, "author": "Payam Safaei", "author_id": 19630855, "aut...
2022/10/20
[ "https://Stackoverflow.com/questions/74142411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14649725/" ]
74,142,429
<p>I want to create a dictionary by List of object for example</p> <pre><code>public class personne { public string code {get; set;} public string ItemName {get;set;} public string Adresse {get;set} } </code></pre> <p>I want to have for each property an element in the dictionary, whose name of the property represents the key and the value is a list of strings which are the values ​​of the list using linq:</p> <pre><code>Dictionary&lt;string, List&lt;string&gt;&gt; test = new Dictionary&lt;string, List&lt;string&gt;&gt;(); </code></pre> <p>key = proprety</p> <p>value = values of property</p>
[ { "answer_id": 74144862, "author": "tinom9", "author_id": 15756325, "author_profile": "https://Stackoverflow.com/users/15756325", "pm_score": 0, "selected": false, "text": "transferFrom" }, { "answer_id": 74204303, "author": "Payam Safaei", "author_id": 19630855, "aut...
2022/10/20
[ "https://Stackoverflow.com/questions/74142429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11571736/" ]
74,142,460
<p>I'm getting data from an API and need to format it differently. I have a <code>car_array</code> that consists of an array of hashes. However, sometimes there will be a sub-array as one of the hash values that contains more than 1 element. In this case, there should be a loop so that each element in the array gets mapped correctly as separate entries.</p> <p>An example of data, note how <code>prices</code> and <code>options_package</code> are arrays with multiple elements.</p> <pre><code>[{ dealer_id: 1, dealer_name: &quot;dealership 1&quot;, car_make: &quot;jeep&quot;, prices: ['30', '32', '35'], options_package: ['A', 'B', 'C'] }, { dealer_id: 2, dealer_name: &quot;dealership 2&quot;, car_make: &quot;ford&quot;, prices: ['50', '55'], options_package: ['X', 'Y'] }, { dealer_id: 3, dealer_name: &quot;dealership 3&quot;, car_make: &quot;dodge&quot;, prices: ['70'], options_package: ['A'] }] </code></pre> <p>I would like to create multiple entries when there are multiple array elements</p> <p>for example, the data above should be broken out and mapped as:</p> <pre><code>some_array = [ { dealer_id: 1, dealer_name: &quot;dealership 1&quot;, car_make: &quot;jeep&quot;, price: '30', options_package: 'A' }, { dealer_id: 1, dealer_name: &quot;dealership 1&quot;, car_make: &quot;jeep&quot;, price: '32', options_package: 'B' }, { dealer_id: 1, dealer_name: &quot;dealership 1&quot;, car_make: &quot;jeep&quot;, price: '35', options_package: 'C' }, { dealer_id: 2, dealer_name: &quot;dealership 2&quot;, car_make: &quot;ford&quot;, price: '50', options_package: 'X' }, { dealer_id: 2, dealer_name: &quot;dealership 2&quot;, car_make: &quot;ford&quot;, price: '55', options_package: 'Y' }, { dealer_id: 3, dealer_name: &quot;dealership 3&quot;, car_make: &quot;dodge&quot;, price: '70', options_package: 'A' } ] </code></pre> <p>Here's what I've got so far:</p> <pre><code>car_arr.each do |car| if car['Prices'].length &gt; 1 # if there are multiple prices/options loop through each one and create a new car car.each do |key, value| if key == 'Prices' value.each do |price| formatted_car_array &lt;&lt; { dealer_id: car['dealer_id'], dealer_name: car['dealer_name'], car_make: car['make'], options_package: ???????, price: price, } end end end else # there's only element for price and options_package formatted_car_array &lt;&lt; { dealer_id: car['dealer_id'], dealer_name: car['dealer_name'], car_make: car['make'], options_package: car['options_package'], price: car['prices'] } end end </code></pre>
[ { "answer_id": 74142745, "author": "Chris", "author_id": 15261315, "author_profile": "https://Stackoverflow.com/users/15261315", "pm_score": 3, "selected": true, "text": "h = {\n dealer_id: 1,\n dealer_name: \"dealership 1\",\n car_make: \"jeep\",\n prices: ['30', '32', '35'],\n opt...
2022/10/20
[ "https://Stackoverflow.com/questions/74142460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8560709/" ]
74,142,464
<p>I have a huge list of different car names which are repeating and their types. I need to sum the amout of types each car has. For example Name1 has 2 van and one medium, Name2 has 2 van 1 medium, Name3 has 1 non_cargo and 2 medium and so on. I don't know how to make a formula for that. I have uploaded example screenshot. Thank you in advance. <img src="https://i.stack.imgur.com/knOfJ.png" alt="enter image description here" /></p>
[ { "answer_id": 74143576, "author": "David Leal", "author_id": 6237093, "author_profile": "https://Stackoverflow.com/users/6237093", "pm_score": 3, "selected": true, "text": "A2:A10" }, { "answer_id": 74143942, "author": "P.b", "author_id": 12634230, "author_profile": ...
2022/10/20
[ "https://Stackoverflow.com/questions/74142464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19105712/" ]
74,142,466
<p>I am trying to return a list of files from a directory. Here's my code:</p> <pre><code>package com.demo.web.api.file; import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.demo.core.Logger; import io.swagger.v3.oas.annotations.Operation; @RestController @RequestMapping(value = &quot;/files&quot;) public class FileService { private static final Logger logger = Logger.factory(FileService.class); @Value(&quot;${file-upload-path}&quot;) public String DIRECTORY; @Value(&quot;${file-upload-check-subfolders}&quot;) public boolean CHECK_SUBFOLDERS; @GetMapping(value = &quot;/list&quot;) @Operation(summary = &quot;Get list of Uploaded files&quot;) public ResponseEntity&lt;List&lt;File&gt;&gt; list() { List&lt;File&gt; files = new ArrayList&lt;&gt;(); if (CHECK_SUBFOLDERS) { // Recursive check try (Stream&lt;Path&gt; walk = Files.walk(Paths.get(DIRECTORY))) { List&lt;Path&gt; result = walk.filter(Files::isRegularFile).collect(Collectors.toList()); for (Path p : result) { files.add(p.toFile().getAbsoluteFile()); } } catch (Exception e) { logger.error(e.getMessage()); } } else { // Checks the root directory only. try (Stream&lt;Path&gt; walk = Files.walk(Paths.get(DIRECTORY), 1)) { List&lt;Path&gt; result = walk.filter(Files::isRegularFile).collect(Collectors.toList()); for (Path p : result) { files.add(p.toFile().getAbsoluteFile()); } } catch (Exception e) { logger.error(e.getMessage()); } } return ResponseEntity.ok().body(files); } } </code></pre> <p>As seen in the code, I am trying to return a <strong>list of files</strong>.</p> <p>However, when I test in PostMan, I get a <strong>list of string</strong> instead. <a href="https://i.stack.imgur.com/3Pts6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Pts6.png" alt="enter image description here" /></a></p> <p>How can I make it return the file object instead of the file path string? I need to get the file attributes (size, date, etc.) to display in my view.</p>
[ { "answer_id": 74143576, "author": "David Leal", "author_id": 6237093, "author_profile": "https://Stackoverflow.com/users/6237093", "pm_score": 3, "selected": true, "text": "A2:A10" }, { "answer_id": 74143942, "author": "P.b", "author_id": 12634230, "author_profile": ...
2022/10/20
[ "https://Stackoverflow.com/questions/74142466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6413141/" ]
74,142,486
<p>I want to create a Card that is reusable with Image. Am I on the right track in the new type of Card? I do not know how to put the Image on the card. all the question regarding the reusable widget card type in stackoverflow and youtube seems old and i dont know if it is truly working in the newer version.</p> <p><a href="https://i.stack.imgur.com/P6Psp.png" rel="nofollow noreferrer">Prototype Figma of My vision of Card in the HomePage</a></p> <p><a href="https://i.stack.imgur.com/aBiDG.png" rel="nofollow noreferrer">Here is the example for the clarifcation of the image on the background</a></p> <p>this is the previous code that I want to be scrapped because they are too many.</p> <pre><code>Container( padding: const EdgeInsets.all(8), color: const Color.fromARGB(255, 75, 175, 78), child: Center( child: TextButton( onPressed: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) =&gt; const SecondPage( plantname: 'Bell Pepper'))); }, child: const Text( &quot;Bell Pepper&quot;, style: TextStyle( fontSize: 19, fontFamily: 'RobotoMedium', color: Color(0xffeeeeee)), )), )), </code></pre> <p>This the new type of Card that I want to be the reusable. But I dont know how to put the image and make it better.</p> <pre><code>import 'package:flutter/material.dart'; import 'package:flutter_native_splash/cli_commands.dart'; class ListViewCard extends StatelessWidget { final String title; final void Function()? onTap; final Image imageOfPlant; const ListViewCard( {super.key, required this.title, required this.onTap, required this.imageOfPlant, }); @override Widget build(BuildContext context) { return Card( color: const Color.fromARGB(255, 75, 175, 78), elevation: 0, margin: const EdgeInsets.all(8), semanticContainer: true, clipBehavior: Clip.antiAliasWithSaveLayer, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), child: InkWell( splashColor: Colors.lightGreenAccent.withAlpha(30), onTap: onTap, //sizedBox of the card child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: &lt;Widget&gt;[ SizedBox( width: 150, height: 200, child: Text(title, style: const TextStyle( fontSize: 19, fontFamily: 'RobotoMedium', color: Color(0xffeeeeee)),// textstyle ),),//text //SizedBox ], // &lt;widget&gt;[] ), // column ), //inkwell ); // card } } </code></pre>
[ { "answer_id": 74143576, "author": "David Leal", "author_id": 6237093, "author_profile": "https://Stackoverflow.com/users/6237093", "pm_score": 3, "selected": true, "text": "A2:A10" }, { "answer_id": 74143942, "author": "P.b", "author_id": 12634230, "author_profile": ...
2022/10/20
[ "https://Stackoverflow.com/questions/74142486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19392593/" ]
74,142,491
<p>I want to schedule a post to my API that sends logs every couple hours while ensuring there is an internet connection, so for example if I reach the 2 hours and I dont have internet at that moment, I want to wait until there is, send the request and reset the timer to the current sync hour.</p> <p>I have seen this related <a href="https://stackoverflow.com/questions/14376470/scheduling-recurring-task-in-android">issue</a> but doesnt take in consideration the internet connectivity part.</p> <p>I extended AppCompatActivity to register a BroadcastReceiver in every activity as so:</p> <pre><code>public class BaseActivity extends AppCompatActivity { InternetReceiver internetReceiver = new InternetReceiver(); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(internetReceiver, intentFilter); } @Override protected void onDestroy() { super.onDestroy(); unregisterReceiver(internetReceiver); } </code></pre> <p>And my InternetReceiver looks like so:</p> <pre><code>public class InternetReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) { boolean noConnection = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); if (!noConnection) { // send some data... } } } } </code></pre> <p>How can I achieve this?</p>
[ { "answer_id": 74143576, "author": "David Leal", "author_id": 6237093, "author_profile": "https://Stackoverflow.com/users/6237093", "pm_score": 3, "selected": true, "text": "A2:A10" }, { "answer_id": 74143942, "author": "P.b", "author_id": 12634230, "author_profile": ...
2022/10/20
[ "https://Stackoverflow.com/questions/74142491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17234028/" ]
74,142,500
<p>I have two objects they are: Student and Courses:</p> <pre><code>public Student(string StudentID, string Name, string Status, Enum StudentMajor, Dictionary&lt;Courses, Grade[]&gt; CompletedCourses) public Courses(string courseName, string courseCode, string passingGrade, int numOfCredits, List&lt;Courses&gt; prerequisites) </code></pre> <p>Here's the objects I created in my Main class</p> <pre><code>//Courses Courses ITEC_120 = new(&quot;Introduction to Computer Hardware&quot;, &quot;ITEC 120&quot;, &quot;C&quot;, 3, new List&lt;Courses&gt; {}); Courses ITEC_122 = new(&quot;Introduction to Operating Systems&quot;, &quot;ITEC 122&quot;, &quot;C&quot;, 3, new List&lt;Courses&gt; { ITEC_120 }); //Student Student student1 = new(&quot;00069110&quot;, &quot;Antony Dos Santos&quot;, &quot;Full-time&quot;, Majors.Computer_Information_Systems, new Dictionary&lt;Courses, Grade[]&gt;() { { ITEC_120, new[] { Grade.F, Grade.B, Grade.Not_Taken } }, { ITEC_122, new[] { Grade.A, Grade.Not_Taken, Grade.Not_Taken } }, }); </code></pre> <p>As you can see the courses have a variable called <code>credit</code> and each <code>Student</code> object has a dictionary that takes a <code>Course</code> and a <code>Grade</code></p> <p>So <code>student1</code> has two courses and each of the courses has 3 credits each. How would I iterate over the Dictionary to get the total of all the courses in <code>CoursesCompleted</code> in this case it should be 6.</p> <p>Each object is added to a List</p> <pre><code>//List for Courses objects List&lt;Courses&gt; CompulsoryCourses = new List&lt;Courses&gt;(); CompulsoryCourses.Add(ITEC_120); CompulsoryCourses.Add(ITEC_122);//Adding the two courses to the List List for Student objects List&lt;Student&gt; students = new List&lt;Student&gt;(); students.Add(student1); foreach(var stu in students) { var GPA = 0.0; var CourseCredits = 0; Console.WriteLine(&quot;\nStudent Information&quot;); foreach (KeyValuePair&lt;Courses, Grade[]&gt; item in stu.CompletedCourses) { var TotalCredits = CourseCredits+item.Key.numOfCredits; Console.WriteLine(&quot;\nName: &quot; + item.Key.courseName + &quot;, Credits: &quot; + item.Key.numOfCredits); GPA = stu.calGPA(CourseCredits); Console.WriteLine(&quot;Total Credits: &quot;+TotalCredits); } Console.WriteLine(stu.Name+ &quot;: GPA = &quot; + GPA); } </code></pre> <p>In the foreach loop above I'm looping through the students List, and then I use another foreach loop to iterate the Dictionary to get the <code>Key</code> which in this case is <code>numOfCredits</code> like: <code>item.Key.numOfCredits</code>, and add them to each other.</p> <p>Currently it's only adding the <code>numOfCredits</code> to itself and not to the other course in the dictionary.</p>
[ { "answer_id": 74142607, "author": "sr28", "author_id": 2381942, "author_profile": "https://Stackoverflow.com/users/2381942", "pm_score": 2, "selected": false, "text": "var cars = new List<Car>\n{\n new Car{ BrandName = \"Lamborghini\", Model = \"Huracan\", Price = 300000M },\n new...
2022/10/20
[ "https://Stackoverflow.com/questions/74142500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19462819/" ]
74,142,510
<p>I have a python script running in views.py within Django which returns two very large string arrays, x and y. It currently is able to run off a button press within my index.html.</p> <pre><code>def python_file(request): final() return HttpResponse(&quot;ran&quot;) </code></pre> <p>The ajax code I have running to do the button press.</p> <pre><code>&lt;script src=&quot;http://code.jquery.com/jquery-3.3.1.min.js&quot; integrity=&quot;sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt; &lt;script&gt; function gotoPython(){ $.ajax({ url: &quot;/python_file&quot;, context: document.body }).done(function() { alert('finished python script'); }); } &lt;/script&gt; </code></pre> <p>It's also attached to the URLS.py. I know there's no array being returned right now, because I am unsure how to run the script, get the data simultaneously, then add it to the page without refreshing the page. So, I am asking what would be the best practice to do what I described. Any help would be appreciated.</p>
[ { "answer_id": 74142607, "author": "sr28", "author_id": 2381942, "author_profile": "https://Stackoverflow.com/users/2381942", "pm_score": 2, "selected": false, "text": "var cars = new List<Car>\n{\n new Car{ BrandName = \"Lamborghini\", Model = \"Huracan\", Price = 300000M },\n new...
2022/10/20
[ "https://Stackoverflow.com/questions/74142510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19981030/" ]
74,142,559
<p>I have a use case where I am loading the HTML page from the variable.</p> <p>now I have 3 states to maintain (PENDING, COMPLETED, FAILED)</p> <p>on each state, I want to show different messages and elements</p> <pre><code>&lt;script&gt; var status = &quot;COMPLETED&quot;; function hideBoth() { document.getElementById(&quot;cont1&quot;).style.visibility = &quot;hidden&quot;; document.getElementById(&quot;cont2&quot;).style.visibility = &quot;hidden&quot;; console.log(status, &quot;-=--Status&quot;); if (status === &quot;COMPLETED&quot;) { console.log(status, &quot;INSIDE COMPLETED&quot;); console.log( document.getElementById(&quot;COMPLETED&quot;), &quot;INSIDE COMPLETED CHECK&quot; ); document.getElementById(status).innerHTML; document.getElementById(&quot;PENDING&quot;).style.visibility = &quot;hidden&quot;; document.getElementById(&quot;FAILED&quot;).style.visibility = &quot;hidden&quot;; } if (status === &quot;PENDING&quot;) { document.getElementById(&quot;COMPLETED&quot;).style.visibility = &quot;hidden&quot;; document.getElementById(&quot;PENDING&quot;).innerHTML = status; document.getElementById(&quot;FAILED&quot;).style.visibility = &quot;hidden&quot;; } else { document.getElementById(&quot;COMPLETED&quot;).style.visibility = &quot;hidden&quot;; document.getElementById(&quot;PENDING&quot;).innerHTML = status; document.getElementById(&quot;FAILED&quot;).style.visibility = &quot;hidden&quot;; } } &lt;/script&gt; </code></pre> <p>This is the script tag looks like</p> <p>the entire code is here <a href="https://codesandbox.io/s/elated-lamport-fwhqsm?file=/index.html" rel="nofollow noreferrer">https://codesandbox.io/s/elated-lamport-fwhqsm?file=/index.html</a></p> <p>Where I am missing things, Not so sure about it. Can I get some pointers on what I am missing?</p> <p>Thanks in advance.</p>
[ { "answer_id": 74142607, "author": "sr28", "author_id": 2381942, "author_profile": "https://Stackoverflow.com/users/2381942", "pm_score": 2, "selected": false, "text": "var cars = new List<Car>\n{\n new Car{ BrandName = \"Lamborghini\", Model = \"Huracan\", Price = 300000M },\n new...
2022/10/20
[ "https://Stackoverflow.com/questions/74142559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15571103/" ]
74,142,560
<p>I am trying to create a TextSplit function in Excel that can accept either a single reference or a range. If it is a single string it returns an array of sub strings. If it is a range it would return an array of sub string arrays. The below code is what I am working with. A single string works fine but when I pass it a single column range it give me a #VALUE! error.</p> <p>The commented lines work. If I store the result of Array to arr Excel displays a grid of &quot;test&quot; strings. If instead set TextSplit to just arr(1) I get a single array of substrings similar to the single string version.</p> <p>I don't know what I am doing wrong. I am an old Java developer new to VBA scripting in Excel. Any help would be appreciated.</p> <pre><code>Function TextSplit(text, delimiter) If IsArray(text) Then Dim arr() As Variant: ReDim arr(0 To text.Count - 1) For i = 1 To text.Count arr(i-1) = Split(text(i), delimiter) 'arr(i-1) = Array(&quot;test&quot;, &quot;test&quot;) Next TextSplit = arr 'TextSplit = arr(1) Else TextSplit = Split(text, delimiter) End If </code></pre>
[ { "answer_id": 74142607, "author": "sr28", "author_id": 2381942, "author_profile": "https://Stackoverflow.com/users/2381942", "pm_score": 2, "selected": false, "text": "var cars = new List<Car>\n{\n new Car{ BrandName = \"Lamborghini\", Model = \"Huracan\", Price = 300000M },\n new...
2022/10/20
[ "https://Stackoverflow.com/questions/74142560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1509130/" ]
74,142,568
<p>So this is my first time using Stripe to integrate payments for a website. What I am trying to do is add Stripe to my terminal for it to work correctly but I am getting an error. I have created a &quot;Server&quot; folder along with a &quot;Server.js&quot; file and when I try to initialize a new project it throws me an error.</p> <pre><code>The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050. Royces-MacBook-Air:Kingdom Website roycewilliams$ $ cd server/ bash: $: command not found Royces-MacBook-Air:Kingdom Website roycewilliams$ cd server/ Royces-MacBook-Air:server roycewilliams$ npm init -y node:internal/modules/cjs/loader:926 throw err; ^ Error: Cannot find module './lib/_stream_readable.js' Require stack: - /usr/local/lib/node_modules/npm/node_modules/readable-stream/readable.js - /usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-stream.js - /usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-group.js - /usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/index.js - /usr/local/lib/node_modules/npm/node_modules/npmlog/log.js - /usr/local/lib/node_modules/npm/lib/cli.js - /usr/local/lib/node_modules/npm/bin/npm-cli.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:923:15) at Function.Module._load (node:internal/modules/cjs/loader:768:27) at Module.require (node:internal/modules/cjs/loader:995:19) at require (node:internal/modules/cjs/helpers:92:18) at Object.&lt;anonymous&gt; (/usr/local/lib/node_modules/npm/node_modules/readable-stream/readable.js:12:30) at Module._compile (node:internal/modules/cjs/loader:1091:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:10) at Module.load (node:internal/modules/cjs/loader:971:32) at Function.Module._load (node:internal/modules/cjs/loader:812:14) at Module.require (node:internal/modules/cjs/loader:995:19) { code: 'MODULE_NOT_FOUND', requireStack: [ '/usr/local/lib/node_modules/npm/node_modules/readable-stream/readable.js', '/usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-stream.js', '/usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/tracker-group.js', '/usr/local/lib/node_modules/npm/node_modules/are-we-there-yet/index.js', '/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js', '/usr/local/lib/node_modules/npm/lib/cli.js', '/usr/local/lib/node_modules/npm/bin/npm-cli.js' ] } Royces-MacBook-Air:server royce williams$ </code></pre>
[ { "answer_id": 74143033, "author": "Pedro Ribeiro", "author_id": 8559424, "author_profile": "https://Stackoverflow.com/users/8559424", "pm_score": 2, "selected": false, "text": "npm i" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74142568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16147870/" ]
74,142,576
<p>I have these two datasets : <code>df</code> as the main data frame and <code>g</code> as a created data frame</p> <pre><code>df = data.frame(x = seq(1,20,2),y = letters[1:10] ) df g = data.frame(xx = c(2,3,4,5,7,8,9) ) </code></pre> <p>and I want to take a subset of the data frame <code>df</code> based on the values xx of the data frame <code>g</code> as follows</p> <pre><code>m = df[df$x==g$xx,] </code></pre> <p>but the result is based on the match between the two data frames for the order of the matched values. not the matched values themselves.</p> <p>output</p> <pre><code>&gt; m x y 2 3 b </code></pre> <p>I don't what the error I am making.</p>
[ { "answer_id": 74142602, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 3, "selected": true, "text": "%in%" }, { "answer_id": 74142626, "author": "akrun", "author_id": 3732271, "author_profile"...
2022/10/20
[ "https://Stackoverflow.com/questions/74142576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19720935/" ]
74,142,592
<p>This fails with <code>tlsv1 alert unknown ca</code></p> <pre><code>psql -h localhost -p 4566 -d dev -U root --set=sslmode=disable </code></pre> <p>This works:</p> <pre><code>psql &quot;port=4566 host=localhost user=root dbname=dev sslmode=disable&quot; </code></pre> <p>Why? Why does one work when the other does not? Is the <code>--set</code> ignored?</p> <p>Is this a bug or a feature?</p>
[ { "answer_id": 74143785, "author": "jjanes", "author_id": 1721239, "author_profile": "https://Stackoverflow.com/users/1721239", "pm_score": 3, "selected": true, "text": "select :'sslmode';" }, { "answer_id": 74197673, "author": "jian", "author_id": 15603477, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74142592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345715/" ]
74,142,594
<p>I have a two div I want to send selected text to another div using onSelect event? Right now entire para sending to another div but I want to send just selected text. How can I do this?</p> <p>Demo:- <a href="https://codesandbox.io/s/selected-text-send-to-another-div-using-onselect-0ccnrn?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/selected-text-send-to-another-div-using-onselect-0ccnrn?file=/src/App.js</a></p> <p>My Code:-</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>import React from "react"; import { Box, Grid, TextField, Typography } from "@material-ui/core"; import { useState } from "react"; const SendSelectedText = () =&gt; { const [label1, setlabel1]=useState(''); const [para, setPara]=useState('This is Old Para'); const handleClick = () =&gt; { setlabel1(para); }; return ( &lt;&gt; &lt;Box className="sendSelectedTextPage"&gt; &lt;Grid container spacing={3}&gt; &lt;Grid item xl={6} lg={6} md={6}&gt; &lt;textarea onSelect={handleClick}&gt;{para}&lt;/textarea&gt; &lt;/Grid&gt; &lt;Grid item xl={6} lg={6} md={6}&gt; &lt;TextField variant="outlined" size="small" label="Label One" value={label1} multiline rows={3} className="sendSelectedTextPageInput" /&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/Box&gt; &lt;/&gt; ); }; export default SendSelectedText;</code></pre> </div> </div> </p> <p>Thanks for your support!</p>
[ { "answer_id": 74143785, "author": "jjanes", "author_id": 1721239, "author_profile": "https://Stackoverflow.com/users/1721239", "pm_score": 3, "selected": true, "text": "select :'sslmode';" }, { "answer_id": 74197673, "author": "jian", "author_id": 15603477, "author_p...
2022/10/20
[ "https://Stackoverflow.com/questions/74142594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7333403/" ]
74,142,622
<p>I have the script below setup in AWS Athena, the goal is to replace <em>some</em> budget numbers (total) with 0 if they are within a certain category (costitemid). I'm getting the following error in AWS Athena and could use some advice as to why it isn't working. Is the problem that I need to repeat everything in the FROM and GROUP BY in the WHEN and ELSE? Code below the error. Thank you!</p> <p><em>SYNTAX_ERROR: line 6:9: 'projectbudgets.projectid' must be an aggregate expression or appear in GROUP BY clause This query ran against the &quot;acorn-prod-reports&quot; database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: 077f007b-61a0-4f6b-aa1f-dd38bb401218</em></p> <pre><code>SELECT CASE WHEN projectbudgetlineitems.costitemid IN (462561,462562,462563,462564,462565,462566,478030) THEN ( SELECT projectbudgets.projectid , projectbudgetyears.year fiscalYear , projectbudgetyears.status , &quot;sum&quot;(((0 * projectbudgetlineitems.unitcost) * (projectbudgetlineitems.costshare * 1E-2))) total ) ELSE ( SELECT projectbudgets.projectid , projectbudgetyears.year fiscalYear , projectbudgetyears.status , &quot;sum&quot;(((projectbudgetlineitems.quantity * projectbudgetlineitems.unitcost) * (projectbudgetlineitems.costshare * 1E-2))) total ) END FROM ((&quot;acorn-prod-etl&quot;.target_acorn_prod_acorn_projectbudgets projectbudgets INNER JOIN &quot;acorn-prod-etl&quot;.target_acorn_prod_acorn_projectbudgetyears projectbudgetyears ON (projectbudgets.id = projectbudgetyears.projectbudgetid)) INNER JOIN &quot;acorn-prod-etl&quot;.target_acorn_prod_acorn_projectbudgetlineitems projectbudgetlineitems ON (projectbudgetyears.id = projectbudgetlineitems.projectbudgetyearid)) --WHERE (((projectbudgetlineitems.costitemid &lt;&gt; 478030) AND (projectbudgetlineitems.costitemid &lt; 462561)) OR (projectbudgetlineitems.costitemid &gt; 462566)) GROUP BY projectbudgets.projectid, projectbudgetyears.year, projectbudgetyears.status </code></pre>
[ { "answer_id": 74143679, "author": "gregor", "author_id": 20198546, "author_profile": "https://Stackoverflow.com/users/20198546", "pm_score": 0, "selected": false, "text": "SELECT\nprojectbudgets.projectid, \nprojectbudgetyears.year, \nprojectbudgetyears.status,\n\"sum\"(((projectbudgetl...
2022/10/20
[ "https://Stackoverflow.com/questions/74142622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1853836/" ]
74,142,625
<p>So I'm new to C# I somewhat know Python I couldn't understand how functions work I tried doing something like this:</p> <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; public class collisiondetectorleft : MonoBehaviour { public class Triggerdetecting() { public void OnTriggerStay(Collider other) { if (other.attachedRigidbody) other.attachedRigidbody.AddForce((Vector3.up * 10); } } void FixedUpdate() { if (Input.GetKeyDown(&quot;space&quot;)) { //I'm so lost Triggerdetecting objTriggerdetecting = new Triggerdetecting(); } } } </code></pre> <p>I'm trying to create some sort of hitbox by detecting trigger if a button pressed and meets the condition make the object more faster. I tried few ways to call function non of them worked. Thank you for your time. If you unable to understand what I meant you can ask me I'll try to explain in other ways.</p> <p>Want something like this:</p> <pre><code>def detection(): if OnTriggerStay == True: moveobject up if Input.GetKeyDown(&quot;space&quot;)) == True: detection() </code></pre>
[ { "answer_id": 74143679, "author": "gregor", "author_id": 20198546, "author_profile": "https://Stackoverflow.com/users/20198546", "pm_score": 0, "selected": false, "text": "SELECT\nprojectbudgets.projectid, \nprojectbudgetyears.year, \nprojectbudgetyears.status,\n\"sum\"(((projectbudgetl...
2022/10/20
[ "https://Stackoverflow.com/questions/74142625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19952343/" ]
74,142,650
<p>I have a list of names. for each name, I start with my dataframe df, and use the elements in the list to define new columns for the df. after my data manipulation is complete, I eventually create a new data frame whose name is partially derived from the list element.</p> <pre><code>list = ['foo','bar'] for x in list : df = prior_df (long code for manipulating df) new_df_x = df new_df_x.to_parquet('new_df_x.parquet') del new_df_x new_df_foo = pd.read_parquet(new_df_foo.parquet) new_df_bar = pd.read_parquet(new_df_bar.parquet) new_df = pd.merege(new_df_foo ,new_df_bar , ...) </code></pre> <p>The reason I am using this approach is that, if I don't use a loop and just add the foo and bar columns one after another to the original df, my data gets really big and highly fragmented before I go from wide to long and I encounter insufficient memory error. The workaround for me is to create a loop and store the data frame for each element and then at the very end join the long-format data frames together. Therefore, I cannot use the approach suggested in other answers such as creating dictionaries etc. I am stuck at the line</p> <pre><code>new_df_x = df </code></pre> <p>where within the loop, I am using the list element in the name of the data frame. I'd appreciate any help.</p>
[ { "answer_id": 74143679, "author": "gregor", "author_id": 20198546, "author_profile": "https://Stackoverflow.com/users/20198546", "pm_score": 0, "selected": false, "text": "SELECT\nprojectbudgets.projectid, \nprojectbudgetyears.year, \nprojectbudgetyears.status,\n\"sum\"(((projectbudgetl...
2022/10/20
[ "https://Stackoverflow.com/questions/74142650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12621381/" ]
74,142,668
<p>I have a string like this</p> <pre class="lang-js prettyprint-override"><code>var string = &quot;{ name: 'something', dependencies: [ 'express', 'axios' ] }&quot; </code></pre> <p>so i want to convert this string into object / json</p> <pre class="lang-js prettyprint-override"><code>{ name: &quot;something&quot;, dependencies: [ &quot;express&quot;, &quot;axios&quot; ] } </code></pre> <p>I tried to do this with <code>JSON.parse(string)</code> but it throw Error</p> <pre><code>undefined:2 dependencies: [ ^ SyntaxError: Unexpected token d in JSON at position 6 </code></pre>
[ { "answer_id": 74142742, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "eval" }, { "answer_id": 74142860, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15397220/" ]
74,142,688
<p>I have a few files with list of full paths to files on the share drive. For example:</p> <pre><code>\\server\share$\Public\HR\reports\report.doc \\server\share$\Public\HR\reports\report.xls </code></pre> <p>I am trying to get a count of files per directory with aggregates to the top:</p> <pre><code>\\server\share$\Public:200 \\server\share$\Public\HR: 10 \\server\share$\Public\HR\reports: 2 </code></pre> <p>So far I have:</p> <pre><code>foreach ($file in Get-ChildItem C:\scripts\FMU) { foreach ($path in Get-Content $file) { while ($path -ne &quot;&quot;) { $path = $path | Split-Path $array.$path.value, count++ #Not sure how to increment the count of the path value in the array } } } </code></pre> <p>How do I set up an array to count all of the paths?</p> <p>Thanks,</p>
[ { "answer_id": 74142742, "author": "David", "author_id": 328193, "author_profile": "https://Stackoverflow.com/users/328193", "pm_score": 2, "selected": false, "text": "eval" }, { "answer_id": 74142860, "author": "Mr. Polywhirl", "author_id": 1762224, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74142688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20293301/" ]
74,142,700
<p>I'm having terrible trouble trying to get Unicode (MS-SQL: nvarchar(length)) data out of an Oracle <em>varchar2</em> column.</p> <p>The connection is through the MS Oracle driver. Source/dest looks like this in the SSIS Toolbox:</p> <p><a href="https://i.stack.imgur.com/rjwwu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rjwwu.png" alt="Oracle SSIS Toolbox items" /></a></p> <p>I thought I would simply go into the Source component's Advanced Editor, and change both the External and Output columns to type DT_WSTR. No go. As soon as I click OK, and then go back into Adv. Editor - it's flipped back to DT_STR. I don't remember any other source behaving this badly. Note that this flip happens before execution or even validation. ValidateExternalMetaData On or Off makes no difference.</p> <p>Looking at <a href="https://stackoverflow.com/questions/59865117/how-to-change-dt-str-to-dt-wstr-by-default-in-ssis-for-oracle-source">this answer</a> I found out the Oracle server's NLS_CHARACTERSET setting, and the one in the local machine's registry:</p> <p>(I ran this against the Oracle server:</p> <pre><code>SELECT parameter, value FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET'; </code></pre> <p>)</p> <p>Oracle server: AL32UTF8 Local machine (registry): AMERICAN_AMERICA.WE8MSWIN1252</p> <p>then tried some conversions in the Oracle SQL in the source. This:</p> <pre><code>CONVERT(THECOLUMN,'WE8MSWIN1252','AL32UTF8') AS THECOLUMN, </code></pre> <p>had no effect.</p> <p>This:</p> <pre><code>CONVERT(THECOLUMN,'UTF8','AL32UTF8') AS THECOLUMN, </code></pre> <p>produced a weird effect. The non-English characters (specifically Polish Ł) came through perfectly in the <em>Preview</em>. But as soon as the data left the source (looked in Data Viewer), it was back to &quot;Some characters [ASCII 26 instead of Ł] some more characters&quot;. And the SSIS datatype was still DT_STR, and refused to change to DT_WSTR.</p> <p>I'm stuck. Can anyone help?</p> <p><strong>EDIT: more information</strong> Thank you all for comments.</p> <p><strong>Context</strong> I'm dealing with an existing ETL installation of 400 packages, so changing the driver will be difficult. For &quot;reasons&quot;, I cannot even access the Oracle DAS except on one server (literally, remote desktop to that server). So fiddling about with server registry settings/language etc isn't possible without DBA/sysadmin involvement. Driver information: <a href="https://i.stack.imgur.com/1msQB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1msQB.png" alt="Control Panel Software detail" /></a> and in ODBC drivers: <a href="https://i.stack.imgur.com/2rXJx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2rXJx.png" alt="ODBC Oracle drivers" /></a></p> <p>The list of possible drivers in the referenced other question isn't an exact match for my situation, as I'm trying to connect through SSIS, not raw .NET. What I'm trying to do is simply: get Unicode character data from an Oracle table (OK, it's probably a view, but that's beyond my reach), through SSIS, into an MS-SQL <em>nvarchar</em> column.</p> <p>The data in Oracle is clearly Unicode of some sort (see my test with the Preview above). The SSIS Source component, however, clearly thinks that it's DT_STR (SSIS datatype corresponding to MS-SQL non-Unicode <em>varchar</em>). And refuses to accept a &quot;hard override&quot; of this column's type through the Advanced Editor. So while in the Preview (presumably, before the Source Component actually gets the data) the data is correct (with Polish characters), once it hits the Source Component it has already been corrupted down to &quot;replace anything non-ASCII with ASCII(26)&quot;.</p> <p>Running this as suggested by Wernfried:</p> <pre><code>SELECT TheColumn,DUMP(TheColumn,1016) </code></pre> <p>gives me this - again, only in the <em>Preview</em>, not in the data which flows out of the Source through SSIS:</p> <p>PLUATREGŁ Typ=1 Len=10 Character Set=AL32UTF8: 50,4c,55,41,54,52,45,47,c5,81</p> <p>Guessing at what this means: If I do MS-SQL</p> <pre><code>SELECT CHAR(CONVERT(int,0x50)) </code></pre> <p>for each of these hex values, the characters makes sense, until C5 (&quot;Å&quot;) and 81 (&quot;&quot;). Perhaps the encoding used by the Oracle server is different from that on the local SQL Server.</p> <p>But my main problem is getting <em>anything</em> other than non-Unicode text through into SSIS.</p>
[ { "answer_id": 74152237, "author": "Wernfried Domscheit", "author_id": 3027266, "author_profile": "https://Stackoverflow.com/users/3027266", "pm_score": 1, "selected": false, "text": "DUMP" }, { "answer_id": 74361047, "author": "SebTHU", "author_id": 3584553, "author_...
2022/10/20
[ "https://Stackoverflow.com/questions/74142700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3584553/" ]
74,142,710
<p>I was writing unit tests to compare an original response to a filtered response using a request object as a parameter. In doing so I noticed that if I change the request object after getting a response the IEnumerable list will change - As I type this, my thinking is that because it is an IEnumerable with LINQ, the <code>request.Filter</code> property is a reference in the LINQ query, which is what causes this behavior. If I converted this to a list instead of an IEnumerable, I suspect the behavior would go away because the <code>.ToList()</code> will evaluate the LINQ expressions instead of deferring. Is that the case?</p> <pre><code>public class VendorResponse { public IEnumerable&lt;string&gt; Vendors { get; set; } } var request = new VendorRequest() { Filter = &quot;&quot; }; var response = await _service.GetVendors(request); int vendorCount = response.Vendors.Count(); // 20 request.Filter = &quot;at&amp;t&quot;; int newCount = response.Vendors.Count(); // 17 public async Task&lt;VendorResponse&gt; GetVendors(VendorRequest request) { var vendors = await _dataService.GetVendors(); return new VendorResponse { Vendors = vendors.Where(v =&gt; v.IndexOf(request.Filter) &gt;= 0) } } </code></pre>
[ { "answer_id": 74152237, "author": "Wernfried Domscheit", "author_id": 3027266, "author_profile": "https://Stackoverflow.com/users/3027266", "pm_score": 1, "selected": false, "text": "DUMP" }, { "answer_id": 74361047, "author": "SebTHU", "author_id": 3584553, "author_...
2022/10/20
[ "https://Stackoverflow.com/questions/74142710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1887101/" ]
74,142,721
<p>I want to create an algorithm to extract data from csv files in different folders / subfolders. each folder will have 9000 csvs. and we will have 12 of them. 12*9000. over 100,000 files</p>
[ { "answer_id": 74142892, "author": "the_strange", "author_id": 16509954, "author_profile": "https://Stackoverflow.com/users/16509954", "pm_score": -1, "selected": false, "text": "import pandas as pd\nfile = \"your_file.csv\"\ndata = pd.read_csv(file)\ndata = data.astype({\"column1\": int...
2022/10/20
[ "https://Stackoverflow.com/questions/74142721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14915169/" ]
74,142,735
<p>I am trying to add a prefix to a field in <code>awk</code> if it is not already present. That is if <code>chr</code> isn't present before the number it is inserted. However, if it is there it is skipped. The first <code>awk</code> adds the prefix to each <code>$2</code> even if it is present and the senond <code>awk</code> does skip the <code>$2</code> with <code>chr</code> in them, but does print <code>chr</code> in the <code>$2</code> without. Thank you :).</p> <p><strong>file</strong></p> <pre><code>ASPA,17:3483575-3483585 ATM,11:108289609-108289613 ATP7B,13:51937469-51937480 ATR,chr3:142562768-142562773 BAG3,chr10:119670120-119670123 </code></pre> <p><strong>desired</strong></p> <pre><code>ASPA,chr17:3483575-3483585 ATM,chr11:108289609-108289613 ATP7B,chr13:51937469-51937480 ATR,chr3:142562768-142562773 BAG3,chr10:119670120-119670123 </code></pre> <p><strong>awk</strong></p> <pre><code>awk -F, '{$2=&quot;chr&quot;$2; print}' file </code></pre> <p><strong>awk 2</strong></p> <pre><code>awk -F, '$2 !~/chr/{gsub(&quot;chr&quot;,&quot;chr&quot;,$2)}1' file </code></pre>
[ { "answer_id": 74142773, "author": "RavinderSingh13", "author_id": 5866580, "author_profile": "https://Stackoverflow.com/users/5866580", "pm_score": 2, "selected": false, "text": "awk" }, { "answer_id": 74142795, "author": "anubhava", "author_id": 548225, "author_prof...
2022/10/20
[ "https://Stackoverflow.com/questions/74142735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4668368/" ]
74,142,769
<p>I have a string that is written in two formats . Either <code>&quot;bill - nick&quot;</code> or <code>&quot;bill @ nick&quot;</code>.I want to get the two names from the string and store them in an array.I can try the <code>split()</code> function but I am looking for something dynamic no matter the divider the names have .</p> <p>I would appreciate your help .</p>
[ { "answer_id": 74142814, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 3, "selected": true, "text": "split()" }, { "answer_id": 74142825, "author": "Tim Biegeleisen", "author_id": 1863229, "author_pr...
2022/10/20
[ "https://Stackoverflow.com/questions/74142769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14020698/" ]
74,142,779
<p>Can I avoid duplicate strings with the sed &quot;a&quot; command?</p> <p>I added the word &quot;apple&quot; under &quot;true&quot; in my file.txt.</p> <p>The problem is that every time I run the command &quot;apple&quot; is appended.</p> <pre><code>$ sed -i '/true/a\apple' file.txt ...execute 3 time </code></pre> <pre><code>$ cat file.txt true apple apple apple </code></pre> <p>If the word &quot;apple&quot; already exists, repeating the sed command does not want to add any more.</p> <p>I have no idea, please help me</p> <p>...</p> <p>I want to do this,</p> <pre><code>...execute sed command anytime $ cat file.txt true apple </code></pre>
[ { "answer_id": 74143196, "author": "GoinOff", "author_id": 158787, "author_profile": "https://Stackoverflow.com/users/158787", "pm_score": 1, "selected": false, "text": "sed" }, { "answer_id": 74143217, "author": "M. Nejat Aydin", "author_id": 13809001, "author_profil...
2022/10/20
[ "https://Stackoverflow.com/questions/74142779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17985497/" ]
74,142,788
<p>I'm trying to use Selenium to find a web element that I know is the To field in a web email application (please see picture). I am able to successfully identify this web element and use send_keys to send an email address to this field.</p> <p>However, the issue is the id always seems to cycle between 299 and 3 other numbers like 359 or 369. Here's the code Im using. Is there another way I can account for this changing ID?</p> <pre><code>to_field = wait.until(EC.element_to_be_clickable((By.ID, &quot;v299-to-input&quot;))) print(to_field) to_field.send_keys(email_reciever) </code></pre> <p><a href="https://i.stack.imgur.com/0t2AC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0t2AC.png" alt="enter image description here" /></a></p> <p>Thanks</p> <p>PS- The web email application is fastmail.com</p>
[ { "answer_id": 74142920, "author": "Prophet", "author_id": 3485434, "author_profile": "https://Stackoverflow.com/users/3485434", "pm_score": 2, "selected": true, "text": "to_field = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, \".s-compose-to textarea\")))\nprint(to_field)\nto...
2022/10/20
[ "https://Stackoverflow.com/questions/74142788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5554763/" ]
74,142,840
<p>HelloAll,</p> <p>I want to use <code>&lt;xsl:variable name=&quot;vPageNumber&quot;&gt;&lt;fo:page-number /&gt;&lt;/xsl:variable&gt;</code> in below code but editor give me a response such as <strong>javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; The prefix &quot;xsl&quot; for element &quot;xsl:variable&quot; is not bound.</strong> What can i do?</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt; &lt;fo:static-content flow-name=&quot;page-header&quot;&gt; &lt;fo:table border=&quot;solid&quot;&gt; &lt;fo:table-column column-width=&quot;20%&quot;/&gt; &lt;fo:table-column column-width=&quot;67%&quot;/&gt; &lt;fo:table-column column-width=&quot;13%&quot;/&gt; &lt;fo:table-body&gt; &lt;fo:table-row &gt; &lt;fo:table-cell&gt; &lt;fo:block padding-right=&quot;15px&quot; padding-bottom=&quot;2mm&quot; padding-top=&quot;1mm&quot;&gt; &lt;fo:block text-align=&quot;right&quot; margin-right=&quot;24px&quot; &gt; &lt;fo:external-graphic content-width=&quot;20mm&quot; src=&quot;url(D:/Atlassian/images/Turkak.gif)&quot; /&gt; &lt;/fo:block&gt; &lt;fo:table width=&quot;20mm&quot; height=&quot;24mm&quot; font-size=&quot;7pt&quot; &gt; &lt;fo:table-row border=&quot;solid&quot; height=&quot;8mm&quot;&gt; &lt;fo:table-cell&gt; &lt;fo:block text-align=&quot;center&quot; padding=&quot;3mm&quot; &gt; AB-1365-T &lt;/fo:block&gt; &lt;/fo:table-cell&gt; &lt;/fo:table-row&gt; &lt;fo:table-row border=&quot;solid&quot; height=&quot;8mm&quot; &gt; &lt;fo:table-cell&gt; &lt;fo:block text-align=&quot;center&quot; padding=&quot;3mm&quot;&gt;$xmlutils.escape($issue.key)&lt;/fo:block&gt; &lt;/fo:table-cell&gt; &lt;/fo:table-row&gt; &lt;fo:table-row border=&quot;solid&quot; height=&quot;8mm&quot; &gt; &lt;fo:table-cell&gt; &lt;fo:block text-align=&quot;center&quot; padding=&quot;3mm&quot;&gt; $date.format(&quot;MM-yy&quot;, $issue.getCustomFieldValue(&quot;customfield_17843&quot;))&lt;/fo:block&gt; &lt;/fo:table-cell&gt; &lt;/fo:table-row&gt; &lt;/fo:table-body&gt; &lt;/fo:table&gt; &lt;/fo:block&gt; &lt;/fo:table-cell&gt; &lt;/fo:table-row&gt; &lt;/fo:table-body&gt; &lt;/fo:table&gt; &lt;/fo:static-content&gt; </code></pre>
[ { "answer_id": 74152369, "author": "hakanb", "author_id": 20291414, "author_profile": "https://Stackoverflow.com/users/20291414", "pm_score": -1, "selected": true, "text": "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:pd...
2022/10/20
[ "https://Stackoverflow.com/questions/74142840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20291414/" ]
74,142,867
<pre><code>#include &lt;stdio.h&gt; int main(){ char a[10]={0,1,0,1,0,1,0,1}; unsigned short *p; p=(unsigned short *)&amp;a[0]; *p=1024; printf(&quot;%d&quot;,a[1]); return 0; } </code></pre> <p>Why answer is 4?? Isn't 1024 entered in array a[0] and a[1] remains? Why does it affect up to a[1]?</p>
[ { "answer_id": 74152369, "author": "hakanb", "author_id": 20291414, "author_profile": "https://Stackoverflow.com/users/20291414", "pm_score": -1, "selected": true, "text": "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:pd...
2022/10/20
[ "https://Stackoverflow.com/questions/74142867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20153000/" ]
74,142,917
<p>I have a piece of code that is supposed to render a component, or a placeholder div.</p> <p>I've placed this inside the return block of another component, but I can't figure out why the placeholder div never renders.</p> <p>Here is the piece of code in the return block mentioned:</p> <pre><code>{renderBannerSummary() || &lt;div className={spacer} /&gt;} </code></pre> <p>renderBannerSummary is a function that renders a component that sometimes returns null.</p> <p>I can see that null is indeed being returned on occasion via the console <a href="https://i.stack.imgur.com/Cca2C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cca2C.png" alt="enter image description here" /></a></p> <p>I can also see that if I extract the logical OR statement entirely, and log it out, it logs the div whenever renderBannerSummary returns null, as expected: <a href="https://i.stack.imgur.com/T8Yu2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T8Yu2.png" alt="enter image description here" /></a></p> <p>So, my question is, why is it that the spacer div is never shown in the UI when renderBannerSummary returns null/is falsy? Instead, nothing renders at all.</p> <p>Any help appreciated, thanks</p>
[ { "answer_id": 74142994, "author": "Adel Benyahia", "author_id": 15106651, "author_profile": "https://Stackoverflow.com/users/15106651", "pm_score": 1, "selected": false, "text": "{ renderBannerSummary() ? renderBannerSummary():<div className={spacer} /> }\n" }, { "answer_id": 74...
2022/10/20
[ "https://Stackoverflow.com/questions/74142917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10324429/" ]
74,142,922
<p>I have a few hundred thousand strings that are laid out like the following</p> <pre><code>AX23784268B2 LJ93842938A1 MN39423287S IY289383N2 </code></pre> <p>With PHP I'm racking my brain how to return <code>B2</code>, <code>A1</code>, <code>S</code>, and <code>N2</code>.</p> <p>Tried all sorts of substr, strstr, strlen manipulation and am coming up short.</p> <pre class="lang-php prettyprint-override"><code>substr('MN39423287S', -2); ?&gt; // returns 7S, not S </code></pre>
[ { "answer_id": 74143050, "author": "Clément Baconnier", "author_id": 8068675, "author_profile": "https://Stackoverflow.com/users/8068675", "pm_score": 1, "selected": false, "text": "\n<?php\n\n$regex = \"/.+([A-Z].?+)$/\";\n\n$tokens = [\n'AX23784268B2',\n'LJ93842938A1',\n'MN39423287S',\...
2022/10/20
[ "https://Stackoverflow.com/questions/74142922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6922773/" ]
74,142,989
<p>Good day everyone,</p> <p>I wanted to develop an advent Calendar webpage, where the doors (1-24) only appear on the designated days. For example: On december 1st, there should only be one door visible On december 15th, there should be doors 1-15 visible, so that every day another door appears.</p> <p>I already figured out how to compare the dates to only trigger if it's a match:</p> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;title&gt;Test&lt;/title&gt; &lt;script src=&quot;test.js&quot;&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;button id=&quot;btn&quot;&gt;Hello&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>JS:</p> <pre><code> var today = new Date(); var date = new Date('2022-10-20'); today.setHours(0,0,0,0); date.setHours(0,0,0,0); if (+today == +date) { console.log(&quot;These are the same dates&quot;); $(&quot;#btn&quot;).hide(); } else { console.log(&quot;These are different dates&quot;); } console.log(today); console.log(date); </code></pre> <p>Which returns this in console if it matches:</p> <p><a href="https://i.stack.imgur.com/hqn1H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hqn1H.png" alt="enter image description here" /></a></p> <p>And this if it does not match:</p> <p><a href="https://i.stack.imgur.com/ndnWM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ndnWM.png" alt="enter image description here" /></a></p> <p>The problem here is, I can't make anything appear, change visibility or enable something. I tried this: <code>document.getElementById(&quot;id&quot;).style.visibility = 'visible';</code>, didn't work. Also made a button with the disabled attribute and tried this: <code>button.disabled = false;</code>, did not work also. I thought it had something to do with the if-statement, but it doesn't even work outside of it.</p> <p>Can someone help me? Thank you guys very much!</p> <p>Greetings Marcel</p>
[ { "answer_id": 74143122, "author": "Attila Gál", "author_id": 19852159, "author_profile": "https://Stackoverflow.com/users/19852159", "pm_score": 1, "selected": false, "text": "$(selector).hide()" }, { "answer_id": 74144164, "author": "xorozo", "author_id": 10810169, ...
2022/10/20
[ "https://Stackoverflow.com/questions/74142989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19745583/" ]
74,143,060
<p>I have a dictionary with a list of file locations</p> <pre><code>dict1 = {'news1':'link1','news2':'link2','sports1':'link3','weather1':'link4'} </code></pre> <p>Now I want to search for a string and return a new dictionary with only the relevant key value pairs. Something like</p> <pre><code>searchstring = 'news' dict2 = if searchstring in dict1 dict2 = {'news1':'link1','news2':'link2'} </code></pre> <p>Any help would be appreciated!</p>
[ { "answer_id": 74143085, "author": "Rahul K P", "author_id": 4407666, "author_profile": "https://Stackoverflow.com/users/4407666", "pm_score": 3, "selected": true, "text": "In [1]: {k:v for k,v in dict1.items() if 'news' in k}\nOut[1]: {'news1': 'link1', 'news2': 'link2'}\n" }, { ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11500371/" ]
74,143,135
<pre><code>char s[] = &quot;MAC122&quot;; char *p = s; printf(&quot;%s&quot;, p + p[2] - p[1]); </code></pre> <p>When I run the C code, the output is &quot;C122&quot;, but I don't really understand these + and - operations with the elements of the string and can't find any online references. Could anyone help me?</p>
[ { "answer_id": 74143268, "author": "babon", "author_id": 452414, "author_profile": "https://Stackoverflow.com/users/452414", "pm_score": 0, "selected": false, "text": "p + p[2] - p[1]" }, { "answer_id": 74143397, "author": "Tropping", "author_id": 10730835, "author_pr...
2022/10/20
[ "https://Stackoverflow.com/questions/74143135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19564165/" ]
74,143,152
<p>If a variable contains an existing function, how can you replace something inside its code?</p> <p>It seems <code>toString()</code> (in order to replace the string) adds an &quot;extra&quot; <code>function() { }</code> and therefore fails.</p> <p>For example changing test1 into test2 or test3 in:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var theparent = { myfunc: function () { console.log('test1'); } } console.log(theparent.myfunc); theparent.myfunc(); theparent.myfunc = new Function("console.log('test2')"); // Works console.log(theparent.myfunc); theparent.myfunc(); theparent.myfunc = new Function(theparent.myfunc.toString().replace('test2', 'test3')); // Adds function() { } console.log(theparent.myfunc); theparent.myfunc(); // Fails</code></pre> </div> </div> </p>
[ { "answer_id": 74143268, "author": "babon", "author_id": 452414, "author_profile": "https://Stackoverflow.com/users/452414", "pm_score": 0, "selected": false, "text": "p + p[2] - p[1]" }, { "answer_id": 74143397, "author": "Tropping", "author_id": 10730835, "author_pr...
2022/10/20
[ "https://Stackoverflow.com/questions/74143152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4829915/" ]
74,143,157
<p>I am finding elements from XML1 in XML2 and after that i want to insert one comment XML1 is:</p> <pre><code>&lt;Price&gt; &lt;Amount&gt;100&lt;/Amount&gt; &lt;Amount&gt;102&lt;/Amount&gt; &lt;Amount&gt;103&lt;/Amount&gt; &lt;/Price&gt; </code></pre> <p>and XML2 is:</p> <pre><code>&lt;List&gt; &lt;Item&gt; &lt;Price&gt; &lt;Amount&gt;100&lt;/Amount&gt; &lt;Next_Item&gt; &lt;Name&gt;Apple&lt;/Name&gt; &lt;/Next_Item&gt; &lt;Next_Item&gt; &lt;Name&gt;Orange&lt;/Name&gt; &lt;/Next_Item&gt; &lt;/Price&gt; &lt;Price&gt; &lt;Amount&gt;200&lt;/Amount&gt; &lt;Next_Item&gt; &lt;Name&gt;Apple&lt;/Name&gt; &lt;/Next_Item&gt; &lt;Next_Item&gt; &lt;Name&gt;Orange&lt;/Name&gt; &lt;/Next_Item&gt; &lt;/Price&gt; &lt;/Item&gt; &lt;/List&gt; </code></pre> <p>Output XML i want is following where I want to insert a comment above Price if the value is matching from price/amount from XML2:</p> <pre><code>&lt;List&gt; &lt;Item&gt; &lt;!--important--&gt; &lt;Price&gt; &lt;Amount&gt;100&lt;/Amount&gt; &lt;Next_Item&gt; &lt;Name&gt;Apple&lt;/Name&gt; &lt;/Next_Item&gt; &lt;Next_Item&gt; &lt;Name&gt;Orange&lt;/Name&gt; &lt;/Next_Item&gt; &lt;/Price&gt; &lt;Price&gt; &lt;Amount&gt;200&lt;/Amount&gt; &lt;Next_Item&gt; &lt;Name&gt;Apple&lt;/Name&gt; &lt;/Next_Item&gt; &lt;Next_Item&gt; &lt;Name&gt;Orange&lt;/Name&gt; &lt;/Next_Item&gt; &lt;/Price&gt; &lt;/Item&gt; &lt;/List&gt; </code></pre> <p>After getting help from this forum I tried coding like this:</p> <pre><code>xml1 = etree.parse('C:/Python/XML1.xml') xml2 = etree.parse('C:/Python/XML2.xml') for am in xml1.xpath('//Price/Id/text()'): x = xml2.xpath(f'//List/Item/Price[./Amount/text()=&quot;{am}&quot;]') if len(x)&gt;0: root = xml2.find('.//List/Item/Price') root.insert(1, etree.Comment('important')) etree.dump(root) with open('C:/Python/output.xml','w') as f: f.write(etree.Comment(root)) </code></pre> <p>I am not able to get proper output xml I am getting error: AttributeError: 'NoneType' object has no attribute 'insert'</p> <p>Grateful for any kind of help.</p>
[ { "answer_id": 74143995, "author": "Parfait", "author_id": 1422451, "author_profile": "https://Stackoverflow.com/users/1422451", "pm_score": 1, "selected": false, "text": "lxml" }, { "answer_id": 74145801, "author": "balderman", "author_id": 415016, "author_profile": ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20131092/" ]
74,143,161
<p>I'm trying to specify an input of nodes per layer, such as <strong>[1,2,5,3,1]</strong> and generate connected nodes in a directed graph <a href="https://i.imgur.com/xs481Zc.png" rel="nofollow noreferrer">like this</a>. Each node has a <strong>next</strong> array and a <strong>prev</strong> array. I keep messing up something in my loop to do this and I could use some guidance. Here's the gist of the pseudocode:</p> <pre><code>var node_layers = [1,2,5,3,1] var prev_nodes = [start_node] for i in range(1, len(node_layers)): var new_nodes = [] for j in range(node_layers[i]): var new_node = Node() new_nodes.append(new_node) # connect the appropriate previous nodes to the current node new_node.prev = ?? prev_nodes = new_nodes </code></pre> <p>Here's the closest I've gotten:</p> <pre><code>start = FloorNode.new(0) current = start var node_layers = [1,2,5,3,1] var prev_nodes = [start] for i in range(1, len(node_layers)): var new_nodes = [] for j in range(node_layers[i]): var new_node = FloorNode.new(0) new_nodes.append(new_node) # connect the appropriate previous nodes to the current node new_node.prev = [] var prev_nodes_per_node = max(1.0, 1.0 * node_layers[i]/node_layers[i-1]) print(&quot;per node: &quot;, prev_nodes_per_node) var relative_index = j * node_layers[i-1] / node_layers[i] print(&quot;j, relative index: &quot;, j, &quot;, &quot;, relative_index) for k in range(ceili(relative_index-prev_nodes_per_node/2), floori(relative_index+prev_nodes_per_node/2) + 1): if k &gt;= 0 and k &lt; len(prev_nodes): print(&quot;Connect &quot;, i-1, &quot;[&quot;, k, &quot;] to &quot;, i, &quot;[&quot;, j, &quot;]&quot;) FloorNode.link(prev_nodes[k], new_node) prev_nodes = new_nodes </code></pre> <p>It generates a graph <a href="https://i.imgur.com/vwUozrr.png" rel="nofollow noreferrer">like this</a> which isn't quite right.</p>
[ { "answer_id": 74143995, "author": "Parfait", "author_id": 1422451, "author_profile": "https://Stackoverflow.com/users/1422451", "pm_score": 1, "selected": false, "text": "lxml" }, { "answer_id": 74145801, "author": "balderman", "author_id": 415016, "author_profile": ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2012968/" ]
74,143,163
<p>I want to initialize a dataframe where some rows have None/Null value in spark scala(version 3.2.1). How to do this ?</p> <pre><code>val df = spark.createDataFrame( Seq((0, &quot;a&quot;, true), (1, &quot;b&quot;, true), (2, &quot;c&quot;, false), (3, &quot;a&quot;, false), (4, &quot;a&quot;, None), (5, &quot;c&quot;, false)) ).toDF(&quot;id&quot;, &quot;category1&quot;, &quot;category2&quot;) df.show() </code></pre> <p>I get this error:</p> <blockquote> <p>UnsupportedOperationException: Schema for type Any is not supported</p> </blockquote>
[ { "answer_id": 74143589, "author": "o_O", "author_id": 11958007, "author_profile": "https://Stackoverflow.com/users/11958007", "pm_score": 1, "selected": false, "text": "import org.apache.spark.sql.Row\nimport org.apache.spark.sql.types.{StructType, StructField, BooleanType};\n\nval data...
2022/10/20
[ "https://Stackoverflow.com/questions/74143163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6407393/" ]
74,143,208
<p>I want to merge arrays based on index .how can I do this? following is my code</p> <pre><code>apple=[&quot;apple1&quot;,&quot;apple2&quot;] mango=[&quot;mango1&quot;,&quot;mango1&quot;] banana=[&quot;banana1&quot;,&quot;banana2&quot;] peach=[&quot;peach1&quot;,&quot;peach2&quot;] The expected output should be [{apple:&quot;apple1&quot;,mango:&quot;mango1&quot;,banana:&quot;banana1&quot;,peach:&quot;peach1&quot;}, {apple:&quot;apple2&quot;,mango:&quot;mango2&quot;,banana:&quot;banana2&quot;,peach:&quot;peach2&quot;}] </code></pre>
[ { "answer_id": 74143589, "author": "o_O", "author_id": 11958007, "author_profile": "https://Stackoverflow.com/users/11958007", "pm_score": 1, "selected": false, "text": "import org.apache.spark.sql.Row\nimport org.apache.spark.sql.types.{StructType, StructField, BooleanType};\n\nval data...
2022/10/20
[ "https://Stackoverflow.com/questions/74143208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19257519/" ]
74,143,211
<p>I want to swap upper and lower case letters with each other using ASCII values. The swapping of the letters works but the numbers get dropped. How can I use this same method without altering the numbers in the string.</p> <pre><code># input the sentance def get_sentence(): sentence = input(&quot;Please input the sentence:&quot;) words = sentence.split(' ') sentence = ' '.join(reversed(words)) return sentence ans = '' # swap the upper and lower case letters def main(): sentence = get_sentence() ans ='' for s in sentence: if ord(s) &gt;= 97 and ord(s) &lt;= 122: ans = ans + chr(ord(s) - 32) elif ord(s) &gt;= 65 and ord(s) &lt;= 90 : ans = ans + chr(ord(s) + 32) elif ord(s) &gt;= 60 and ord(s) &lt;= 71: ans = chr(order(s)) else : ans += ' ' print(ans) #call main function if __name__ == &quot;__main__&quot;: main() </code></pre>
[ { "answer_id": 74143589, "author": "o_O", "author_id": 11958007, "author_profile": "https://Stackoverflow.com/users/11958007", "pm_score": 1, "selected": false, "text": "import org.apache.spark.sql.Row\nimport org.apache.spark.sql.types.{StructType, StructField, BooleanType};\n\nval data...
2022/10/20
[ "https://Stackoverflow.com/questions/74143211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19352264/" ]
74,143,246
<p>Hey working with redisJSON NodeJS package npm Redis 4.3.1</p> <p>Key (userID):(Country) with values Json</p> <p>Example</p> <p>data = { &quot;info&quot;: { &quot;name&quot;:&quot;test&quot;, &quot;email&quot;: &quot;test@test,test&quot; }, &quot;suppliers&quot;: { &quot;s1&quot;: 1, &quot;s2&quot;: 22 }, &quot;suppliersCap&quot;: { &quot;s1&quot;: 0, &quot;s2&quot;: 10 } }</p> <p>redis.json.set('22:AU', '.', data);</p> <p>now I try to add TTL for 5 minutes on the specific key in the JSON for example on this key</p> <p>22:AU .data.suppliersCap.s2, after 5 minutes the cap will be 0;</p> <p>bit this not works</p> <p>redis.json.set(<code>22:AU</code>, '.data.suppliersCap.s2', { EX: 300 });</p>
[ { "answer_id": 74147846, "author": "Max Ivanov", "author_id": 2579733, "author_profile": "https://Stackoverflow.com/users/2579733", "pm_score": 1, "selected": true, "text": "NX" } ]
2022/10/20
[ "https://Stackoverflow.com/questions/74143246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14529472/" ]
74,143,253
<p>the file location is: /Users/D/Desktop/Files/1/no.h5 and its the same filename (no.h5) in the folders 1-400. I want all these files to collect in the same folder with their number as their new names.</p> <p>Your help is greatly appreciated!</p>
[ { "answer_id": 74143323, "author": "learner", "author_id": 17658327, "author_profile": "https://Stackoverflow.com/users/17658327", "pm_score": 2, "selected": false, "text": "shutil" }, { "answer_id": 74143592, "author": "tdelaney", "author_id": 642070, "author_profile...
2022/10/20
[ "https://Stackoverflow.com/questions/74143253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20293646/" ]
74,143,262
<p>I have an <code>n*m</code> sized array <code>A</code>, and I would like to create a grid of its elements. The output should look something like:</p> <pre><code>B = (A[1,1], A[2,1] A[1,1], A[2,2] ... A[1,1], A[2,m] A[1,2], A[2,1] A[1,2], A[2,2] ... A[1,2], A[2,m] ... A[n,1], A[n,m]) </code></pre> <p>My first approach would be to do something like this:</p> <pre><code>A = [1 5; 2 6; 3 7; 4 8] B = collect(Iterators.product(A)) </code></pre> <p>However, this only returns</p> <pre><code>4×2 Matrix{Tuple{Int64}}: (1,) (5,) (2,) (6,) (3,) (7,) (4,) (8,) </code></pre> <p>Instead of the desired output above.</p> <p>Any ideas?</p>
[ { "answer_id": 74143323, "author": "learner", "author_id": 17658327, "author_profile": "https://Stackoverflow.com/users/17658327", "pm_score": 2, "selected": false, "text": "shutil" }, { "answer_id": 74143592, "author": "tdelaney", "author_id": 642070, "author_profile...
2022/10/20
[ "https://Stackoverflow.com/questions/74143262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20293271/" ]
74,143,350
<p>The textbook functional programming introduction example &quot;return a function with a curried parameter&quot; in C++ does not compile for me:</p> <pre><code>// return a function x(v) parameterized with b, which tells if v &gt; b bool (*greater(int))(int b) { return [b](int v) { return v &gt; b; }; } </code></pre> <p>It says that identifier <code>b</code> in the capture <code>[b]</code> is undefined. I know that I'm being naive here, but where is my error?</p> <p>EDIT: as @some-programmer-dude pointed out correctly, the function signature is wrong.</p> <p><em><code>greater</code> is a function accepting an <code>int b</code> returning ( a pointer <code>*</code> to a function accepting an <code>(int)</code> returning a <code>bool</code> ).</em></p> <pre><code>// return a function x(v) parameterized with b, which tells if v &gt; b bool (*greater(int b))(int) { return [b](int v) { return v &gt; b; }; } </code></pre> <p>This of course does not remove the original question which all three replies answered correctly.</p>
[ { "answer_id": 74143420, "author": "iammilind", "author_id": 514235, "author_profile": "https://Stackoverflow.com/users/514235", "pm_score": 2, "selected": false, "text": "[b]" }, { "answer_id": 74143427, "author": "Some programmer dude", "author_id": 440558, "author_...
2022/10/20
[ "https://Stackoverflow.com/questions/74143350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1819452/" ]
74,143,380
<p>I have a simple dataframe with datetime and their date</p> <pre><code>df = pd.DataFrame( [['2021-01-01 10:10', '2021-01-01'], ['2021-01-03 13:33', '2021-01-03'], ['2021-01-03 14:44', '2021-01-03'], ['2021-01-07 17:17', '2021-01-07'], ['2021-01-07 07:07', '2021-01-07'], ['2021-01-07 01:07', '2021-01-07'], ['2021-01-09 09:09', '2021-01-09']], columns=['datetime', 'date']) </code></pre> <p>I would like to create a new column containing the last datetime of each day. I have something quite close, but the last datetime of the day is only filled on the last datetime of the day... A weird NaT (Not a Time) is filled on all other cells. Can you suggest something better?</p> <pre><code>df['eod']=df.groupby('date')['datetime'].tail(1) </code></pre>
[ { "answer_id": 74143437, "author": "ThePyGuy", "author_id": 9136348, "author_profile": "https://Stackoverflow.com/users/9136348", "pm_score": 0, "selected": false, "text": "date" }, { "answer_id": 74143480, "author": "Chris", "author_id": 4718350, "author_profile": "h...
2022/10/20
[ "https://Stackoverflow.com/questions/74143380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5248243/" ]
74,143,399
<p>I am looking to clean URL's in the else block of an if. Specifically, strip the ? and all query parameters after it as well as everything before the first &quot;/&quot;.</p> <p><strong>Example Input</strong> = 'somesite.com/somepage?param=1&amp;else=2'</p> <p><strong>Example Output</strong> = 'somepage'</p> <p>** All that is left is our page (no query params and no domain) **</p> <p>Below is what I have so far (not working). I was focused on piecing this out and the below was an attempt on stripping all query parameters. I'm not sure how I would chain both together.</p> <pre><code>def new_url_check(x): if 'some condition' in x: x = 'some random condition' else: re.sub(r'^([^?]+)', '', x) return x </code></pre>
[ { "answer_id": 74143437, "author": "ThePyGuy", "author_id": 9136348, "author_profile": "https://Stackoverflow.com/users/9136348", "pm_score": 0, "selected": false, "text": "date" }, { "answer_id": 74143480, "author": "Chris", "author_id": 4718350, "author_profile": "h...
2022/10/20
[ "https://Stackoverflow.com/questions/74143399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9982613/" ]
74,143,435
<p>I want to switch the current fragment (containing recycler-View) to a different fragment on clicking the itemView of the recycler view.</p> <p>Adapter Code</p> <p>class pastActivity_adapter(options: FirestoreRecyclerOptions, val context: Context): FirestoreRecyclerAdapter&lt;UserIssue, pastActivity_adapter.MyViewHolder&gt;(options) {</p> <pre><code>class MyViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){ val author_name : TextView = itemView.findViewById(R.id.post_author_name) val author_defect : TextView = itemView.findViewById(R.id.defect_post_text) val author_hostel : TextView = itemView.findViewById(R.id.author_hostel_no) } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { val itemView = LayoutInflater.from(parent.context).inflate(R.layout.item_view_recycler,parent,false) return MyViewHolder(itemView) } override fun onBindViewHolder(holder: MyViewHolder, position: Int, model: UserIssue) { val db = FirebaseFirestore.getInstance() val userId = FirebaseAuth.getInstance().currentUser?.uid val userRef = db.collection(&quot;Users&quot;) holder.author_defect.text = model.issueDefect holder.author_hostel.text = &quot;Hostel no. ${model.userHostelno}&quot; holder.dateTime.text = model.issueDataTime holder.typeIssue.text = &quot;IssueType - ${model.issueType}&quot; if (model.admin_resolved_checkbox){ holder.processStatus.setImageDrawable(ContextCompat.getDrawable(context,R.drawable.greentick_icon)) } **holder.itemView.setOnClickListener{ FragmentActivity.beginTransaction() .replace(R.id.view_complaint_fragment, view_allComplaint()) .commit() } }** </code></pre> <p>}</p> <p>XML File</p> <pre><code>&lt;FrameLayout android:id=&quot;@+id/view_complaint_fragment&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; app:layout_constraintBottom_toBottomOf=&quot;parent&quot; app:layout_constraintEnd_toEndOf=&quot;parent&quot; app:layout_constraintStart_toStartOf=&quot;parent&quot; app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;&lt;/FrameLayout&gt; </code></pre> <p>&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;</p>
[ { "answer_id": 74143437, "author": "ThePyGuy", "author_id": 9136348, "author_profile": "https://Stackoverflow.com/users/9136348", "pm_score": 0, "selected": false, "text": "date" }, { "answer_id": 74143480, "author": "Chris", "author_id": 4718350, "author_profile": "h...
2022/10/20
[ "https://Stackoverflow.com/questions/74143435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12731398/" ]
74,143,448
<p>Is there any simplistic way to avoid people from spamming a button, I have a ticket bot with a simple discord button and embed, but people can spam the button 5-10 times and create numerous tickets. How can I stop this?</p>
[ { "answer_id": 74144947, "author": "moinierer3000", "author_id": 14797384, "author_profile": "https://Stackoverflow.com/users/14797384", "pm_score": 1, "selected": false, "text": "class ButtonOnCooldown(commands.CommandError):\n def __init__(self, retry_after: float):\n self.retry_af...
2022/10/20
[ "https://Stackoverflow.com/questions/74143448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18495113/" ]
74,143,475
<p><strong>Source code:</strong></p> <pre><code>import os import shutil import errno from pathlib import Path def copyFile(src, dst, buffer_size=10485760, perserveFileDate=True): ''' Copies a file to a new location. Much faster performance than Apache Commons due to use of larger buffer @param src: Source File @param dst: Destination File (not file path) @param buffer_size: Buffer size to use during copy @param perserveFileDate: Preserve the original file date ''' # Check to make sure destination directory exists. If it doesn't create the directory dstParent, dstFileName = os.path.split(dst) if(not(os.path.exists(dstParent))): os.makedirs(dstParent) # Optimize the buffer for small files buffer_size = min(buffer_size,os.path.getsize(src)) if(buffer_size == 0): buffer_size = 1024 if shutil._samefile(src, dst): raise shutil.Error(&quot;`%s` and `%s` are the same file&quot; % (src, dst)) for fn in [src, dst]: try: st = os.stat(fn) except OSError: # File most likely does not exist pass else: # X X X What about other special files? (sockets, devices...) if shutil.stat.S_ISFIFO(st.st_mode): raise shutil.SpecialFileError(&quot;`%s` is a named pipe&quot; % fn) with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: shutil.copyfileobj(fsrc, fdst, buffer_size) if(perserveFileDate): shutil.copystat(src, dst) pdb_dir_str = &quot;/mnt/storage/DATABASES/PDB_MIRROR/wwpdb&quot; if __name__ == &quot;__main__&quot;: full_file_name_str = Path(pdb_dir_str, &quot;pdb1a6j.ent.gz&quot;) print(full_file_name_str) copyFile(full_file_name_str, &quot;new_file.zip&quot;) </code></pre> <p><strong>Output:</strong></p> <pre><code>user_name@server_name:~/kfc_spatial/kfc_pdb_list$ ls /mnt/storage/DATABASES/PDB_MIRROR/wwpdb/pdb1a6j.ent.gz /mnt/storage/DATABASES/PDB_MIRROR/wwpdb/pdb1a6j.ent.gz user_name@server_name:~/kfc_spatial/kfc_pdb_list$ nano *.py user_name@server_name:~/kfc_spatial/kfc_pdb_list$ python3 file_copy.py /mnt/storage/DATABASES/PDB_MIRROR/wwpdb/pdb1a6j.ent.gz Traceback (most recent call last): File &quot;file_copy.py&quot;, line 70, in &lt;module&gt; copyFile(full_file_name_str, &quot;new_file.zip&quot;) File &quot;file_copy.py&quot;, line 18, in copyFile os.makedirs(dstParent) File &quot;/usr/local/lib/python3.7/os.py&quot;, line 221, in makedirs mkdir(name, mode) FileNotFoundError: [Errno 2] No such file or directory: '' user_name@server_name:~/kfc_spatial/kfc_pdb_list$ </code></pre> <p><strong>Debug:</strong></p> <pre><code>Python 3.7.3 (default, Jul 23 2019, 01:21:07) [GCC 5.5.0 20171010] on linux Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information. &gt;&gt;&gt; import os &gt;&gt;&gt; os.path.split(&quot;pdb1a6j.ent.gz&quot;) ('', 'pdb1a6j.ent.gz') &gt;&gt;&gt; </code></pre> <p>Why is my python script unable to copy a file which definitely exists?</p>
[ { "answer_id": 74143635, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 3, "selected": true, "text": "mkdir()" }, { "answer_id": 74143741, "author": "rafathasan", "author_id": 9465840, "author_profile":...
2022/10/20
[ "https://Stackoverflow.com/questions/74143475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/159072/" ]
74,143,559
<p>I'm trying to create a progress bar in PowerShell, I would like the progress bar to reach 100% after certain amount of time. The below script does that but I have to click on the button to get it started. Is there way to start the progress bar right away without the need to click on the button? FYI: I'm simply trying to create a progress bar that will reach 100% after set amount of time. Below is my script:</p> <pre><code>Function StartProgressBar { if($i -le 5){ $pbrTest.Value = $i $script:i += 1 } else { $timer.enabled = $false } } $Form = New-Object System.Windows.Forms.Form $Form.width = 400 $Form.height = 200 $Form.Text = &quot;Add Resource&quot; # Init ProgressBar $pbrTest = New-Object System.Windows.Forms.ProgressBar $pbrTest.Maximum = 100 $pbrTest.Minimum = 0 $pbrTest.Location = new-object System.Drawing.Size(10,10) $pbrTest.size = new-object System.Drawing.Size(100,50) $i = 0 $Form.Controls.Add($pbrTest) # Button $btnConfirm = new-object System.Windows.Forms.Button $btnConfirm.Location = new-object System.Drawing.Size(120,10) $btnConfirm.Size = new-object System.Drawing.Size(100,30) $btnConfirm.Text = &quot;Start Progress&quot; $Form.Controls.Add($btnConfirm) $timer = New-Object System.Windows.Forms.Timer $timer.Interval = 1000 $timer.add_Tick({ StartProgressBar }) $timer.Enabled = $true $timer.Start() # Button Click Event to Run ProgressBar $btnConfirm.Add_Click({ While ($i -le 100) { $pbrTest.Value = $i Start-Sleep -m 1 &quot;VALLUE EQ&quot; $i $i += 1 } }) # Show Form $Form.Add_Shown({$Form.Activate()}) $Form.ShowDialog() ``` </code></pre>
[ { "answer_id": 74143640, "author": "Kirby One", "author_id": 20293862, "author_profile": "https://Stackoverflow.com/users/20293862", "pm_score": -1, "selected": false, "text": "Function StartProgressBar\n{\n if($i -le 5){\n $pbrTest.Value = $i\n $script:i += 1\n }\n ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18368599/" ]
74,143,565
<p>In the following dataframe, I want to separate and put every sub-link (divided by <strong>/</strong>) into separate columns</p> <pre><code>df &lt;- data.frame (URL = c(&quot;/es/export-340130-from-mx-to-us/market&quot;, &quot;/ar/category/access/regulations/requirements&quot;), X = c(100,200)) URL X 1 /es/export-340130-from-mx-to-us/market-overview 100 2 /ar/category/access/regulations/requirements 200 </code></pre> <p>Like:</p> <p><a href="https://i.stack.imgur.com/MvCvh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MvCvh.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74143596, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 3, "selected": true, "text": "/" }, { "answer_id": 74143826, "author": "onyambu", "author_id": 8380272, "author_profile": "https:...
2022/10/20
[ "https://Stackoverflow.com/questions/74143565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20181941/" ]
74,143,587
<p>I am getting the following error in my traceback, I am currently running tests for my new website and when I try to create more than one blog post I get returned a MultipleObjectsReturned error, how would I fix this?</p> <p>I am guessing the issue lies with get_object_or_404 as other questions on Stack Overflow have suggested that I use primary keys but I don't want just one object to filter, I need to show all the objects in my Post model</p> <p>traceback: <a href="https://dpaste.com/6J3C7MLSU" rel="nofollow noreferrer">https://dpaste.com/6J3C7MLSU</a></p> <p>views.py</p> <pre><code>```python3 class PostDetail(LoginRequiredMixin, DetailView): model = Post form_class = CommentForm template_name = &quot;cubs/post_detail.html&quot; def get_form(self): form = self.form_class(instance=self.object) return form def post(self, request, slug): new_comment = None post = get_object_or_404(Post) form = CommentForm(request.POST) if form.is_valid(): # Create new_comment object but don't save to the database yet new_comment = form.save(commit=False) # Assign the current post to the comment new_comment.post = post # Save the comment to the database new_comment.save() messages.warning(request, &quot;Your comment is awaiting moderation, once moderated it will be published&quot;) return redirect('cubs_blog_post_detail', slug=slug) else: return render(request, self.template_name, {'form': form}) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) post = get_object_or_404(Post) comments = post.cubs_blog_comments.filter(active=True).order_by('-date_posted') articles = Article.objects.filter(status=1).order_by('-date_posted')[:2] post_likes = get_object_or_404(Post, slug=self.kwargs['slug']) total_likes = post_likes.total_likes() if post_likes.likes.filter(id=self.request.user.id).exists(): liked = True else: liked = False context['liked'] = liked context['articles'] = articles context['comments'] = comments context['total_likes'] = total_likes context['title'] = 'Post Details' context.update({ 'comment_form': self.get_form(), }) return context ``` </code></pre> <p>models.py</p> <pre><code>```python3 class Post(models.Model): class Status(models.IntegerChoices): Draft = 0 Published = 1 title = models.CharField(max_length=200, unique=True) slug = models.SlugField(max_length=200, unique=True) author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='cubs_blog_posts') updated_on = models.DateTimeField(auto_now=True) content = models.TextField() date_posted = models.DateTimeField(auto_now_add=True) status = models.IntegerField(choices=Status.choices, default=Status.Draft) likes = models.ManyToManyField(User, related_name=&quot;cubs_blog_posts_likes&quot;) class Meta: ordering = ['-date_posted'] def __str__(self): return self.title def total_likes(self): return self.likes.count() def get_absolute_url(self): return reverse(&quot;cubs_blog_post_detail&quot;, kwargs={&quot;slug&quot;: str(self.slug)}) def save(self, *args, **kwargs): self.slug = slugify(self.title) super(Post, self).save(*args, **kwargs) ``` </code></pre> <p>post_form.html</p> <pre><code>```html {% extends &quot;cubs/base.html&quot; %} {% load crispy_forms_tags %} {% block content %} &lt;div class=&quot;content-section&quot;&gt; &lt;form method=&quot;POST&quot; autocomplete=&quot;off&quot;&gt; {% csrf_token %} {{ form.media }} &lt;fieldset class=&quot;form-group&quot;&gt; &lt;legend class=&quot;border-bottom mb-4&quot;&gt;Blog Post&lt;/legend&gt; {{ form | crispy }} &lt;/fieldset&gt; &lt;div class=&quot;form-group&quot;&gt; &lt;button class=&quot;btn btn-outline-info&quot; type=&quot;submit&quot;&gt; &lt;i class=&quot;fa-duotone fa-mailbox&quot;&gt;&lt;/i&gt; Post &lt;/button&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; {% endblock content %} ``` </code></pre>
[ { "answer_id": 74146388, "author": "Hashem", "author_id": 18806558, "author_profile": "https://Stackoverflow.com/users/18806558", "pm_score": 0, "selected": false, "text": "objects.filter()" }, { "answer_id": 74169470, "author": "Alombaros", "author_id": 20263044, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74143587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13340105/" ]
74,143,595
<p>I have a function takes a string and logs only the vowels of this string. Currently each vowel is logged on a new line and that is no good.</p> <pre><code>function vowelsOnly(str) { let vowels = ['a','e','i','o','u']; for (let i = 0; i &lt; str.length; i++) { if (vowels.indexOf(str[i]) &gt; -1 ) { // newstr convert to string let newstr = str[i].toString(); console.log(newstr); } // if no vowels in str log empty string else { console.log(&quot;&quot;); } } } </code></pre> <p>I need assistance making my code replicate this example: Input is &quot;welcome to my world&quot; expected output is &quot;eoeoo&quot; no commas.</p> <p>Thank you for your time.</p> <p>EDIT this code is working for me.</p> <pre><code>const str = &quot;qqwwrrttppssddaeu&quot; const vowels = str =&gt; str.split('').filter(i=&gt;&quot;aeiou&quot;.includes(i)).join(''); let newstr = vowels(str).length; if (newstr &gt; 1){ console.log(vowels(str)); } else { console.log(&quot;&quot;); } </code></pre>
[ { "answer_id": 74146388, "author": "Hashem", "author_id": 18806558, "author_profile": "https://Stackoverflow.com/users/18806558", "pm_score": 0, "selected": false, "text": "objects.filter()" }, { "answer_id": 74169470, "author": "Alombaros", "author_id": 20263044, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74143595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20226524/" ]
74,143,602
<p>I have created a Micrometer class where counters are created and incremented. How to write unit test cases for the public method and avoid registering or sending the events to micrometer.</p> <pre><code>public class MicroMeter { private static final MeterRegistry registry = Metrics.globalRegistry; private Counter createCounter(final String meterName, Map&lt;String, String&gt; mp) { List&lt;Tag&gt; tags = new ArrayList&lt;&gt;(); for (Map.Entry&lt;String, String&gt; entry : mp.entrySet()) { tags.add(Tag.of(entry.getKey(), entry.getValue())); } return Counter .builder(meterName) .tags(tags) .register(registry); } private void incrementCounter(Counter counter) { counter.increment(); } public static void createCounterAndIncrement(final String meterName, Map&lt;String, String&gt; mp){ MicroMeter microMeter = new MicroMeter(); Counter counter = microMeter.createCounter(meterName, dimensions); microMeter.incrementCounter(counter); } </code></pre> <p>}</p>
[ { "answer_id": 74146388, "author": "Hashem", "author_id": 18806558, "author_profile": "https://Stackoverflow.com/users/18806558", "pm_score": 0, "selected": false, "text": "objects.filter()" }, { "answer_id": 74169470, "author": "Alombaros", "author_id": 20263044, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74143602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19114283/" ]
74,143,606
<p>When we use a class as a type, only keys of that class should be allowed. Anyway, when assigning <code>[Symbol()]</code>, <code>[String()]</code> or <code>[Number()]</code> as property key no error is given, allowing wrong properties to be assigned. One even more curious case is that if <code>[Symbol()]</code> is assigned to a variable before being used as a prop key, it does error as expected while the same doesn't happen if we assign <code>[String()]</code> or <code>[Number()]</code> to a variable before being used.</p> <pre class="lang-js prettyprint-override"><code>const sym = Symbol() const str = String('another unwanted prop') const num = Number(1) class A { // &lt;-- can be class/type/interface a?: string b?: number } let a: A = { [Symbol()]: 'anything', [String('unwanted prop')]: 'anything', [Number(0)]: 'anything', [str]: 'anything', [num]: 'anything', [sym]: 'anything' // &lt;-- why does this error while [Symbol()], [String()] and [Number()] don't? // ~~~~~~~~~~~~~~~~~ } </code></pre> <p><a href="https://www.typescriptlang.org/play?#code/MYewdgzgLgBBCeBbGBeGBlJAjEAbAFAJQBQoks0ATqhlJQJZgDm+A5AIZghQAWAptQCuYAO6cofACYwADpRAzWJMtBhhByNADkNWAfgCMJUrnYQIMAIIwA3sRgOY7APwAuOHUZN7jrG7W6AsQAvsTEuHyw7O7WaDYwPg4A2piIOASEALruHGDwvF6sADQJjjApnsxswmJgEtJyCkrZMLn5PIUlieU6afoADFk5nO2dpY5JVC1tBczF3UnqiNMjs0zzZZNIK3lrrDAA9AcwADwAtGcwIjzwMJIgfBYFFgLy1Nf0EeWp6USZJRUGFUsk4wNIkr09JQ-ncHhAwKwoM4QmEVHg+AA6XAgFjsQhAA" rel="nofollow noreferrer">Playground Link</a></p> <p>This doesn't looks like expected behaviour to me and I find it a bit confusing.</p> <p>Is this an issue or the desired behaviour? Am I missing something?</p>
[ { "answer_id": 74146388, "author": "Hashem", "author_id": 18806558, "author_profile": "https://Stackoverflow.com/users/18806558", "pm_score": 0, "selected": false, "text": "objects.filter()" }, { "answer_id": 74169470, "author": "Alombaros", "author_id": 20263044, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74143606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17607331/" ]
74,143,614
<p>I'm getting &quot;Person.introduce&quot; is not a function with the following code.</p> <p>Essentially, what I am trying to do is:</p> <p>Create a static method called introducePeople that will take in an array of Person instances.</p> <ul> <li>Have the method console.log an error message of &quot;introducePeople only takes an array as an argument.&quot; if the argument is not of type Array.</li> <li>Have the method console.log an error message of &quot;All items in array must be Person class instances.&quot; if any of the items in the array are not instances of the Person class.</li> <li>If there are no errors logged to the console, call introduce on each of the People instances in the input array.</li> </ul> <pre><code>class Person{ firstName; lastName; age; constructor(firstName, lastName, age) { this.firstName = firstName, this.lastName = lastName, this.age = age } introduce() { console.log(`Hi, I'm ${this.firstName} ${this.lastName}, and I'm ${this.age} years old.`); } static introducePeople(...people) { if (Array.isArray(people)) { console.error(&quot;introducePeople only takes an array as an argument.&quot;) } else if (!(people instanceof Person)) { console.error(&quot;All items in array must be Person class instances.&quot;) } else { return people .forEach((aPerson) =&gt; Person.introduce(aPerson)) } } }; </code></pre> <p>I've also tried:</p> <pre><code>static introducePeople(...people) { if (!Array.isArray(people)) { console.log(&quot;introducePeople only takes an array as an argument.&quot;) } else if (!(people instanceof Person)) { console.log(&quot;All items in array must be Person class instances.&quot;) } else { return people .forEach((aPerson) =&gt; aPerson.introduce) } } </code></pre> <p>Which takes away the aforementioned error, however, the code does not work the way it seems it should.</p> <p>Lastly, I've tried this:</p> <pre><code>static introducePeople(array) { for (const person of array) { if (person instanceof Person) { person.introduce(); } else if (!(Array.isArray(array))) { console.error(&quot;introducePeople only takes an array as an argument.&quot;) return; } else { console.error(&quot;All items in array must be Person class instances.&quot;) return; }(!(person instanceof Person)) } } </code></pre> <p>Which is good but it does not pass the &quot;Must provide error message if array is not array/person is not instance of person&quot;</p>
[ { "answer_id": 74146388, "author": "Hashem", "author_id": 18806558, "author_profile": "https://Stackoverflow.com/users/18806558", "pm_score": 0, "selected": false, "text": "objects.filter()" }, { "answer_id": 74169470, "author": "Alombaros", "author_id": 20263044, "au...
2022/10/20
[ "https://Stackoverflow.com/questions/74143614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19677744/" ]
74,143,617
<p>I am doing the following operation</p> <pre><code>a &lt;- c(3, 7, 1) M &lt;- matrix(data = NA, nrow = 3, ncol = 3) M # a_i - a_j for(i in seq_along(a)) { for (j in seq_along(a)) { M[i, j] &lt;- a[i] - a[j] } } </code></pre> <p>and wonder if there is a more elegant, i.e. R-like way of doing this. In analogy to <code>tcrossprod()</code>.</p>
[ { "answer_id": 74143639, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 3, "selected": true, "text": "outer" }, { "answer_id": 74145779, "author": "ThomasIsCoding", "author_id": 12158757, "author_profi...
2022/10/20
[ "https://Stackoverflow.com/questions/74143617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14692575/" ]
74,143,645
<p>I have this C# program that, and this loop doesn't want to exit, it just becomes a blank row until the user answers yes? Not sure why or how this is happening. <a href="https://dotnetfiddle.net/A6vJtd" rel="nofollow noreferrer">https://dotnetfiddle.net/A6vJtd</a></p> <pre><code>using System; namespace Assignment2 { class FunFeatures { private string name = &quot;&quot;; private string email = &quot;&quot;; static void Main(string[] args) { Console.Title = &quot;Strings, selection and interation in C#&quot;; FunFeatures funObj = new FunFeatures(); funObj.Start(); ContinueToNextPart(); //call the method below } private static void ContinueToNextPart() { Console.WriteLine(&quot;\nPress enter to continue to the next part&quot;); Console.ReadLine(); Console.Clear(); } public void Start() { Introduce(); bool done = false; do { //Call method to read a number 1 to 7 and display //name of the day (1 = Monday, 7 = Sunday with a comment PredictTheDay(); //Calculate the length of a given text CalculateStrengthLength(); //Run again or exit done = RunAgain(); } while (!done); Console.WriteLine(&quot;Welcome back, &quot; + name); } public void CalculateStrengthLength() { Console.WriteLine(&quot;\nLength of text: Write a text with a number of characters and press Enter&quot;); Console.WriteLine(&quot;It will then calculate the number of chars included in the text&quot;); Console.WriteLine(&quot;Give me a text of any length, or press Enter to exit!&quot;); string str = Console.ReadLine(); int strLength = str.Length; Console.WriteLine(&quot;\n&quot;+ str.ToUpper()); Console.WriteLine(&quot;Number of chars = &quot; + strLength); } private void Introduce() { Console.WriteLine(&quot;\nLet me know about yourself!&quot;); ReadName(); Console.Write(&quot;Give me your email please: &quot;); email = Console.ReadLine(); Console.WriteLine(&quot;\nHere is your full name and your email.&quot;); //split first name and last name var names = name.Split(&quot; &quot;); string fName = names[0]; string lName = names[1]; Console.WriteLine(lName + &quot;, &quot; + fName + &quot; &quot; + email); } public void PredictTheDay() { Console.WriteLine(); // blank row Console.WriteLine(&quot;\nI am a fortune teller.&quot;); Console.Write(&quot;Select a number between 1 and 7: &quot;); string str = Console.ReadLine(); int day = int.Parse(str); switch (day) { case 1: // Monday Console.WriteLine(&quot;Monday: Keep calm my friend! You can fall apart!&quot;); break; case 2: //Tuesday Console.WriteLine(&quot;Tuesday and Wednesday break your heart!&quot;); break; case 3: //Wednesday Console.WriteLine(&quot;Tuesday and Wednesday break your heart!&quot;); break; case 4: //Thursday Console.WriteLine(&quot;Thursday, OMG, still one day to Friday!&quot;); break; case 5: //Friday Console.WriteLine(&quot;It's Friday! You are in love!&quot;); break; case 6: //Saturday Console.WriteLine(&quot;Saturday, do nothing and do plenty of it!&quot;); break; case 7: //Sunday Console.WriteLine(&quot;And Sunday always comes too soon!&quot;); break; default: // if user gives a number out of range Console.WriteLine(&quot;Not in a good mode? This is not a valid date!&quot;); break; } } public void ReadName() { Console.WriteLine(&quot;Your first name please: &quot;); string firstname = Console.ReadLine(); Console.Write(&quot;Your last name please: &quot;); string lastname = Console.ReadLine().ToUpper(); name = firstname + &quot; &quot; + lastname; Console.WriteLine(&quot;Nice to meet you &quot; + firstname + &quot;!&quot;); } //Ask user to whether to continue, //return true if the user answers Y, y or any word beginning //with these, or N, n or any word beginning with these. //Otherwise, return false. private bool RunAgain() { bool done = false; //true = y, false = n Console.WriteLine(); //blankline Console.Write(&quot;Run again? (y/n) &quot;); do { string str = Console.ReadLine(); //change str to uppercase letters to make comparison //easier str = str.ToUpper(); if (str[0] == 'Y') //str[0]is the first letter in the string { // continue wit done = true; } else if (str[0] == 'N') { // do not continue with calculation done = false; } } while (!done); //if (!done) is same as: if (done == false) return done; } } } </code></pre>
[ { "answer_id": 74143746, "author": "Thomas Weller", "author_id": 480982, "author_profile": "https://Stackoverflow.com/users/480982", "pm_score": 3, "selected": true, "text": "private bool RunAgain()\n{\n Console.WriteLine();\n Console.Write(\"Run again? (y/n) \");\n\n bool done ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14847558/" ]
74,143,651
<p>I'm trying to scrap data from this website &quot;https://quranromanurdu.com/chapter/1&quot; , I want only text or content from id-contentpara and return that content in JSON format, this below code gives html content but i want that to convert to JSON. I tried to convert but I'm getting error , please somebody help me to clear this error</p> <p>python code :</p> <pre><code>import requests from bs4 import BeautifulSoup import json import codecs URL = &quot;https://quranromanurdu.com/chapter/1&quot; page = requests.get(URL) soup = BeautifulSoup(page.content, &quot;html.parser&quot;) table = soup.findAll('div',attrs={&quot;id&quot;:&quot;contentpara&quot;}) data0 = json.loads(table) print(data0) </code></pre> <p>Error</p> <pre><code>line 24, in &lt;module&gt; data0 = json.loads(table) File &quot;C:\Users\arbazalx\AppData\Local\Programs\Python\Python310\lib\json\__init__.py&quot;, line 339, in loads raise TypeError(f'the JSON object must be str, bytes or bytearray, ' TypeError: the JSON object must be str, bytes or bytearray, not ResultSet </code></pre>
[ { "answer_id": 74143746, "author": "Thomas Weller", "author_id": 480982, "author_profile": "https://Stackoverflow.com/users/480982", "pm_score": 3, "selected": true, "text": "private bool RunAgain()\n{\n Console.WriteLine();\n Console.Write(\"Run again? (y/n) \");\n\n bool done ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15316256/" ]
74,143,653
<p>I am building a utility to store failed DB records from original application. I am printing failed Objects in Log and using this file as input to my utility app.</p> <p>Input: &quot;Class01(name=&quot;John&quot;,age=30,dateModified=2022-09-30)&quot;</p> <p>Now I want to read this same class from utility, is there any easy way to read this?</p>
[ { "answer_id": 74143746, "author": "Thomas Weller", "author_id": 480982, "author_profile": "https://Stackoverflow.com/users/480982", "pm_score": 3, "selected": true, "text": "private bool RunAgain()\n{\n Console.WriteLine();\n Console.Write(\"Run again? (y/n) \");\n\n bool done ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20293929/" ]
74,143,656
<p>So I have 2 <code>router</code> functions for learning to work with <code>clack</code> in common lisp. One is written without macros, and the other is written with macros that expand to match the first function, but only the non-macro version is working. The code below has <code>(:use :trivia)</code> from <code>(ql:quickload 'trivia)</code>.</p> <p>This one is written without any macros, and works:</p> <pre class="lang-lisp prettyprint-override"><code>(defun router (env) (match env ((guard (property :path-info path) (equalp &quot;/&quot; path)) (home env)) ((guard (property :path-info path) (equalp &quot;/live/clicked&quot; path)) (live-clicked env)) ((property :path-info path) `(404 nil (,(format nil &quot;404 page not found&quot;)))))) </code></pre> <p>I decided I didn't like those guard clauses taking up so much space in the function definition, so I rewrote the function:</p> <pre class="lang-lisp prettyprint-override"><code>(defun router (env) (match env (route &quot;/&quot; (home env)) (route &quot;/live/clicked&quot; (live-clicked env)) ((property :path-info path) `(404 nil (,(format nil &quot;404 page not found&quot;)))))) </code></pre> <p><code>route</code> is defined as so:</p> <pre class="lang-lisp prettyprint-override"><code>(defmacro route (valid-path &amp;body body) (let ((path (gensym))) `((guard (property :path-info ,path) (equalp ,valid-path ,path)) ,@body))) </code></pre> <p>With this new router function and macro, the function is always short-circuiting on the first clause. When macroexpanding the 2 <code>(route ...)</code> clauses, I receive this output, matching the function I wrote:</p> <pre class="lang-lisp prettyprint-override"><code>* `(defun router (env) (match env ,(macroexpand '(route &quot;/&quot; (home env))) ,(macroexpand '(route &quot;/live/clicked&quot; (live-clicked env))) ((property :path-info path) `(404 nil (,(format nil &quot;404&quot;))))))) (DEFUN ROUTER (ENV) (MATCH ENV ((GUARD (PROPERTY :PATH-INFO #:G120) (EQUALP &quot;/&quot; #:G120)) (HOME ENV)) ((GUARD (PROPERTY :PATH-INFO #:G121) (EQUALP &quot;/live/clicked&quot; #:G121)) (LIVE-CLICKED ENV)) ((PROPERTY :PATH-INFO PATH) `(404 NIL (,(FORMAT NIL &quot;404&quot;))))) </code></pre> <p><code>(home env)</code> and <code>(live-clicked env)</code> are functions that return something similar to <code>(backquote (200 nil (,(*form generating html*))))</code>. <code>env</code> is the state of the web request, but in this instance it only needs to be <code>(list :path-info &quot;/live/clicked&quot;)</code></p>
[ { "answer_id": 74145266, "author": "sds", "author_id": 850781, "author_profile": "https://Stackoverflow.com/users/850781", "pm_score": 2, "selected": false, "text": "macroexpand" }, { "answer_id": 74148947, "author": "Kaz", "author_id": 1250772, "author_profile": "htt...
2022/10/20
[ "https://Stackoverflow.com/questions/74143656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13264751/" ]
74,143,691
<p>I have the following problem:</p> <ul> <li>I have a 3D engine that has their scenes, but they are not compatible with Unity.</li> <li>But I have the metadata of this another 3D engine about everything on the scene, like: position, lights, models, light probes, physics, cameras etc...</li> <li>I'd like to recreate this scene on Unity, but programmatically doing a parser onto this metadata I have, but not using the Unity Editor. (In the end I would have a .scene file and some created prefabs)</li> <li>But in the same time I'd like to be able to load this created scene (from the metadata) inside the the Unity Editor (since I created it for Unity now)</li> <li>I would like to have all the models and things created as prefabs to be able to use addressable in the future.</li> </ul> <p>Is this feasible?</p> <p>Maybe is there a way to create UnityYAML scene files?</p>
[ { "answer_id": 74144810, "author": "John B", "author_id": 57698, "author_profile": "https://Stackoverflow.com/users/57698", "pm_score": 2, "selected": false, "text": "PrefabUtility.SaveAsPrefabAssetAndConnect(gameObject, localPath, InteractionMode.UserAction, out prefabSuccess);\n" }, ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/440803/" ]
74,143,727
<p>I have two soap applications implementing different, soap actions which I want to route accordingly. How can I get the listing of the soap actions available in my spyne service? Is it available through spyne.interface.xml_schema or Application?</p> <p>I do not want to hardcode a list of soap actions in my app if possible.</p>
[ { "answer_id": 74144810, "author": "John B", "author_id": 57698, "author_profile": "https://Stackoverflow.com/users/57698", "pm_score": 2, "selected": false, "text": "PrefabUtility.SaveAsPrefabAssetAndConnect(gameObject, localPath, InteractionMode.UserAction, out prefabSuccess);\n" }, ...
2022/10/20
[ "https://Stackoverflow.com/questions/74143727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7514253/" ]
74,143,732
<p>I would like to customize the labels on the geopandas plot legend.</p> <pre><code>fig, ax = plt.subplots(figsize = (8,5)) gdf.plot(column = &quot;WF_CEREAL&quot;, ax = ax, legend=True, categorical=True, cmap='YlOrBr',legend_kwds = {&quot;loc&quot;:&quot;lower right&quot;}, figsize =(10,6)) </code></pre> <p><a href="https://i.stack.imgur.com/q7bSZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q7bSZ.png" alt="enter image description here" /></a></p> <p>Adding <code>&quot;labels&quot;</code> in <code>legend_kwds</code> does not help.</p> <p>I tried to add labels with <code>legend_kwds</code> in the following ways, but it didn't work-</p> <p><code>legend_kwds = {&quot;loc&quot;:&quot;lower right&quot;, &quot;labels&quot;:[&quot;low&quot;, &quot;mid&quot;, &quot;high&quot;, &quot;strong&quot;, &quot;severe&quot;]</code></p> <p><code>legend_labels:[&quot;low&quot;, &quot;mid&quot;, &quot;high&quot;, &quot;strong&quot;, &quot;severe&quot;]</code></p> <p><code>legend_labels=[&quot;low&quot;, &quot;mid&quot;, &quot;high&quot;, &quot;strong&quot;, &quot;severe&quot;]</code></p>
[ { "answer_id": 74146876, "author": "Hanna", "author_id": 16645466, "author_profile": "https://Stackoverflow.com/users/16645466", "pm_score": 0, "selected": false, "text": "gdf.plot(column = \"WF_CEREAL\", ax = ax, legend=True, categorical=True, cmap='YlOrBr',legend_kwds = {\"loc\":\"lowe...
2022/10/20
[ "https://Stackoverflow.com/questions/74143732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10705248/" ]
74,143,735
<p>I'm new to PHP.</p> <p>I am currently creating an App in Laravel. When I write <code>echo</code> in the php directive of Blade and pass the php code as a string as an argument, the contents of the php code is output to HTML as it is. What I want to do is to have the HTML output as the result of the execution of the php code written in the argument of the <code>echo</code>.</p> <p>In a simple way, I can put a judgment in the php directive of Blade and divide it into two branches: one that outputs the contents of the <code>echo</code> argument as it is, and another that outputs the result of the execution of the php code. For example, changing the URL and switching between the above two results is not a problem. It's a bit of a roundabout way of doing things, but I'm doing it because I need the two results above and I don't want to affect the logic of the one that outputs the contents of the <code>echo</code> argument as it is passed.</p> <p>What I came up with is to prepare a separate App in Laravel, get the HTML output of the contents passed to the <code>echo</code> argument in the separate App, execute the PHP code, and return it as HTML. However, I am not very knowledgeable about infrastructure and have no clue if this is possible or not.</p> <p>Can you please give me some wisdom? If I didn't understand your question, please forget it.</p> <p>Thank you.</p> <p><a href="https://i.stack.imgur.com/tReT0.jpg" rel="nofollow noreferrer">jpg file of the image</a></p> <hr /> <p>Postscript.</p> <p>Thank you kind-hearted people. Indeed <code>{{ echo '&lt;? php echo date(&quot;Y-m-d&quot;); ? &gt;'; }}</code> also has a way to write it, which I had forgotten. (I also modified the jpg file of the image) The actual code also has <code>echo</code> that spans multiple lines, and I think I wrote this question in confusion.</p> <p>I was using <code>{{ echo '&lt;? php echo date(&quot;Y-m-d&quot;); ? &gt;'; }}</code> of the code and I want the output of the result. I understand that the background behind wanting this is complex and I am talking about something awesomely weird.</p> <p>Thank you.</p>
[ { "answer_id": 74143864, "author": "Ebi", "author_id": 11021885, "author_profile": "https://Stackoverflow.com/users/11021885", "pm_score": 0, "selected": false, "text": "{{}}" }, { "answer_id": 74143975, "author": "Sahil Chraya", "author_id": 20257486, "author_profile...
2022/10/20
[ "https://Stackoverflow.com/questions/74143735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11609580/" ]
74,143,749
<p>I have tried many scripts to separate below json payload <strong>downloadSpeed</strong> value alone as Number and unit of measure as separate attribute(like <strong>umo</strong>) ,</p> <p>In <strong>productCharacters</strong>[] array when name as &quot;<strong>downloadSpeed</strong>&quot; then <strong>value</strong>[] array value attribute want to change as <strong>Number</strong> and unit of value have to add as additional attribute(<strong>umo</strong>)</p> <p>Can some one help to write script for below requirement?.</p> <p><strong>json payload</strong></p> <p>--</p> <pre><code>{ &quot;status&quot;: &quot;Success&quot;, &quot;offers&quot;: [ { &quot;id&quot;: 100, &quot;name&quot;: &quot;Test1&quot;, &quot;productCharacters&quot;: [ { &quot;name&quot;: &quot;downloadSpeed&quot;, &quot;priority&quot;: 1, &quot;value&quot;: [ { &quot;value&quot;: &quot;2000 mpbs&quot;, &quot;localValue&quot;: &quot;300 mbps&quot; } ] }, { &quot;name&quot;: &quot;uploadSpeed&quot;, &quot;priority&quot;: 2, &quot;value&quot;: [ { &quot;value&quot;: &quot;1000 mpbs&quot;, &quot;localValue&quot;: &quot;200 mbps&quot; } ] }, { &quot;name&quot;: &quot;highlights&quot;, &quot;priority&quot;: 3 } ], &quot;category&quot;: [ { &quot;name&quot;: &quot;INTERNET&quot;, &quot;priority&quot;: 1 } ] }, { &quot;id&quot;: 200, &quot;name&quot;: &quot;Test2&quot;, &quot;productCharacters&quot;: [ { &quot;name&quot;: &quot;downloadSpeed&quot;, &quot;priority&quot;: 1, &quot;value&quot;: [ { &quot;value&quot;: &quot;2000 mpbs&quot;, &quot;localValue&quot;: &quot;300 mbps&quot; } ] }, { &quot;name&quot;: &quot;uploadSpeed&quot;, &quot;priority&quot;: 2, &quot;value&quot;: [ { &quot;value&quot;: &quot;4000 mpbs&quot;, &quot;localValue&quot;: &quot;500 mbps&quot; } ] }, { &quot;name&quot;: &quot;benefits&quot;, &quot;priority&quot;: 3 } ] } ] } </code></pre> <p><strong>Expected Result</strong></p> <p>--</p> <pre><code>{ &quot;status&quot;: &quot;Success&quot;, &quot;offers&quot;: [ { &quot;id&quot;: 100, &quot;name&quot;: &quot;Test1&quot;, &quot;productCharacters&quot;: [ { &quot;name&quot;: &quot;downloadSpeed&quot;, &quot;priority&quot;: 1, &quot;value&quot;: [ { &quot;value&quot;: 2000, &quot;umo&quot; : &quot;mbps&quot;, &quot;localValue&quot;: &quot;300 mbps&quot; } ] }, { &quot;name&quot;: &quot;uploadSpeed&quot;, &quot;priority&quot;: 2, &quot;value&quot;: [ { &quot;value&quot;: &quot;1000 mpbs&quot;, &quot;localValue&quot;: &quot;200 mbps&quot; } ] }, { &quot;name&quot;: &quot;highlights&quot;, &quot;priority&quot;: 3 } ], &quot;category&quot;: [ { &quot;name&quot;: &quot;INTERNET&quot;, &quot;priority&quot;: 1 } ] }, { &quot;id&quot;: 200, &quot;name&quot;: &quot;Test2&quot;, &quot;productCharacters&quot;: [ { &quot;name&quot;: &quot;downloadSpeed&quot;, &quot;priority&quot;: 1, &quot;value&quot;: [ { &quot;value&quot;: 2000, &quot;umo&quot; : &quot;mbps&quot;, &quot;localValue&quot;: &quot;300 mbps&quot; } ] }, { &quot;name&quot;: &quot;uploadSpeed&quot;, &quot;priority&quot;: 2, &quot;value&quot;: [ { &quot;value&quot;: &quot;4000 mpbs&quot;, &quot;localValue&quot;: &quot;500 mbps&quot; } ] }, { &quot;name&quot;: &quot;benefits&quot;, &quot;priority&quot;: 3 } ] } ] } </code></pre>
[ { "answer_id": 74144356, "author": "sudhish_s", "author_id": 16762366, "author_profile": "https://Stackoverflow.com/users/16762366", "pm_score": 1, "selected": false, "text": "%dw 2.0\noutput application/json\n---\npayload update {\n case offers at .offers -> offers map ((offer) -> \n...
2022/10/20
[ "https://Stackoverflow.com/questions/74143749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5251414/" ]
74,143,759
<p>I'm trying to parse a query string like this: <code>filename=logo.txt\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01x&amp;filename=.hidden.txt</code></p> <p>Since it mixes bytes and text, I tried to alter it such that it will produce the desired escaped url output like so:</p> <pre><code> extended = 'filename=logo.txt\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01x&amp;filename=.hidden.txt' fixbytes = bytes(extended, 'utf-8') fixbytes = fixbytes.decode(&quot;unicode_escape&quot;) algoext = '?' + urllib.parse.quote(fixbytes, safe='?&amp;=') </code></pre> <p>This outputs <code>b'filename=logo.txt\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01x&amp;filename=.hidden.txt'</code></p> <p><code>filename=logo.txtx&amp;filename=.hidden.txt</code></p> <p><code>?filename=logo.txt%C2%80%00%00%00%00%00%00%00%00%00%00%00%00%00%00%01x&amp;filename=.hidden.txt</code></p> <p>Where does the %C2 byte come from? It's not in the source string and it's not in any of the intermediate steps. What could I do other than manually remove it from the final output string?</p> <p>P.S. I'm relying on a library to generate the string so changing the way it's represented initially is not an option.</p>
[ { "answer_id": 74144264, "author": "Sören", "author_id": 1707427, "author_profile": "https://Stackoverflow.com/users/1707427", "pm_score": 1, "selected": false, "text": ">>> '\\x80'.encode('utf-8')\nb'\\xc2\\x80'\n" }, { "answer_id": 74144561, "author": "Sören", "author_i...
2022/10/20
[ "https://Stackoverflow.com/questions/74143759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12997184/" ]