{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); ');\nresponse.write('');\nresponse.end();\n\nFor more details:\n\n*\n\n*response.write(chunk[, encoding][, callback])\n\n*Anatomy of an HTTP Transaction: Sending Response Body\n\nA: I am also a beginner in this. But what I observed is that, if you write only res.write() the page will be loading continuously until you write res.end(). Whereas if you write res.send() there is no need of res.end(). res.send() basically it does both res.write() and res.end().\n\nA: Suppose you have two line that needs to be shown up and you use res.send as\nres.send(\"shows only First Line\")\nres.send(\"won't show second Line\")\n\nThen only first line will show up, whereas using res.write you have flexibility to write multiple line such as\nres.write(\"Shows first line\")\nres.write(\"Shows second line\")\nres.send()\n\n\nA: res.send() is equivalent to res.write()+ res.end().\nbasically, res.send is for express and res.write+res.end() is for bare metal node ways to send data.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 434,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:912916\",\n \"question_score\": \"77\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692048\"\n}"}}},{"rowIdx":1709316,"cells":{"id":{"kind":"string","value":"cb4baf62d9f4c0bad03a491ba4aeded54fb07706"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to add an array/list to an object I create a student class with :\nsetClass(\"student\", slots=list(name=\"character\", age=\"numeric\", GPA=\"numeric\"))\n\nNow I want to create another class : \nsetClass(\"classRoom\", slots=list(id = \"numeric\"),contains = \"student\")\n\nonly issue is instead of one student I want to add a list of students.\nHow do I achieve this?\n\nA: I guess you have already achieved what you wanted.\nAdding student class in classRoom will give access to all the properties of class student. You can now enter new students in classRoom with the properties of class student.\n# define a class called student\nsetClass(\"student\", slots=list(name=\"character\", age=\"numeric\", GPA=\"numeric\"))\n\n# inherit from student\nsetClass(\"classRoom\", slots=list(id = \"numeric\"),contains = \"student\")\n\n# Now create new objects of classroom:\n> s1 <- new(\"classRoom\",name=\"John\", age=21, GPA=3.5, id=001)\n> s2 <- new(\"classRoom\",name=\"Grisham\", age=24, GPA=345, id=002)\n> s3 <- new(\"classRoom\",name=\"Flamingo\", age=22, GPA=3.8, id=003)\n\nLike this, you have added students in your classRoom.\n"},"original_text":{"kind":"string","value":"Q: How to add an array/list to an object I create a student class with :\nsetClass(\"student\", slots=list(name=\"character\", age=\"numeric\", GPA=\"numeric\"))\n\nNow I want to create another class : \nsetClass(\"classRoom\", slots=list(id = \"numeric\"),contains = \"student\")\n\nonly issue is instead of one student I want to add a list of students.\nHow do I achieve this?\n\nA: I guess you have already achieved what you wanted.\nAdding student class in classRoom will give access to all the properties of class student. You can now enter new students in classRoom with the properties of class student.\n# define a class called student\nsetClass(\"student\", slots=list(name=\"character\", age=\"numeric\", GPA=\"numeric\"))\n\n# inherit from student\nsetClass(\"classRoom\", slots=list(id = \"numeric\"),contains = \"student\")\n\n# Now create new objects of classroom:\n> s1 <- new(\"classRoom\",name=\"John\", age=21, GPA=3.5, id=001)\n> s2 <- new(\"classRoom\",name=\"Grisham\", age=24, GPA=345, id=002)\n> s3 <- new(\"classRoom\",name=\"Flamingo\", age=22, GPA=3.8, id=003)\n\nLike this, you have added students in your classRoom.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 150,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:912918\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692063\"\n}"}}},{"rowIdx":1709317,"cells":{"id":{"kind":"string","value":"7c13302d5a7f5a885e3e0586634a8da283bf06db"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to convert screenshot object into file object in Ashot selenium I wrote a java method whose return type is file. This method grabs a screenshot of screen with Ashot and store it on a Screenshot object. I need to convert that screenshot object into file object so that I can return file object.\n public static File grabScreenshot() {\n\n try { \n\n Thread.sleep(Integer.parseInt(Property.getProperty(\"screenshotDelay\")));\n\n } catch (InterruptedException e) {\n e.printStackTrace();\n\n } catch (NumberFormatException e) {\n e.printStackTrace();\n } catch (IOException e) {\n\n e.printStackTrace();\n } \n\n File screenshot=null; //creating null file object to return\n\n Screenshot screenshot1 = new AShot().shootingStrategy(new ViewportPastingStrategy(1000)).takeScreenshot(driver());\n\n //Here I have to typecast the screenshot1 to file type so that I can return\n return screenshot;\n}\n\n\nA: This should do the trick \n// getImage() will give buffered image which can be used to write to file\nBufferedImage bi = new AShot()\n .shootingStrategy(ShootingStrategies.viewportPasting(100))\n .takeScreenshot(driver).getImage();\n\nFile outputfile = new File(\"image.jpg\");\ntry {\n ImageIO.write(bi, \"jpg\", outputfile);\n} catch (IOException e) {\n e.printStackTrace();\n}\n\n// Print the absolute path to see where the file is created\nSystem.out.println(outputfile.getAbsolutePath());\n\n"},"original_text":{"kind":"string","value":"Q: How to convert screenshot object into file object in Ashot selenium I wrote a java method whose return type is file. This method grabs a screenshot of screen with Ashot and store it on a Screenshot object. I need to convert that screenshot object into file object so that I can return file object.\n public static File grabScreenshot() {\n\n try { \n\n Thread.sleep(Integer.parseInt(Property.getProperty(\"screenshotDelay\")));\n\n } catch (InterruptedException e) {\n e.printStackTrace();\n\n } catch (NumberFormatException e) {\n e.printStackTrace();\n } catch (IOException e) {\n\n e.printStackTrace();\n } \n\n File screenshot=null; //creating null file object to return\n\n Screenshot screenshot1 = new AShot().shootingStrategy(new ViewportPastingStrategy(1000)).takeScreenshot(driver());\n\n //Here I have to typecast the screenshot1 to file type so that I can return\n return screenshot;\n}\n\n\nA: This should do the trick \n// getImage() will give buffered image which can be used to write to file\nBufferedImage bi = new AShot()\n .shootingStrategy(ShootingStrategies.viewportPasting(100))\n .takeScreenshot(driver).getImage();\n\nFile outputfile = new File(\"image.jpg\");\ntry {\n ImageIO.write(bi, \"jpg\", outputfile);\n} catch (IOException e) {\n e.printStackTrace();\n}\n\n// Print the absolute path to see where the file is created\nSystem.out.println(outputfile.getAbsolutePath());\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 171,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:912927\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692095\"\n}"}}},{"rowIdx":1709318,"cells":{"id":{"kind":"string","value":"fe74e379aaf10830ddb1d4bd275a1e8e11ed0d44"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Visual Studio Queries open in Browser instead of inside Visual Studio In Visual Studio 2017 When I am clicking on a Query it opens in a browser instead of opening (like it used to) inside visual studio\nHow can I change this to be opened in visual studio?\n\nA: In Visual Studio 2017 (aka VS version 15) the default behaviour for opening work items has been changed to browser. You can switch back to the old behaviour: Open Tools > Options > Work Items and change \"Open work items in\" to \"Visual Studio\".\nMore details here:\nhttps://blogs.msdn.microsoft.com/devops/2016/08/22/work-items-now-open-in-the-web-from-visual-studio-15/\n"},"original_text":{"kind":"string","value":"Q: Visual Studio Queries open in Browser instead of inside Visual Studio In Visual Studio 2017 When I am clicking on a Query it opens in a browser instead of opening (like it used to) inside visual studio\nHow can I change this to be opened in visual studio?\n\nA: In Visual Studio 2017 (aka VS version 15) the default behaviour for opening work items has been changed to browser. You can switch back to the old behaviour: Open Tools > Options > Work Items and change \"Open work items in\" to \"Visual Studio\".\nMore details here:\nhttps://blogs.msdn.microsoft.com/devops/2016/08/22/work-items-now-open-in-the-web-from-visual-studio-15/\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 98,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:912967\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692264\"\n}"}}},{"rowIdx":1709319,"cells":{"id":{"kind":"string","value":"b89bcb1cb68790a6f6dd1be6c5370905d62f3225"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: webpack.optimize.ModuleConcatenationPlugin is not a constructor Getting the following error on Travis CI since upgrading to Webpack 3.\nIt seems to work fine on my local environment, but when I commit to master and kick of Travis it keeps failing now with the following error.\n21 06 2017 20:16:31.514:ERROR [config]: Invalid config file!\n TypeError: webpack.optimize.ModuleConcatenationPlugin is not a constructor\n at Object. (/home/travis/build/.../webpack.prod.config.babel.js:91:3)\n at Module._compile (module.js:569:30)\n at loader (/home/travis/build/.../node_modules/babel-register/lib/node.js:144:5)\n at Object.require.extensions.(anonymous function) [as .js] (/home/travis/build/.../node_modules/babel-register/lib/node.js:154:7)\n at Module.load (module.js:503:32)\n at tryModuleLoad (module.js:466:12)\n at Function.Module._load (module.js:458:3)\n\nAnd the Line it's complaining about\n// Webpack 3 Scope Hoisting\nnew webpack.optimize.ModuleConcatenationPlugin(),\n\nAnd also have set Webpack to version 3 in my package.json of course.\n\"webpack\": \"^3.0.0\",\n\nAnd my Travis yml is pretty simple\nlanguage: node_js\nsudo: false\nnode_js:\n- '8'\n\n\nA: Delete node_modules and package-lock.json then run npm install again to generate a new package-lock.json. Once you commit the new package-lock.json, Travis should work correctly.\nI was having the exact same issue locally, I did what I described and I stopped having that issue.\n"},"original_text":{"kind":"string","value":"Q: webpack.optimize.ModuleConcatenationPlugin is not a constructor Getting the following error on Travis CI since upgrading to Webpack 3.\nIt seems to work fine on my local environment, but when I commit to master and kick of Travis it keeps failing now with the following error.\n21 06 2017 20:16:31.514:ERROR [config]: Invalid config file!\n TypeError: webpack.optimize.ModuleConcatenationPlugin is not a constructor\n at Object. (/home/travis/build/.../webpack.prod.config.babel.js:91:3)\n at Module._compile (module.js:569:30)\n at loader (/home/travis/build/.../node_modules/babel-register/lib/node.js:144:5)\n at Object.require.extensions.(anonymous function) [as .js] (/home/travis/build/.../node_modules/babel-register/lib/node.js:154:7)\n at Module.load (module.js:503:32)\n at tryModuleLoad (module.js:466:12)\n at Function.Module._load (module.js:458:3)\n\nAnd the Line it's complaining about\n// Webpack 3 Scope Hoisting\nnew webpack.optimize.ModuleConcatenationPlugin(),\n\nAnd also have set Webpack to version 3 in my package.json of course.\n\"webpack\": \"^3.0.0\",\n\nAnd my Travis yml is pretty simple\nlanguage: node_js\nsudo: false\nnode_js:\n- '8'\n\n\nA: Delete node_modules and package-lock.json then run npm install again to generate a new package-lock.json. Once you commit the new package-lock.json, Travis should work correctly.\nI was having the exact same issue locally, I did what I described and I stopped having that issue.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 169,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:912971\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692289\"\n}"}}},{"rowIdx":1709320,"cells":{"id":{"kind":"string","value":"308a9439791803b74470fb7b613b9fa56f9b2e33"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Angular CLI - ng serve I know that the command \"ng serve\" creates all my stuff in memory.\nNow I have such url: http://localhost:4200/some-angular-route\nBut I want this url: http://localhost:4200/subfolder/some-angular-route\nMy Question is how can I create such a \"subfolder\"? My Problem is that in my production environment the requests go via Spring Boot Zuul and there are prefixes at urls.\n\nA: You can set base href as follows\n@NgModule({\n imports: [\n RouterModule.forRoot(routes)\n ],\n declarations: [AppComponent],\n providers: [{ provide: APP_BASE_HREF, useValue: '/urlPrefix' }]\n})\nexport class AppModule { }\n\nAlso, when you build your code, you can give --directory and --baseHref as follows.\nng build --deploy-url /mySubFolder/ --base-href /urlPrefix/\nYou can find more here https://github.com/angular/angular-cli/wiki/build\n"},"original_text":{"kind":"string","value":"Q: Angular CLI - ng serve I know that the command \"ng serve\" creates all my stuff in memory.\nNow I have such url: http://localhost:4200/some-angular-route\nBut I want this url: http://localhost:4200/subfolder/some-angular-route\nMy Question is how can I create such a \"subfolder\"? My Problem is that in my production environment the requests go via Spring Boot Zuul and there are prefixes at urls.\n\nA: You can set base href as follows\n@NgModule({\n imports: [\n RouterModule.forRoot(routes)\n ],\n declarations: [AppComponent],\n providers: [{ provide: APP_BASE_HREF, useValue: '/urlPrefix' }]\n})\nexport class AppModule { }\n\nAlso, when you build your code, you can give --directory and --baseHref as follows.\nng build --deploy-url /mySubFolder/ --base-href /urlPrefix/\nYou can find more here https://github.com/angular/angular-cli/wiki/build\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 116,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913018\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692410\"\n}"}}},{"rowIdx":1709321,"cells":{"id":{"kind":"string","value":"51cd80c3faf587de675d2a52e723dd1d75ac69fb"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to connect to postgresql google cloud sql instance? Need to import postgresql dump using pg_restore command I have a google cloud sql postgresql instance. When I try to import postgresql dump I get following error.\n\nI am able to connect to instance with the command given below.\ngcloud sql connect instance-name --user postgres\n\nIt takes me to the psql command line client where I can not use database restore command like pg_restore\nDoes anyone have an idea on how can I actually connect to Google Cloud SQL instance so that I can perform operation such as pg_restore?\n\nA: if you need pg_restore can simply use:\ngcloud sql connect instance-name --user postgres < dbbackup.sql\nwhere dbbackup.sql is a file obtained from:\npg_dump olddb --format=plain --no-owner -v >> dbbackup.sql\n"},"original_text":{"kind":"string","value":"Q: How to connect to postgresql google cloud sql instance? Need to import postgresql dump using pg_restore command I have a google cloud sql postgresql instance. When I try to import postgresql dump I get following error.\n\nI am able to connect to instance with the command given below.\ngcloud sql connect instance-name --user postgres\n\nIt takes me to the psql command line client where I can not use database restore command like pg_restore\nDoes anyone have an idea on how can I actually connect to Google Cloud SQL instance so that I can perform operation such as pg_restore?\n\nA: if you need pg_restore can simply use:\ngcloud sql connect instance-name --user postgres < dbbackup.sql\nwhere dbbackup.sql is a file obtained from:\npg_dump olddb --format=plain --no-owner -v >> dbbackup.sql\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 129,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913031\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692455\"\n}"}}},{"rowIdx":1709322,"cells":{"id":{"kind":"string","value":"91044f0cd73680190290a8b6ae459d06931d7add"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Session handling in Google oauth I'm using Google's javascript auth library for authenticating users to my webapp where I check the token's expiry for validity.\nCurrently I'm using the client-side only oauth flow.\nFew questions:\n\n\n*\n\n*Does Google auth handle token refresh by itself or do I have to do so manually?\n\n*If it does handle token refresh by itself - is there a hook method I can use to detect when the access token has changed?\n\n*If it doesn't - what alternatives am I facing?\nMany thanks.\n\nA: Revisiting this question:\n\n\n*\n\n*After a lot of trial and error I've come to the conclusion that Google's javascript auth lib does handle the refreshing of tokens on its own.\n\n*No there is no such hook available.\n\n*N/A.\n"},"original_text":{"kind":"string","value":"Q: Session handling in Google oauth I'm using Google's javascript auth library for authenticating users to my webapp where I check the token's expiry for validity.\nCurrently I'm using the client-side only oauth flow.\nFew questions:\n\n\n*\n\n*Does Google auth handle token refresh by itself or do I have to do so manually?\n\n*If it does handle token refresh by itself - is there a hook method I can use to detect when the access token has changed?\n\n*If it doesn't - what alternatives am I facing?\nMany thanks.\n\nA: Revisiting this question:\n\n\n*\n\n*After a lot of trial and error I've come to the conclusion that Google's javascript auth lib does handle the refreshing of tokens on its own.\n\n*No there is no such hook available.\n\n*N/A.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 128,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913052\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692526\"\n}"}}},{"rowIdx":1709323,"cells":{"id":{"kind":"string","value":"99d62de2eab193b2adf8effdcdc8a4895c555825"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Docker Alpine image + grpc: Warning: insecure environment read function 'getenv' used When I used this image: node:6.11.0-alpine to run my service (use GRPC), then keep getting these warnings:\nD0622 06:52:01.170502843 1 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.554446816 12 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.559295167 14 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.566036292 13 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.569975088 15 env_linux.c:66] Warning: insecure environment read function 'getenv' used\n\nDo I miss any package? How to fix this?\nThis issue Issue #8104 can be referred.\n\nA: I believe this has been fixed in grpc-1.23.0 and newer: https://github.com/grpc/grpc/commit/5efa660b41ab05971901f3a7b19e3890ea1e8884\n"},"original_text":{"kind":"string","value":"Q: Docker Alpine image + grpc: Warning: insecure environment read function 'getenv' used When I used this image: node:6.11.0-alpine to run my service (use GRPC), then keep getting these warnings:\nD0622 06:52:01.170502843 1 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.554446816 12 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.559295167 14 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.566036292 13 env_linux.c:66] Warning: insecure environment read function 'getenv' used\nD0622 06:52:01.569975088 15 env_linux.c:66] Warning: insecure environment read function 'getenv' used\n\nDo I miss any package? How to fix this?\nThis issue Issue #8104 can be referred.\n\nA: I believe this has been fixed in grpc-1.23.0 and newer: https://github.com/grpc/grpc/commit/5efa660b41ab05971901f3a7b19e3890ea1e8884\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 113,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913071\",\n \"question_score\": \"8\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692590\"\n}"}}},{"rowIdx":1709324,"cells":{"id":{"kind":"string","value":"ebfc293de01360921721ad5d2838f51e9b4057a5"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: MySQL trigger before insert with INSERT IGNORE Is MySQL trigger which is set before insert to certain table, executed when I call INSERT IGNORE and inserting is ignored?\n\nA: Here's a demonstration:\nmysql> create table foo (foo_id int primary key);\n\nmysql> create table bar (foo_id int);\n\nmysql> create trigger foo_ins before insert on foo \n for each row insert into bar set foo_id = new.foo_id;\n\nmysql> insert ignore into foo set foo_id=123;\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert ignore into foo set foo_id=123;\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nThis should have inserted just one row in the foo table, because the second try would conflict with the primary key value. We see that the second insert affects 0 rows, which means no new row was inserted.\nLet's see what the effect on the bar table is:\nmysql> select * from bar;\n+--------+\n| foo_id |\n+--------+\n| 123 |\n| 123 |\n+--------+\n\nTwo rows were inserted. This proves that the trigger is fired even when doing insert ignore.\n"},"original_text":{"kind":"string","value":"Q: MySQL trigger before insert with INSERT IGNORE Is MySQL trigger which is set before insert to certain table, executed when I call INSERT IGNORE and inserting is ignored?\n\nA: Here's a demonstration:\nmysql> create table foo (foo_id int primary key);\n\nmysql> create table bar (foo_id int);\n\nmysql> create trigger foo_ins before insert on foo \n for each row insert into bar set foo_id = new.foo_id;\n\nmysql> insert ignore into foo set foo_id=123;\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert ignore into foo set foo_id=123;\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nThis should have inserted just one row in the foo table, because the second try would conflict with the primary key value. We see that the second insert affects 0 rows, which means no new row was inserted.\nLet's see what the effect on the bar table is:\nmysql> select * from bar;\n+--------+\n| foo_id |\n+--------+\n| 123 |\n| 123 |\n+--------+\n\nTwo rows were inserted. This proves that the trigger is fired even when doing insert ignore.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 176,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913081\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692628\"\n}"}}},{"rowIdx":1709325,"cells":{"id":{"kind":"string","value":"f4998a4aabf5b87227c831c64750987e6e16687e"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: iOS 11 is removing native facebook integration. So, applications with current facebook sdk will not work on iOS 11? Recently, I have read that iOS 11 is dropping the native system integration with Twitter, Facebook, Flickr, and Vimeo. I have used facebook sdk for various apps which are on the store. Will they stop working with the release of iOS 11?\n\nA: Depends on what you are using, the login with facebook is still working with beta 2\n"},"original_text":{"kind":"string","value":"Q: iOS 11 is removing native facebook integration. So, applications with current facebook sdk will not work on iOS 11? Recently, I have read that iOS 11 is dropping the native system integration with Twitter, Facebook, Flickr, and Vimeo. I have used facebook sdk for various apps which are on the store. Will they stop working with the release of iOS 11?\n\nA: Depends on what you are using, the login with facebook is still working with beta 2\n\nA: They shouldn't. The most important thing that changes is the authorization flow with the new SFAuthenticationSession. You should test the functionalities that rely on FB's SDK thoroughly though, to catch any API changes or bugs.\n\nA: You have to remove native code (Account Kit) and use Facebook Latest SDK. this will work.\nIf you have only used Account Kit for login then you have to give a new update of the app on AppStore as there is now option to login in setting in iOS 11 now.\nRef Blog\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 169,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913082\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692632\"\n}"}}},{"rowIdx":1709326,"cells":{"id":{"kind":"string","value":"4777fcc04dae998b0bda8b025b27d431b067c0f9"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Plotting Networkx graph in Python I recently started using networkx library in python to generate and visualize graph plots. I started with a simple code (comprising of 4 nodes) as shown \nimport networkx as nx\nimport matplotlib.pyplot as plt\nG = nx.Graph()\nG.add_edges_from([(1 ,2) , (2 ,3) , (1 ,3) , (1 ,4) ])\nnx.draw(G)\nplt.show()\n\nWhen I run the code for two consecutive times, the outputs for same code is as shown in the images (the orientation of the plot is random) \n \nIs it possible to generate the output of the plots with the same/fixed orientation? \n\nA: Per default a spring layout is used to draw the graph. This can have a new orientation each time it is drawn.\nThere are also other layouts available.\n\nUsing e.g. nx.draw_circular or nx.draw_spectral will give you always the same layout.\nYou may also define the positions of the nodes using a dictionary, which maps nodenumber to a position.\nimport networkx as nx\nimport matplotlib.pyplot as plt\nG = nx.Graph()\nG.add_edges_from([(1 ,2) , (2 ,3) , (1 ,3) , (1 ,4) ])\npos = { 1: (20, 30), 2: (40, 30), 3: (30, 10),4: (0, 40)} \n\nnx.draw_networkx(G, pos=pos)\n\nplt.show()\n\n\n"},"original_text":{"kind":"string","value":"Q: Plotting Networkx graph in Python I recently started using networkx library in python to generate and visualize graph plots. I started with a simple code (comprising of 4 nodes) as shown \nimport networkx as nx\nimport matplotlib.pyplot as plt\nG = nx.Graph()\nG.add_edges_from([(1 ,2) , (2 ,3) , (1 ,3) , (1 ,4) ])\nnx.draw(G)\nplt.show()\n\nWhen I run the code for two consecutive times, the outputs for same code is as shown in the images (the orientation of the plot is random) \n \nIs it possible to generate the output of the plots with the same/fixed orientation? \n\nA: Per default a spring layout is used to draw the graph. This can have a new orientation each time it is drawn.\nThere are also other layouts available.\n\nUsing e.g. nx.draw_circular or nx.draw_spectral will give you always the same layout.\nYou may also define the positions of the nodes using a dictionary, which maps nodenumber to a position.\nimport networkx as nx\nimport matplotlib.pyplot as plt\nG = nx.Graph()\nG.add_edges_from([(1 ,2) , (2 ,3) , (1 ,3) , (1 ,4) ])\npos = { 1: (20, 30), 2: (40, 30), 3: (30, 10),4: (0, 40)} \n\nnx.draw_networkx(G, pos=pos)\n\nplt.show()\n\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 197,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913088\",\n \"question_score\": \"10\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692644\"\n}"}}},{"rowIdx":1709327,"cells":{"id":{"kind":"string","value":"e4503ee71cc22471c1d983d8dbf72b001044683b"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How can I upgrade Python version and packages in pyenv virtualenv? I used pyenv, pyenv-virtualenv for managing python virtual environment.\nI have a project working in Python 3.4 virtual environment.\nSo all installed packages(pandas, numpy etc) are not newest version.\nWhat I want to do is to upgrade Python version from 3.4 to 3.6 as well as upgrade other package version to higher one.\nHow can I do this easily?\n\nA: Here is how you can switch to 3.9.0 for a given virtual environement venv-name:\npip freeze > requirements-lock.txt\npyenv virtualenv-delete venv-name\npyenv virtualenv 3.9.0 venv-name\npip install -r requirements-lock.txt\n\nOnce everything works correctly you can safely remove the temporary requirements lock file:\nrm requirements-lock.txt\n\nNote that using pip freeze > requirements.txt is usually not a good idea as this file is often used to handle your package requirements (not necessarily pip freeze output). It's better to use a different (temporary) file just to be sure.\n"},"original_text":{"kind":"string","value":"Q: How can I upgrade Python version and packages in pyenv virtualenv? I used pyenv, pyenv-virtualenv for managing python virtual environment.\nI have a project working in Python 3.4 virtual environment.\nSo all installed packages(pandas, numpy etc) are not newest version.\nWhat I want to do is to upgrade Python version from 3.4 to 3.6 as well as upgrade other package version to higher one.\nHow can I do this easily?\n\nA: Here is how you can switch to 3.9.0 for a given virtual environement venv-name:\npip freeze > requirements-lock.txt\npyenv virtualenv-delete venv-name\npyenv virtualenv 3.9.0 venv-name\npip install -r requirements-lock.txt\n\nOnce everything works correctly you can safely remove the temporary requirements lock file:\nrm requirements-lock.txt\n\nNote that using pip freeze > requirements.txt is usually not a good idea as this file is often used to handle your package requirements (not necessarily pip freeze output). It's better to use a different (temporary) file just to be sure.\n\nA: OP asked to upgrade the packages alongside Python. No other answers address the upgrade of packages. Lock files are not the answer here.\n\nSave your packages to a requirements file without the version.\npip freeze | cut -d\"=\" -f1 > requirements-to-upgrade.txt\n\nDelete your environment, create a new one with the upgraded Python version, then install the requirements file.\npyenv virtualenv-delete venv-name\npyenv virtualenv 3.6.8 venv-name\npip install -r requirements-to-upgrade.txt\n\nThe dependency resolver in pip should try to find the latest package. This assumes you have the upgrade Python version installed (e.g., pyenv install 3.6.8).\n\nA: Use pip freeze > requirements.txt to save a list of installed packages.\nCreate a new venv with python 3.6.\nInstall saved packages with pip install -r requirements.txt. When pip founds an universal wheel in its cache it installs the package from the cache. Other packages will be downloaded, cached, built and installed.\n\nA: If you use anaconda, just type \nconda install python==$pythonversion$\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 315,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913097\",\n \"question_score\": \"24\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692668\"\n}"}}},{"rowIdx":1709328,"cells":{"id":{"kind":"string","value":"f074e1f12ccbfb1eb758a9821585980e01f53191"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to add color to transparent area of font awesome icons I want to change the transparent middle portion of fa-youtube-play icon to red. I try this code:\n\n\n.fa {\r\n background-color: red;\r\n}\n\r\n
\r\n \r\n
\n\n\nBut sing this code will overlaps the icon. How do I make color to the inner transparent are only?\n\nA: You can do that by using psuedo character i.e. :after. This might help:\n https://jsfiddle.net/kr8axdc3/\n"},"original_text":{"kind":"string","value":"Q: How to add color to transparent area of font awesome icons I want to change the transparent middle portion of fa-youtube-play icon to red. I try this code:\n\n\n.fa {\r\n background-color: red;\r\n}\n\r\n
\r\n \r\n
\n\n\nBut sing this code will overlaps the icon. How do I make color to the inner transparent are only?\n\nA: You can do that by using psuedo character i.e. :after. This might help:\n https://jsfiddle.net/kr8axdc3/\n\nA: universal means no. I'm afraid you'll have to work with each icon individually.\n\n\n.fa {\r\n background-image: radial-gradient(at center, red 40%, transparent 40%);\r\n}\n\r\n
\r\n \r\n
\n\n\n\nA: In CSS use the clip property like so .fa { clip: rect(0px,0px,0px,0px); }. Set to whatever values are appropriate. I believe this property only applies to images, however.\n\nA: As you can see there are many ways to do it. The easiest way to fix this is to add line-height.\n\n\ndiv .fa {\r\n background-color:red;\r\n line-height: 22px;\r\n}\n\r\n
\r\n \r\n
\n\n\n\nA: try this one,\n.fa{\n background-color:red;\n line-height:25px;\n width:40px;\n }\n\n\nA: You could even do that using pseudo selector :before as below, bit lengthy styling but adds background to that transparent area. \n\n\ndiv {\r\n display: inline-block;\r\n position: relative;\r\n}\r\n\r\ndiv:before {\r\n content: \"\";\r\n position: absolute;\r\n background: red;\r\n width: 30px;\r\n height: 30px;\r\n z-index: -1;\r\n top: 10px;\r\n left: 10px;\r\n}\n\r\n
\r\n \r\n
\n\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 248,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913105\",\n \"question_score\": \"5\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692692\"\n}"}}},{"rowIdx":1709329,"cells":{"id":{"kind":"string","value":"6b4df4d33020980d96be634416c3f301dd61e250"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Google Script number format in Google Docs I'm currently generating a google document with Google Script.\nI have an issue with number formats. I have a table with currency values, so I tried to format the text like this ( like how I'd do it normally ):\nvar number = 12345;\nvar currencyString = number.toLocaleString(); // This 'works' but outputs : 12345\nvar euroCurrencyString = number.toLocaleString(\"nl-NL\", { style: 'currency', currency: 'EUR' }); // This throws exception\n\nBut it throws this exception: \nTypeError: InternalError: Illegal radix 0.\nIs there any other way to format a number to a currency string? ( eq; € 12.345,00 )\nEDIT: toLocaleString() actually works, I just mistyped it\n"},"original_text":{"kind":"string","value":"Q: Google Script number format in Google Docs I'm currently generating a google document with Google Script.\nI have an issue with number formats. I have a table with currency values, so I tried to format the text like this ( like how I'd do it normally ):\nvar number = 12345;\nvar currencyString = number.toLocaleString(); // This 'works' but outputs : 12345\nvar euroCurrencyString = number.toLocaleString(\"nl-NL\", { style: 'currency', currency: 'EUR' }); // This throws exception\n\nBut it throws this exception: \nTypeError: InternalError: Illegal radix 0.\nIs there any other way to format a number to a currency string? ( eq; € 12.345,00 )\nEDIT: toLocaleString() actually works, I just mistyped it\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 113,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913113\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692708\"\n}"}}},{"rowIdx":1709330,"cells":{"id":{"kind":"string","value":"02b2eb5cc2ecc28ad0f355a6d845845fec707169"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: how to compute the probability of Poisson distribution in julia I have to compute the probability of Poisson distribution in Julia. I just know how to get Poisson distribution. But i have to compute the probability. also i have lambda from 20 to 100.\nusing Distributions \nPoisson()\n\n\nA: The objects in Distributions.jl are like random variables. If you declare a value to be of a distribution, you can sample from it using rand, but there are a whole lot of other methods you can apply to it. Among them is pdf:\njulia> X = Poisson(30)\nDistributions.Poisson{Float64}(λ=30.0)\n\njulia> pdf(X, 2)\n4.2109303359780846e-11\n\njulia> pdf(X, 0:1:10)\n11-element Array{Float64,1}:\n 9.35762e-14\n 2.80729e-12\n 4.21093e-11\n 4.21093e-10\n 3.1582e-9 \n 1.89492e-8 \n 9.47459e-8 \n 4.06054e-7 \n 1.5227e-6 \n 5.07567e-6 \n 1.5227e-5 \n\n"},"original_text":{"kind":"string","value":"Q: how to compute the probability of Poisson distribution in julia I have to compute the probability of Poisson distribution in Julia. I just know how to get Poisson distribution. But i have to compute the probability. also i have lambda from 20 to 100.\nusing Distributions \nPoisson()\n\n\nA: The objects in Distributions.jl are like random variables. If you declare a value to be of a distribution, you can sample from it using rand, but there are a whole lot of other methods you can apply to it. Among them is pdf:\njulia> X = Poisson(30)\nDistributions.Poisson{Float64}(λ=30.0)\n\njulia> pdf(X, 2)\n4.2109303359780846e-11\n\njulia> pdf(X, 0:1:10)\n11-element Array{Float64,1}:\n 9.35762e-14\n 2.80729e-12\n 4.21093e-11\n 4.21093e-10\n 3.1582e-9 \n 1.89492e-8 \n 9.47459e-8 \n 4.06054e-7 \n 1.5227e-6 \n 5.07567e-6 \n 1.5227e-5 \n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 117,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913122\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692754\"\n}"}}},{"rowIdx":1709331,"cells":{"id":{"kind":"string","value":"b234bdcb57fa70ee8a142843471688c553a13000"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Configure spring boot to redirect 404 to a single page app I want to configure my Spring Boot app to redirect any 404 not found request to my single page app.\nFor example if I am calling localhost:8080/asdasd/asdasdasd/asdasd which is does not exist, it should redirect to localhost:8080/notFound.\nThe problem is that I have a single page react app and it runs in the root path localhost:8080/. So spring should redirect to localhost:8080/notFound and then forward to / (to keep route).\n\nA: This is the full Spring Boot 2.0 example:\n@Configuration\npublic class WebApplicationConfig implements WebMvcConfigurer {\n\n@Override\npublic void addViewControllers(ViewControllerRegistry registry) {\n registry.addViewController(\"/notFound\").setViewName(\"forward:/index.html\");\n}\n\n\n@Bean\npublic WebServerFactoryCustomizer containerCustomizer() {\n return container -> {\n container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,\n \"/notFound\"));\n };\n }\n\n}\n\n"},"original_text":{"kind":"string","value":"Q: Configure spring boot to redirect 404 to a single page app I want to configure my Spring Boot app to redirect any 404 not found request to my single page app.\nFor example if I am calling localhost:8080/asdasd/asdasdasd/asdasd which is does not exist, it should redirect to localhost:8080/notFound.\nThe problem is that I have a single page react app and it runs in the root path localhost:8080/. So spring should redirect to localhost:8080/notFound and then forward to / (to keep route).\n\nA: This is the full Spring Boot 2.0 example:\n@Configuration\npublic class WebApplicationConfig implements WebMvcConfigurer {\n\n@Override\npublic void addViewControllers(ViewControllerRegistry registry) {\n registry.addViewController(\"/notFound\").setViewName(\"forward:/index.html\");\n}\n\n\n@Bean\npublic WebServerFactoryCustomizer containerCustomizer() {\n return container -> {\n container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,\n \"/notFound\"));\n };\n }\n\n}\n\n\nA: This should do the trick: Add an error page for 404 that routes to /notFound, and forward that to your SPA (assuming the entry is on /index.html):\n@Configuration\npublic class WebApplicationConfig extends WebMvcConfigurerAdapter {\n\n @Override\n public void addViewControllers(ViewControllerRegistry registry) {\n registry.addViewController(\"/notFound\").setViewName(\"forward:/index.html\");\n }\n\n\n @Bean\n public EmbeddedServletContainerCustomizer containerCustomizer() {\n return container -> {\n container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,\n \"/notFound\"));\n };\n }\n\n}\n\n\nA: //add this controller : perfect solution(from jhipster)\n@Controller\npublic class ClientForwardController {\n @GetMapping(value = \"/**/{path:[^\\\\.]*}\")\n public String forward() {\n return \"forward:/\";\n }\n}\n\n\nA: In case anyone stumbles here looking for how to handle Angular/React/other routes and paths in a Spring Boot app - but not always return index.html for any 404 - it can be done in a standard Spring controller RequestMapping. This can be done without adding view controllers and/or customizing the container error page.\nThe RequestMapping supports wild cards, so you can make it match against a set of well known paths (ie. angular routes etc.) in your application and only then return forward index.html: \n@Controller \npublic class Html5PathsController { \n\n @RequestMapping( method = {RequestMethod.OPTIONS, RequestMethod.GET}, path = {\"/path1/**\", \"/path2/**\", \"/\"} )\n public String forwardAngularPaths() { \n return \"forward:/index.html\"; \n } \n}\n\nAnother option (borrowed from an old Spring article here: https://spring.io/blog/2015/05/13/modularizing-the-client-angular-js-and-spring-security-part-vii) is to use a naming convention:\n@Controller \npublic class Html5PathsController { \n\n @RequestMapping(value = \"/{[path:[^\\\\.]*}\")\n public String redirect() {\n return \"forward:/index.html\";\n } \n}\n\nThe above configuration will match all paths that do not contain a period and are not already mapped to another controller. \n\nA: Here the security configuration (SecurityConfig.java)\n@Configuration\n@EnableWebSecurity\n@EnableGlobalMethodSecurity(prePostEnabled=true)\npublic class SecurityConfig extends WebSecurityConfigurerAdapter {\n @Autowired\n private Environment env;\n\n @Autowired\n private UserSecurityService userSecurityService;\n\n private BCryptPasswordEncoder passwordEncoder() {\n return SecurityUtility.passwordEncoder();\n }\n\n private static final String[] PUBLIC_MATCHERS = {\n \"/css/**\",\n \"/js/**\",\n \"/data/**\",\n \"/sound/**\",\n \"/img/**\",\n \"/\",\n \"/login\",\n \"/logout,\n \"/error\",\n \"/index2\",\n };\n\n @Override\n protected void configure(HttpSecurity http) throws Exception {\n http\n .authorizeRequests().\n /* antMatchers(\"/**\").*/\n antMatchers(PUBLIC_MATCHERS).\n permitAll().anyRequest().authenticated();\n //.logout().logoutRequestMatcher(new AntPathRequestMatcher(\"/logout\")).logoutSuccessUrl(\"/login\");\n\n http\n .csrf().disable().cors().disable()\n .formLogin().failureUrl(\"/login?error\")\n .defaultSuccessUrl(\"/index2\")\n .loginPage(\"/login\").permitAll()\n .and()\n .logout().logoutRequestMatcher(new AntPathRequestMatcher(\"/logout\"))\n .logoutSuccessUrl(\"/?logout\").deleteCookies(\"remember-me\").permitAll()\n .and()\n .rememberMe()\n .and()\n .sessionManagement().maximumSessions(3600)\n .and().\n invalidSessionUrl(\"/login\");\n }\n\n @Autowired\n public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {\n auth.userDetailsService(userSecurityService).passwordEncoder(passwordEncoder());\n }\n}\n\nIf not found any resource redirect to error page\n@Controller\npublic class IndexController implements ErrorController{\n\n private static final String PATH = \"/error\";\n\n @RequestMapping(value = PATH)\n public String error() {\n return PATH;\n }\n\n @Override\n public String getErrorPath() {\n return PATH;\n }\n}\n\nError page like\n\n\n \n\n

Page not found please login the system!

\n\n\n\n\nA: Simply implementing the org.springframework.boot.web.servlet.error.ErrorController did the trick for me. I use SpringBoot 2.0 with React. (If you are interested in how to do that here is a boilerplate project made by me: https://github.com/archangel1991/react-with-spring)\n@Controller\npublic class CustomErrorController implements ErrorController {\n\n @Override\n public String getErrorPath() {\n return \"/error\";\n }\n}\n\nI am not sure why is this working though.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 579,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913129\",\n \"question_score\": \"19\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692781\"\n}"}}},{"rowIdx":1709332,"cells":{"id":{"kind":"string","value":"ac1b5603e0c27ec2559ac3f8e58e42e4c01d83e3"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: @page :first not working I have to use two different headers in the print version: one for the first page and one for the other pages. I would like to put a header (fixed on the top) for the other pages and use the css display: none for the first page. But I have not any effect with @page :first. \nThis is my code:\n@page :first {\n .header {\n display: none;\n }\n}\n\nI tried also putting !important in the css but nothing happens.\nWhat should I do?\n\nA: :first allows only few CSS properties. You can only change margins, page breaks and windows with it.Other CSS properties will be ignored. So i assume display:none may not work.\nThough you can refer more about how to use @page and with what type of CSS properties it works.\nhttps://developer.mozilla.org/en/docs/Web/CSS/:first\n"},"original_text":{"kind":"string","value":"Q: @page :first not working I have to use two different headers in the print version: one for the first page and one for the other pages. I would like to put a header (fixed on the top) for the other pages and use the css display: none for the first page. But I have not any effect with @page :first. \nThis is my code:\n@page :first {\n .header {\n display: none;\n }\n}\n\nI tried also putting !important in the css but nothing happens.\nWhat should I do?\n\nA: :first allows only few CSS properties. You can only change margins, page breaks and windows with it.Other CSS properties will be ignored. So i assume display:none may not work.\nThough you can refer more about how to use @page and with what type of CSS properties it works.\nhttps://developer.mozilla.org/en/docs/Web/CSS/:first\n\nA: According to: https://developer.mozilla.org/en/docs/Web/CSS/@page\n\nThe @page CSS at-rule is used to modify some CSS properties when\n printing a document. You can't change all CSS properties with @page.\n You can only change the margins, orphans, widows, and page breaks of\n the document. Attempts to change any other CSS properties will be\n ignored.\n\nAnd also for the :first https://developer.mozilla.org/en-US/docs/Web/CSS/:first\n\nNote: you cannot change all CSS properties with :first. You can only\n change the margins, orphans, widows, and page breaks of the document.\n All other CSS properties will be ignored.\n\nSo since you're trying to remove one of your own elements - try using media queries instead:\n@media print {\n .header { display: none; }\n}\n\nhttps://benfrain.com/create-print-styles-using-css3-media-queries/\n\nA: It looks like it's a Mozilla bug.\nI am not able to get margins working, even when following their own example here:\nhttps://developer.mozilla.org/en-US/docs/Web/CSS/:first\nBoth pages are printed in an identical way, no difference.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 287,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913130\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692784\"\n}"}}},{"rowIdx":1709333,"cells":{"id":{"kind":"string","value":"bac714e58f674a401b189d9f8160cec5bf66d99b"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: iOS silent notifications for killed apps after device restart According to the documentation silent notifications are processed by the delegate application(_:didReceiveRemoteNotification:fetchCompletionHandler:) also when the app is in \"Not Running\" state. This behavior does not apply if the app was force-quitted by the user.\nBut the documentation mentions that if the device has been restarted after a force-quit, the notification will trigger again the app launch on the device.\nExcerpt from the documentation:\n\n... However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.\n\nCan anyone confirm this to be working (maybe with earlier iOS versions)?\nMy experience (using iOS 10.x) is that if the app was force-quitted the app won't be restarted even after (multiple) device reboot.\n"},"original_text":{"kind":"string","value":"Q: iOS silent notifications for killed apps after device restart According to the documentation silent notifications are processed by the delegate application(_:didReceiveRemoteNotification:fetchCompletionHandler:) also when the app is in \"Not Running\" state. This behavior does not apply if the app was force-quitted by the user.\nBut the documentation mentions that if the device has been restarted after a force-quit, the notification will trigger again the app launch on the device.\nExcerpt from the documentation:\n\n... However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.\n\nCan anyone confirm this to be working (maybe with earlier iOS versions)?\nMy experience (using iOS 10.x) is that if the app was force-quitted the app won't be restarted even after (multiple) device reboot.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 146,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913131\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692786\"\n}"}}},{"rowIdx":1709334,"cells":{"id":{"kind":"string","value":"b0466e5a5ec7755f6d828a6847ad2d7816556214"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: C# restart a while loop in the middle I have a while loop that i want to restart if a condition is false, in my case. It is because i'm checking if a ip is valid and if it is then run the whole loop normal and if not i need it to restart from the start again at that point. I can't use a break and i dont want to use a goto. What is your sugestions?\nThis is my code, where i want to restart my while loop.\nwhile (calculateAgain == \"y\")\n{\n Console.Write(\"Your ip here: \");\n string ip = Console.ReadLine();\n\n IpValidation(ip);\n if (IpValidation(ip) == false)\n {\n Console.WriteLine(\"Ugyldig IP og eller Subnet mask!\\n\");\n // goto or break\n }\n\nAfter this my code runs on a lot...\nTell me some solutions to this other than goto.\n\nA: You need to use the word continue\n if (IpValidation(ip) == false)\n {\n Console.WriteLine(\"Ugyldig IP og eller Subnet mask!\\n\");\n continue;\n }\n\nThis will skip the rest and go to the top of your loop.\n"},"original_text":{"kind":"string","value":"Q: C# restart a while loop in the middle I have a while loop that i want to restart if a condition is false, in my case. It is because i'm checking if a ip is valid and if it is then run the whole loop normal and if not i need it to restart from the start again at that point. I can't use a break and i dont want to use a goto. What is your sugestions?\nThis is my code, where i want to restart my while loop.\nwhile (calculateAgain == \"y\")\n{\n Console.Write(\"Your ip here: \");\n string ip = Console.ReadLine();\n\n IpValidation(ip);\n if (IpValidation(ip) == false)\n {\n Console.WriteLine(\"Ugyldig IP og eller Subnet mask!\\n\");\n // goto or break\n }\n\nAfter this my code runs on a lot...\nTell me some solutions to this other than goto.\n\nA: You need to use the word continue\n if (IpValidation(ip) == false)\n {\n Console.WriteLine(\"Ugyldig IP og eller Subnet mask!\\n\");\n continue;\n }\n\nThis will skip the rest and go to the top of your loop.\n\nA: There is the continue statement. If it will be hit it will skip back to the start of the loop.\nwhile (calculateAgain == \"y\")\n{\n // ...\n if (IpValidation(ip) == false)\n {\n Console.WriteLine(\"Ugyldig IP og eller Subnet mask!\\n\");\n continue;\n }\n Console.WriteLine(\"This will not be executed when continue is called\");\n}\n\n\nA: You can do this on two ways, (by using break or continue) break will exit the loop completely, continue will just skip the current iteration.\nSo by reading your question. You need to use continue here, so your example might look like this:\nwhile (calculateAgain == \"y\")\n{\n Console.Write(\"Your ip here: \");\n string ip = Console.ReadLine();\n\n IpValidation(ip);\n if (IpValidation(ip) == false)\n {\n Console.WriteLine(\"Ugyldig IP og eller Subnet mask!\\n\");\n continue;\n }\n}\n\nThis above means, for condition if (IpValidation(ip) == false) code below will be skiped (will never be executed) if condition is satisfied\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 317,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913138\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692801\"\n}"}}},{"rowIdx":1709335,"cells":{"id":{"kind":"string","value":"4f40547932ef65e7e222617a20007a83333f8490"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to use \"vuetify\" transitions on my components? I'm using Vuetifyjs library in my project. I want to add transitions to my components - but there are no documentation about how to start transitions. \nFor example I want to add some transitions to appearance of my cards on screen.\n...\n\nHow to start transition?\n\nA: If you are using Vuetify transitions around your router-view, the transition can sometimes be jarring on leave/enter.\nTo make the transition look smoother try the prop hide-on-leave=\"true\"\n\n \n\n\n"},"original_text":{"kind":"string","value":"Q: How to use \"vuetify\" transitions on my components? I'm using Vuetifyjs library in my project. I want to add transitions to my components - but there are no documentation about how to start transitions. \nFor example I want to add some transitions to appearance of my cards on screen.\n...\n\nHow to start transition?\n\nA: If you are using Vuetify transitions around your router-view, the transition can sometimes be jarring on leave/enter.\nTo make the transition look smoother try the prop hide-on-leave=\"true\"\n\n \n\n\n\nA: This wraps some card text in a transition. When I trigger the v-show=\"show\" model to true, the text slides in.\n\n \n Example text\n \n\n\nYou could have a button trigger it or even add an onCreate() method that triggers the show to true after the component loads.\n\nA: try this :\n\n

hello

\n
\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 148,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913144\",\n \"question_score\": \"33\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692813\"\n}"}}},{"rowIdx":1709336,"cells":{"id":{"kind":"string","value":"e089a6982ae52b231991d494198b48bd4ad0b3b1"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: ShadowAlertDialog.getLatestAlertDialog() returns null for android.support.v7.app.AlertDialog Is there any workaround that will allow us to test android.support.v7.app.AlertDialog in Robolectric?\n someActivity.findViewById(R.id.alet_btn).performClick();\n AlertDialog alert = ShadowAlertDialog.getLatestAlertDialog();\n ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alert);\n assertThat(shadowAlertDialog.getTitle()).isEqualTo(\"Hello\");\n\n\nA: Try the below\n List shownDialogs = ShadowAlertDialog.getShownDialogs();\n if (shownDialogs.get(0) instanceof AlertDialog) {\n AlertDialog dialog = (android.support.v7.app.AlertDialog) shownDialogs.get(0);\n assertThat(dialog).isShowing();\n dialog.getButton(AlertDialog.BUTTON_NEGATIVE).performClick();\n }\n\nor\n if (ShadowAlertDialog.getLatestDialog() instanceof AlertDialog) {\n AlertDialog dialog = (android.support.v7.app.AlertDialog) ShadowAlertDialog.getLatestDialog();\n assertThat(dialog).isShowing();\n dialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();\n }\n\nIt allows you to click the buttons, but can't verify title or message AFAIK.\n"},"original_text":{"kind":"string","value":"Q: ShadowAlertDialog.getLatestAlertDialog() returns null for android.support.v7.app.AlertDialog Is there any workaround that will allow us to test android.support.v7.app.AlertDialog in Robolectric?\n someActivity.findViewById(R.id.alet_btn).performClick();\n AlertDialog alert = ShadowAlertDialog.getLatestAlertDialog();\n ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alert);\n assertThat(shadowAlertDialog.getTitle()).isEqualTo(\"Hello\");\n\n\nA: Try the below\n List shownDialogs = ShadowAlertDialog.getShownDialogs();\n if (shownDialogs.get(0) instanceof AlertDialog) {\n AlertDialog dialog = (android.support.v7.app.AlertDialog) shownDialogs.get(0);\n assertThat(dialog).isShowing();\n dialog.getButton(AlertDialog.BUTTON_NEGATIVE).performClick();\n }\n\nor\n if (ShadowAlertDialog.getLatestDialog() instanceof AlertDialog) {\n AlertDialog dialog = (android.support.v7.app.AlertDialog) ShadowAlertDialog.getLatestDialog();\n assertThat(dialog).isShowing();\n dialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick();\n }\n\nIt allows you to click the buttons, but can't verify title or message AFAIK.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 78,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913156\",\n \"question_score\": \"5\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692860\"\n}"}}},{"rowIdx":1709337,"cells":{"id":{"kind":"string","value":"162fbfac9fdaff6a506e9a0a026cbe600ab6f1c5"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: DNS resolution fails on android There is restriction on UDP response size for DNS protocol. It can only contain ~500bytes. When data exceeds the limit all the DNS servers sets flag \"truncated\" in response but some (google 8.8.8.8 for example) does not put any IPs in response others just put trimmed list. Utilities like nslookup and dig tries to ask DNS server by TCP to get full response but android does not. Instead it fails. The example of code that fails is bellow.\nvar host = \"prdimg.affili.net\";\nvar addressList = Dns.GetHostEntry(host).AddressList;\n\nThe Modernhttpclient uses gets IPs the same way so I cannot get files from prdimg.affili.net. To fix it I've implemented the temporary solution. I use GooglePublicDnsClient to resolve DNS and then change hostname to resolved ip with UriBuilder.\nvar builder = new UriBuilder(originalUrl);\nbuilder.Host = ip;\nBut the solution has two disadvantages\n\n\n*\n\n*it does not work for https because of certificate check\n\n*it does not work if server uses Vhosts\n\n\nCan anyone propose a better solution?\n"},"original_text":{"kind":"string","value":"Q: DNS resolution fails on android There is restriction on UDP response size for DNS protocol. It can only contain ~500bytes. When data exceeds the limit all the DNS servers sets flag \"truncated\" in response but some (google 8.8.8.8 for example) does not put any IPs in response others just put trimmed list. Utilities like nslookup and dig tries to ask DNS server by TCP to get full response but android does not. Instead it fails. The example of code that fails is bellow.\nvar host = \"prdimg.affili.net\";\nvar addressList = Dns.GetHostEntry(host).AddressList;\n\nThe Modernhttpclient uses gets IPs the same way so I cannot get files from prdimg.affili.net. To fix it I've implemented the temporary solution. I use GooglePublicDnsClient to resolve DNS and then change hostname to resolved ip with UriBuilder.\nvar builder = new UriBuilder(originalUrl);\nbuilder.Host = ip;\nBut the solution has two disadvantages\n\n\n*\n\n*it does not work for https because of certificate check\n\n*it does not work if server uses Vhosts\n\n\nCan anyone propose a better solution?\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 169,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913157\",\n \"question_score\": \"10\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692863\"\n}"}}},{"rowIdx":1709338,"cells":{"id":{"kind":"string","value":"5a27fba2e7e2261abd837239a55d52a9ccd28176"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Is a (local) file path a URI? On some input we allow the following paths:\n\n*\n\n*C:\\Folder\n\n*\\\\server\\Folder\n\n*http://example.com/...\n\nCan I mark them all as \"URI\"s?\n\nA: Strictly speaking no, unless you make sure it's an absolute path and add add \"file://\" to the beginning.\nAs per RFC 3986 Section 3:\n\nURI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n\nhier-part = \"//\" authority path-abempty\n / path-absolute\n / path-rootless\n / path-empty\n\n\nThe scheme and the \":\" are not in square brackets [], which means they are not optional.\nHowever, the HTML standard calls these \"path-relative-scheme-less-URL strings\" and they're valid in the href attribute of an HTML element so maybe it's fine to call relative Unix paths \"URLs\" (not absolute Unix paths or Windows paths though).\n"},"original_text":{"kind":"string","value":"Q: Is a (local) file path a URI? On some input we allow the following paths:\n\n*\n\n*C:\\Folder\n\n*\\\\server\\Folder\n\n*http://example.com/...\n\nCan I mark them all as \"URI\"s?\n\nA: Strictly speaking no, unless you make sure it's an absolute path and add add \"file://\" to the beginning.\nAs per RFC 3986 Section 3:\n\nURI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n\nhier-part = \"//\" authority path-abempty\n / path-absolute\n / path-rootless\n / path-empty\n\n\nThe scheme and the \":\" are not in square brackets [], which means they are not optional.\nHowever, the HTML standard calls these \"path-relative-scheme-less-URL strings\" and they're valid in the href attribute of an HTML element so maybe it's fine to call relative Unix paths \"URLs\" (not absolute Unix paths or Windows paths though).\n\nA: C:/Folder and /server/Folder/ are file paths.\nhttp://example.com/ is a URL, which is a URI sub-type, so you could mark it as a URI but not the other way around (like how squares are rectangles but not vice versa).\nOf course, here you have posted a clear, simple example. When discussing the distinction between URI and URL, not only is the answer not clear cut, it is also disputed. I recommend taking a look at this thread and the answers posted in it for clarification. Generally though, it is mostly agreed that the main difference is that URLs provide an access method (such as http://).\nSo if we were to convert your first file path into a URL it would become the following (note the addition of the access method):\nfile:///c:/Folder/test.txt\n\nIf you modify all your file paths to include an access method like in my example, then it will be okay for you to mark them as URIs.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 289,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913159\",\n \"question_score\": \"13\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692872\"\n}"}}},{"rowIdx":1709339,"cells":{"id":{"kind":"string","value":"7b799dc81b390e16f10e44c0ddb6a1b4184a7b42"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Effect of aria-hidden in Font Awesome what's the effect of aria-hidden in Font Awesome?\nIs it necessary to use it? why? or why not?\nfor example, I want to know the effect of aria-hidden=\"true\" in the code below:\n\n\n\nA: In short, it makes the icon not visible to screen readers, to enhance accessibility.\nFrom the documentation:\n\nIf you're using an icon to add some extra decoration or branding, it does not need to be announced to users as they are navigating your site or app aurally. Additionally, if you're using an icon to visually re-emphasize or add styling to content already present in your HTML, it does not need to be repeated to an assistive technology-using user. You can make sure this is not read by adding the aria-hidden=\"true\" to your Font Awesome markup.\n\n"},"original_text":{"kind":"string","value":"Q: Effect of aria-hidden in Font Awesome what's the effect of aria-hidden in Font Awesome?\nIs it necessary to use it? why? or why not?\nfor example, I want to know the effect of aria-hidden=\"true\" in the code below:\n\n\n\nA: In short, it makes the icon not visible to screen readers, to enhance accessibility.\nFrom the documentation:\n\nIf you're using an icon to add some extra decoration or branding, it does not need to be announced to users as they are navigating your site or app aurally. Additionally, if you're using an icon to visually re-emphasize or add styling to content already present in your HTML, it does not need to be repeated to an assistive technology-using user. You can make sure this is not read by adding the aria-hidden=\"true\" to your Font Awesome markup.\n\n\nA: \nIf you're using an icon to add some extra decoration or branding, it\n does not need to be announced to users as they are navigating your\n site or app aurally. Additionally, if you're using an icon to visually\n re-emphasize or add styling to content already present in your HTML,\n it does not need to be repeated to an assistive technology-using user.\n You can make sure this is not read by adding the aria-hidden=\"true\" to\n your Font Awesome markup.\n\n\n\nan icon being used as pure decoration\n

\n \n Pied Piper, A Middle-Out Compression Solution Making Data Storage Problems Smaller\n

\n\nan icon being used as a logo\nSource: http://fontawesome.io/accessibility/\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 256,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913172\",\n \"question_score\": \"13\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692917\"\n}"}}},{"rowIdx":1709340,"cells":{"id":{"kind":"string","value":"901516b8c38fd5fc5b73eacc10e917e36644a286"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Open XML change fontsize of table for (var i = 0; i <= data.GetUpperBound(0); i++)\n{\n var tr = new DocumentFormat.OpenXml.Wordprocessing.TableRow();\n for (var j = 0; j <= data.GetUpperBound(1); j++)\n {\n var tc = new DocumentFormat.OpenXml.Wordprocessing.TableCell();\n\n tc.Append(new DocumentFormat.OpenXml.Wordprocessing.Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data[i, j]))));\n\n\n tr.Append(tc);\n\n }\n table.Append(tr);\n}\n\nI want to change fontsize in table cell. Can you help me with that? I don't know why they didn't add a property for cell fontsize.\n\nA: To change the fontsize of a table cell, you need to add a RunProperties to the Run. The fontsize is specified inside a FontSize element inside that RunProperties.\nFor example to change all of your entries to fontsize 18, your code would look like:\nfor (var i = 0; i <= data.GetUpperBound(0); i++)\n{\n var tr = new DocumentFormat.OpenXml.Wordprocessing.TableRow();\n for (var j = 0; j <= data.GetUpperBound(1); j++)\n {\n var tc = new DocumentFormat.OpenXml.Wordprocessing.TableCell();\n\n var paragraph = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();\n var run = new DocumentFormat.OpenXml.Wordprocessing.Run();\n var text = new DocumentFormat.OpenXml.Wordprocessing.Text(data[i, j]);\n\n // your old code for reference: tc.Append(new DocumentFormat.OpenXml.Wordprocessing.Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data[i, j]))));\n\n RunProperties runProperties1 = new RunProperties();\n FontSize fontSize1 = new FontSize(){ Val = \"36\" };\n runProperties1.Append(fontSize1);\n\n run.Append(runProperties1);\n run.Append(text);\n\n paragraph.Append(run);\n tc.Append(paragraph);\n\n tr.Append(tc);\n\n }\n table.Append(tr);\n}\n\n"},"original_text":{"kind":"string","value":"Q: Open XML change fontsize of table for (var i = 0; i <= data.GetUpperBound(0); i++)\n{\n var tr = new DocumentFormat.OpenXml.Wordprocessing.TableRow();\n for (var j = 0; j <= data.GetUpperBound(1); j++)\n {\n var tc = new DocumentFormat.OpenXml.Wordprocessing.TableCell();\n\n tc.Append(new DocumentFormat.OpenXml.Wordprocessing.Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data[i, j]))));\n\n\n tr.Append(tc);\n\n }\n table.Append(tr);\n}\n\nI want to change fontsize in table cell. Can you help me with that? I don't know why they didn't add a property for cell fontsize.\n\nA: To change the fontsize of a table cell, you need to add a RunProperties to the Run. The fontsize is specified inside a FontSize element inside that RunProperties.\nFor example to change all of your entries to fontsize 18, your code would look like:\nfor (var i = 0; i <= data.GetUpperBound(0); i++)\n{\n var tr = new DocumentFormat.OpenXml.Wordprocessing.TableRow();\n for (var j = 0; j <= data.GetUpperBound(1); j++)\n {\n var tc = new DocumentFormat.OpenXml.Wordprocessing.TableCell();\n\n var paragraph = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();\n var run = new DocumentFormat.OpenXml.Wordprocessing.Run();\n var text = new DocumentFormat.OpenXml.Wordprocessing.Text(data[i, j]);\n\n // your old code for reference: tc.Append(new DocumentFormat.OpenXml.Wordprocessing.Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data[i, j]))));\n\n RunProperties runProperties1 = new RunProperties();\n FontSize fontSize1 = new FontSize(){ Val = \"36\" };\n runProperties1.Append(fontSize1);\n\n run.Append(runProperties1);\n run.Append(text);\n\n paragraph.Append(run);\n tc.Append(paragraph);\n\n tr.Append(tc);\n\n }\n table.Append(tr);\n}\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 197,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913176\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44692925\"\n}"}}},{"rowIdx":1709341,"cells":{"id":{"kind":"string","value":"4e187c9f1f9f4fb18d6251fdb6c47a3f1f145176"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Regular expression for Visual Studio Power Tools custom tab color to match on tabs that start with I (for Interface) I'd like to colour code my tabs according to file types.\nI'd like Interface files to be white.\nMy naming convention for interfaces is the usual\nIFoo.cs\nIIgloo.cs\netc\nTo try and colour code these I'm using this regex\n^I([A-Z][a-z0-9]*){1}\\.cs$\n\nHowever that is colour coding \nInvoice.cs\nand \nIInvoice.cs\nWhere I would like it to only catch IInvoice.cs\nWhere have I gone wrong with my regex?\nI thought this regex would match:\n^I - Starts with I\n([A-Z][a-z0-9]*) - Then has an upper case character followed by lowercase characters or numbers\n{1}\\.cs$ - Ends with .cs\nOther regex I've tried:\nI[A-Z]+[a-z0-9]+\\.cs - Matches both Invoice.cs and IInvoice.cs\n(?:I[A-Z]+[a-z0-9]+\\.cs) - Matches both Invoice.cs and IInvoice.cs\n"},"original_text":{"kind":"string","value":"Q: Regular expression for Visual Studio Power Tools custom tab color to match on tabs that start with I (for Interface) I'd like to colour code my tabs according to file types.\nI'd like Interface files to be white.\nMy naming convention for interfaces is the usual\nIFoo.cs\nIIgloo.cs\netc\nTo try and colour code these I'm using this regex\n^I([A-Z][a-z0-9]*){1}\\.cs$\n\nHowever that is colour coding \nInvoice.cs\nand \nIInvoice.cs\nWhere I would like it to only catch IInvoice.cs\nWhere have I gone wrong with my regex?\nI thought this regex would match:\n^I - Starts with I\n([A-Z][a-z0-9]*) - Then has an upper case character followed by lowercase characters or numbers\n{1}\\.cs$ - Ends with .cs\nOther regex I've tried:\nI[A-Z]+[a-z0-9]+\\.cs - Matches both Invoice.cs and IInvoice.cs\n(?:I[A-Z]+[a-z0-9]+\\.cs) - Matches both Invoice.cs and IInvoice.cs\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 134,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913205\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693018\"\n}"}}},{"rowIdx":1709342,"cells":{"id":{"kind":"string","value":"fcbb10e64d66f5a45edf608dfd31ebed5025eaf9"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Issue converting video to live photo to wallpaper I'm using this way of converting a video + image to live photo. It adds the needed metadata to the video and still image. It exports the new video with the correct metadata using AVAssetExportPresetPassthrough so the codec settings shouldn't be changed.\nAfter I set the output high resolution live photo as wallpaper on my phone's home screen, the quality is greatly reduced and pixelated.\nThis does not happen, or at least not to the same extent, when setting a photo taken from the camera as live wallpaper.\nAnyone have any idea on what could be the issue?\n"},"original_text":{"kind":"string","value":"Q: Issue converting video to live photo to wallpaper I'm using this way of converting a video + image to live photo. It adds the needed metadata to the video and still image. It exports the new video with the correct metadata using AVAssetExportPresetPassthrough so the codec settings shouldn't be changed.\nAfter I set the output high resolution live photo as wallpaper on my phone's home screen, the quality is greatly reduced and pixelated.\nThis does not happen, or at least not to the same extent, when setting a photo taken from the camera as live wallpaper.\nAnyone have any idea on what could be the issue?\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 107,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913211\",\n \"question_score\": \"7\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693037\"\n}"}}},{"rowIdx":1709343,"cells":{"id":{"kind":"string","value":"70b3657cd621734d12d70bddfdeaefc10f26def5"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Rx-Android library import rx.android.plugins vs io.reactivex.android.plugins my build.gradle:\ncompile 'io.reactivex.rxjava2:rxandroid:2.0.1'\ncompile \"io.reactivex.rxjava2:rxjava:2.1.0\"\n\nIn using the exact libraries External Libraries shows rxandroid-1.2.0 & rxandroid-2.0.1 in one project of mine, whereas in another just shows the latter. \n1.2.0 uses rx.android.schedulers.Scheduler; which is compatible with rx.Observable when used as follows:\nsomeRxObservable\n .subscribeOn(Schedulers.io())\n .observeOn(AndroidSchedulers.mainThread())\n .subscribe();\n\nio.reactivex.Scheduler used by 2.0.1 isn't, as it does not subclass rx.Scheduler. I'm not sure if this is a dependency gradle, in expecting to have downloaded both libraries by using gradle dependency mentioned above. That said however, in looking at the source code on github for the latest version 2.0.1 it only shows the io.reactive solution.\n\nA: io.reactivex is the newer RxJava and the issue was that AndroidRx only works with version 2 of RxJava. The fix was to use io.reactivex across the board with its Observables, Schedulers, & Subscriptions.\n"},"original_text":{"kind":"string","value":"Q: Rx-Android library import rx.android.plugins vs io.reactivex.android.plugins my build.gradle:\ncompile 'io.reactivex.rxjava2:rxandroid:2.0.1'\ncompile \"io.reactivex.rxjava2:rxjava:2.1.0\"\n\nIn using the exact libraries External Libraries shows rxandroid-1.2.0 & rxandroid-2.0.1 in one project of mine, whereas in another just shows the latter. \n1.2.0 uses rx.android.schedulers.Scheduler; which is compatible with rx.Observable when used as follows:\nsomeRxObservable\n .subscribeOn(Schedulers.io())\n .observeOn(AndroidSchedulers.mainThread())\n .subscribe();\n\nio.reactivex.Scheduler used by 2.0.1 isn't, as it does not subclass rx.Scheduler. I'm not sure if this is a dependency gradle, in expecting to have downloaded both libraries by using gradle dependency mentioned above. That said however, in looking at the source code on github for the latest version 2.0.1 it only shows the io.reactive solution.\n\nA: io.reactivex is the newer RxJava and the issue was that AndroidRx only works with version 2 of RxJava. The fix was to use io.reactivex across the board with its Observables, Schedulers, & Subscriptions.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 141,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913227\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693095\"\n}"}}},{"rowIdx":1709344,"cells":{"id":{"kind":"string","value":"eb36a32465876179cecc74dd2d2f84cdeb98507c"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: how to add inline style width:calc(100% / var) in reactjs? for (let i = 0; i < divCount.length; i++) {\n var radio = divCount[i].getElementsByClassName(\"radio_count\");\n for (var index = 0; index < radio.length; index++) {\n var element: any = radio[index];\n console.log(element);\n var style =\"width:calc(100% / \" + element + \")\";\n element.style = style;\n }\n\n }\n\n\n\n*\n\n*i want add inline style\n\n*set dynamic value in 100% divided\nex. width:clac(100% / var);\nhow can i do this ?\n\n\nA: What @Andrew wrote is correct, however here's a non ES2015/ES6 version (the question did not specify):\nIn the react component render, you can use the following JSX:\nrender: function() {\n var dynamicWidth = 'calc(100% / ' + value + ')';\n return (\n
\n
\n
\n );\n\nBasically how this works is on each render that string gets interpolated.\nWhat @Andrew has shown you is just a better syntax available to do the same thing in ES6\ncalc(100% / ${value}) is conceptually equivalent to 'calc(100% / ' + value + ')'\n"},"original_text":{"kind":"string","value":"Q: how to add inline style width:calc(100% / var) in reactjs? for (let i = 0; i < divCount.length; i++) {\n var radio = divCount[i].getElementsByClassName(\"radio_count\");\n for (var index = 0; index < radio.length; index++) {\n var element: any = radio[index];\n console.log(element);\n var style =\"width:calc(100% / \" + element + \")\";\n element.style = style;\n }\n\n }\n\n\n\n*\n\n*i want add inline style\n\n*set dynamic value in 100% divided\nex. width:clac(100% / var);\nhow can i do this ?\n\n\nA: What @Andrew wrote is correct, however here's a non ES2015/ES6 version (the question did not specify):\nIn the react component render, you can use the following JSX:\nrender: function() {\n var dynamicWidth = 'calc(100% / ' + value + ')';\n return (\n
\n
\n
\n );\n\nBasically how this works is on each render that string gets interpolated.\nWhat @Andrew has shown you is just a better syntax available to do the same thing in ES6\ncalc(100% / ${value}) is conceptually equivalent to 'calc(100% / ' + value + ')'\n\nA: Template literals should help.\n
\n\nExample https://jsfiddle.net/69z2wepo/81579/\n\nA: 1.Inline styles can be added to a component in ReactJS as shown below:\nrender() {\n return (\n
\n Div to be styled\n
\n )\n}\n\nOr by passing a style object to the component:\nrender() {\n const divStyle = {\n color: 'white',\n backgroundColor: 'red'\n };\n\n return (\n
\n Div to be styled\n
\n )\n}\n\n\n\n*In order to set a dynamic width based on the number of child elements as you have described, I would recommend using CSS. Use display: flex on the wrapping element and flex-grow: 1 on the inner element.\n\n\nExample: https://jsfiddle.net/edyjt34r/\n\nA: Without using Calc function you can this desired result\n
\n\n\nA: for (let i = 0; i < divCount.length; i++) {\n var radio = divCount[i].getElementsByClassName(\"radio_count\");\n for (var index = 0; index < radio.length; index++) {\n var element: any = radio[index];\n console.log(element);\n let width = 100 / radio.length;\n element.style.width=width + \"%\";\n }\n }\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 343,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913257\",\n \"question_score\": \"15\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693208\"\n}"}}},{"rowIdx":1709345,"cells":{"id":{"kind":"string","value":"0699af6357ad395ec8ef07f4b0a8c5f44d5a8134"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Uploading large files with Django: How should one go about doing this? I have to upload >= 20 GBs of data with Django.\nShould I break the file into chunks and then upload it with some kind of a checksum to maintain integrity or does Django implicitly does it?\nWill it be better if I use FTP instead of regular HTTP for such large files?\n\nA: Django uses so-called Upload Handlers to upload files, and has a related setting called FILE_UPLOAD_MAX_MEMORY_SIZE (default value of 2.5Mb). Files smaller than this threshold will be handled in memory, larger files will be streamed into a temporary file on disk. I haven't yet tried uploading files larger than about 1Gb, but I would expect you can just use django without problems. \n"},"original_text":{"kind":"string","value":"Q: Uploading large files with Django: How should one go about doing this? I have to upload >= 20 GBs of data with Django.\nShould I break the file into chunks and then upload it with some kind of a checksum to maintain integrity or does Django implicitly does it?\nWill it be better if I use FTP instead of regular HTTP for such large files?\n\nA: Django uses so-called Upload Handlers to upload files, and has a related setting called FILE_UPLOAD_MAX_MEMORY_SIZE (default value of 2.5Mb). Files smaller than this threshold will be handled in memory, larger files will be streamed into a temporary file on disk. I haven't yet tried uploading files larger than about 1Gb, but I would expect you can just use django without problems. \n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 128,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913277\",\n \"question_score\": \"5\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693272\"\n}"}}},{"rowIdx":1709346,"cells":{"id":{"kind":"string","value":"fc33a6d3fad868dfb318971e7aa3a4ef0b0ca392"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Run code when an element is added to a list How do I detect when something is added to a list? Is there an equivalent to the dictionary __setitem__ method, that will get called when something is added to the list by insert, extend, append or using + or += (__add__, __iadd__), or some other method that I probably forgot about? Or do I need to hook into each of those methods, one by one?\n\nA: You'll need to override each method separately. Especially as the operations you've mentioned are different in nature - append, insert, extend, and += modify the list in place while + creates a new list.\nIf you're feeling fancy, this is a potential way to do it without having to write too much boilerplate:\nclass MyList(list):\n pass\n\nfor method in ['append', 'insert', 'extend', '__add__', '__iadd__']:\n def code_added(self, *args, **kwargs):\n # Your code here\n getattr(super(MyList, self), method)(*args, **kwargs)\n\n setattr(MyList, method, code_added)\n\nDepending on what the code you want to run accesses, you might need to handle __add__ separately.\n"},"original_text":{"kind":"string","value":"Q: Run code when an element is added to a list How do I detect when something is added to a list? Is there an equivalent to the dictionary __setitem__ method, that will get called when something is added to the list by insert, extend, append or using + or += (__add__, __iadd__), or some other method that I probably forgot about? Or do I need to hook into each of those methods, one by one?\n\nA: You'll need to override each method separately. Especially as the operations you've mentioned are different in nature - append, insert, extend, and += modify the list in place while + creates a new list.\nIf you're feeling fancy, this is a potential way to do it without having to write too much boilerplate:\nclass MyList(list):\n pass\n\nfor method in ['append', 'insert', 'extend', '__add__', '__iadd__']:\n def code_added(self, *args, **kwargs):\n # Your code here\n getattr(super(MyList, self), method)(*args, **kwargs)\n\n setattr(MyList, method, code_added)\n\nDepending on what the code you want to run accesses, you might need to handle __add__ separately.\n\nA: as obskyr answer is suggesting, you have to define a child class of list and override a lot of methods, and test carefully to see if you're not missing something.\nMy approach uses a deeper hook using __getattribute__ (for method calls), __iadd__ (for +=) and __setitem__ (for slice assignment) to catch the maximum of changes, and call the original parent method so it acts like a generic middleman:\nclass MyList(list):\n def __getattribute__(self,a):\n if a in {\"append\",\"extend\",\"remove\",\"insert\",\"pop\",\"reverse\",\"sort\",\"clear\"}:\n print(\"modification by {}\".format(a))\n else:\n print(\"not modified {}\".format(a))\n return list.__getattribute__(self,a)\n\n def __iadd__(self,v):\n print(\"in place add\")\n return list.__iadd__(self,v)\n\n def __setitem__(self,i,v):\n print(\"setitem {},{}\".format(i,v))\n return list.__setitem__(self,i,v)\n\nl = MyList()\n\nl.append(12)\nl.extend([12])\nl.remove(12)\nprint(l)\nl[:] = [4,5,6]\nl += [5]\nprint(l)\n\noutput:\nmodification by append\nmodification by extend\nmodification by remove\n[12]\nsetitem slice(None, None, None),[4, 5, 6]\nin place add\n[4, 5, 6, 5]\n\nas you see\n\n\n*\n\n*the list is modified properly\n\n*all changes are detected\n\n\nI may have missed some accesses, but that seems pretty close to me.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 336,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913318\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693429\"\n}"}}},{"rowIdx":1709347,"cells":{"id":{"kind":"string","value":"42dbe55b748a586ea94ade4b11c01d48595cf067"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Image color changed after converting from numpy array to PIL image python I am trying to convert the image that I read using cv2.imread which is store in numpy array to PIL Image object , the color of Image will be changed Here is the code\nI=cv2.imread(\"Image.jpg\")\nPILImage=Image.fromarray(I,mode='RGB')\n\nHow can get back my original Image?\n\nA: OpenCV likes to treat images as having BGR layers instead of RGB layers. Adding\nI = cv2.cvtColor(I, cv2.COLOR_BGR2RGB)\n\nwill swap layers to what you expect.\n"},"original_text":{"kind":"string","value":"Q: Image color changed after converting from numpy array to PIL image python I am trying to convert the image that I read using cv2.imread which is store in numpy array to PIL Image object , the color of Image will be changed Here is the code\nI=cv2.imread(\"Image.jpg\")\nPILImage=Image.fromarray(I,mode='RGB')\n\nHow can get back my original Image?\n\nA: OpenCV likes to treat images as having BGR layers instead of RGB layers. Adding\nI = cv2.cvtColor(I, cv2.COLOR_BGR2RGB)\n\nwill swap layers to what you expect.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 82,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913343\",\n \"question_score\": \"5\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693507\"\n}"}}},{"rowIdx":1709348,"cells":{"id":{"kind":"string","value":"7949279f40b2c77e5d8419b23e69aa054f1b118d"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to use the API to download a repo I want to download a single file from my Bitbucket repository. In the documentary I found the following API call.\nhttps://api.bitbucket.org/1.0/repositories/{accountname}/{repo_slug}/raw/{revision}/{path}\n\nHowever I struggle to find out what my \"accountname\", \"repo_slug\", \"revision\" and \"path\" is.\nIf I open the folder \"scripts\" in my Bitbucket account the browser displays the following link.\nhttps://example.com/projects/MMMA/repos/iapc_reporting/browse/scripts\n\nFor accountname I used \"MMMA\", for repo_slug \"iapc_reporting\", for revision the branch \"master\", and for path \"scripts/main.py\". The URL now looks like this:\nhttps://api.bitbucket.org/1.0/repositories/MMMA/iapc_reporting/raw/master/scripts/main.py\n\nUnfortunately opening this link in my browser gives me an 404 error. How do I properly buidl this link? If you had a solution with the V2 API that would be even better.\n\nA: If your server \"example.com\" is managed by a BitBucket server, then the API url should be:\nhttps://example.com/rest/api/1.0/projects/MMMA/repos/iapc_reporting\n\nSee \"Bitbucket Server REST APIs\".\nIn your case, since it is a private repo, with a curl --user user:pw:\nhttps://example.com/rest/api/1.0/projects/MMMA/repos/iapc_reporting/raw/master/scripts/main.py\n\n"},"original_text":{"kind":"string","value":"Q: How to use the API to download a repo I want to download a single file from my Bitbucket repository. In the documentary I found the following API call.\nhttps://api.bitbucket.org/1.0/repositories/{accountname}/{repo_slug}/raw/{revision}/{path}\n\nHowever I struggle to find out what my \"accountname\", \"repo_slug\", \"revision\" and \"path\" is.\nIf I open the folder \"scripts\" in my Bitbucket account the browser displays the following link.\nhttps://example.com/projects/MMMA/repos/iapc_reporting/browse/scripts\n\nFor accountname I used \"MMMA\", for repo_slug \"iapc_reporting\", for revision the branch \"master\", and for path \"scripts/main.py\". The URL now looks like this:\nhttps://api.bitbucket.org/1.0/repositories/MMMA/iapc_reporting/raw/master/scripts/main.py\n\nUnfortunately opening this link in my browser gives me an 404 error. How do I properly buidl this link? If you had a solution with the V2 API that would be even better.\n\nA: If your server \"example.com\" is managed by a BitBucket server, then the API url should be:\nhttps://example.com/rest/api/1.0/projects/MMMA/repos/iapc_reporting\n\nSee \"Bitbucket Server REST APIs\".\nIn your case, since it is a private repo, with a curl --user user:pw:\nhttps://example.com/rest/api/1.0/projects/MMMA/repos/iapc_reporting/raw/master/scripts/main.py\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 157,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913411\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693698\"\n}"}}},{"rowIdx":1709349,"cells":{"id":{"kind":"string","value":"8c66a1f49e1ce6b04e8a0bd0d41c8831f0f577d5"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Get the exit code of a Python script in a Bash script I'm new to Bash and want to catch my Python script exit code.\nMy script.py looks like:\n#! /usr/bin/python\ndef foofoo():\n ret = # Do logic\n if ret != 0:\n print repr(ret) + 'number of errors'\n sys.ext(1)\n else:\n print 'NO ERRORS!!!!'\n sys.exit(0)\n\ndef main(argv):\n # Do main stuff\n foofoo()\n\nif __main__ == \"__main__\":\n main(sys.argv[1:]\n\nMy Bash script:\n#!/bin/bash\npython script.py -a a1 -b a2 -c a3\nif [ $?!=0 ];\nthen\n echo \"exit 1\"\nfi\necho \"EXIT 0\"\n\nMy problem is that I am always getting exit 1 printed in my Bash script. How can I get my Python exit code in my Bash script?\n\nA: The spaces are important because they are the arguments delimiter:\nif [ $? != 0 ];\nthen\n echo \"exit 1\"\nfi\necho \"EXIT 0\"\n\nOr numeric test -ne. See man [ for [ command or man bash for builtin more details.\n# Store in a variable. Otherwise, it will be overwritten after the next command\nexit_status=$?\nif [ \"${exit_status}\" -ne 0 ];\nthen\n echo \"exit ${exit_status}\"\nfi\necho \"EXIT 0\"\n\n"},"original_text":{"kind":"string","value":"Q: Get the exit code of a Python script in a Bash script I'm new to Bash and want to catch my Python script exit code.\nMy script.py looks like:\n#! /usr/bin/python\ndef foofoo():\n ret = # Do logic\n if ret != 0:\n print repr(ret) + 'number of errors'\n sys.ext(1)\n else:\n print 'NO ERRORS!!!!'\n sys.exit(0)\n\ndef main(argv):\n # Do main stuff\n foofoo()\n\nif __main__ == \"__main__\":\n main(sys.argv[1:]\n\nMy Bash script:\n#!/bin/bash\npython script.py -a a1 -b a2 -c a3\nif [ $?!=0 ];\nthen\n echo \"exit 1\"\nfi\necho \"EXIT 0\"\n\nMy problem is that I am always getting exit 1 printed in my Bash script. How can I get my Python exit code in my Bash script?\n\nA: The spaces are important because they are the arguments delimiter:\nif [ $? != 0 ];\nthen\n echo \"exit 1\"\nfi\necho \"EXIT 0\"\n\nOr numeric test -ne. See man [ for [ command or man bash for builtin more details.\n# Store in a variable. Otherwise, it will be overwritten after the next command\nexit_status=$?\nif [ \"${exit_status}\" -ne 0 ];\nthen\n echo \"exit ${exit_status}\"\nfi\necho \"EXIT 0\"\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 189,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913426\",\n \"question_score\": \"7\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693740\"\n}"}}},{"rowIdx":1709350,"cells":{"id":{"kind":"string","value":"945b0b3af8bca0db3b999e7106217987c12f8445"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: PHP - How to start google chrome with PHP script Here is my code:\n$output\";\n?>\n\nHere is what i have in test.sh:\n#!/bin/bash\nexport DISPLAY=:0\ngoogle-chrome\necho \"Starting Chrome\"\n\nWhen i execute ./test.sh google-chrome is started and then i see in my terminal the text Starting Chrome.\nHowever when i execute the php script i see only the text Starting Chrome. Why google-chrome does not start when the test.sh is called by apache2 ?\nI think there is something regarding permissions.\nIs it even possible to achieve such thing somehow ?\n"},"original_text":{"kind":"string","value":"Q: PHP - How to start google chrome with PHP script Here is my code:\n$output\";\n?>\n\nHere is what i have in test.sh:\n#!/bin/bash\nexport DISPLAY=:0\ngoogle-chrome\necho \"Starting Chrome\"\n\nWhen i execute ./test.sh google-chrome is started and then i see in my terminal the text Starting Chrome.\nHowever when i execute the php script i see only the text Starting Chrome. Why google-chrome does not start when the test.sh is called by apache2 ?\nI think there is something regarding permissions.\nIs it even possible to achieve such thing somehow ?\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 99,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913428\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693747\"\n}"}}},{"rowIdx":1709351,"cells":{"id":{"kind":"string","value":"13e9ab4bcdb8878c0c187a87c9aa2aa05f66dc70"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Performance issues when using C# attributes? As far as I've understood attributes are generated at compile time (otherwise it would not be possible to load attributes via relflection). Anyhow, are there certain cases where attributes might lead to performance issues at runtime?\n\nA: \nAnyhow, are there certain cases where attributes might lead to performance issues at runtime?\n\nOnly if your program is excessively looking for attributes in your code.\nAttributes are only useful when something is looking for it. If you decorate your class with [MyAwsomeAttribute] and nothing is looking for it, then there will be no performance difference.\nThe performance difference will depend on how many attributes you have; if it was discovered; and the time it takes to execute the offending attribute (assuming it has this ability, many attributes are purely metadata).\nGood examples are WCF custom behaviour attributes with their detailed and potentially complex implementation methods. \n"},"original_text":{"kind":"string","value":"Q: Performance issues when using C# attributes? As far as I've understood attributes are generated at compile time (otherwise it would not be possible to load attributes via relflection). Anyhow, are there certain cases where attributes might lead to performance issues at runtime?\n\nA: \nAnyhow, are there certain cases where attributes might lead to performance issues at runtime?\n\nOnly if your program is excessively looking for attributes in your code.\nAttributes are only useful when something is looking for it. If you decorate your class with [MyAwsomeAttribute] and nothing is looking for it, then there will be no performance difference.\nThe performance difference will depend on how many attributes you have; if it was discovered; and the time it takes to execute the offending attribute (assuming it has this ability, many attributes are purely metadata).\nGood examples are WCF custom behaviour attributes with their detailed and potentially complex implementation methods. \n\nA: (To test out MickyD's answer)\nEven this code, with a really evil attribute still has no\nperformance impact because the attribute is never contructed.\nclass Program\n{\n static void Main(string[] args)\n {\n Console.WriteLine(new Foo().ToString());\n Console.ReadLine();\n }\n}\n\n[ThrowExceptionAttribute]\npublic class Foo\n{\n}\n\npublic class ThrowExceptionAttribute : Attribute\n{\n public ThrowExceptionAttribute()\n {\n throw new NotImplementedException();\n }\n}\n\nOf course if you do reflect over the attribute you can get performance impacts.\nBut then your question becomes, \"Can running arbitrary code have performance implications?\".\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 234,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913499\",\n \"question_score\": \"10\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693976\"\n}"}}},{"rowIdx":1709352,"cells":{"id":{"kind":"string","value":"bf424b19b2107fa14be6cfc4b06da233363efff3"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Spring new transaction combined with Retryable If I have a method that has a Spring retryable for a certain exception, and also has a Transactional(Requires_new), every time the retry is done, will it create a new transaction or use the existing one?\nie\n@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 250), include = {ActivitiOptimisticLockingException.class})\n@Transactional(propagation = Propagation.REQUIRES_NEW)\npublic void setVariable(String processId, String variableName, String variableValue){\n engine.getRuntimeService().setVariable(processId, variableName, variableValue);\n}\n\nWhat will actually happen here?\n\nA: will be created new transaction each time. \nit the same as get service from spring context and call method N times. every call creates new transaction (use propagation that you added into service or method). Call your transactioanl servics method call it's call a proxy, retry calls that proxy also. Also your transaction might have timeout,retry try call in new timeout duration ,not N try times in one timeout\n"},"original_text":{"kind":"string","value":"Q: Spring new transaction combined with Retryable If I have a method that has a Spring retryable for a certain exception, and also has a Transactional(Requires_new), every time the retry is done, will it create a new transaction or use the existing one?\nie\n@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 250), include = {ActivitiOptimisticLockingException.class})\n@Transactional(propagation = Propagation.REQUIRES_NEW)\npublic void setVariable(String processId, String variableName, String variableValue){\n engine.getRuntimeService().setVariable(processId, variableName, variableValue);\n}\n\nWhat will actually happen here?\n\nA: will be created new transaction each time. \nit the same as get service from spring context and call method N times. every call creates new transaction (use propagation that you added into service or method). Call your transactioanl servics method call it's call a proxy, retry calls that proxy also. Also your transaction might have timeout,retry try call in new timeout duration ,not N try times in one timeout\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 145,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913502\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44693983\"\n}"}}},{"rowIdx":1709353,"cells":{"id":{"kind":"string","value":"a1c90180121241302ea235df3b65f04d1b3902eb"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to change key of lookup kwargs field in RetrieveAPIView in Django REST Framework? Django REST Framework uses pk has the lookup field when using the \nRetrieveApiView and same has to be defined in the url kwargs .\nThis makes the url look like : \nurl(r'^(/foobar/(?P[\\d]+)/$', FooBarFetch.as_view(), name=\"foo_bar\")\n\nBut I want to replace the pk in the url with something more descriptive like foo_bar_id.\nChanging the look_up_field doesn't work as it still has to use the pk to perform the lookup. \nJust kwrags key has to be changed in the url.\n\nA: So I dug into the classes GenericAPIView etc and found that it uses a field lookup_url_kwarg for this purpose.\nBy default, it is None and that makes the kwarg key to be pk\nin the url.\nWe just need to override the field like :\nlookup_url_kwarg = 'foo_bar_id'\nWhere foo_bar_id is the key used in url.\n"},"original_text":{"kind":"string","value":"Q: How to change key of lookup kwargs field in RetrieveAPIView in Django REST Framework? Django REST Framework uses pk has the lookup field when using the \nRetrieveApiView and same has to be defined in the url kwargs .\nThis makes the url look like : \nurl(r'^(/foobar/(?P[\\d]+)/$', FooBarFetch.as_view(), name=\"foo_bar\")\n\nBut I want to replace the pk in the url with something more descriptive like foo_bar_id.\nChanging the look_up_field doesn't work as it still has to use the pk to perform the lookup. \nJust kwrags key has to be changed in the url.\n\nA: So I dug into the classes GenericAPIView etc and found that it uses a field lookup_url_kwarg for this purpose.\nBy default, it is None and that makes the kwarg key to be pk\nin the url.\nWe just need to override the field like :\nlookup_url_kwarg = 'foo_bar_id'\nWhere foo_bar_id is the key used in url.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 149,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913529\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694082\"\n}"}}},{"rowIdx":1709354,"cells":{"id":{"kind":"string","value":"6fb71f3cf224a82e510ffb50591a68701935d168"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: EditorConfig in Android Studio There is an option in Android studio to enable EditorConfig support( defaultsettings->codingstyle dialog),but not sure how it works.Could you please let me know how to integrate .editorconfig file in the Andriod Studio project? \n\nA: The website EditorConfig.org has a good explanation of how to get it set up. Android Studio has it built-in so there should be no need to add a plugin or set up Android Studio, just..\n\n*\n\n*Add your .editorconfig file in the root directory of the project (as mentioned at EditorConfig.org)\n\n*Enable EditorConfig support (Settings → Editor → Code Style → Enable EditorConfig support)\n\nNote:\n\nA search for .editorconfig files will stop if the root filepath is reached or an EditorConfig file with root=true is found.\n\nEdit:\nI would recommend starting with something along these lines, and tweaking it as your team sees fit:\n# indicate this is the root of the project\nroot = true\n\n[*.{kt,java,xml,gradle,md}]\ncharset = utf-8\nindent_style = space\nindent_size = 4\ntrim_trailing_whitespace = true\ninsert_final_newline = true\nend_of_line = lf\n\n"},"original_text":{"kind":"string","value":"Q: EditorConfig in Android Studio There is an option in Android studio to enable EditorConfig support( defaultsettings->codingstyle dialog),but not sure how it works.Could you please let me know how to integrate .editorconfig file in the Andriod Studio project? \n\nA: The website EditorConfig.org has a good explanation of how to get it set up. Android Studio has it built-in so there should be no need to add a plugin or set up Android Studio, just..\n\n*\n\n*Add your .editorconfig file in the root directory of the project (as mentioned at EditorConfig.org)\n\n*Enable EditorConfig support (Settings → Editor → Code Style → Enable EditorConfig support)\n\nNote:\n\nA search for .editorconfig files will stop if the root filepath is reached or an EditorConfig file with root=true is found.\n\nEdit:\nI would recommend starting with something along these lines, and tweaking it as your team sees fit:\n# indicate this is the root of the project\nroot = true\n\n[*.{kt,java,xml,gradle,md}]\ncharset = utf-8\nindent_style = space\nindent_size = 4\ntrim_trailing_whitespace = true\ninsert_final_newline = true\nend_of_line = lf\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 174,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913543\",\n \"question_score\": \"19\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694132\"\n}"}}},{"rowIdx":1709355,"cells":{"id":{"kind":"string","value":"ab95655c96b9250ab66e5827a5c822b9d44af854"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: xlwings: Delete a col | row from Excel How do I delete a row in Excel?\nwb = xw.Book('Shipment.xlsx')\nwb.sheets['Page1_1'].range('1:1').clear()\n\n.clear() works to remove the content. I want to delete the row. I'm surprise the .clear() function works, but not .delete()\nAny advice helps! Thank you\n\nA: I use xlwings 0.11.7 with Python 3.6.0 on my Windows7.\nI do this, and it can work very well :\nimport xlwings as xw\nfrom xlwings.constants import DeleteShiftDirection\n\napp = xw.App()\nwb = app.books.open('name.xlsx')\nsht = wb.sheets['Sheet1']\n\n# Delete row 2\nsht.range('2:2').api.Delete(DeleteShiftDirection.xlShiftUp) \n\n# Delete row 2, 3 and 4 \nsht.range('2:4').api.Delete(DeleteShiftDirection.xlShiftUp) \n\n# Delete Column A\nsht.range('A:A').api.Delete(DeleteShiftDirection.xlShiftToLeft)\n\n# Delete Column A, B and C\nsht.range('A:C').api.Delete(DeleteShiftDirection.xlShiftToLeft)\n\nwb.save()\napp.kill()\n\n"},"original_text":{"kind":"string","value":"Q: xlwings: Delete a col | row from Excel How do I delete a row in Excel?\nwb = xw.Book('Shipment.xlsx')\nwb.sheets['Page1_1'].range('1:1').clear()\n\n.clear() works to remove the content. I want to delete the row. I'm surprise the .clear() function works, but not .delete()\nAny advice helps! Thank you\n\nA: I use xlwings 0.11.7 with Python 3.6.0 on my Windows7.\nI do this, and it can work very well :\nimport xlwings as xw\nfrom xlwings.constants import DeleteShiftDirection\n\napp = xw.App()\nwb = app.books.open('name.xlsx')\nsht = wb.sheets['Sheet1']\n\n# Delete row 2\nsht.range('2:2').api.Delete(DeleteShiftDirection.xlShiftUp) \n\n# Delete row 2, 3 and 4 \nsht.range('2:4').api.Delete(DeleteShiftDirection.xlShiftUp) \n\n# Delete Column A\nsht.range('A:A').api.Delete(DeleteShiftDirection.xlShiftToLeft)\n\n# Delete Column A, B and C\nsht.range('A:C').api.Delete(DeleteShiftDirection.xlShiftToLeft)\n\nwb.save()\napp.kill()\n\n\nA: It is now possible to delete without using api property:\nwb.sheets['Page1_1'].range('1:1').delete()\n\n\nA: Try using the .Rows, for example:\nwb.sheets(\"Page1_1\").Rows(1).Delete\n\nAnd you would similarly use the .Columns for deleting columns:\nwb.sheets(\"Page1_1\").Columns(1).Delete\n\n\nA: for i in range(end+1, max_col):\n\n workbook.sheets[sheet_name].api.Columns(end+1).Delete()\n\nI have done this to Delete a certain range of columns, should work with rows too, you just need to keep in mind that the Columns/Rows shift so i just stay at the same column\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 186,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913553\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694156\"\n}"}}},{"rowIdx":1709356,"cells":{"id":{"kind":"string","value":"8fe01128bcac299a51dda5a04390b0ce2973ad73"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Elasticsearch Java API 5.4 - How to get the inner hits of a nested query? I recently started to migrate from Elasticsearch version 2.4 to version 5.4. In version 2.4 I implemented some nested queries including inner hits, using the official Java API, which do not work in version 5.4 anymore. \nCan anyone tell me, how to get the inner hits of a nested query using the Elasticsearch Java API 5.4? \nUnfortunately, I can't find any sources regarding this topic, not even in the Elasticsearch documentation. \nMy functioning nested query in version 2.4: \nQueryBuilders.nestedQuery(\"classes.links\",\n QueryBuilders.boolQuery()\n .must(QueryBuilders.termQuery(\"classes.links.name\", \"xyz\"))\n).innerHit(new QueryInnerHitBuilder())\n\nMy attempt to get this query to work in version 5.4:\nQueryBuilders.nestedQuery(\"classes.links\",\n QueryBuilders.boolQuery()\n .must(QueryBuilders.termQuery(\"classes.links.name\", \"xyz\")), \n ScoreMode.Avg\n).innerHit(new InnerHitBuilder()) //Error here\n\nAs suggested here Elastic Search - java api for inner hit, I tried to replace QueryInnerHitBuilder() with InnerHitBuilder(), but it still does not work. I am getting following error: \n\"Cannot resolve method 'innerHit(org.elasticsearch.index.query.InnerHitBuilder)'\"\n\nA: The below implementation worked for me .\ninnerHit(new InnerHitBuilder())\n"},"original_text":{"kind":"string","value":"Q: Elasticsearch Java API 5.4 - How to get the inner hits of a nested query? I recently started to migrate from Elasticsearch version 2.4 to version 5.4. In version 2.4 I implemented some nested queries including inner hits, using the official Java API, which do not work in version 5.4 anymore. \nCan anyone tell me, how to get the inner hits of a nested query using the Elasticsearch Java API 5.4? \nUnfortunately, I can't find any sources regarding this topic, not even in the Elasticsearch documentation. \nMy functioning nested query in version 2.4: \nQueryBuilders.nestedQuery(\"classes.links\",\n QueryBuilders.boolQuery()\n .must(QueryBuilders.termQuery(\"classes.links.name\", \"xyz\"))\n).innerHit(new QueryInnerHitBuilder())\n\nMy attempt to get this query to work in version 5.4:\nQueryBuilders.nestedQuery(\"classes.links\",\n QueryBuilders.boolQuery()\n .must(QueryBuilders.termQuery(\"classes.links.name\", \"xyz\")), \n ScoreMode.Avg\n).innerHit(new InnerHitBuilder()) //Error here\n\nAs suggested here Elastic Search - java api for inner hit, I tried to replace QueryInnerHitBuilder() with InnerHitBuilder(), but it still does not work. I am getting following error: \n\"Cannot resolve method 'innerHit(org.elasticsearch.index.query.InnerHitBuilder)'\"\n\nA: The below implementation worked for me .\ninnerHit(new InnerHitBuilder())\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 163,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913561\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694174\"\n}"}}},{"rowIdx":1709357,"cells":{"id":{"kind":"string","value":"71df6d21889d06de29e5966b42e8d62eb1977bf7"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to check for correlation among continuous and categorical variables? I have a dataset including categorical variables(binary) and continuous variables. I'm trying to apply a linear regression model for predicting a continuous variable. Can someone please let me know how to check for correlation among the categorical variables and the continuous target variable.\nCurrent Code:\nimport pandas as pd\ndf_hosp = pd.read_csv('C:\\Users\\LAPPY-2\\Desktop\\LengthOfStay.csv')\n\ndata = df_hosp[['lengthofstay', 'male', 'female', 'dialysisrenalendstage', 'asthma', \\\n 'irondef', 'pneum', 'substancedependence', \\\n 'psychologicaldisordermajor', 'depress', 'psychother', \\\n 'fibrosisandother', 'malnutrition', 'hemo']]\nprint data.corr()\n\nAll of the variables apart from lengthofstay are categorical. Should this work?\n\nA: correlation in this scenario is quite misleading as we are comparing categorical variable with continuous variable\n"},"original_text":{"kind":"string","value":"Q: How to check for correlation among continuous and categorical variables? I have a dataset including categorical variables(binary) and continuous variables. I'm trying to apply a linear regression model for predicting a continuous variable. Can someone please let me know how to check for correlation among the categorical variables and the continuous target variable.\nCurrent Code:\nimport pandas as pd\ndf_hosp = pd.read_csv('C:\\Users\\LAPPY-2\\Desktop\\LengthOfStay.csv')\n\ndata = df_hosp[['lengthofstay', 'male', 'female', 'dialysisrenalendstage', 'asthma', \\\n 'irondef', 'pneum', 'substancedependence', \\\n 'psychologicaldisordermajor', 'depress', 'psychother', \\\n 'fibrosisandother', 'malnutrition', 'hemo']]\nprint data.corr()\n\nAll of the variables apart from lengthofstay are categorical. Should this work?\n\nA: correlation in this scenario is quite misleading as we are comparing categorical variable with continuous variable\n\nA: Convert your categorical variable into dummy variables here and put your variable in numpy.array. For example:\ndata.csv:\nage,size,color_head\n4,50,black\n9,100,blonde\n12,120,brown\n17,160,black\n18,180,brown\n\nExtract data:\nimport numpy as np\nimport pandas as pd\n\ndf = pd.read_csv('data.csv')\n\ndf:\n\nConvert categorical variable color_head into dummy variables:\ndf_dummies = pd.get_dummies(df['color_head'])\ndel df_dummies[df_dummies.columns[-1]]\ndf_new = pd.concat([df, df_dummies], axis=1)\ndel df_new['color_head']\n\ndf_new:\n\nPut that in numpy array:\nx = df_new.values\n\nCompute the correlation:\ncorrelation_matrix = np.corrcoef(x.T)\nprint(correlation_matrix)\n\nOutput:\narray([[ 1. , 0.99574691, -0.23658011, -0.28975028],\n [ 0.99574691, 1. , -0.30318496, -0.24026862],\n [-0.23658011, -0.30318496, 1. , -0.40824829],\n [-0.28975028, -0.24026862, -0.40824829, 1. ]])\n\nSee :\nnumpy.corrcoef\n\nA: There is one more method to compute the correlation between continuous variable and dichotomic (having only 2 classes) variable, since this is also a categorical variable, we can use it for the correlation computation.\nThe link for point biserial correlation is given below.\nhttps://www.statology.org/point-biserial-correlation-python/\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 257,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913578\",\n \"question_score\": \"18\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694228\"\n}"}}},{"rowIdx":1709358,"cells":{"id":{"kind":"string","value":"530110dceea1430285a1af457587fe7a73f5a74b"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to scale from left to right only This is my css code\n body\n {\n transform: scaleX(0.67);\n }\n\nIn this my entire website shrink both from right and left.but i need only scale from left how can i do this\n\nA: You add transform-origin which define from which position the transform should occur.\nIts default value is center center (50% 50%) and you need left center (0 50%)\nbody\n{\n transform: scaleX(0.67);\n transform-origin: left center;\n}\n\n"},"original_text":{"kind":"string","value":"Q: How to scale from left to right only This is my css code\n body\n {\n transform: scaleX(0.67);\n }\n\nIn this my entire website shrink both from right and left.but i need only scale from left how can i do this\n\nA: You add transform-origin which define from which position the transform should occur.\nIts default value is center center (50% 50%) and you need left center (0 50%)\nbody\n{\n transform: scaleX(0.67);\n transform-origin: left center;\n}\n\n\nA: I believe the transform-origin can be helpful here:\nbody {\n transform:scale(0.67);\n transform-origin:left center;\n}\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 92,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913579\",\n \"question_score\": \"10\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694230\"\n}"}}},{"rowIdx":1709359,"cells":{"id":{"kind":"string","value":"b49745aa1453d59e1964b82b2cedb07302825c5d"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Detect when the device emulation mode is turned on or off in Chrome Chrome DevTools has the option to use the device emulation mode. \nI know there's a way to test whether the mode is on or not. But I'd like to know when it's being activated or deactivated, on click.\nAre there any events I could listen to, fired by the browser, that indicate the mode was turned on or off?\n\nA: I ended up doing this:\n$(window).on('orientationchange', function(e) {\n\n if (e.tagret && e.target.devicePixelRatio > 1) {\n // Emulation mode activated\n } else {\n // Emulation mode deactivated\n }\n\n});\n\nWorks for Google Chrome (my version: 58.0). Is it the bulletproof way? Not sure. It's enough for my needs, though.\norientationchange docs here.\n"},"original_text":{"kind":"string","value":"Q: Detect when the device emulation mode is turned on or off in Chrome Chrome DevTools has the option to use the device emulation mode. \nI know there's a way to test whether the mode is on or not. But I'd like to know when it's being activated or deactivated, on click.\nAre there any events I could listen to, fired by the browser, that indicate the mode was turned on or off?\n\nA: I ended up doing this:\n$(window).on('orientationchange', function(e) {\n\n if (e.tagret && e.target.devicePixelRatio > 1) {\n // Emulation mode activated\n } else {\n // Emulation mode deactivated\n }\n\n});\n\nWorks for Google Chrome (my version: 58.0). Is it the bulletproof way? Not sure. It's enough for my needs, though.\norientationchange docs here.\n\nA: My solution:\n$(window).on('orientationchange', function(e) {\n setTimeout(function() {\n var emulationModeActivated = window.navigator.userAgent.indexOf('Mobile') !== -1;\n }, 0);\n});\n\nChrome adds Mobile to userAgent in device emulation mode, for example \"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1\"\ne.target.devicePixelRatio isn't usable on Mac with Retina Display as value is always > 1\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 184,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913581\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694234\"\n}"}}},{"rowIdx":1709360,"cells":{"id":{"kind":"string","value":"39993a7feda3c696433d8040ab00775bc0c212aa"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to get a WCF ClientBase in a faulted state? As I remember correctly, in .NET Framework 3.x, a WCF service client (ClientBase) would get a faulted state when the service returned an exception (FaultException). This could result in problems when the service client was not disposed / closed correctly. (See the many posts about this subject, like: What is the best workaround for the WCF client `using` block issue?).\nThis behavior has been changed! Somehow, when the service throws an exception, the service client rethrows that exception, but the client does not enter a faulted state anymore.\nTwo questions:\n\n\n*\n\n*Under which conditions does the service client enter a faulted state?\n\n*Since when (what framework version or patch) has this behavior been altered? \n\n"},"original_text":{"kind":"string","value":"Q: How to get a WCF ClientBase in a faulted state? As I remember correctly, in .NET Framework 3.x, a WCF service client (ClientBase) would get a faulted state when the service returned an exception (FaultException). This could result in problems when the service client was not disposed / closed correctly. (See the many posts about this subject, like: What is the best workaround for the WCF client `using` block issue?).\nThis behavior has been changed! Somehow, when the service throws an exception, the service client rethrows that exception, but the client does not enter a faulted state anymore.\nTwo questions:\n\n\n*\n\n*Under which conditions does the service client enter a faulted state?\n\n*Since when (what framework version or patch) has this behavior been altered? \n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 125,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913595\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694294\"\n}"}}},{"rowIdx":1709361,"cells":{"id":{"kind":"string","value":"48acf0bf4cab711c97f70a5813003cf7561cf416"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to accept JSON POST parameters as @RequestParam in Spring Servlet? I'm trying to create a POST servlet that should be called with JSON request. The following should work, but does not. What might be missing?\n@RestController\npublic class MyServlet {\n @PostMapping(\"/\")\n public String test(@RequestParam String name, @RequestParam String[] params) {\n return \"name was: \" + name;\n }\n}\n\nJSON POST:\n{\n \"name\": \"test\",\n \"params\": [\n \"first\", \"snd\"\n ]\n}\n\nResult: name is always null. Why?\n\"Response could not be created: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'name' is not present\"\n\nA: In general I don't pass a request param in a POST method. Instead, I am using a DTO to pass it in the body like:\n@RequestMapping(value = \"/items\", method = RequestMethod.POST)\n public void addItem(@RequestBody ItemDTO itemDTO) \n\nThen, you need to create the ItemDTO as a POJO with the necessary fields.\n"},"original_text":{"kind":"string","value":"Q: How to accept JSON POST parameters as @RequestParam in Spring Servlet? I'm trying to create a POST servlet that should be called with JSON request. The following should work, but does not. What might be missing?\n@RestController\npublic class MyServlet {\n @PostMapping(\"/\")\n public String test(@RequestParam String name, @RequestParam String[] params) {\n return \"name was: \" + name;\n }\n}\n\nJSON POST:\n{\n \"name\": \"test\",\n \"params\": [\n \"first\", \"snd\"\n ]\n}\n\nResult: name is always null. Why?\n\"Response could not be created: org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'name' is not present\"\n\nA: In general I don't pass a request param in a POST method. Instead, I am using a DTO to pass it in the body like:\n@RequestMapping(value = \"/items\", method = RequestMethod.POST)\n public void addItem(@RequestBody ItemDTO itemDTO) \n\nThen, you need to create the ItemDTO as a POJO with the necessary fields.\n\nA: In addition to @stzoannos answer, if you do not want to create POJO for json object, you can use google GSON library to parse json into JsonObject class, which allow to work with parameters through same as get and set methods.\nJsonObject jsonObj = new JsonParser().parse(json).getAsJsonObject();\nreturn \"name is: \" + jsonObj.get(\"name\").getAsString();\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 194,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913599\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694305\"\n}"}}},{"rowIdx":1709362,"cells":{"id":{"kind":"string","value":"1c599f83b5bf7df382bc014db726a29d4c1293a7"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: What is the \"M- notation\" and where is it documented? The man page of cat says:\n-v, --show-nonprinting\n use ^ and M- notation, except for LFD and TAB \n\nWhat is the M- notation and where is it documented?\nExample:\n$cat log -A\nwrote 262144 bytes from file test.x in 9.853947s (25.979 KiB/s)^M$\n^M> ^H^H ^H^H>\n\nWhat do ^M and ^H mean?\n\nA: ^M is for Control-M (a carriage return), ^H for Control-H (a backspace). M-Something is Meta-Something (Meta- is what the Alt key does in some terminals).\n"},"original_text":{"kind":"string","value":"Q: What is the \"M- notation\" and where is it documented? The man page of cat says:\n-v, --show-nonprinting\n use ^ and M- notation, except for LFD and TAB \n\nWhat is the M- notation and where is it documented?\nExample:\n$cat log -A\nwrote 262144 bytes from file test.x in 9.853947s (25.979 KiB/s)^M$\n^M> ^H^H ^H^H>\n\nWhat do ^M and ^H mean?\n\nA: ^M is for Control-M (a carriage return), ^H for Control-H (a backspace). M-Something is Meta-Something (Meta- is what the Alt key does in some terminals).\n\nA: I was wondering this too. I checked the source but it seemed easier to create a input file to get the mapping. \nI created a test input file with a Perl scrip for( my $i=0 ; $i < 256; $i++ ) { print ( sprintf( \"%c is %d %x\\n\", $i, $i ,$i ) ); } and then ran it through cat -v\nAlso if you see M-oM-;M-? at the start of a file it is the UTF-8 byte order mark.\nScroll down through these to get to the M- values:\n^@ is 0 0\n^A is 1 1\n^B is 2 2\n^C is 3 3\n^D is 4 4\n^E is 5 5\n^F is 6 6\n^G is 7 7\n^H is 8 8\n(9 is tab)\n(10 is NL)\n^K is 11 b\n^L is 12 c\n^M is 13 d\n^N is 14 e\n^O is 15 f\n^P is 16 10\n^Q is 17 11\n^R is 18 12\n^S is 19 13\n^T is 20 14\n^U is 21 15\n^V is 22 16\n^W is 23 17\n^X is 24 18\n^Y is 25 19\n^Z is 26 1a\n^[ is 27 1b\n^\\ is 28 1c\n^] is 29 1d\n^^ is 30 1e\n^_ is 31 1f\n...printing chars removed...\n^? is 127 7f\nM-^@ is 128 80\nM-^A is 129 81\nM-^B is 130 82\nM-^C is 131 83\nM-^D is 132 84\nM-^E is 133 85\nM-^F is 134 86\nM-^G is 135 87\nM-^H is 136 88\nM-^I is 137 89\nM-^J is 138 8a\nM-^K is 139 8b\nM-^L is 140 8c\nM-^M is 141 8d\nM-^N is 142 8e\nM-^O is 143 8f\nM-^P is 144 90\nM-^Q is 145 91\nM-^R is 146 92\nM-^S is 147 93\nM-^T is 148 94\nM-^U is 149 95\nM-^V is 150 96\nM-^W is 151 97\nM-^X is 152 98\nM-^Y is 153 99\nM-^Z is 154 9a\nM-^[ is 155 9b\nM-^\\ is 156 9c\nM-^] is 157 9d\nM-^^ is 158 9e\nM-^_ is 159 9f\nM- is 160 a0\nM-! is 161 a1\nM-\" is 162 a2\nM-# is 163 a3\nM-$ is 164 a4\nM-% is 165 a5\nM-& is 166 a6\nM-' is 167 a7\nM-( is 168 a8\nM-) is 169 a9\nM-* is 170 aa\nM-+ is 171 ab\nM-, is 172 ac\nM-- is 173 ad\nM-. is 174 ae\nM-/ is 175 af\nM-0 is 176 b0\nM-1 is 177 b1\nM-2 is 178 b2\nM-3 is 179 b3\nM-4 is 180 b4\nM-5 is 181 b5\nM-6 is 182 b6\nM-7 is 183 b7\nM-8 is 184 b8\nM-9 is 185 b9\nM-: is 186 ba\nM-; is 187 bb\nM-< is 188 bc\nM-= is 189 bd\nM-> is 190 be\nM-? is 191 bf\nM-@ is 192 c0\nM-A is 193 c1\nM-B is 194 c2\nM-C is 195 c3\nM-D is 196 c4\nM-E is 197 c5\nM-F is 198 c6\nM-G is 199 c7\nM-H is 200 c8\nM-I is 201 c9\nM-J is 202 ca\nM-K is 203 cb\nM-L is 204 cc\nM-M is 205 cd\nM-N is 206 ce\nM-O is 207 cf\nM-P is 208 d0\nM-Q is 209 d1\nM-R is 210 d2\nM-S is 211 d3\nM-T is 212 d4\nM-U is 213 d5\nM-V is 214 d6\nM-W is 215 d7\nM-X is 216 d8\nM-Y is 217 d9\nM-Z is 218 da\nM-[ is 219 db\nM-\\ is 220 dc\nM-] is 221 dd\nM-^ is 222 de\nM-_ is 223 df\nM-` is 224 e0\nM-a is 225 e1\nM-b is 226 e2\nM-c is 227 e3\nM-d is 228 e4\nM-e is 229 e5\nM-f is 230 e6\nM-g is 231 e7\nM-h is 232 e8\nM-i is 233 e9\nM-j is 234 ea\nM-k is 235 eb\nM-l is 236 ec\nM-m is 237 ed\nM-n is 238 ee\nM-o is 239 ef\nM-p is 240 f0\nM-q is 241 f1\nM-r is 242 f2\nM-s is 243 f3\nM-t is 244 f4\nM-u is 245 f5\nM-v is 246 f6\nM-w is 247 f7\nM-x is 248 f8\nM-y is 249 f9\nM-z is 250 fa\nM-{ is 251 fb\nM-| is 252 fc\nM-} is 253 fd\nM-~ is 254 fe\nM-^? is 255 ff \n\n\nA: I am not sure about the M- notation, but the ones involving ^ uses the caret notation:\n\nCaret notation is a notation for control characters in ASCII.\n\nIn particular, \n\nThe digraph stands for the control character whose ASCII code is the\n same as the character's ASCII code with the uppermost bit, in a 7-bit\n encoding, reversed.\n\nwhich you can verify by looking at the ASCII binary (octal) representation:\n\nImage source: http://www.asciitable.com\nBecause ASCII is such a limited character set (as you can see above), it's straightforward to list all control chars representable by the caret notation, e.g., http://xahlee.info/comp/unicode_character_representation.html.\n\nA: You can see the definition in the key_name(3) manpage\n\nLikewise, the meta(3X) function allows the caller to change the output of keyname, i.e., it determines whether to use the “M-” prefix for “meta” keys (codes in the range 128 to 255). Both use_legacy_coding(3X) and meta(3X) succeed only after curses is initialized. X/Open Curses does not document the treatment of codes 128 to 159. When treating them as “meta” keys (or if keyname is called before initializing curses), this implementation returns strings “M-^@”, “M-^A”, etc.\nkey_name(3X)\n\nSo basically the Meta analog of the Ctrl version is the keycode of Ctrl + 128. You can see that easily in Brian's table. Here's a slightly modified version for ease of comparison\n$ LC_ALL=C perl -e 'for( my $i=0 ; $i < 128; $i++ ) {\n print ( sprintf( \"%c is %d %x\\t\\t%c is %d %x\\n\",\n $i, $i, $i, $i + 128, $i + 128, $i + 128 ) );\n}' >bytes.txt\n\n$ cat -v bytes.txt\n^@ is 0 0 M-^@ is 128 80\n^A is 1 1 M-^A is 129 81\n^B is 2 2 M-^B is 130 82\n^C is 3 3 M-^C is 131 83\n...\n^Y is 25 19 M-^Y is 153 99\n^Z is 26 1a M-^Z is 154 9a\n^[ is 27 1b M-^[ is 155 9b\n^\\ is 28 1c M-^\\ is 156 9c\n^] is 29 1d M-^] is 157 9d\n^^ is 30 1e M-^^ is 158 9e\n^_ is 31 1f M-^_ is 159 9f\n is 32 20 M- is 160 a0\n! is 33 21 M-! is 161 a1\n\" is 34 22 M-\" is 162 a2\n# is 35 23 M-# is 163 a3\n$ is 36 24 M-$ is 164 a4\n% is 37 25 M-% is 165 a5\n& is 38 26 M-& is 166 a6\n' is 39 27 M-' is 167 a7\n( is 40 28 M-( is 168 a8\n) is 41 29 M-) is 169 a9\n* is 42 2a M-* is 170 aa\n+ is 43 2b M-+ is 171 ab\n, is 44 2c M-, is 172 ac\n- is 45 2d M-- is 173 ad\n. is 46 2e M-. is 174 ae\n/ is 47 2f M-/ is 175 af\n0 is 48 30 M-0 is 176 b0\n1 is 49 31 M-1 is 177 b1\n...\n: is 58 3a M-: is 186 ba\n; is 59 3b M-; is 187 bb\n< is 60 3c M-< is 188 bc\n= is 61 3d M-= is 189 bd\n> is 62 3e M-> is 190 be\n? is 63 3f M-? is 191 bf\n@ is 64 40 M-@ is 192 c0\nA is 65 41 M-A is 193 c1\nB is 66 42 M-B is 194 c2\n...\nZ is 90 5a M-Z is 218 da\n[ is 91 5b M-[ is 219 db\n\\ is 92 5c M-\\ is 220 dc\n] is 93 5d M-] is 221 dd\n^ is 94 5e M-^ is 222 de\n_ is 95 5f M-_ is 223 df\n` is 96 60 M-` is 224 e0\na is 97 61 M-a is 225 e1\nb is 98 62 M-b is 226 e2\n...\nz is 122 7a M-z is 250 fa\n{ is 123 7b M-{ is 251 fb\n| is 124 7c M-| is 252 fc\n} is 125 7d M-} is 253 fd\n~ is 126 7e M-~ is 254 fe\n^? is 127 7f M-^? is 255 ff\n\nThe part after M- on the right is exactly the same as on the left, with the keycodes differ by 128\n\nYou can also check cat's source code, the basic expression is *bpout++ = ch - 128; for the Meta key version in the show_nonprinting case\n\nA: Answer from the book.\nUnix power tools.\n25.7 Show Non-Printing Characters with cat -v or od -c.\n\"cat -v has its own symbol for characters outside the ASCII range with their high bits set, also called metacharacters. cat -v prints those as M- followed by another character. There are two of them in the cat -v output: M-^? and M-a . To get a metacharacter, you add 200 octal. \"Say what?\" Let's look at M-a first. The octal value of the letter a is 141. When cat -v prints M-a , it means the character you get by adding 141+200, or 341 octal. You can decode the character cat prints as M-^? in the same way. The ^? stands for the DEL character, which is octal 177. Add 200+177 to get 377 octal. \"\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 1694,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913608\",\n \"question_score\": \"16\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694331\"\n}"}}},{"rowIdx":1709363,"cells":{"id":{"kind":"string","value":"ff6958944786c32346e12f735a392d5b2e110a31"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: API for Spark Streaming Statistics I'm looking for API which allows for accessing Spark Streaming Statistics which are available in \"Streaming\" tab in history server.\nI'm mainly interested in batch processing time value but it's not directly available via REST API at least according to documentation:\nhttps://spark.apache.org/docs/latest/monitoring.html#rest-api\n\nAny ideas how to get various information like in \"Streaming\" tab or running job in history server?\n\nA: There's a metrics endpoint available on the same port as the Spark UI on the driver node.\nhttp://:/metrics/json/\nStreaming-related metrics have a .StreamingMetrics in their name:\nSample from a local test job:\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_processingDelay: {\nvalue: 30\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_processingEndTime: {\nvalue: 1498124090031\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_processingStartTime: {\nvalue: 1498124090001\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_schedulingDelay: {\nvalue: 1\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_submissionTime: {\nvalue: 1498124090000\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_totalDelay: {\nvalue: 31\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastReceivedBatch_processingEndTime: {\nvalue: 1498124090031\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastReceivedBatch_processingStartTime: {\nvalue: 1498124090001\n} \n\nTo get the processing time we need to diff local-StreamingMetrics.streaming.lastCompletedBatch_processingEndTime - \nStreamingMetrics.streaming.lastCompletedBatch_processingStartTime\n"},"original_text":{"kind":"string","value":"Q: API for Spark Streaming Statistics I'm looking for API which allows for accessing Spark Streaming Statistics which are available in \"Streaming\" tab in history server.\nI'm mainly interested in batch processing time value but it's not directly available via REST API at least according to documentation:\nhttps://spark.apache.org/docs/latest/monitoring.html#rest-api\n\nAny ideas how to get various information like in \"Streaming\" tab or running job in history server?\n\nA: There's a metrics endpoint available on the same port as the Spark UI on the driver node.\nhttp://:/metrics/json/\nStreaming-related metrics have a .StreamingMetrics in their name:\nSample from a local test job:\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_processingDelay: {\nvalue: 30\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_processingEndTime: {\nvalue: 1498124090031\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_processingStartTime: {\nvalue: 1498124090001\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_schedulingDelay: {\nvalue: 1\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_submissionTime: {\nvalue: 1498124090000\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastCompletedBatch_totalDelay: {\nvalue: 31\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastReceivedBatch_processingEndTime: {\nvalue: 1498124090031\n},\nlocal-1498040220092.driver.printWriter.snb.StreamingMetrics.streaming.lastReceivedBatch_processingStartTime: {\nvalue: 1498124090001\n} \n\nTo get the processing time we need to diff local-StreamingMetrics.streaming.lastCompletedBatch_processingEndTime - \nStreamingMetrics.streaming.lastCompletedBatch_processingStartTime\n\nA: As Spark 2.2.0 was released in july, one month after your post I guess your link refers to: spark 2.1.0. Apparently the REST API got extended for Spark Streaming, see spark 2.2.0.\nSo if you still got the possibility to update the Spark version, I recommend doing that. You can then receive data from all batches with the endpoint: \n/applications/[app-id]/streaming/batches\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 211,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913640\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694424\"\n}"}}},{"rowIdx":1709364,"cells":{"id":{"kind":"string","value":"c2e179bcd202a8d606075fb083cf902eb2204e96"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Extract first object from array with es6 array methods I have this code to get an array of one object:\nlet selectedShop = initialResultsState.get('products')\n .filter(product => product.shop.selected)\n\nconsole.log(selectedShop)\nresult:\n\nCan I extract the object from the array in the same operation by stringing another es6 array method to the end of filter, rather than doing let newVariable = selesctedShop[0]?\nI tried to string this to it:\n.map(x => {return { shop: x.shop, products: x.products }})\n\nbut it is still an array of one object because map always returns a new array.\n\nA: Two basic ways:\nFirst way is shift'ing:\nArray method, you can use Array.prototype.shift().\nlet selectedShop = initialResultsState.get('products')\n .filter(product => product.shop.selected)\n .shift();\n\nSecond way is an assignment:\nYou can do this, by destructuring assignment. In your case:\nlet [selectedShop] = initialResultsState.get('products')\n .filter(product => product.shop.selected);\n\nThis is available in ES6, supported in major browsers without transpiling.\n\nBut you could see another approach, in answers (Mikael Lennholm's answer) is Array.prototype.find(). This can be more performance-effective.\n"},"original_text":{"kind":"string","value":"Q: Extract first object from array with es6 array methods I have this code to get an array of one object:\nlet selectedShop = initialResultsState.get('products')\n .filter(product => product.shop.selected)\n\nconsole.log(selectedShop)\nresult:\n\nCan I extract the object from the array in the same operation by stringing another es6 array method to the end of filter, rather than doing let newVariable = selesctedShop[0]?\nI tried to string this to it:\n.map(x => {return { shop: x.shop, products: x.products }})\n\nbut it is still an array of one object because map always returns a new array.\n\nA: Two basic ways:\nFirst way is shift'ing:\nArray method, you can use Array.prototype.shift().\nlet selectedShop = initialResultsState.get('products')\n .filter(product => product.shop.selected)\n .shift();\n\nSecond way is an assignment:\nYou can do this, by destructuring assignment. In your case:\nlet [selectedShop] = initialResultsState.get('products')\n .filter(product => product.shop.selected);\n\nThis is available in ES6, supported in major browsers without transpiling.\n\nBut you could see another approach, in answers (Mikael Lennholm's answer) is Array.prototype.find(). This can be more performance-effective.\n\nA: How about using the find() method instead of filter()? find() always return a single item, not wrapped in an array, unless it doesn't find any item, in which case it returns undefined\nlet selectedShop = initialResultsState.get('products')\n .find(product => product.shop.selected)\n\nIt's also a lot more efficient since it actually stops iterating over the array as soon as it has found an item. filter() will always iterate over the entire array which is a waste if you're only interested in the first relevant item anyway.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 249,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913656\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694494\"\n}"}}},{"rowIdx":1709365,"cells":{"id":{"kind":"string","value":"da31eb5d859075aafc180fd81580a10614707382"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to check if Error is subclass of NSError I want a function which, for any given Error, will give me some description of it\nprotocol CustomError { }\n\nfunc customDescription(_ error: Error) -> String {\n switch error {\n case let customError as CustomError:\n return \"custom error\"\n case ???:\n return \"not subclass of NSError\"\n case let nsError as NSError:\n return \"subclass of NSError\"\n }\n}\n\nAbove is not the real code, and I don't want a String description, but a Dictionary, but this is not important in context of the question.\nThe problem is I don't know how to distinguish Errors which is subclass of NSError and which is not because any swift error could be bridged to NSError. Is it possible in swift?\n\nA: As you already noticed, any type conforming to Error can be bridged\nto NSError, therefore error is NSError is always true, and a cast\nerror as NSError does always succeed.\nWhat you can do is to check the dynamic type of the value with type(of:):\ntype(of: error) is NSError.Type\n\nevaluates to true if error is an instance of NSError or a subclass.\n"},"original_text":{"kind":"string","value":"Q: How to check if Error is subclass of NSError I want a function which, for any given Error, will give me some description of it\nprotocol CustomError { }\n\nfunc customDescription(_ error: Error) -> String {\n switch error {\n case let customError as CustomError:\n return \"custom error\"\n case ???:\n return \"not subclass of NSError\"\n case let nsError as NSError:\n return \"subclass of NSError\"\n }\n}\n\nAbove is not the real code, and I don't want a String description, but a Dictionary, but this is not important in context of the question.\nThe problem is I don't know how to distinguish Errors which is subclass of NSError and which is not because any swift error could be bridged to NSError. Is it possible in swift?\n\nA: As you already noticed, any type conforming to Error can be bridged\nto NSError, therefore error is NSError is always true, and a cast\nerror as NSError does always succeed.\nWhat you can do is to check the dynamic type of the value with type(of:):\ntype(of: error) is NSError.Type\n\nevaluates to true if error is an instance of NSError or a subclass.\n\nA: private protocol _NSError: Error { // private, so _NSError is equal to NSError\n}\n\nextension NSError: _NSError {\n\n}\n\npublic func customDescription(_ error: Error) -> String {\n switch error {\n case let nsError as _NSError:\n print(nsError as! NSError)\n return \"NSError\"\n default:\n return \"others\"\n }\n}\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 234,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913673\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694549\"\n}"}}},{"rowIdx":1709366,"cells":{"id":{"kind":"string","value":"cb82f430f317cf935a058fd822cbd1bf31beecca"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Docker Swarm with image versions externalized to .env file I used to externalized my image versions to my .env file. This make it easy to maintain and I don't modify my docker-compose.yml file just to upgrade a version, so I'm sure I won't delete a line by mistake or whatever.\nBut when I try to deploy my services with stack to the swarm, docker engine complains that my image is not a correct reposity/tag, with the exact following message : \n\nError response from daemon: rpc error: code = 3 desc = ContainerSpec: \"GROUP/IMAGE:\" is not a valid repository/tag\n\nTo fix this, I can fix the image version directly in the docker-compose.yml file. Is there any logic here or it that a bug? But this mixes fix part of the docker-compose and variable ones.\nCheers,\nOlivier\n\nA: The answer is quite simple: it's not a bug, nor a feature. .env is not currently supported by docker stack.\nYou must source manually the .env running export $(cat .env) before running docker stack ...\nThere is an issue discussing this needs in the Docker Github.\nhttps://github.com/docker/docker.github.io/issues/3654\nand another one discussing the problem and solution: https://github.com/moby/moby/issues/29133#issuecomment-285980447\n"},"original_text":{"kind":"string","value":"Q: Docker Swarm with image versions externalized to .env file I used to externalized my image versions to my .env file. This make it easy to maintain and I don't modify my docker-compose.yml file just to upgrade a version, so I'm sure I won't delete a line by mistake or whatever.\nBut when I try to deploy my services with stack to the swarm, docker engine complains that my image is not a correct reposity/tag, with the exact following message : \n\nError response from daemon: rpc error: code = 3 desc = ContainerSpec: \"GROUP/IMAGE:\" is not a valid repository/tag\n\nTo fix this, I can fix the image version directly in the docker-compose.yml file. Is there any logic here or it that a bug? But this mixes fix part of the docker-compose and variable ones.\nCheers,\nOlivier\n\nA: The answer is quite simple: it's not a bug, nor a feature. .env is not currently supported by docker stack.\nYou must source manually the .env running export $(cat .env) before running docker stack ...\nThere is an issue discussing this needs in the Docker Github.\nhttps://github.com/docker/docker.github.io/issues/3654\nand another one discussing the problem and solution: https://github.com/moby/moby/issues/29133#issuecomment-285980447\n\nA: you can create a deploy.sh\nexport $(cat .env) > /dev/null 2>&1; docker stack deploy ${1:-STACK_NAME}\n\n\n*\n\n*The .env parses without regular expressions or unstable tricks.\n\n*Errors on stderr produced by #comments inside the .env will be redirected to stdin (2>&1)\n\n*Undesired prints of all export and error now on stdin too, are redirected to /dev/null. This prevents console flood.\n\n*Those errors do not prevent .env being parsed correctly.\n\nWe can define STACK_NAME in our .env but we can also pass our customized stack_name\n. deploy.sh (stack_name opcional)\n\nThis workaround gave me headaches for 3 nights\n\nA: As already mentioned the .env isn't currently supported by the docker stack.\nSo the alternative way is to clearly specify the environment file using by env_file, e.g.:\nversion: '3.3'\nservices:\n foo-service:\n image: foo-image\n env_file:\n - .env\n environment:\n - SOME_ENV=qwerty\n\n\nA: The yaml parser in docker stack deploy doesn't have all the same features of that in docker-compose. However, you can use docker-compose config to output a yaml file after it's done all the variable substitutions, extending other files, and merging multiple files together. This effectively turns docker-compose into a preprocessor.\n\nA: I have encountered the same issue,\nMy issue was caused by running docker-compose in a different python virtual environment.\nI hope this could help.\nIt seems that by running on a different python virtual env, I ruined the docker-compose dependency pythondotenv\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 423,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913704\",\n \"question_score\": \"10\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694640\"\n}"}}},{"rowIdx":1709367,"cells":{"id":{"kind":"string","value":"cbe40ed5ff7ee6eefe598e3899556a35900f7bcd"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: The difference between logical shift right, arithmetic shift right, and rotate right I've been reading the classic Hacker's delight and I am having trouble understanding the difference between logical shift right,arithmetic shift right, and rotate right. Please excuse if the doubt seems too simple. \n\n\nA: The difference is pretty much explained in the right-most column.\n\n\n*\n\n*Logical shift treats the number as a bunch of bits, and shifts in zeros. This is the >> operator in C.\n\n*Arithmetic shift treats the number as a signed integer (in 2s complement), and \"retains\" the topmost bit, shifting in zeros if the topmost bit was 0, and ones if it was one. C's right-shift operator has implementation-defined behavior if the number being shifted is negative.For example, the binary number 11100101 (-27 in decimal, assuming 2s complement), when right-shifted 3 bits using logical shift, becomes 00011100 (decimal 28). This is clearly confusing. Using an arithmetic shift, the sign bit would be kept, and the result would become 11111100 (decimal -4, which is about right for -27 / 8).\n\n*Rotation does neither, since topmost bits are replaced by lowermost bits. C does not have an operator to do rotation.\n"},"original_text":{"kind":"string","value":"Q: The difference between logical shift right, arithmetic shift right, and rotate right I've been reading the classic Hacker's delight and I am having trouble understanding the difference between logical shift right,arithmetic shift right, and rotate right. Please excuse if the doubt seems too simple. \n\n\nA: The difference is pretty much explained in the right-most column.\n\n\n*\n\n*Logical shift treats the number as a bunch of bits, and shifts in zeros. This is the >> operator in C.\n\n*Arithmetic shift treats the number as a signed integer (in 2s complement), and \"retains\" the topmost bit, shifting in zeros if the topmost bit was 0, and ones if it was one. C's right-shift operator has implementation-defined behavior if the number being shifted is negative.For example, the binary number 11100101 (-27 in decimal, assuming 2s complement), when right-shifted 3 bits using logical shift, becomes 00011100 (decimal 28). This is clearly confusing. Using an arithmetic shift, the sign bit would be kept, and the result would become 11111100 (decimal -4, which is about right for -27 / 8).\n\n*Rotation does neither, since topmost bits are replaced by lowermost bits. C does not have an operator to do rotation.\n\nA: First remember that machine words are of fixed size. Say 4, and that your input is:\n+---+---+---+---+\n| a | b | c | d |\n+---+---+---+---+\n\nThen pushing everything one position to the left gives:\n+---+---+---+---+\n| b | c | d | X |\n+---+---+---+---+\n\nQuestion what to put as X?\n\n\n*\n\n*with a shift put 0\n\n*with rotate put a\nNow push everything one position to the right gives:\n+---+---+---+---+\n| X | a | b | c |\n+---+---+---+---+\n\nQuestion what to put as X?\n\n\n*\n\n*with a logical shift put 0\n\n*with an arithmetic shift put a\n\n*with rotate put d\nRoughly.\nLogical shift correspond to (left-shift) multiplication by 2, (right-shift) integer division by 2.\nArithmetic shift is something related to 2's-complement representation of signed numbers. In this representation, the sign is the leftmost bit, then arithmetic shift preserves the sign (this is called sign extension).\nRotate has no ordinary mathematical meaning, and is almost an obsolete operation even in computers.\n\nA: Logical right shift means shifting the bits to the right and MSB(most significant bit) becomes 0.\nExample: Logical right shift of number 1 0 1 1 0 1 0 1 is 0 1 0 1 1 0 1 0.\nArithmetic right shift means shifting the bits to the right and MSB(most significant bit) is same as in the original number.\nExample: Arithmetic right shift of number 1 0 1 1 0 1 0 1 is 1 1 0 1 1 0 1 0.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 446,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913807\",\n \"question_score\": \"53\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694957\"\n}"}}},{"rowIdx":1709368,"cells":{"id":{"kind":"string","value":"d539f5f82f3db957d2f569e8131513e3066ade28"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to compare 'CBCharacteristic.uuid == \"String\"' in swift? How to compare this? uuid and string cant compare\n func charValues()\n {\n let charValue = String(data: getCharacteristic.value!, encoding: \n String.Encoding.ascii)!\n if getCharacteristic.uuid == \"Manufacturer Name String\"\n {\n self.lblManufactureName.text = charValue\n }\n } \n\n\nA: There’s a uuidString property on CBUUID.\n"},"original_text":{"kind":"string","value":"Q: How to compare 'CBCharacteristic.uuid == \"String\"' in swift? How to compare this? uuid and string cant compare\n func charValues()\n {\n let charValue = String(data: getCharacteristic.value!, encoding: \n String.Encoding.ascii)!\n if getCharacteristic.uuid == \"Manufacturer Name String\"\n {\n self.lblManufactureName.text = charValue\n }\n } \n\n\nA: There’s a uuidString property on CBUUID.\n\nA: You need to compare UUID against UUID.\nHer you compare UUID against name.\nCBPeripheral: 0x1c41066f0, identifier = 1CE90EC4-F208-ED69-A4A8-8CF804DDA0D3, name = fxc0c945fc40, state = disconnected\nas you can see there is a difference.\ntry comparing name to name or UUIDS\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 87,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913814\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694992\"\n}"}}},{"rowIdx":1709369,"cells":{"id":{"kind":"string","value":"c066ca7a15d9c8d23489b8f8be7cdeb36de24612"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Storing IV when using AES asymmetric encryption and decryption I'm looking at an C# AES asymmetric encryption and decryption example here and not sure if i should store the IV in a safe place (also encrypted??). Or i can just attach it to the encrypted text for using later when i with to decrypt. From a short reading about AES it seems it's not needed at all for decryption but i'm not sure i got it right and also the aes.CreateDecryptor(keyBytes, iv) need it as parameter.\nI use a single key for all encryptions.\n\nA: It's fairly standard to transmit the encrypted data as IV.Concat(cipherText). It's also fairly standard to put the IV off to the side, like in PKCS#5.\nThe IV-on-the-side approach matches more closely with how .NET wants to process the data, since it's somewhat annoying to slice off the IV to pass it separately to the IV parameter (or property), and then to have a more complicated slicing operation with the ciphertext (or recovered plaintext).\nBut the IV is usually transmitted in the clear either way.\nSo, glue it together, or make it a separate column... whatever fits your program and structure better.\n"},"original_text":{"kind":"string","value":"Q: Storing IV when using AES asymmetric encryption and decryption I'm looking at an C# AES asymmetric encryption and decryption example here and not sure if i should store the IV in a safe place (also encrypted??). Or i can just attach it to the encrypted text for using later when i with to decrypt. From a short reading about AES it seems it's not needed at all for decryption but i'm not sure i got it right and also the aes.CreateDecryptor(keyBytes, iv) need it as parameter.\nI use a single key for all encryptions.\n\nA: It's fairly standard to transmit the encrypted data as IV.Concat(cipherText). It's also fairly standard to put the IV off to the side, like in PKCS#5.\nThe IV-on-the-side approach matches more closely with how .NET wants to process the data, since it's somewhat annoying to slice off the IV to pass it separately to the IV parameter (or property), and then to have a more complicated slicing operation with the ciphertext (or recovered plaintext).\nBut the IV is usually transmitted in the clear either way.\nSo, glue it together, or make it a separate column... whatever fits your program and structure better.\n\nA: Answer: IV is necessary for decryption as long as the content has been encrypted with it. You don't need to encrypt or hide the IV. It may be public.\n--\nThe purpose of the IV is to be combined to the key that you are using, so it's like you are encrypting every \"block of data\" with a different \"final key\" and then it guarantees that the cipher data (the encrypted one) will always be different along the encryption (and decryption) process.\nThis is a very good illustration of what happens IF YOU DON'T use IV.\n\nBasically, the encryption process is done by encrypting the input data in blocks. So during the encryption of this example, all the parts of the image that have the same color (let's say the white background) will output the same \"cipher data\" if you use always the same key, then a pattern can still be found and then you didn't hide the image as desired.\nSo combining a different extra data (the IV) to the key for each block is like you are using a different \"final key\" for each block, then you solve your problem.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 390,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913815\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694994\"\n}"}}},{"rowIdx":1709370,"cells":{"id":{"kind":"string","value":"03bb26f746b52867cb3765db86f8e11cf9702e5f"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Use Remote Config to set API Url in app - Good or Bad idea? I have been reading a lot of articles in regards to security and other parties reverse engineering your app and then flooding your APIs etc.\nFor my current (nativescript) app I am using Firebase for Auth and then have my own API URL hardcoded into the app.\nI am considering using Firebase Remote Config to retrieve my API URL and then setting it in the app. In order to not have my API URL exposed.\nI was wondering if someone has done this before? And if this approach is a good or bad idea?\nThanks. Robert\n"},"original_text":{"kind":"string","value":"Q: Use Remote Config to set API Url in app - Good or Bad idea? I have been reading a lot of articles in regards to security and other parties reverse engineering your app and then flooding your APIs etc.\nFor my current (nativescript) app I am using Firebase for Auth and then have my own API URL hardcoded into the app.\nI am considering using Firebase Remote Config to retrieve my API URL and then setting it in the app. In order to not have my API URL exposed.\nI was wondering if someone has done this before? And if this approach is a good or bad idea?\nThanks. Robert\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 111,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913816\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44694996\"\n}"}}},{"rowIdx":1709371,"cells":{"id":{"kind":"string","value":"c0b7209a92a53ec431092f874573e602129bf68b"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: where is the source control->History menu going in xcode 9? i just install the xcode 9 beta version , and i found that i can't see svn's all checkin logs in xcode 9 which are available in source control->History in xcode 8 and before , how to get these infomation in xcode 9?\n\nA: They moved it to this tab on the left nav.\n\n"},"original_text":{"kind":"string","value":"Q: where is the source control->History menu going in xcode 9? i just install the xcode 9 beta version , and i found that i can't see svn's all checkin logs in xcode 9 which are available in source control->History in xcode 8 and before , how to get these infomation in xcode 9?\n\nA: They moved it to this tab on the left nav.\n\n\nA: This works for a git repository:\nOpen Menu View/Navigators/Show Source Control Navigator (%2)\nCommit details appear in the Utilities pane if Source Control Inspector is selected.\n\nA: Xcode Version 9.2\nView -> Navigators -> Show Source Control Navigator\n\nor just\n⌘ Command + 2\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 110,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913849\",\n \"question_score\": \"21\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44695116\"\n}"}}},{"rowIdx":1709372,"cells":{"id":{"kind":"string","value":"5a71ded9499abedd698f27c8dbebc49c2066ec80"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: LEFT JOIN with DAX I am looking for a way to do a LEFT JOIN like in SQL but with DAX. So let say that I have 2 tables A and B. B is a subset of A.\nso having \nTable A:\n rowa \n rowb \n rowc \n\nand having\nTabel B:\nrowa\n\nI need TableC with:\nA.rowa; B.rowa\nA.rowb; null\nA.rowc; null\n\nHow can I achieve this with DAX?\nThank you for your time!\n\nA: For example:\nDEFINE\n VAR TABLE1=DATATABLE(\"L1\",STRING,{{1},{2}})\n VAR TABLE2=DATATABLE(\"L1\",STRING,{{1},{3}})\nEVALUATE\n NATURALLEFTOUTERJOIN(TABLE1,ADDCOLUMNS(TABLE2,\"L2\",[L1]))\n\n"},"original_text":{"kind":"string","value":"Q: LEFT JOIN with DAX I am looking for a way to do a LEFT JOIN like in SQL but with DAX. So let say that I have 2 tables A and B. B is a subset of A.\nso having \nTable A:\n rowa \n rowb \n rowc \n\nand having\nTabel B:\nrowa\n\nI need TableC with:\nA.rowa; B.rowa\nA.rowb; null\nA.rowc; null\n\nHow can I achieve this with DAX?\nThank you for your time!\n\nA: For example:\nDEFINE\n VAR TABLE1=DATATABLE(\"L1\",STRING,{{1},{2}})\n VAR TABLE2=DATATABLE(\"L1\",STRING,{{1},{3}})\nEVALUATE\n NATURALLEFTOUTERJOIN(TABLE1,ADDCOLUMNS(TABLE2,\"L2\",[L1]))\n\n\nA: try this.............\nNATURALINNERJOIN(, ) \n\n\nA: please provide more context and explain what is the problem you are trying to solve.\nIn general, DAX works with extended table which means that it works by default with tables already denormalized according to relationships you define in the data model.\nTherefore, unless of specific needs or constraints, it is best practice to define this as a relationship in the data model, and not a left join in DAX formula.\nPhysical relationships in the data model is what makes DAX execution quick and clear.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 174,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:913851\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44695125\"\n}"}}},{"rowIdx":1709373,"cells":{"id":{"kind":"string","value":"95f696258a561bb4f7b0b9fcb10eda81b5a1df76"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Remove every occurence of special characters in QString How can I remove every occurence of special characters ^ and $ in a QString?\nI tried:\nQString str = \"^TEST$^TEST$\";\nstr = str.remove(QRegularExpression(\"[^$].\"));\n\n\nA: You missed to escape the ^. To escape that, a \\ is needed, but that also needs to be escaped because of C strings. Also you want one ore more occurences to match with +. \nThis regular expression should work: [\\\\^$]+, see online.\nSo it has to be:\nQString str = \"^TEST$^TEST$\";\nstr = str.remove(QRegularExpression(\"[\\\\^$]+\"));\n\nAnother possibility as said in the comments below by Joe P is:\nQString str = \"^TEST$^TEST$\";\nstr = str.remove(QRegularExpression(\"[$^]+\"));\n\nbecause the ^ has just a special meaning at the beginning, where you have to escape it to get it literally, see online.\n"},"original_text":{"kind":"string","value":"Q: Remove every occurence of special characters in QString How can I remove every occurence of special characters ^ and $ in a QString?\nI tried:\nQString str = \"^TEST$^TEST$\";\nstr = str.remove(QRegularExpression(\"[^$].\"));\n\n\nA: You missed to escape the ^. To escape that, a \\ is needed, but that also needs to be escaped because of C strings. Also you want one ore more occurences to match with +. \nThis regular expression should work: [\\\\^$]+, see online.\nSo it has to be:\nQString str = \"^TEST$^TEST$\";\nstr = str.remove(QRegularExpression(\"[\\\\^$]+\"));\n\nAnother possibility as said in the comments below by Joe P is:\nQString str = \"^TEST$^TEST$\";\nstr = str.remove(QRegularExpression(\"[$^]+\"));\n\nbecause the ^ has just a special meaning at the beginning, where you have to escape it to get it literally, see online.\n\nA: You can also try using a regular expression where you can remove every non-alphanumeric character:\nQString str = \"$om\n\nOutput:\n\n\nor this is work also...\nimport LogoImage from \"@/assets/logo.svg?inline\"\n\n"},"original_text":{"kind":"string","value":"Q: How can I import a svg file to a Vue component? In vue single file component.I import a svg file like this:\nimport A from 'a.svg' \nAnd then how can I use A in my component?\n\nA: I would just use vue-svg\nInstall via Vue CLI 3:\nvue add svg\n\nInput:\n\n\nOutput:\n\n\nor this is work also...\nimport LogoImage from \"@/assets/logo.svg?inline\"\n\n\nA: You can also use something like this:\n\n\n\n\nThis doesn't require installing external modules and works out of the box.\n\nA: Based on the information you provided, what you can do is:\n\n\n*\n\n*Install vue-svg-loader \n\n\nnpm install --save-dev vue-svg-loader\n\n\n*Configure webpack: \n\n\n\n\nmodule: {\r\n rules: [\r\n {\r\n test: /\\.svg$/,\r\n loader: 'vue-svg-loader', // `vue-svg` for webpack 1.x\r\n },\r\n ],\r\n },\n\n\n\n\n*Import the svg and use it as a regular component: \n\n\n\n\n\r\n\r\n\n\n\nReference: https://github.com/visualfanatic/vue-svg-loader\n\nA: I've gotten the following to work in Vue 3. Doesn't require messing with webpack or installing any third party plugins.\n\n\n\n\nNote: I'm aware that you cannot modify certain pieces of the SVG when using it in img src, but if you simply want to use SVG files like you would any other image, this seems to be a quick and easy solution.\n\nA: If you have control over the svg file, you can just wrap it in a vue file like so:\na.vue:\n\n\nJust require the file like this afterwards: import A from 'a.vue'\n\nA: I like to use pug as a template engine (comes with many advantages) - if you do so, you will be able to easily include files like SVG's just by writing:\ninclude ../assets/some-icon.svg\n\nThat's it! there is nothing else to do - I think this is an very easy and convenient way to include stuff like smaller svg's - file's easily included code is still clean!\nHere you can get some more information how to include PugJS into you Vue instance https://www.npmjs.com/package/vue-cli-plugin-pug\n\nA: First you need a specific loader for the component which will contain the svg\nmy webpack.base.config.js\nmodule: {\n rules: [\n {\n test: /\\.svg$/,\n loader: 'vue-svg-loader',\n },\n {\n test: /\\.vue$/,\n\n use: [\n {\n loader: \"vue-loader\", \n options: vueLoaderConfig\n },\n {\n loader: \"vue-svg-inline-loader\",\n options: { /* ... */ }\n }\n ]\n }\n//.. your other rules\n}\n\ndocs of vues-svg-inline-loader : https://www.npmjs.com/package/vue-svg-inline-loader\ndocs of vue-svg-loader : https://www.npmjs.com/package/vue-svg-loader\nNext, you can initialise a vue file \n\n\n\n\n\n\n\n\n\nYour svg fils must dont contain style tag so copy paste the style in the vue style with scoped propoerty to keep it specific to this component\n\nyou can just load you component in specific place of your app \nand use it\n\n\n\n\n\n\n\nA: If you are using Webpack you can use the require context to load SVG files from a directory. Be aware that this will put all SVG files within your Javascript files and might bloat your code though.\nAs a simplified example I am using this svg component:\ndata() {\n return {\n svg: ''\n };\n},\n\nprops: {\n name: {\n type: String,\n required: true\n }\n}\n\ncreated() {\n this.svg = require(`resources/assets/images/svg/${this.name}.svg`);\n}\n\nThe template simply looks like this:\n\n\nNormally you can't simply load SVG files like that and expect them to be used with a v-html directive since you are not getting the raw output. You have to use the Webpack raw-loader so make sure you get the raw output:\n{\n test: /\\.svg$/,\n use: [\n {\n loader: 'raw-loader',\n query: {\n name: 'images/svg/[name].[ext]'\n }\n },\n {\n loader: 'svgo-loader',\n options: svgoConfig\n }\n ]\n}\n\nThe example above also uses the svgo-loader since you will want to heavily optimize your SVG files if you do down this route.\nHopefully this help you or anyone else out on how to solve this without diving straight into a third-party solution to fix this.\n\nA: You can always save it as a .svg file in your /static/svg/myfile.svg (using webpack) and just use it as an image file: . No require / import / loader needed.\n\nA: +1 for @Stephan-v's solution, but here's a slightly modified approach for 2021 with Webpack 5.\n\n*\n\n*Your Vue component