{ // 获取包含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 }); }); } })(); \n\n\n\nA: To change the text size without changing the button size, you would need to fix the size of the button. This can be done using height and width in CSS. That way you can change the font-size without having it affect the button size.\nTake a look at my code below. As you can see, with the height and width changed, the button is now a fixed size. This is proven by the text being larger than the button.\nCSS\nbutton {\n font-size: 30px;\n height: 60px;\n width: 60px;\n}\n\nHTML\n\n\n"},"original_text":{"kind":"string","value":"Q: how to Change font size, Without changing the size of button in CSS In the following code I want to change just inner font size not the button size.\n\n \n \n \n \n \n \n\n\n\nA: To change the text size without changing the button size, you would need to fix the size of the button. This can be done using height and width in CSS. That way you can change the font-size without having it affect the button size.\nTake a look at my code below. As you can see, with the height and width changed, the button is now a fixed size. This is proven by the text being larger than the button.\nCSS\nbutton {\n font-size: 30px;\n height: 60px;\n width: 60px;\n}\n\nHTML\n\n\n\nA: You can also use span tag which worked quite well for me.\n \n\n\nA: Change your style to this \n.sm\n{\n font-size:20px;\n height:30px;\n width: 120px;\n}\n\nhope this helps !\n\nA: Another method to achieve this would be to take advantage of the 3rd dimension.\nThis method does not require you to fix the size of your button and allows it to still adapt to the content size. It would also scale any svg or other content you put in the button to provide a nice hover pop effect.\nHTML\n\n\nCSS\nbutton div {\n -webkit-transition: -webkit-transform 0.14s ease;\n}\n\nbutton:hover div {\n -webkit-transform: perspective(100px) scale(1.05);\n}\nbutton:active div {\n -webkit-transform: perspective(100px) scale(1.08);\n}\n\nI am not sure this is what your trying to achieve but I think its a neat solution and I thought I'd share it in case anyone else want to try it.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 291,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910085\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683370\"\n}"}}},{"rowIdx":1709158,"cells":{"id":{"kind":"string","value":"6a9fb40d40e4c0030809894f11b44fdce142fa04"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: iOS App using iCloud storage is adding .icloud file extension to my documents In my iOS (swift 3.0) mobile application, the device creating a document to store in iCloud is able to load and manipulate the file again. Once iCloud transfers the file(s) to another device, they are no longer able to open and have a \".\" prepended to the original file name AND .icloud appended to the end.\nMy document structure is as follows:\nProject_Name.spp (directory file wrapper) holding a project.data file and additional directory file wrappers Page_Name.spg containing page.meta, page.plist, and screenshot.jpg\nExcept for the root directory file wrapper, all files are renamed as similar to: .project.data.icloud\nThis was not happening previously so I'm not certain what code update would have created this behavior. Any thoughts would be helpful.\n\nA: The files are in the process of being downloaded by the iCloud sync process. Did you call startDownloadingUbiquitousItem on the parent directory?\n"},"original_text":{"kind":"string","value":"Q: iOS App using iCloud storage is adding .icloud file extension to my documents In my iOS (swift 3.0) mobile application, the device creating a document to store in iCloud is able to load and manipulate the file again. Once iCloud transfers the file(s) to another device, they are no longer able to open and have a \".\" prepended to the original file name AND .icloud appended to the end.\nMy document structure is as follows:\nProject_Name.spp (directory file wrapper) holding a project.data file and additional directory file wrappers Page_Name.spg containing page.meta, page.plist, and screenshot.jpg\nExcept for the root directory file wrapper, all files are renamed as similar to: .project.data.icloud\nThis was not happening previously so I'm not certain what code update would have created this behavior. Any thoughts would be helpful.\n\nA: The files are in the process of being downloaded by the iCloud sync process. Did you call startDownloadingUbiquitousItem on the parent directory?\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 155,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910094\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683400\"\n}"}}},{"rowIdx":1709159,"cells":{"id":{"kind":"string","value":"d90d3132a140480367b3b57a602168ee6495da97"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Converting a string looking list as a list in python The HTTP response header for 'packages_list' returns the following, which is a list looking string. How do i convert this to an actual list? I have tried typecasting the string as a list which didn't work. I am not keen on doing find and replace or strip. Once I have the list I am creating a windows forms with buttons with text for each of the items in list. Any help is appreciated\nI am using IronPython 2.6 (yes, I know its old but cant move away for backward compatibility reasons) \n['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\n\n\nhttpConn = httplib.HTTPConnection(base_server_url)\nhttpConn.request(\"POST\", urlparser.path, params)\nresponse = httpConn.getresponse()\nheaders = dict(response.getheaders())\nprint headers['packages_list']\n\n\nA: The simplest approach, IMHO, would be to use literal_eval:\n>>> s = \"['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\"\n>>> s\n\"['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\"\n>>> from ast import literal_eval\n>>> literal_eval(s)\n['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\n\n"},"original_text":{"kind":"string","value":"Q: Converting a string looking list as a list in python The HTTP response header for 'packages_list' returns the following, which is a list looking string. How do i convert this to an actual list? I have tried typecasting the string as a list which didn't work. I am not keen on doing find and replace or strip. Once I have the list I am creating a windows forms with buttons with text for each of the items in list. Any help is appreciated\nI am using IronPython 2.6 (yes, I know its old but cant move away for backward compatibility reasons) \n['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\n\n\nhttpConn = httplib.HTTPConnection(base_server_url)\nhttpConn.request(\"POST\", urlparser.path, params)\nresponse = httpConn.getresponse()\nheaders = dict(response.getheaders())\nprint headers['packages_list']\n\n\nA: The simplest approach, IMHO, would be to use literal_eval:\n>>> s = \"['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\"\n>>> s\n\"['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\"\n>>> from ast import literal_eval\n>>> literal_eval(s)\n['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\n\n\nA: You can to check if the string is a valid python type\n>>> import ast\n>>> s = \"['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\"\n>>> ast.literal_eval(s)\n['Admin', 'MMX_G10_Asia', 'MMX_G10_London', 'MMX_G10_Readonly', 'MMX_Credit_Readonly', 'MMX_Govies_ReadOnly']\n\n\nA: Another option is to convert this string to JSON format and then read it in:\nimport json\ns = headers['packages_list'].replace(\"'\", '\"')\nresult = json.loads(s)\n\n\nA: Ugly but I am going with the below. Thanks again everyone for the help !\nheaders = dict(response.getheaders())\nprint headers['packages_list']\nresult = headers['packages_list'].replace(\"'\",'')\nresult = result.replace(\"[\",\"\")\nresult = result.replace(\"]\", \"\")\nprint result\npackage_list = result.split(\",\") \nprint \"the 2nd item in teh list is \", package_list[1]\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 266,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910110\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683457\"\n}"}}},{"rowIdx":1709160,"cells":{"id":{"kind":"string","value":"5e6e0076ad378ada9dfc7f0be944211bed9a3f3f"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Best way to store images for Google Cloud Machine Learning project? I am running a Machine Learning project using Google Cloud Platform with Tensorflow and Keras. I have about 30,000 PNG images in my dataset. When I run it locally, Keras has great utilities to load images but Google Cloud Services needs to use certain librairies such as tensorflow.file_io (see: Load numpy array in google-cloud-ml job) in order to read in files from a GC bucket.\nWhat is the best way to load the images from a Google Cloud Storage bucket? Right now I am saving them as bytes and reading them in from one file, but it would be great to be able to load the images directly from the GC bucket.\nThanks,\n"},"original_text":{"kind":"string","value":"Q: Best way to store images for Google Cloud Machine Learning project? I am running a Machine Learning project using Google Cloud Platform with Tensorflow and Keras. I have about 30,000 PNG images in my dataset. When I run it locally, Keras has great utilities to load images but Google Cloud Services needs to use certain librairies such as tensorflow.file_io (see: Load numpy array in google-cloud-ml job) in order to read in files from a GC bucket.\nWhat is the best way to load the images from a Google Cloud Storage bucket? Right now I am saving them as bytes and reading them in from one file, but it would be great to be able to load the images directly from the GC bucket.\nThanks,\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 125,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910123\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683492\"\n}"}}},{"rowIdx":1709161,"cells":{"id":{"kind":"string","value":"64450909fce7d32d65eceb3b2dd275164a9e8b24"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: JSON Error when create react app Trying to follow tutorial on react (Here: https://hackernoon.com/simple-react-development-in-2017-113bd563691f), but I keep getting JSON error \"Error parsing JSON. unexpected end of JSON input.\" I'm using yarn. How do i fix the JSON input? \n\nA: i faced the same issue & this solved the issue : \ntry the below command in your terminal\nnpm cache clean --force\nsolution ref \n"},"original_text":{"kind":"string","value":"Q: JSON Error when create react app Trying to follow tutorial on react (Here: https://hackernoon.com/simple-react-development-in-2017-113bd563691f), but I keep getting JSON error \"Error parsing JSON. unexpected end of JSON input.\" I'm using yarn. How do i fix the JSON input? \n\nA: i faced the same issue & this solved the issue : \ntry the below command in your terminal\nnpm cache clean --force\nsolution ref \n\nA: For me the answer given by @M.abosalem didn't work but \nyarn cache clean\n\ndid the trick\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 81,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910141\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683555\"\n}"}}},{"rowIdx":1709162,"cells":{"id":{"kind":"string","value":"bc1808e275130886ce3917b19bed4755baee178f"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: cannot log to console using scala-logging with logback.xml configuration on amazon-emr I am using scala-logging with a logback.xml configuration file to send log messages to the console, but they do not appear. My code is running on an Amazon-EMR cluster and my code is called using spark-sumbit.\nMy build.sbt file contains the dependencies:\nlibraryDependencies += \"ch.qos.logback\" % \"logback-classic\" % \"1.1.7\"\nlibraryDependencies += \"com.typesafe.scala-logging\" %% \"scala-logging\" % \"3.5.0\"\n\nMy src/main/resources/logback.xml contains:\n\n \n \n %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\n \n \n\n \n \n \n\n\nI am logging from a method in a class that resembles:\nimport com.typesafe.scalalogging.LazyLogging\nclass MyClass() extends LazyLogging {\n def myMethod() = {\n logger.debug(\"debug logging test\")\n logger.info(\"info logging test\")\n logger.warn(\"warn logging test\")\n logger.error(\"error logging test\")\n println(\"This message appears in console\")\n }\n}\n\nNone of the messages at any log level appear. Note that when I use println method, the messages appear in the console/stdout.\n"},"original_text":{"kind":"string","value":"Q: cannot log to console using scala-logging with logback.xml configuration on amazon-emr I am using scala-logging with a logback.xml configuration file to send log messages to the console, but they do not appear. My code is running on an Amazon-EMR cluster and my code is called using spark-sumbit.\nMy build.sbt file contains the dependencies:\nlibraryDependencies += \"ch.qos.logback\" % \"logback-classic\" % \"1.1.7\"\nlibraryDependencies += \"com.typesafe.scala-logging\" %% \"scala-logging\" % \"3.5.0\"\n\nMy src/main/resources/logback.xml contains:\n\n \n \n %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\n \n \n\n \n \n \n\n\nI am logging from a method in a class that resembles:\nimport com.typesafe.scalalogging.LazyLogging\nclass MyClass() extends LazyLogging {\n def myMethod() = {\n logger.debug(\"debug logging test\")\n logger.info(\"info logging test\")\n logger.warn(\"warn logging test\")\n logger.error(\"error logging test\")\n println(\"This message appears in console\")\n }\n}\n\nNone of the messages at any log level appear. Note that when I use println method, the messages appear in the console/stdout.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 153,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910171\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683645\"\n}"}}},{"rowIdx":1709163,"cells":{"id":{"kind":"string","value":"9fa797fc93fea6764bb3425b0bb1cf8c908865ae"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Equating symbolic coefficients I would like to seek y particular of ODE y'' - y' - 2y = 4x^2\nI made the following script:\nsyms x A0 A1 A2\nypa = A2*x^2+A1*x+A0; % y_p assume\ncyp = diff(ypa,2) - diff(ypa) - 2*ypa % according to ODE\nP1 = 4*x^2; P2 = cyp ; % Equating P1 and P2\nC = coeffs(P1 - P2,x);\nA0 = solve(C(1),A0) \nA1 = solve(C(2),A1) \nA2 = solve(C(3),A2) \n\nI got the correct answer for A2 = -2. But I did not get for A0 (should be -3) and A1 (should be 2). How to get them automatically?\nP.S I'm using MATLAB R2013a.\n\nA: Instead of calling solve 3 times, once on each equation of C, you should call it once on the entire system of equations so that the proper substitutions are done to give you a numeric result for each variable:\n>> [A0, A1, A2] = solve(C)\n\nA0 =\n-3\n\nA1 =\n2\n\nA2 =\n-2\n\n"},"original_text":{"kind":"string","value":"Q: Equating symbolic coefficients I would like to seek y particular of ODE y'' - y' - 2y = 4x^2\nI made the following script:\nsyms x A0 A1 A2\nypa = A2*x^2+A1*x+A0; % y_p assume\ncyp = diff(ypa,2) - diff(ypa) - 2*ypa % according to ODE\nP1 = 4*x^2; P2 = cyp ; % Equating P1 and P2\nC = coeffs(P1 - P2,x);\nA0 = solve(C(1),A0) \nA1 = solve(C(2),A1) \nA2 = solve(C(3),A2) \n\nI got the correct answer for A2 = -2. But I did not get for A0 (should be -3) and A1 (should be 2). How to get them automatically?\nP.S I'm using MATLAB R2013a.\n\nA: Instead of calling solve 3 times, once on each equation of C, you should call it once on the entire system of equations so that the proper substitutions are done to give you a numeric result for each variable:\n>> [A0, A1, A2] = solve(C)\n\nA0 =\n-3\n\nA1 =\n2\n\nA2 =\n-2\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 162,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910174\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683663\"\n}"}}},{"rowIdx":1709164,"cells":{"id":{"kind":"string","value":"4fde8f8346778b85aaf92c66e01737c206765a5a"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: reserve array memory in advance in Julia How can we reserve memory (or allocate memory without initialization) in Julia? In C++, a common pattern is to call reserve before calling push_back several times to avoid having to call on malloc more than once. Is there an equivalent in Julia?\n\nA: I think you are looking for sizehint!\nhelp?> sizehint!\nsearch: sizehint!\n\n sizehint!(s, n)\n\n Suggest that collection s reserve capacity for at least n elements. This can\n improve performance.\n\n"},"original_text":{"kind":"string","value":"Q: reserve array memory in advance in Julia How can we reserve memory (or allocate memory without initialization) in Julia? In C++, a common pattern is to call reserve before calling push_back several times to avoid having to call on malloc more than once. Is there an equivalent in Julia?\n\nA: I think you are looking for sizehint!\nhelp?> sizehint!\nsearch: sizehint!\n\n sizehint!(s, n)\n\n Suggest that collection s reserve capacity for at least n elements. This can\n improve performance.\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 79,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910183\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683685\"\n}"}}},{"rowIdx":1709165,"cells":{"id":{"kind":"string","value":"95c3d8fa1a88a7eb9f816ec537e3cb4fbad77bb9"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Setting the prompt in Beeline When connecting to beeline, my prompt is some hefty truncated version of the JDBC url:\n0: jdbc:hive2//fully.qualified.host.na\nWhich takes up an annoying amount of real estate.\nI tried set hive.cli.prompt=foo>>, and get an error that that property is not in the list of params that are allowed to be modified at runtime.\nIs there no way to set the prompt to a custom values?\n\nA: EDIT:\nFor hive, you can set hive.cli.prompt; for beeline it is hardcoded here:\nhttps://github.com/apache/hive/blob/477f541844db3ea5eaee8746033bf80cd48b7f8c/beeline/src/java/org/apache/hive/beeline/BeeLine.java#L1769-L1775\n"},"original_text":{"kind":"string","value":"Q: Setting the prompt in Beeline When connecting to beeline, my prompt is some hefty truncated version of the JDBC url:\n0: jdbc:hive2//fully.qualified.host.na\nWhich takes up an annoying amount of real estate.\nI tried set hive.cli.prompt=foo>>, and get an error that that property is not in the list of params that are allowed to be modified at runtime.\nIs there no way to set the prompt to a custom values?\n\nA: EDIT:\nFor hive, you can set hive.cli.prompt; for beeline it is hardcoded here:\nhttps://github.com/apache/hive/blob/477f541844db3ea5eaee8746033bf80cd48b7f8c/beeline/src/java/org/apache/hive/beeline/BeeLine.java#L1769-L1775\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 85,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910202\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683735\"\n}"}}},{"rowIdx":1709166,"cells":{"id":{"kind":"string","value":"f34b455c297bdb10048cdb97c170a4ec9faeb284"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Have a list of hours between two dates in python I have two times and I want to make a list of all the hours between them using the same format in Python \nfrom= '2016-12-02T11:00:00.000Z'\nto= '2017-06-06T07:00:00.000Z'\nhours=to-from\n\nso the result will be something like this \n2016-12-02T11:00:00.000Z\n2016-12-02T12:00:00.000Z\n2016-12-02T13:00:00.000Z\n..... and so on\nHow can I so this and what kind of plugin should I use?\n\nA: simpler solution using standard library's datetime package:\nfrom datetime import datetime, timedelta\n\nDATE_TIME_STRING_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'\n\nfrom_date_time = datetime.strptime('2016-12-02T11:00:00.000Z',\n DATE_TIME_STRING_FORMAT)\nto_date_time = datetime.strptime('2017-06-06T07:00:00.000Z',\n DATE_TIME_STRING_FORMAT)\n\ndate_times = [from_date_time.strftime(DATE_TIME_STRING_FORMAT)]\ndate_time = from_date_time\nwhile date_time < to_date_time:\n date_time += timedelta(hours=1)\n date_times.append(date_time.strftime(DATE_TIME_STRING_FORMAT))\n\nwill give us\n>>>date_times\n['2016-12-02T11:00:00.000000Z', \n '2016-12-02T12:00:00.000000Z',\n '2016-12-02T13:00:00.000000Z', \n '2016-12-02T14:00:00.000000Z',\n '2016-12-02T15:00:00.000000Z', \n '2016-12-02T16:00:00.000000Z',\n '2016-12-02T17:00:00.000000Z', \n '2016-12-02T18:00:00.000000Z',\n '2016-12-02T19:00:00.000000Z', \n '2016-12-02T20:00:00.000000Z',\n ...]\n\n"},"original_text":{"kind":"string","value":"Q: Have a list of hours between two dates in python I have two times and I want to make a list of all the hours between them using the same format in Python \nfrom= '2016-12-02T11:00:00.000Z'\nto= '2017-06-06T07:00:00.000Z'\nhours=to-from\n\nso the result will be something like this \n2016-12-02T11:00:00.000Z\n2016-12-02T12:00:00.000Z\n2016-12-02T13:00:00.000Z\n..... and so on\nHow can I so this and what kind of plugin should I use?\n\nA: simpler solution using standard library's datetime package:\nfrom datetime import datetime, timedelta\n\nDATE_TIME_STRING_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'\n\nfrom_date_time = datetime.strptime('2016-12-02T11:00:00.000Z',\n DATE_TIME_STRING_FORMAT)\nto_date_time = datetime.strptime('2017-06-06T07:00:00.000Z',\n DATE_TIME_STRING_FORMAT)\n\ndate_times = [from_date_time.strftime(DATE_TIME_STRING_FORMAT)]\ndate_time = from_date_time\nwhile date_time < to_date_time:\n date_time += timedelta(hours=1)\n date_times.append(date_time.strftime(DATE_TIME_STRING_FORMAT))\n\nwill give us\n>>>date_times\n['2016-12-02T11:00:00.000000Z', \n '2016-12-02T12:00:00.000000Z',\n '2016-12-02T13:00:00.000000Z', \n '2016-12-02T14:00:00.000000Z',\n '2016-12-02T15:00:00.000000Z', \n '2016-12-02T16:00:00.000000Z',\n '2016-12-02T17:00:00.000000Z', \n '2016-12-02T18:00:00.000000Z',\n '2016-12-02T19:00:00.000000Z', \n '2016-12-02T20:00:00.000000Z',\n ...]\n\n\nA: If possible I would recommend using pandas.\nimport pandas\ntime_range = pandas.date_range('2016-12-02T11:00:00.000Z', '2017-06-06T07:00:00.000Z', freq='H')\n\nIf you need strings then use the following:\ntimestamps = [str(x) + 'Z' for x in time_range]\n# Output\n# ['2016-12-02 11:00:00+00:00Z',\n# '2016-12-02 12:00:00+00:00Z',\n# '2016-12-02 13:00:00+00:00Z',\n# '2016-12-02 14:00:00+00:00Z',\n# '2016-12-02 15:00:00+00:00Z',\n# '2016-12-02 16:00:00+00:00Z',\n# ...]\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 174,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910220\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683774\"\n}"}}},{"rowIdx":1709167,"cells":{"id":{"kind":"string","value":"0bf8216640748f1e1e06ea23043ae57a9b679100"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Why would one want to use string.Format with only one parameter? I encountered the following code string in a project's code:\nvar result = string.Format(source);\n\nwith variable 'source' being a string\nI can't understand what useful this line is doing. As I always thought, we need at least two parameters for string.Format method to have some useful output.\nReSharper is not highlighting this as a something redundant so it seems that this line might have some purpose which I can't grasp at the moment. (Or maybe ReSharper just doesn't handle this case specifically)\nWhy would one want to use string.Format with only one parameter?\n\nA: Perhaps the overloaded function\npublic static string Format(string format, params object[] args);\n\nis allowing that code to compile. I cann't imagine that string.Format(source) would be helping in any meaningful way. \n"},"original_text":{"kind":"string","value":"Q: Why would one want to use string.Format with only one parameter? I encountered the following code string in a project's code:\nvar result = string.Format(source);\n\nwith variable 'source' being a string\nI can't understand what useful this line is doing. As I always thought, we need at least two parameters for string.Format method to have some useful output.\nReSharper is not highlighting this as a something redundant so it seems that this line might have some purpose which I can't grasp at the moment. (Or maybe ReSharper just doesn't handle this case specifically)\nWhy would one want to use string.Format with only one parameter?\n\nA: Perhaps the overloaded function\npublic static string Format(string format, params object[] args);\n\nis allowing that code to compile. I cann't imagine that string.Format(source) would be helping in any meaningful way. \n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 136,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910223\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683784\"\n}"}}},{"rowIdx":1709168,"cells":{"id":{"kind":"string","value":"d979643845c9dc7687f07d7863334f0a71325453"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Using spread notation in Array.reduce I am trying to get the es6 syntax working for this code fragment.\nlet checkList = [1, 2].map(i => \"Check \" + i)\n\nlet checks = checkList\n // .reduce((acc, check) => Object.assign(acc, {[check]: {valid: false}}), {})\n .reduce((acc, check) => {...acc, {[check]: {valid: false}}}, {})\nconsole.log(checks)\n\nThe output if i use the commented line in https://babeljs.io is as below and which is what i want to get using the new syntax.\nObject {\n \"Check 1\": Object {\n \"valid\": false\n },\n \"Check 2\": Object {\n \"valid\": false\n }\n}\n\nI am not sure if there is a syntax error in this code. I tried selecting all the presets in babeljs but it does't compile properly.\n\nA: Object spread is stage 4 proposal and isn't part of existing specifications. Stage 3 preset should be enabled in Babel, namely, transform-object-rest-spread.\nThere are syntax errors in the code above that will prevent it from being compiled properly even with required presets.\nIt should be \nlet checks = checkList\n .reduce((acc, check) => ({...acc, [check]: {valid: false}}), {});\n\n"},"original_text":{"kind":"string","value":"Q: Using spread notation in Array.reduce I am trying to get the es6 syntax working for this code fragment.\nlet checkList = [1, 2].map(i => \"Check \" + i)\n\nlet checks = checkList\n // .reduce((acc, check) => Object.assign(acc, {[check]: {valid: false}}), {})\n .reduce((acc, check) => {...acc, {[check]: {valid: false}}}, {})\nconsole.log(checks)\n\nThe output if i use the commented line in https://babeljs.io is as below and which is what i want to get using the new syntax.\nObject {\n \"Check 1\": Object {\n \"valid\": false\n },\n \"Check 2\": Object {\n \"valid\": false\n }\n}\n\nI am not sure if there is a syntax error in this code. I tried selecting all the presets in babeljs but it does't compile properly.\n\nA: Object spread is stage 4 proposal and isn't part of existing specifications. Stage 3 preset should be enabled in Babel, namely, transform-object-rest-spread.\nThere are syntax errors in the code above that will prevent it from being compiled properly even with required presets.\nIt should be \nlet checks = checkList\n .reduce((acc, check) => ({...acc, [check]: {valid: false}}), {});\n\n\nA: First of all you don't have wrap the properties in an extra object (unless you also want to use the spread operator on that).\nSo {...acc, {[check]: {valid: false}}} can become {...acc, [check]: {valid: false}}\nThis means you're adding an object to accumulator. The key of this object is the name you assigned it (Check[n]) and the values are the ones you set ({valid...}).\nSecondly, as far I know, you cannot use the spread operator without explicitly a new value. So you should either write your state on a new line like:\nlet checks = checkList.reduce((acc, check) => {\n return {...acc, [check]: {valid: false}}\n}, {})\n\nOr wrap it in extra parentheses:\nlet checks = checkList.reduce((acc, check) => ({...acc, [check]: {valid: false}}) , {})\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 302,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910225\",\n \"question_score\": \"5\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683789\"\n}"}}},{"rowIdx":1709169,"cells":{"id":{"kind":"string","value":"f76ab877e9459ae3eb6065a74a5c5e12269f743e"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Android animated button size change from both sides Android animation\nHow to change button size from both sides (Left and Right)\nin the same time \nAs this image\n\nI tried this .. but it doesn't work like what I wish\npublic void scaleView(View v, float startScale, float endScale) {\n Animation anim = new ScaleAnimation(\n startScale, endScale, // Start and end values for the X axis scaling\n 1f, 1f, // Start and end values for the Y axis scaling\n Animation.RELATIVE_TO_SELF, 0f, // Pivot point of X scaling\n Animation.RELATIVE_TO_SELF, 1f); // Pivot point of Y scaling\n anim.setFillAfter(true); // Needed to keep the result of the animation\n anim.setDuration(3000);\n v.startAnimation(anim);\n}\n\n\nA: Change pivotXValue to 0.5\n public void scaleView(View v, float startScale, float endScale) {\n Animation anim = new ScaleAnimation(\n startScale, endScale, // Start and end values for the X axis scaling\n 1f, 1f, // Start and end values for the Y axis scaling\n Animation.RELATIVE_TO_SELF, 0.5f, // Pivot point of X scaling\n Animation.RELATIVE_TO_SELF, 1f); // Pivot point of Y scaling\n anim.setFillAfter(true); // Needed to keep the result of the animation\n anim.setDuration(3000);\n v.startAnimation(anim);\n}\n\n"},"original_text":{"kind":"string","value":"Q: Android animated button size change from both sides Android animation\nHow to change button size from both sides (Left and Right)\nin the same time \nAs this image\n\nI tried this .. but it doesn't work like what I wish\npublic void scaleView(View v, float startScale, float endScale) {\n Animation anim = new ScaleAnimation(\n startScale, endScale, // Start and end values for the X axis scaling\n 1f, 1f, // Start and end values for the Y axis scaling\n Animation.RELATIVE_TO_SELF, 0f, // Pivot point of X scaling\n Animation.RELATIVE_TO_SELF, 1f); // Pivot point of Y scaling\n anim.setFillAfter(true); // Needed to keep the result of the animation\n anim.setDuration(3000);\n v.startAnimation(anim);\n}\n\n\nA: Change pivotXValue to 0.5\n public void scaleView(View v, float startScale, float endScale) {\n Animation anim = new ScaleAnimation(\n startScale, endScale, // Start and end values for the X axis scaling\n 1f, 1f, // Start and end values for the Y axis scaling\n Animation.RELATIVE_TO_SELF, 0.5f, // Pivot point of X scaling\n Animation.RELATIVE_TO_SELF, 1f); // Pivot point of Y scaling\n anim.setFillAfter(true); // Needed to keep the result of the animation\n anim.setDuration(3000);\n v.startAnimation(anim);\n}\n\n\nA: Did you try this:\nv.animate().setDuration(3000).scaleX(endScale);\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 186,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910227\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683791\"\n}"}}},{"rowIdx":1709170,"cells":{"id":{"kind":"string","value":"2d730f148f401b37569860ef6986d0e9011a74f3"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How can you clone a branch from the original GitHub project to your fork? I forked a GitHub project. I want to create a new branch, that is a clone of the original project's master branch (the master branch has new commits from when I last forked).\nHow can I do this?\n\nA: Fetch from your upstream, checkout to that branch, then force push to that branch on your fork.\ngit fetch upstream\ngit checkout \ngit push -f origin \n\nDisclaimer: I haven't tested this.\n"},"original_text":{"kind":"string","value":"Q: How can you clone a branch from the original GitHub project to your fork? I forked a GitHub project. I want to create a new branch, that is a clone of the original project's master branch (the master branch has new commits from when I last forked).\nHow can I do this?\n\nA: Fetch from your upstream, checkout to that branch, then force push to that branch on your fork.\ngit fetch upstream\ngit checkout \ngit push -f origin \n\nDisclaimer: I haven't tested this.\n\nA: First you need to configure a remote for a the original repo.\n$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git\n$ git fetch upstream\n\nNow you can use any git command with any branch from the original repo.\n$ git checkout master\n$ git pull upstream master\n\nOf course, you can checkout any other branch than master. \n$ git checkout my-radical-new-feature\n$ git pull upstream master\n\nTypically I pull directly to my local master branch as shown here and then merge the local master into other branches where I am working.\n$ git checkout master\n$ git pull upstream master\n$ git checkout my-radical-new-feature\n$ git merge master\n\nSee the GitHub docs for more details\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 203,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910243\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683831\"\n}"}}},{"rowIdx":1709171,"cells":{"id":{"kind":"string","value":"215e14fb4e161afbbf9f9f2da9ccfab089965088"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Split a list from some element and getting the item values into another list in Python 2.7 This is my list:\nl = ['today','is','a','holiday','but','nothing','to','do']\n\nI wish to put the items after 'but' into another list such as:\nanother_list = ['nothing','to','do']\n\nI tried the following way:\nl = ['today','is','a','holiday','but','nothing','to','do']\nfor element in l:\n parts = element.split('but')\n\nBut it does not provide the output I expected.\n\nA: You are splitting on an array element not a string.. so in this case you a split isn't going to work. There is nothing to split. Instead find the index and continue from there. Checkout https://www.tutorialspoint.com/python/python_lists.htm to learn more about python list\nl = ['today','is','a','holiday','but','nothing','to','do']\n# get the index of but\ni = l.index(\"but\") # \"This method returns index of the found object otherwise raise an exception indicating that value does not find.\"\n# print everything after \"but\" using slice logic.\nprint l[i+1:]\n\n"},"original_text":{"kind":"string","value":"Q: Split a list from some element and getting the item values into another list in Python 2.7 This is my list:\nl = ['today','is','a','holiday','but','nothing','to','do']\n\nI wish to put the items after 'but' into another list such as:\nanother_list = ['nothing','to','do']\n\nI tried the following way:\nl = ['today','is','a','holiday','but','nothing','to','do']\nfor element in l:\n parts = element.split('but')\n\nBut it does not provide the output I expected.\n\nA: You are splitting on an array element not a string.. so in this case you a split isn't going to work. There is nothing to split. Instead find the index and continue from there. Checkout https://www.tutorialspoint.com/python/python_lists.htm to learn more about python list\nl = ['today','is','a','holiday','but','nothing','to','do']\n# get the index of but\ni = l.index(\"but\") # \"This method returns index of the found object otherwise raise an exception indicating that value does not find.\"\n# print everything after \"but\" using slice logic.\nprint l[i+1:]\n\n\nA: You can use index:\nl[l.index('but')+1:]\n>>> ['nothing', 'to', 'do']\n\n\nA: Join the list, partition it, and then re-split it.\n' '.join(l).partition('but')[-1].split() # ['nothing', 'to', 'do']\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 175,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910272\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683916\"\n}"}}},{"rowIdx":1709172,"cells":{"id":{"kind":"string","value":"3cf3c3a90f53b3871906c04f013c16db271d3f69"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: I have a PopupBox that I want to change the icon for. Currently it defaults to DotsVertical and I would like to have it as a DotsHorizontal I am using MaterialDesignInXAML for a WPF application. I have a PopupBox that I want to change the icon for. Currently it defaults to DotsVertical and I would like to have it as a DotsHorizontal.\nI tried the following with no luck.\n\n \n \n \n \n \n \n \n \n\n\nThanks in advance!\n\nA: In order to change the Icon and preserve the current style use this:\n\n\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\n\n\n"},"original_text":{"kind":"string","value":"Q: I have a PopupBox that I want to change the icon for. Currently it defaults to DotsVertical and I would like to have it as a DotsHorizontal I am using MaterialDesignInXAML for a WPF application. I have a PopupBox that I want to change the icon for. Currently it defaults to DotsVertical and I would like to have it as a DotsHorizontal.\nI tried the following with no luck.\n\n \n \n \n \n \n \n \n \n\n\nThanks in advance!\n\nA: In order to change the Icon and preserve the current style use this:\n\n\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\n\n\n\nA: Figured it out and will leave an answer here in case anyone else comes across this issue. There is a property called ToggleContent\n\n \n \n \n \n \n \n \n \n\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 176,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910280\",\n \"question_score\": \"11\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44683929\"\n}"}}},{"rowIdx":1709173,"cells":{"id":{"kind":"string","value":"f76850775bfe3eb07e0946be48f8bd39936f6212"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Remove duplicate words from cells in R I have a 2-column data frame, where the first column is a number, and the second column contains a list of research categories. A reduced version of my data:\naa <- data.frame(a=c(1:4),b=c(\"Fisheries, Fisheries, Geography, Marine Biology\", \n\"Fisheries\", \"Marine Biology, Marine Biology, Fisheries, Zoology\", \"Geography\"))\n\nI want to convert column b into a unique list of elements, i.e., remove the duplicates, so that the end result is\n a b\n 1 Fisheries, Geography, Marine Biology\n 2 Fisheries\n 3 Marine Biology, Fisheries, Zoology\n 4 Geography\n\nI am able to do this for individual elements of the list, for example, using unique(unlist(strsplit(aa[1]))) BUT only on individual elements, not the entire column (otherwise it returns a single unique list for the entire column). I can’t figure out how to do this for the entire list, one element at a time. Maybe with lapply and write my own function for *unique(unlist(strsplit()))?\nMany thanks!\n\nA: This should work for you.\naa <- data.frame(a=c(1:4),b=c(\"Fisheries, Fisheries, Geography, Marine Biology\", \n \"Fisheries\", \"Marine Biology, Marine Biology, Fisheries, Zoology\", \"Geography\"))\n\naa$b <- sapply(aa$b, function(x) paste(unique(unlist(str_split(x,\", \"))), collapse = \", \"))\n\n"},"original_text":{"kind":"string","value":"Q: Remove duplicate words from cells in R I have a 2-column data frame, where the first column is a number, and the second column contains a list of research categories. A reduced version of my data:\naa <- data.frame(a=c(1:4),b=c(\"Fisheries, Fisheries, Geography, Marine Biology\", \n\"Fisheries\", \"Marine Biology, Marine Biology, Fisheries, Zoology\", \"Geography\"))\n\nI want to convert column b into a unique list of elements, i.e., remove the duplicates, so that the end result is\n a b\n 1 Fisheries, Geography, Marine Biology\n 2 Fisheries\n 3 Marine Biology, Fisheries, Zoology\n 4 Geography\n\nI am able to do this for individual elements of the list, for example, using unique(unlist(strsplit(aa[1]))) BUT only on individual elements, not the entire column (otherwise it returns a single unique list for the entire column). I can’t figure out how to do this for the entire list, one element at a time. Maybe with lapply and write my own function for *unique(unlist(strsplit()))?\nMany thanks!\n\nA: This should work for you.\naa <- data.frame(a=c(1:4),b=c(\"Fisheries, Fisheries, Geography, Marine Biology\", \n \"Fisheries\", \"Marine Biology, Marine Biology, Fisheries, Zoology\", \"Geography\"))\n\naa$b <- sapply(aa$b, function(x) paste(unique(unlist(str_split(x,\", \"))), collapse = \", \"))\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 186,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910320\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684052\"\n}"}}},{"rowIdx":1709174,"cells":{"id":{"kind":"string","value":"22b558a83a2fce418791a7f7ea65da0a1b312bf9"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Jquery Check if element's title contains specific text I have a list like this\n
    \n
  1. ...
  2. \n
  3. ...
  4. \n
  5. ...
  6. \n
  7. ...
  8. \n
\n\nI want to check if a \"li\" has title contain \"Example\" then add class for it. The result should be like this\n
    \n
  1. ...
  2. \n
  3. ...
  4. \n
  5. ...
  6. \n
  7. ...
  8. \n
\n\nPlease help me. And sorry for my bad English.\n\nA: You can use the attribute contains selector (*=)\n$(\"li[title*=Example]\").addClass(\"someClass\");\n\nhttps://api.jquery.com/attribute-contains-selector/\n"},"original_text":{"kind":"string","value":"Q: Jquery Check if element's title contains specific text I have a list like this\n
    \n
  1. ...
  2. \n
  3. ...
  4. \n
  5. ...
  6. \n
  7. ...
  8. \n
\n\nI want to check if a \"li\" has title contain \"Example\" then add class for it. The result should be like this\n
    \n
  1. ...
  2. \n
  3. ...
  4. \n
  5. ...
  6. \n
  7. ...
  8. \n
\n\nPlease help me. And sorry for my bad English.\n\nA: You can use the attribute contains selector (*=)\n$(\"li[title*=Example]\").addClass(\"someClass\");\n\nhttps://api.jquery.com/attribute-contains-selector/\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 82,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910343\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684117\"\n}"}}},{"rowIdx":1709175,"cells":{"id":{"kind":"string","value":"1a42a1fa5ff84cf6f84ac03fe93a17c76cdb642a"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: iOS - Change the height of text field inside a UIStackView I have this layout \n\nAnd I want to resize the height of every text field inside, but I cant do it on inspector. Its something about constraints?\nCan someone help me with this thing?\nHere is my tree of components\n\n\nA: yes you will need to set height constraints for the stuff that is in your stack view. Have a look at this:How to set height of containers in stack view?\n"},"original_text":{"kind":"string","value":"Q: iOS - Change the height of text field inside a UIStackView I have this layout \n\nAnd I want to resize the height of every text field inside, but I cant do it on inspector. Its something about constraints?\nCan someone help me with this thing?\nHere is my tree of components\n\n\nA: yes you will need to set height constraints for the stuff that is in your stack view. Have a look at this:How to set height of containers in stack view?\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 83,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910347\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684130\"\n}"}}},{"rowIdx":1709176,"cells":{"id":{"kind":"string","value":"25b1b3816899500ae2e48d5877e3f74418750d63"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Is there a way to get F#'s constructor-parameters-are-automatically-immutable-private-members feature in C#? In F#, the constructor parameters are automatically saved as immutable fields in the class without having to write the declaration of the field or the copying of the constructor parameter to the field in the constructor. \nIs there any way to mimic this functionality in C#? Is there a reason why a future version of C# couldn't have this feature (i.e. is there some fundamental limitation of the existing language that conflicts with this feature)?\n\nA: The C# equivalent will be records. These are currently earmarked for C# 8, but there's no guarantees (especially as they were proposed for C# 6 & 7 too and were delayed in both cases).\n"},"original_text":{"kind":"string","value":"Q: Is there a way to get F#'s constructor-parameters-are-automatically-immutable-private-members feature in C#? In F#, the constructor parameters are automatically saved as immutable fields in the class without having to write the declaration of the field or the copying of the constructor parameter to the field in the constructor. \nIs there any way to mimic this functionality in C#? Is there a reason why a future version of C# couldn't have this feature (i.e. is there some fundamental limitation of the existing language that conflicts with this feature)?\n\nA: The C# equivalent will be records. These are currently earmarked for C# 8, but there's no guarantees (especially as they were proposed for C# 6 & 7 too and were delayed in both cases).\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 122,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910370\",\n \"question_score\": \"7\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684203\"\n}"}}},{"rowIdx":1709177,"cells":{"id":{"kind":"string","value":"56182aad6d4f47e0bf6774ab3fc29c8871171896"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Can't edit LaunchScreen.storyboard on Visual Studio I have a Xamarin.Forms app, and am trying to publish the iOS app in it. I'm following the Xamarin tutorial here for the launch screen.\nIn steps 6 and 7 it assumes there is some View on the screen. I don't see one. This is what I have:\n\nWhen I try to drag an Image View as mentioned in the tutorial - I get a \"do not enter\" symbol on the Image View. (I assume, because I first need the default View there.)\nWhat now? (I'm using VS2017 on Windows 10 Pro.)\n\nA: Just add ViewController and go from there\n"},"original_text":{"kind":"string","value":"Q: Can't edit LaunchScreen.storyboard on Visual Studio I have a Xamarin.Forms app, and am trying to publish the iOS app in it. I'm following the Xamarin tutorial here for the launch screen.\nIn steps 6 and 7 it assumes there is some View on the screen. I don't see one. This is what I have:\n\nWhen I try to drag an Image View as mentioned in the tutorial - I get a \"do not enter\" symbol on the Image View. (I assume, because I first need the default View there.)\nWhat now? (I'm using VS2017 on Windows 10 Pro.)\n\nA: Just add ViewController and go from there\n\nA: Drag and drop ViewController to LaunchScreen.storyboard\nExample here:\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 116,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910371\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684206\"\n}"}}},{"rowIdx":1709178,"cells":{"id":{"kind":"string","value":"e21a5115942aaf16c97a148492368f40d28cc407"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Game Center Leaderboard not appearing on production version of game? My game went on the app store a few days ago and I cannot see my leaderboard at all. It just says \"no data available\"\nHowever, when I build my game directly to my phone using an ad hoc profile I'm seeing my beta player's scores.. \n\nMy leaderboard is in the not live status. I'm not sure if that matters or how to change that. I have other games with a \"not live\" leaderboard that are working on production..\nShould I delete and remake the leaderboard now that my game is actually up on the app store?\nI cleared my test data.. no luck. \nDo I just need to wait? It's confusing.\nI've called Apple support and theyre \"working on it\" but I feel like I'm stuck in a black hole now.. any way I can fix this myself?\n\nA: I'm not sure if this section existed before. But I needed to explicitly add my created leaderboards to my release.\n"},"original_text":{"kind":"string","value":"Q: Game Center Leaderboard not appearing on production version of game? My game went on the app store a few days ago and I cannot see my leaderboard at all. It just says \"no data available\"\nHowever, when I build my game directly to my phone using an ad hoc profile I'm seeing my beta player's scores.. \n\nMy leaderboard is in the not live status. I'm not sure if that matters or how to change that. I have other games with a \"not live\" leaderboard that are working on production..\nShould I delete and remake the leaderboard now that my game is actually up on the app store?\nI cleared my test data.. no luck. \nDo I just need to wait? It's confusing.\nI've called Apple support and theyre \"working on it\" but I feel like I'm stuck in a black hole now.. any way I can fix this myself?\n\nA: I'm not sure if this section existed before. But I needed to explicitly add my created leaderboards to my release.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 171,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910372\",\n \"question_score\": \"8\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684208\"\n}"}}},{"rowIdx":1709179,"cells":{"id":{"kind":"string","value":"56d7198068ad9ca99b0ebf04a36c76ba28a142cd"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Spring Oauth2RestTemplate error \"access_denied\" I need to consume a OAuth2 Rest service with ClientCredential Grant.\nI'm using spring security and spring oauth2.\nTo get the access token i need to call the token uri passing to it a clientId and a password\nBasically i need to send a POST with this body\n{\"clientId\":\"demo\",\n\"password\": \"demo_password\"\n}\n\nand I should get something like that in the response\n{\n \"expiresIn\": 3600,\n \"accessToken\": \"EF2I5xhL2GU9pAwK\",\n \"statusCode\": 200,\n \"refreshToken\": \"72BIcYWYhPjuPDGb\"\n}\n\nI was trying to configure OAuth2RestTemplate in this way\n@Configuration\n@EnableOAuth2Client\npublic class RestTemplateConf {\n\n @Value(\"${ApiClient}\")\n private String oAuth2ClientId;\n\n @Value(\"${ApiSecret}\")\n private String oAuth2ClientSecret;\n\n @Value(\"${ApiUrl}\")\n private String accessTokenUri;\n\n\n @Bean\n public OAuth2RestTemplate oAuthRestTemplate() {\n ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();\n resourceDetails.setClientId(oAuth2ClientId);\n resourceDetails.setClientSecret(oAuth2ClientSecret);\n resourceDetails.setAccessTokenUri(accessTokenUri);\n resourceDetails.setTokenName(\"accessToken\");\n\n\n OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resourceDetails, new DefaultOAuth2ClientContext());\n\n return restTemplate;\n }\n\n\n}\n\nbut i get always \nServlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is error=\"access_denied\", error_description=\"Error requesting access token.\"] with root cause\norg.springframework.web.client.HttpServerErrorException: 500 Internal Server Error\n\nIf i make a POST call to the tokenUri with POSTMAN, for instance, i get the token correctly...\n"},"original_text":{"kind":"string","value":"Q: Spring Oauth2RestTemplate error \"access_denied\" I need to consume a OAuth2 Rest service with ClientCredential Grant.\nI'm using spring security and spring oauth2.\nTo get the access token i need to call the token uri passing to it a clientId and a password\nBasically i need to send a POST with this body\n{\"clientId\":\"demo\",\n\"password\": \"demo_password\"\n}\n\nand I should get something like that in the response\n{\n \"expiresIn\": 3600,\n \"accessToken\": \"EF2I5xhL2GU9pAwK\",\n \"statusCode\": 200,\n \"refreshToken\": \"72BIcYWYhPjuPDGb\"\n}\n\nI was trying to configure OAuth2RestTemplate in this way\n@Configuration\n@EnableOAuth2Client\npublic class RestTemplateConf {\n\n @Value(\"${ApiClient}\")\n private String oAuth2ClientId;\n\n @Value(\"${ApiSecret}\")\n private String oAuth2ClientSecret;\n\n @Value(\"${ApiUrl}\")\n private String accessTokenUri;\n\n\n @Bean\n public OAuth2RestTemplate oAuthRestTemplate() {\n ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();\n resourceDetails.setClientId(oAuth2ClientId);\n resourceDetails.setClientSecret(oAuth2ClientSecret);\n resourceDetails.setAccessTokenUri(accessTokenUri);\n resourceDetails.setTokenName(\"accessToken\");\n\n\n OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resourceDetails, new DefaultOAuth2ClientContext());\n\n return restTemplate;\n }\n\n\n}\n\nbut i get always \nServlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is error=\"access_denied\", error_description=\"Error requesting access token.\"] with root cause\norg.springframework.web.client.HttpServerErrorException: 500 Internal Server Error\n\nIf i make a POST call to the tokenUri with POSTMAN, for instance, i get the token correctly...\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 181,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910375\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684212\"\n}"}}},{"rowIdx":1709180,"cells":{"id":{"kind":"string","value":"2543b2eb1ccda72b85a5f0f289ef5fdbfc94d551"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Python webkit2 can't open links in Gmail or Google inbox I'm creating a Gtk+ app with Python that contains a WebKit2 webview. Anytime an outgoing link in GMail or Google Inbox is clicked a popup is spawned by javascript saying:\n\"Grrr! A popup blocker may be preventing the application from opening the page. If you have a popup blocker, try disabling it to open the window.\"\n\nI've enabled the \"javascript-can-open-windows-automatically\" setting for the webview but it still doesn't work.\nIf I right-click on any of the outgoing links, and select \"open link\" or \"open in new window\", the links will open.\nI've also created a handler for navigation requests using \"decide-policy\" signal and \"create\" signal, in the hopes of retrieving the uri, however in request object the uri is blank.\nThis seems to be a problem with webview and gmail/inbox in general as discussed here. The previous question hasn't been solved, therefore I'm asking again but in the context of Python.\n"},"original_text":{"kind":"string","value":"Q: Python webkit2 can't open links in Gmail or Google inbox I'm creating a Gtk+ app with Python that contains a WebKit2 webview. Anytime an outgoing link in GMail or Google Inbox is clicked a popup is spawned by javascript saying:\n\"Grrr! A popup blocker may be preventing the application from opening the page. If you have a popup blocker, try disabling it to open the window.\"\n\nI've enabled the \"javascript-can-open-windows-automatically\" setting for the webview but it still doesn't work.\nIf I right-click on any of the outgoing links, and select \"open link\" or \"open in new window\", the links will open.\nI've also created a handler for navigation requests using \"decide-policy\" signal and \"create\" signal, in the hopes of retrieving the uri, however in request object the uri is blank.\nThis seems to be a problem with webview and gmail/inbox in general as discussed here. The previous question hasn't been solved, therefore I'm asking again but in the context of Python.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 162,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910383\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684251\"\n}"}}},{"rowIdx":1709181,"cells":{"id":{"kind":"string","value":"c10e96e540fae3eb06a0ea562b3d3bcd13b4695d"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: MBProgressHUD not show When I write like this, it works as expected:\noverride func viewDidLoad() {\n super.viewDidLoad()\n MBProgressHUD.showAdded(to: navigationController!.view, animated: true)\n}\n\nHowever, when I put it in DispatchQueue.main block, the hud doesn't show:\noverride func viewDidLoad() {\n super.viewDidLoad()\n\n DispatchQueue.main.async {\n MBProgressHUD.showAdded(to: self.navigationController!.view, animated: true)\n }\n}\n\nI debug the view hierarchy, and there is a layout issue: \n\"Position and size are ambiguous for MBProgressHUD\"\nThe navigationController is a childViewController of fatherViewController and the container view is set by auto layout in fatherViewController's view.\nIs that cause the issue?\n\nA: I have built a demo to test it, but it didn't occur. So I rechecked my code and found I put some work in DispatchQueue.main.async which block the UI and cause the problem.\n"},"original_text":{"kind":"string","value":"Q: MBProgressHUD not show When I write like this, it works as expected:\noverride func viewDidLoad() {\n super.viewDidLoad()\n MBProgressHUD.showAdded(to: navigationController!.view, animated: true)\n}\n\nHowever, when I put it in DispatchQueue.main block, the hud doesn't show:\noverride func viewDidLoad() {\n super.viewDidLoad()\n\n DispatchQueue.main.async {\n MBProgressHUD.showAdded(to: self.navigationController!.view, animated: true)\n }\n}\n\nI debug the view hierarchy, and there is a layout issue: \n\"Position and size are ambiguous for MBProgressHUD\"\nThe navigationController is a childViewController of fatherViewController and the container view is set by auto layout in fatherViewController's view.\nIs that cause the issue?\n\nA: I have built a demo to test it, but it didn't occur. So I rechecked my code and found I put some work in DispatchQueue.main.async which block the UI and cause the problem.\n\nA: I performed test especially for you and following code works for me:\noverride func viewDidLoad() {\n super.viewDidLoad()\n\n DispatchQueue.main.async {\n MBProgressHUD.showAdded(to: self.navigationController!.view, animated: true)\n }\n}\n\nso the problem is somewhere else located\n\nA: The root UIView geometry is not being calculated(viewDidLayoutSubviews is not called) at the point of viewDidLoad. I'd recommend putting your code into viewDidAppear. \nAlso, no need to explicitly call it inside DispatchAsync.main, as other mentioned it is being called in the UI thread unless you want to call it from the background thread.\n\nA: Actually MBProgressHUD works on UI main thread and you are trying to call it in background thread.\nTry this:- \n override func viewDidLoad() {\n super.viewDidLoad()\n DispatchQueue.main.async { start()\n }\n}\nfunc start(){\n\n\n MBProgressHUD.showAdded(to: self.navigationController!.view, animated: true)}\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 247,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910428\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684397\"\n}"}}},{"rowIdx":1709182,"cells":{"id":{"kind":"string","value":"e33fe0b29d70740522450cd5b45c86c4630eb92c"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Is the constructor still needed in React with autobinding and property initializers I am refactoring an es6 class based React component that uses the normal constructor, and then binds methods, and defines state/attributes within that constructor. Something like this:\nclass MySpecialComponent extends React.Component {\n constructor(props) {\n super(props)\n this.state = { thing: true }\n this.myMethod = this.myMethod.bind(this)\n this.myAttribute = { amazing: false }\n }\n\n myMethod(e) {\n this.setState({ thing: e.target.value })\n }\n}\n\nI want to refactor this so that I am autobinding the functions, and using property initializers for the state and attributes. Now my code looks something like this:\nclass MySpecialComponent extends React.Component {\n state = { thing: true }\n myAttribute = { amazing: false }\n\n\n myMethod = (e) => {\n this.setState({ thing: e.target.value })\n }\n}\n\nMy question is, do I still need the constructor? Or are the props also autobound? I would have expected to still need the constructor and included super(props), but my code seems to be working and I'm confused.\nThanks\n\nA: You don't need an explicitly defined constructor unless you need to reference the props in your initial state object.\n"},"original_text":{"kind":"string","value":"Q: Is the constructor still needed in React with autobinding and property initializers I am refactoring an es6 class based React component that uses the normal constructor, and then binds methods, and defines state/attributes within that constructor. Something like this:\nclass MySpecialComponent extends React.Component {\n constructor(props) {\n super(props)\n this.state = { thing: true }\n this.myMethod = this.myMethod.bind(this)\n this.myAttribute = { amazing: false }\n }\n\n myMethod(e) {\n this.setState({ thing: e.target.value })\n }\n}\n\nI want to refactor this so that I am autobinding the functions, and using property initializers for the state and attributes. Now my code looks something like this:\nclass MySpecialComponent extends React.Component {\n state = { thing: true }\n myAttribute = { amazing: false }\n\n\n myMethod = (e) => {\n this.setState({ thing: e.target.value })\n }\n}\n\nMy question is, do I still need the constructor? Or are the props also autobound? I would have expected to still need the constructor and included super(props), but my code seems to be working and I'm confused.\nThanks\n\nA: You don't need an explicitly defined constructor unless you need to reference the props in your initial state object.\n\nA: You don't need to define a constructor explicitly , and then do super(props).You can access the props as in the example below. i.e. 'prop1'\nclass MySpecialComponent extends React.Component {\n state = { \n thing: true ,\n prop1:this.props.prop1\n }\n myAttribute = { amazing: false }\n\n\n myMethod = (e) => {\n this.setState({ thing: e.target.value })\n}\n\n\n render(){\n console.log(this.state.prop1);\n return(\n
Hi
\n );\n\n }\n }\n\n\n ReactDOM.render( , mountNode);\n\n\nA: From my understanding, you don't need to type out a constructor at all when using class properties (as in your second code example). The accepted answer states that you do need one if you \"need to reference the props in your initial state object,\" but if you're using said class properties, then you're probably using Babel to transpile it, in which case a constructor is used, it's just being done behind the scenes. Because of this, you don't need to add a constructor yourself, even if you are using props in state.\nSee this aricle for better examples and a better explanation.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 354,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910451\",\n \"question_score\": \"13\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684481\"\n}"}}},{"rowIdx":1709183,"cells":{"id":{"kind":"string","value":"f60fbe3fd514bb1e6010e2f2e0514c360ee5a924"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: SQL Server: CREATE FUNCTION with declare variables inside I would like to create a function in SQL Server.\nIn this function, I need to define some variables and then use it in the SELECT.\nSQL looks like below:\nCREATE FUNCTION [dbo].[MyFussnction] \n(\n @path [nvarchar](10)\n)\nRETURNS TABLE\n\nBEGIN\n DECLARE @xx varchar(50);\n SET @xx = 'Windows%';\nRETURN \n SELECT * FROM MyTable WHERE DataPath LIKE @path AND XX LIKE @xx;\nEND\n\nBut, it is not able to be created and the error says:\nMsg 102, Level 15, State 31, Procedure MyFussnction, Line 12 [Batch Start Line 0]\nIncorrect syntax near 'BEGIN'.\n\n\nA: You need to define columns of table to return, then you can use declare, something like below\nCREATE FUNCTION [dbo].[MyFussnction] ( \n@path [nvarchar](10)\n)\nRETURNS @Mytable TABLE \n(\n ID int PRIMARY KEY NOT NULL\n -- define other columns\n)\nAS\nBEGIN\n DECLARE @xx varchar(50);\n SET @xx = 'Windows%';\n\n Insert into @Mytable\n SELECT Id FROM MyTable WHERE DataPath LIKE @path AND XX LIKE @xx;\n RETURN; \nEND\n\n"},"original_text":{"kind":"string","value":"Q: SQL Server: CREATE FUNCTION with declare variables inside I would like to create a function in SQL Server.\nIn this function, I need to define some variables and then use it in the SELECT.\nSQL looks like below:\nCREATE FUNCTION [dbo].[MyFussnction] \n(\n @path [nvarchar](10)\n)\nRETURNS TABLE\n\nBEGIN\n DECLARE @xx varchar(50);\n SET @xx = 'Windows%';\nRETURN \n SELECT * FROM MyTable WHERE DataPath LIKE @path AND XX LIKE @xx;\nEND\n\nBut, it is not able to be created and the error says:\nMsg 102, Level 15, State 31, Procedure MyFussnction, Line 12 [Batch Start Line 0]\nIncorrect syntax near 'BEGIN'.\n\n\nA: You need to define columns of table to return, then you can use declare, something like below\nCREATE FUNCTION [dbo].[MyFussnction] ( \n@path [nvarchar](10)\n)\nRETURNS @Mytable TABLE \n(\n ID int PRIMARY KEY NOT NULL\n -- define other columns\n)\nAS\nBEGIN\n DECLARE @xx varchar(50);\n SET @xx = 'Windows%';\n\n Insert into @Mytable\n SELECT Id FROM MyTable WHERE DataPath LIKE @path AND XX LIKE @xx;\n RETURN; \nEND\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 166,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910468\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684527\"\n}"}}},{"rowIdx":1709184,"cells":{"id":{"kind":"string","value":"d67af615f9195d922df0fd13e7925fe5aedaabc7"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: GLoVe word embedding for special words in seq2seq I am training a seq2seq model in Tensorflow. I want to use GLoVe as word embedding for words in my sequences. In seq2seq, I am using some of tags like EOS(End of Sequence), GO(start of sequence for decoder), PAD(for padding sequence), as words in my sequences. \nBut GLoVe won't be having embedding for these tags.\nSo, how should I represent these tags ? \n"},"original_text":{"kind":"string","value":"Q: GLoVe word embedding for special words in seq2seq I am training a seq2seq model in Tensorflow. I want to use GLoVe as word embedding for words in my sequences. In seq2seq, I am using some of tags like EOS(End of Sequence), GO(start of sequence for decoder), PAD(for padding sequence), as words in my sequences. \nBut GLoVe won't be having embedding for these tags.\nSo, how should I represent these tags ? \n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 72,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910552\",\n \"question_score\": \"5\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684721\"\n}"}}},{"rowIdx":1709185,"cells":{"id":{"kind":"string","value":"8fc5824fc60f3100b6272c01319e5082415d9df8"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: how to type sudo password when using subprocess.call? i defined a function that switch my proxy settings every now and then,\nproblem is that i want it to run in a loop without manual intervention. But when i execute the program in sudo it gets called the first time en runs smoothly, second time it asks me for my sudo password. Here is the bit of code:\ndef ProxySetting(Proxy):\n print \"ProxyStetting(Proxy)\"\n call(\"networksetup -setwebproxy 'Wi-Fi' %s\" \"on\" % Proxy, shell = True)\n call(\"networksetup -setsecurewebproxy 'Wi-Fi' %s\" \"on\" % Proxy, shell = True)\n call(\"networksetup -setftpproxy 'Wi-Fi' %s\" \"on\" %Proxy , shell=True)\n\nI could use threading but am sure there is a way of doing it that wont cause problems. How can i hard code my sudo password so that it runs at the beginning of the function? \n\nA: Another method of passing your password to a shell command through python that wouldn't involve it showing up in any command history or ps output is:\np = subprocess.Popen(['sudo', self.resubscribe_script], stdin=subprocess.PIPE)\np.communicate('{}\\n'.format(self.sudo_password))\n\nNote that using communicate will only allow one input to be given to stdin; there are other methods for getting a reusable input.\n"},"original_text":{"kind":"string","value":"Q: how to type sudo password when using subprocess.call? i defined a function that switch my proxy settings every now and then,\nproblem is that i want it to run in a loop without manual intervention. But when i execute the program in sudo it gets called the first time en runs smoothly, second time it asks me for my sudo password. Here is the bit of code:\ndef ProxySetting(Proxy):\n print \"ProxyStetting(Proxy)\"\n call(\"networksetup -setwebproxy 'Wi-Fi' %s\" \"on\" % Proxy, shell = True)\n call(\"networksetup -setsecurewebproxy 'Wi-Fi' %s\" \"on\" % Proxy, shell = True)\n call(\"networksetup -setftpproxy 'Wi-Fi' %s\" \"on\" %Proxy , shell=True)\n\nI could use threading but am sure there is a way of doing it that wont cause problems. How can i hard code my sudo password so that it runs at the beginning of the function? \n\nA: Another method of passing your password to a shell command through python that wouldn't involve it showing up in any command history or ps output is:\np = subprocess.Popen(['sudo', self.resubscribe_script], stdin=subprocess.PIPE)\np.communicate('{}\\n'.format(self.sudo_password))\n\nNote that using communicate will only allow one input to be given to stdin; there are other methods for getting a reusable input.\n\nA: Here you can execute a command sudo without interactive prompt asking you to type your password :\nfrom subprocess import call \n\npwd='my password'\ncmd='ls'\n\ncall('echo {} | sudo -S {}'.format(pwd, cmd), shell=True)\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 225,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910565\",\n \"question_score\": \"7\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684764\"\n}"}}},{"rowIdx":1709186,"cells":{"id":{"kind":"string","value":"5dfc89807bdce33cfec083503f53119526733e29"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to add base URI in RestTemplate Is there any other way to initialize RestTemplate with base URI other than\nextending RestTemplate and overriding the execute method.currently i have the code like below.Thanks\nclass CustomRestTemplate extends RestTemplate {\nString baseUrl\n\n@Override\nprotected T doExecute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor responseExtractor) throws RestClientException {\n return super.doExecute(new URI(baseUrl + url.toString()), method, requestCallback, responseExtractor)\n}\n\n\nA: Spring 5.0:\nThis sends a GET request to http://localhost:8080/myservice\nRestTemplate restTemplate = new RestTemplate();\nrestTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(\"http://localhost:8080\"));\nrestTemplate.getForObject(\"/myservice\", String.class);\n\n"},"original_text":{"kind":"string","value":"Q: How to add base URI in RestTemplate Is there any other way to initialize RestTemplate with base URI other than\nextending RestTemplate and overriding the execute method.currently i have the code like below.Thanks\nclass CustomRestTemplate extends RestTemplate {\nString baseUrl\n\n@Override\nprotected T doExecute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor responseExtractor) throws RestClientException {\n return super.doExecute(new URI(baseUrl + url.toString()), method, requestCallback, responseExtractor)\n}\n\n\nA: Spring 5.0:\nThis sends a GET request to http://localhost:8080/myservice\nRestTemplate restTemplate = new RestTemplate();\nrestTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(\"http://localhost:8080\"));\nrestTemplate.getForObject(\"/myservice\", String.class);\n\n\nA: If you are using Spring Boot, you can use org.springframework.boot.web.client.RestTemplateBuilder.rootUri(baseUrl).build()\n\nA: You can create your custom DefaultUriTemplateHandler\nDefaultUriTemplateHandler defaultUriTemplateHandler = new DefaultUriTemplateHandler();\ndefaultUriTemplateHandler.setBaseUrl(url);\n\nAnd then add it to restTemplate\nreturn new RestTemplateBuilder()\n .uriTemplateHandler(defaultUriTemplateHandler)\n .build();\n\n\nA: Spring's RestTemplate (version 4.2.0.RELEASE) support a method named setUriTemplateHandler. If this is never set, it contains a DefaultUriTemplateHandler\nDefaultUriTemplateHandler supports a method named 'setBaseUrl`\nSo, you can set the base URL there.\n\nA: AFAIK there is no way other than what you have listed above\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 164,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910584\",\n \"question_score\": \"27\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684823\"\n}"}}},{"rowIdx":1709187,"cells":{"id":{"kind":"string","value":"e5d4053088c824338ccfb12573d41a67f43b2123"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: error: zlib library and headers are required R on HPC System: \nRed Hat Enterprise Linux Server release 6.5 (Santiago)\nI’ve installed zlib 1.2.11 on the home folder of a Red Hat HPC as part of the process for installing R base 3.4.0.\nI get this error even after successful install of zlib\nchecking for inflateInit2_ in -lz... no\nchecking whether zlib support suffices... configure: error: zlib library and headers are required\n\nI’ve checked R documentation and configure file for the issue of R requiring versions newer than 1.2.6 but not lexicographically recognizing 1.2.11 as >1.2.6, and that particular bug was patched in R 3.4.\nI've reviewed this question posted previously and the response is not relevant due to R 3.4 resolving that issue.\nAny suggestion and/or input would be much appreciated.\n"},"original_text":{"kind":"string","value":"Q: error: zlib library and headers are required R on HPC System: \nRed Hat Enterprise Linux Server release 6.5 (Santiago)\nI’ve installed zlib 1.2.11 on the home folder of a Red Hat HPC as part of the process for installing R base 3.4.0.\nI get this error even after successful install of zlib\nchecking for inflateInit2_ in -lz... no\nchecking whether zlib support suffices... configure: error: zlib library and headers are required\n\nI’ve checked R documentation and configure file for the issue of R requiring versions newer than 1.2.6 but not lexicographically recognizing 1.2.11 as >1.2.6, and that particular bug was patched in R 3.4.\nI've reviewed this question posted previously and the response is not relevant due to R 3.4 resolving that issue.\nAny suggestion and/or input would be much appreciated.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 132,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910593\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684848\"\n}"}}},{"rowIdx":1709188,"cells":{"id":{"kind":"string","value":"8c6f3dc114cf7e4f380a690fb62ad23585c68e95"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Access to store.dispatch in a saga for use with react router redux I'm currently refactoring a react + redux + saga + react-router 3 application to use the new react-router 4 due to breaking changes. Before I would use browserHistory to direct to an appropriate path based on the results from a saga. Due to react-router 4 changes, I can't use browserHistory any longer. \nNow I've incorporated react-router-redux to essentially do what browserHistory did. The problem is that react-router-redux only works within a store.dispatch, e.g. store.dispatch(push('/')). I can't seem to find a way to access either the store or it's dispatch function inside my sagas. Any ideas on how to access store.dispatch within a saga? I know you can pass arguments in the root saga but I don't know how to retrieve them in my actual sagas. \n\nA: Use redux-saga's put effect, which dispatches redux actions to the store - docs.\nimport { call, put } from 'redux-saga/effects'\n// ...\n\nfunction* fetchProducts() {\n const products = yield call(Api.fetch, '/products')\n // create and yield a dispatch Effect\n yield put({ type: 'PRODUCTS_RECEIVED', products })\n}\n\n"},"original_text":{"kind":"string","value":"Q: Access to store.dispatch in a saga for use with react router redux I'm currently refactoring a react + redux + saga + react-router 3 application to use the new react-router 4 due to breaking changes. Before I would use browserHistory to direct to an appropriate path based on the results from a saga. Due to react-router 4 changes, I can't use browserHistory any longer. \nNow I've incorporated react-router-redux to essentially do what browserHistory did. The problem is that react-router-redux only works within a store.dispatch, e.g. store.dispatch(push('/')). I can't seem to find a way to access either the store or it's dispatch function inside my sagas. Any ideas on how to access store.dispatch within a saga? I know you can pass arguments in the root saga but I don't know how to retrieve them in my actual sagas. \n\nA: Use redux-saga's put effect, which dispatches redux actions to the store - docs.\nimport { call, put } from 'redux-saga/effects'\n// ...\n\nfunction* fetchProducts() {\n const products = yield call(Api.fetch, '/products')\n // create and yield a dispatch Effect\n yield put({ type: 'PRODUCTS_RECEIVED', products })\n}\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 184,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910615\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44684910\"\n}"}}},{"rowIdx":1709189,"cells":{"id":{"kind":"string","value":"0307df8dcf647032c5c4bea4aae55258a3ca0314"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Boundary points from a set of coordinates I have a set of lat,long points, and from this points I'd like to extract the points that form the boundaries, I've used convexhull, but for my purpouse is not enough as convehull just returns the most distant points that form the polygon where all the points fit, I need ALL the points that form the peremiter, something like the image I've attached. What could I do? Is there some kind of package ready to use instead of implement any spatial algorithm?\nThanks\n \n\nA: You must use a package for convex polygons. Here is an example:\nimport alphashape\nimport matplotlib.pyplot as plt\n\npoints = put your points here (can be array)!\nalpha = 0.95 * alphashape.optimizealpha(points)\nhull = alphashape.alphashape(points, alpha)\nhull_pts = hull.exterior.coords.xy\n\nfig, ax = plt.subplots()\nax.scatter(hull_pts[0], hull_pts[1], color='red') \n\n"},"original_text":{"kind":"string","value":"Q: Boundary points from a set of coordinates I have a set of lat,long points, and from this points I'd like to extract the points that form the boundaries, I've used convexhull, but for my purpouse is not enough as convehull just returns the most distant points that form the polygon where all the points fit, I need ALL the points that form the peremiter, something like the image I've attached. What could I do? Is there some kind of package ready to use instead of implement any spatial algorithm?\nThanks\n \n\nA: You must use a package for convex polygons. Here is an example:\nimport alphashape\nimport matplotlib.pyplot as plt\n\npoints = put your points here (can be array)!\nalpha = 0.95 * alphashape.optimizealpha(points)\nhull = alphashape.alphashape(points, alpha)\nhull_pts = hull.exterior.coords.xy\n\nfig, ax = plt.subplots()\nax.scatter(hull_pts[0], hull_pts[1], color='red') \n\n\nA: Assuming that you have all points (latitudes and longitudes) in two lists LATS, LONGS respectively, this python snippet cand do the trick. hullPoint will have the set of points that can draw the convex hull. \nimport numpy as np\nfrom scipy.spatial import ConvexHull\nallPoints=np.column_stack((LATS,LONGS))\nhullPoints = ConvexHull(allPoints)\n\n\nA: Use Concave hull (Alpha shape) instead.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 193,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910656\",\n \"question_score\": \"7\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44685052\"\n}"}}},{"rowIdx":1709190,"cells":{"id":{"kind":"string","value":"6cfe54cc854af536ba2d991397998d237326292a"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Can I combine {% include %} with custom filter in django 1.11? First I have created custom filter that makes autoindentation:\ntemplatetags/indent.py\nfrom django import template\nfrom django.template.defaultfilters import stringfilter\n\nregister = template.Library()\n\n@register.filter(name='indent')\n@stringfilter\ndef indent(value, arg):\n import re\n regex = re.compile('^', re.M)\n return re.sub(regex, ' ' * int(arg), value)\n\nand I want to include subtemplate that will be indented by certain number of spaces (eg. 8):\nIs this allowed in django's templates:\n{% load indent %}\n\n{% include \"footer.html\"|indent:\"8\" %}\n\n\nA: I think you do can do it by using filter:\n{% load indent %}\n\n{% filter indent:\"8\" %}\n {% include \"footer.html\" %}\n{% endfilter %}\n\n"},"original_text":{"kind":"string","value":"Q: Can I combine {% include %} with custom filter in django 1.11? First I have created custom filter that makes autoindentation:\ntemplatetags/indent.py\nfrom django import template\nfrom django.template.defaultfilters import stringfilter\n\nregister = template.Library()\n\n@register.filter(name='indent')\n@stringfilter\ndef indent(value, arg):\n import re\n regex = re.compile('^', re.M)\n return re.sub(regex, ' ' * int(arg), value)\n\nand I want to include subtemplate that will be indented by certain number of spaces (eg. 8):\nIs this allowed in django's templates:\n{% load indent %}\n\n{% include \"footer.html\"|indent:\"8\" %}\n\n\nA: I think you do can do it by using filter:\n{% load indent %}\n\n{% filter indent:\"8\" %}\n {% include \"footer.html\" %}\n{% endfilter %}\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 109,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910682\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44685126\"\n}"}}},{"rowIdx":1709191,"cells":{"id":{"kind":"string","value":"a6aade42d9b3dda6dd110edaa1ad7f85d4b1cb32"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Ansible password_hash with variable I am writing a simple task to create a user. As part of this task, I want to read the password from defaults/main.yml\ndefaults/main.yml\ntest_user: testuser\ntest_group: testgroup\ntest_user_password: somepassword\n\nmy tasks file is as below\n- name: \"Creating Group for testuser\"\n group:\n name: \"{{ test_group }}\"\n state: present\n\n- name: \"Creating testuser\"\n user:\n name: \"{{ test_user }}\"\n password: \"{{ [test_user_password] | password_hash('sha512') }}\"\n shell: /bin/ksh\n group: \"{{ test_group }}\"\n update_password: on_create\n\nThis gives me a unexpected templating error. How can I read the password from main.yml and use it inside the password filter?\n\nA: In the Creating testuser task remove the square brackets around test_user_password. When a variable is referenced in Ansible it has to be enclosed with {{}}.\n- hosts: localhost\n remote_user: user\n become: yes\n\n vars:\n test_user: testuser\n test_group: testgroup\n test_user_password: somepassword\n\n tasks:\n - name: Creating Group for testuser\n group:\n name: \"{{ test_group }}\"\n state: present\n\n - name: Creating testuser\n user:\n name: \"{{ test_user }}\"\n password: \"{{ test_user_password | password_hash('sha512') }}\"\n shell: /bin/bash\n group: \"{{ test_group }}\"\n update_password: on_create\n\n"},"original_text":{"kind":"string","value":"Q: Ansible password_hash with variable I am writing a simple task to create a user. As part of this task, I want to read the password from defaults/main.yml\ndefaults/main.yml\ntest_user: testuser\ntest_group: testgroup\ntest_user_password: somepassword\n\nmy tasks file is as below\n- name: \"Creating Group for testuser\"\n group:\n name: \"{{ test_group }}\"\n state: present\n\n- name: \"Creating testuser\"\n user:\n name: \"{{ test_user }}\"\n password: \"{{ [test_user_password] | password_hash('sha512') }}\"\n shell: /bin/ksh\n group: \"{{ test_group }}\"\n update_password: on_create\n\nThis gives me a unexpected templating error. How can I read the password from main.yml and use it inside the password filter?\n\nA: In the Creating testuser task remove the square brackets around test_user_password. When a variable is referenced in Ansible it has to be enclosed with {{}}.\n- hosts: localhost\n remote_user: user\n become: yes\n\n vars:\n test_user: testuser\n test_group: testgroup\n test_user_password: somepassword\n\n tasks:\n - name: Creating Group for testuser\n group:\n name: \"{{ test_group }}\"\n state: present\n\n - name: Creating testuser\n user:\n name: \"{{ test_user }}\"\n password: \"{{ test_user_password | password_hash('sha512') }}\"\n shell: /bin/bash\n group: \"{{ test_group }}\"\n update_password: on_create\n\n\nA: Take into account that given task will always be marked as \"changed\" meaning that it is not idempotent. To avoid this behaviour you can add salt as a second parameter to password_hash function, like this:\n- name: Creating testuser\n user:\n name: \"{{ test_user }}\"\n password: \"{{ test_user_password | password_hash('sha512', test_user_salt) }}\"\n shell: /bin/bash\n group: \"{{ test_group }}\"\n update_password: on_create\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 236,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910689\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44685150\"\n}"}}},{"rowIdx":1709192,"cells":{"id":{"kind":"string","value":"d0898c8d41dd87537f100622d5eacdc900111039"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Error installing and using laravel mix I want to install Mix in laravel . I run \"npm install --no-bin-links\" in my IDE terminal or in CMD but I get this error: (my laravel version is 5.4.27)\nD:\\wamp64\\www\\laravelProject>npm install --no-bin-links\nnpm WARN deprecated node-uuid@1.4.8: Use uuid module instead\nnpm ERR! Windows_NT 6.3.9600\nnpm ERR! argv \"D:\\Program Files\\nodejs\\node.exe\" \"D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\" \"install\" \"--no-bin-links\"\nnpm ERR! node v6.11.0\nnpm ERR! npm v3.10.10\nnpm ERR! Maximum call stack size exceeded\nnpm ERR!\nnpm ERR! If you need help, you may report this error at:\nnpm ERR! https://github.com/npm/npm/issues\nnpm ERR! Please include the following file with any support request:\nnpm ERR! D:\\wamp64\\www\\laravelProject\\npm-debug.log\n\nA: I found!!\nI remove node-modules then removed package-lock.json and ran \n"},"original_text":{"kind":"string","value":"Q: Error installing and using laravel mix I want to install Mix in laravel . I run \"npm install --no-bin-links\" in my IDE terminal or in CMD but I get this error: (my laravel version is 5.4.27)\nD:\\wamp64\\www\\laravelProject>npm install --no-bin-links\nnpm WARN deprecated node-uuid@1.4.8: Use uuid module instead\nnpm ERR! Windows_NT 6.3.9600\nnpm ERR! argv \"D:\\Program Files\\nodejs\\node.exe\" \"D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\" \"install\" \"--no-bin-links\"\nnpm ERR! node v6.11.0\nnpm ERR! npm v3.10.10\nnpm ERR! Maximum call stack size exceeded\nnpm ERR!\nnpm ERR! If you need help, you may report this error at:\nnpm ERR! https://github.com/npm/npm/issues\nnpm ERR! Please include the following file with any support request:\nnpm ERR! D:\\wamp64\\www\\laravelProject\\npm-debug.log\n\nA: I found!!\nI remove node-modules then removed package-lock.json and ran \n\nA: The following command helped me too:\nnpm cache clean --force\nAlso, you might need to add sudo in linux.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 138,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910700\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44685191\"\n}"}}},{"rowIdx":1709193,"cells":{"id":{"kind":"string","value":"2025f0725f6a186a52afa0dc7d2caefa9e0e8fbc"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Will go test code only referenced in test files be compiled into the binary? I am wondering what code will be compiled into the go binary if you compile a binary using go build ./... . This will compile a binary that has a cli program. For this cli program, I have test code and non test code. I currently have several flavours of test code:\n\n\n*\n\n*foo_test.go in package foo_test\n\n*foo_internal_test.go in package foo\n\n*testutil.go in package testutil that provides test utility functions\n\n\nNo test code is actually referenced in the non test code. The testutil functions are only imported in the test files. \nIf the test code is infact compiled into the binary , how much of a problem is this?\n\nA: I believe that if you have an init() function in an otherwise unreachable file, it will still be linked into the executable.\n_test.go files would be still excluded.\nThis bit us when we had some test helper code that was not in _test files. One had an init() function which ran on the executable startup.\n"},"original_text":{"kind":"string","value":"Q: Will go test code only referenced in test files be compiled into the binary? I am wondering what code will be compiled into the go binary if you compile a binary using go build ./... . This will compile a binary that has a cli program. For this cli program, I have test code and non test code. I currently have several flavours of test code:\n\n\n*\n\n*foo_test.go in package foo_test\n\n*foo_internal_test.go in package foo\n\n*testutil.go in package testutil that provides test utility functions\n\n\nNo test code is actually referenced in the non test code. The testutil functions are only imported in the test files. \nIf the test code is infact compiled into the binary , how much of a problem is this?\n\nA: I believe that if you have an init() function in an otherwise unreachable file, it will still be linked into the executable.\n_test.go files would be still excluded.\nThis bit us when we had some test helper code that was not in _test files. One had an init() function which ran on the executable startup.\n\nA: A go binary only includes code reachable from its main() entry point. For test binaries main() is the test runner.\nAs to \"how much of a problem\" it is if it were included... none. It would increase the binary size and compilation time somewhat but otherwise have no impact - code that isn't executed, by definition, does nothing.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 239,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910704\",\n \"question_score\": \"10\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44685206\"\n}"}}},{"rowIdx":1709194,"cells":{"id":{"kind":"string","value":"0ada06c1d3a029dc7b1434db1dbe6dcc99957806"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How can i sort semantic versions in pandas? I have a list of software releases as versions. The software follows the semantic version specification, meaning there is a major version, a minor version and patch versions:\n\n\n*\n\n*0.1\n\n*0.2\n\n*0.2.1\n\n*0.3\n\n*...\n\n*0.10\n\n*0.10.1\n\n\nIs there a way in pandas to sort these versions so that 0.2 is bigger than 0.1 but smaller than 0.10?\n\nA: You can use the standard distutils for this!\nfrom distutils.version import StrictVersion\nversions = ['0.1', '0.10', '0.2.1', '0.2', '0.10.1']\nversions.sort(key=StrictVersion)\n\nNow it's sorted like this: ['0.1', '0.2', '0.2.1', '0.10', '0.10.1']\nSource\n"},"original_text":{"kind":"string","value":"Q: How can i sort semantic versions in pandas? I have a list of software releases as versions. The software follows the semantic version specification, meaning there is a major version, a minor version and patch versions:\n\n\n*\n\n*0.1\n\n*0.2\n\n*0.2.1\n\n*0.3\n\n*...\n\n*0.10\n\n*0.10.1\n\n\nIs there a way in pandas to sort these versions so that 0.2 is bigger than 0.1 but smaller than 0.10?\n\nA: You can use the standard distutils for this!\nfrom distutils.version import StrictVersion\nversions = ['0.1', '0.10', '0.2.1', '0.2', '0.10.1']\nversions.sort(key=StrictVersion)\n\nNow it's sorted like this: ['0.1', '0.2', '0.2.1', '0.10', '0.10.1']\nSource\n\nA: Pandas solution with sorted, StrictVersion solution and assign to column:\nprint (df)\n ver\n0 0.1\n1 0.2\n2 0.10\n3 0.2.1\n4 0.3\n5 0.10.1\n\nfrom distutils.version import StrictVersion\n\ndf['ver'] = sorted(df['ver'], key=StrictVersion)\nprint (df)\n ver\n0 0.1\n1 0.2\n2 0.2.1\n3 0.3\n4 0.10\n5 0.10.1\n\nEDIT:\nFor sort index is possible use reindex: \nprint (df)\n a b\nver \n0.1 1 q\n0.2 2 w\n0.10 3 e\n0.2.1 4 r\n0.3 5 t\n0.10.1 6 y\n\nfrom distutils.version import StrictVersion\n\ndf = df.reindex(index=pd.Index(sorted(df.index, key=StrictVersion)))\nprint (df)\n a b\n0.1 1 q\n0.2 2 w\n0.2.1 4 r\n0.3 5 t\n0.10 3 e\n0.10.1 6 y\n\n\nA: Those work fine if your values are unique, but here is the best solution that I've found for columns of semantic values that might have duplication.\nimport pandas as pd\nfrom distutils.version import StrictVersion \n\nunique_sorted_versions = sorted(set(df['Version']), key=StrictVersion)\n\ngroups = [df[df['Version'].isin([version])]\n for version in unique_sorted_versions]\n\nnew_df = pd.concat(groups)\n\n\nA: I come across this problem too, after googling a lot (the first page I find is this SO question :D), I suppose my solution is worth to mention.\nSo for now there is two sort functions in pandas, sort_values and sort_index, neither of them have a key parameter for us to pass a custom sort function to it. See this github issue.\njezrael's answer is very helpful and I'll build my solution based on that.\ndf['ver'] = sorted(df['ver'], key=StrictVersion) is useful only if the verion column is the single column in the DataFrame, otherwise we need to sort the other columns following the version column.\njezrael reindex the DataFrame, because the wanted index order can be obtained by the buitin sorted function, who does have a key parameter.\nBut, what if the version is not the index and I don't want to set_index('ver')?\nWe can use apply to map the original version string to a StrictVersion object, then sort_values will sort in the wanted order:\nfrom distutils.version import StrictVersion\ndf['ver'] = df['ver'].apply(StrictVersion)\ndf.sort_values(by='ver')\n\n\nA: You can come up with something like that:\nfor module, versions in result.items():\n result[module] = sorted(\n versions, key=lambda x: mixutil.SemVersion(x.version), reverse=True\n )\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 454,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:910708\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44685219\"\n}"}}},{"rowIdx":1709195,"cells":{"id":{"kind":"string","value":"6959f67ed2bba200a5e5c21135940f9959100b21"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: React Native - Can't place icon on top of image I'm trying to place an icon over an image, but all it's doing is pushing the image down the page.\nHere's what it currently looks like:\n\nI'm trying to place the blue back arrow on top of that image as you can see. \nHere's what my markup looks like:\n\n \n \n \n \n \n \n \n ...\n\nAnd here are my styles:\ncontainer: {\n backgroundColor: '#f9f9f9',\n flex: 1,\n},\n\ncoverImageContainer: {\n backgroundColor: '#000',\n},\n\ncoverImage: {\n width: null,\n height: 170,\n resizeMode: 'cover',\n opacity: 0.7,\n flex: 1,\n},\n\nWhat am I doing wrong?\nIf I get rid of the icon, the image displays how I want it to, but I would like the back button icon on top of it too. Here's what it looks like without the icon:\n\n\nA: Position Icon component absolutely.\n\n\n"},"original_text":{"kind":"string","value":"Q: React Native - Can't place icon on top of image I'm trying to place an icon over an image, but all it's doing is pushing the image down the page.\nHere's what it currently looks like:\n\nI'm trying to place the blue back arrow on top of that image as you can see. \nHere's what my markup looks like:\n\n \n \n \n \n \n \n \n ...\n\nAnd here are my styles:\ncontainer: {\n backgroundColor: '#f9f9f9',\n flex: 1,\n},\n\ncoverImageContainer: {\n backgroundColor: '#000',\n},\n\ncoverImage: {\n width: null,\n height: 170,\n resizeMode: 'cover',\n opacity: 0.7,\n flex: 1,\n},\n\nWhat am I doing wrong?\nIf I get rid of the icon, the image displays how I want it to, but I would like the back button icon on top of it too. Here's what it looks like without the icon:\n\n\nA: Position Icon component absolutely.\n\n\n\nA: The StatusBar is always visible, even if you use position:'absolute'; zIndex: 99999 on back button, the are 2 ways:\n\n\n*\n\n*Remove status bar by adding