{ // 获取包含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"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 210,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865500\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544369\"\n}"}}},{"rowIdx":1706741,"cells":{"id":{"kind":"string","value":"1f2c5ebbd21627e06b1028137b33717aa4bedee8"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Redundant use of distinct in group by? I'm reviewing some SQL queries in SAS and I encountered the following query structure:\nSELECT distinct A, B, Sum(C) FROM Table1 GROUP BY A, B;\n\nI would like to know if it's strictly equivalent to:\nSELECT A, B, Sum(C) FROM Table1 GROUP BY A, B;\n\nOr if I'm missing a nuance, in the output or the way the computation is handled\n\nA: The two queries are equivalent.\nGenerally,\nSELECT DISTINCT a, b, c\nFROM \n\nis equivalent to\nSELECT a, b, c\nFROM \nGROUP BY a, b, c\n\nIn your case, happens to be a result of GROUP BY query, which has distinct columns A and B. This is enough to ensure that triples A, B, SUM(C) are going to be unique as well.\n"},"original_text":{"kind":"string","value":"Q: Redundant use of distinct in group by? I'm reviewing some SQL queries in SAS and I encountered the following query structure:\nSELECT distinct A, B, Sum(C) FROM Table1 GROUP BY A, B;\n\nI would like to know if it's strictly equivalent to:\nSELECT A, B, Sum(C) FROM Table1 GROUP BY A, B;\n\nOr if I'm missing a nuance, in the output or the way the computation is handled\n\nA: The two queries are equivalent.\nGenerally,\nSELECT DISTINCT a, b, c\nFROM \n\nis equivalent to\nSELECT a, b, c\nFROM \nGROUP BY a, b, c\n\nIn your case, happens to be a result of GROUP BY query, which has distinct columns A and B. This is enough to ensure that triples A, B, SUM(C) are going to be unique as well.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 134,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865555\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544535\"\n}"}}},{"rowIdx":1706742,"cells":{"id":{"kind":"string","value":"e79cb2cefce9746ca07f9e823f1abbdce059e924"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: 64 bit Random number value in hex gives 16 characters sometimes 15 characters why? I have scenario in the application where I need to generate an ID which should be Random 64 bit value in hex representation,\nWhat I have done so far,\n Random randomLong = new Random();\n long m = randomLong.nextLong();\n String uid = Long.toHexString(m);\n\nThe o/p could be like 43c45c243f90326a or 82cf8e3863102f3a etc.\nBut not every time it gives 16 character, but 15 characters instead I don't get why :( \nWhat is the most efficient way to get Random 64 bit value in hex representation which contains 16 characters \n\nA: Use String.format()\nlong value=123L;\nString uid = String.format(\"%016x\", value);\n// 000000000000007b\n\nA word of explanation:\nEach hex digit represents 4-bits. A 64-bit long can be represented by 16 (64/4) hexadecimal characters. To include the leading zeros, you want 16 hex digits. So your format specifier is %016x. Basically, %x for hex modified by inserting 016 to left-pad with zeros to achieve a minimum width of 16 characters.\n"},"original_text":{"kind":"string","value":"Q: 64 bit Random number value in hex gives 16 characters sometimes 15 characters why? I have scenario in the application where I need to generate an ID which should be Random 64 bit value in hex representation,\nWhat I have done so far,\n Random randomLong = new Random();\n long m = randomLong.nextLong();\n String uid = Long.toHexString(m);\n\nThe o/p could be like 43c45c243f90326a or 82cf8e3863102f3a etc.\nBut not every time it gives 16 character, but 15 characters instead I don't get why :( \nWhat is the most efficient way to get Random 64 bit value in hex representation which contains 16 characters \n\nA: Use String.format()\nlong value=123L;\nString uid = String.format(\"%016x\", value);\n// 000000000000007b\n\nA word of explanation:\nEach hex digit represents 4-bits. A 64-bit long can be represented by 16 (64/4) hexadecimal characters. To include the leading zeros, you want 16 hex digits. So your format specifier is %016x. Basically, %x for hex modified by inserting 016 to left-pad with zeros to achieve a minimum width of 16 characters.\n\nA: this is because the method toHExString is not adding leading zeros to the random number you are converting, if the number can be represented with only one char as hex, then one char is what you get \nsee this\n String uid = Long.toHexString(-1L);\n String uid2 = Long.toHexString(1L);\n System.out.println(uid);\n System.out.println(uid2);\n\nthe output is \n\nffffffffffffffff\n1\n\n-1 will require the 64 bits to be represented but 1 doesnt\nedit: \nif you always need 16 nibbles then format that string in order to add the missing zeros\n String uid = String.format(\"%016x\", Long.toHexString(1L)); \n\n\nA: String.format(\"%016x\", uid);\n\nThis will add the leading 0's, or 'padding'\nas if the hex number is smaller than filling all 16, it wont show 16 digits.\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 287,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865557\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544541\"\n}"}}},{"rowIdx":1706743,"cells":{"id":{"kind":"string","value":"0ad29157c2a0306109a8aeb81d0b72795c2e8ab3"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: react-native-video can't display HLS stream on Android I'm using Android device to push a video stream with RTMP to SRS. In SRS I use HLS to deliver the stream.Then I use react-native-video to fetch the stream,but it is in white,it can't display the stream.\nSRS logs show react-native-video had fetched the stream.The react-native-video onError logs\n\n{ error: { extra: -22, what: 1 } } \n\nHowever, when I put a video in SRS in advance,react-native-video can display the stream well.\nI'm sure the pushed stream encoded in the right video/audio codec.\n"},"original_text":{"kind":"string","value":"Q: react-native-video can't display HLS stream on Android I'm using Android device to push a video stream with RTMP to SRS. In SRS I use HLS to deliver the stream.Then I use react-native-video to fetch the stream,but it is in white,it can't display the stream.\nSRS logs show react-native-video had fetched the stream.The react-native-video onError logs\n\n{ error: { extra: -22, what: 1 } } \n\nHowever, when I put a video in SRS in advance,react-native-video can display the stream well.\nI'm sure the pushed stream encoded in the right video/audio codec.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 91,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865564\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544566\"\n}"}}},{"rowIdx":1706744,"cells":{"id":{"kind":"string","value":"ba92a82a1d48791ff2d0a9e1e1a33850ee60dde1"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Remove row if any column contains a specific string I am trying to figure out the best approach in R to remove rows that contain a specific string, in my case 'no_data'.\nI have data from an outside source that imputes na's with 'no_data'\nan example is this:\n time |speed |wheels\n1:00 |30 |no_data\n2:00 |no_data|18\nno_data|no_data|no_data\n3:00 |50 |18\n\nI want to go through the data and remove each row containing this 'no_data' string in any column. I have had a lot of trouble figuring this out. I have tried an sapply, filter, grep and combinations of the three. I am by no means an r expert so it could just be me incorrectly using these. Any help would be appreciated.\n\nA: You can read the data using na.strings = 'no_data' to set them as NA and then simply omit NAs (or take complete.cases), i.e. (Using @akrun's data set)\nd1 <- read.table(text = 'time speed wheels\n 1 1:00 30 no_data\n 2 2:00 no_data 18\n 3 no_data no_data no_data\n 4 3:00 50 18', na.strings = 'no_data', h=TRUE)\n\nd1[complete.cases(d1),]\n# time speed wheels\n#4 3:00 50 18\n\n#OR\n\nna.omit(d1)\n# time speed wheels\n#4 3:00 50 18\n\n"},"original_text":{"kind":"string","value":"Q: Remove row if any column contains a specific string I am trying to figure out the best approach in R to remove rows that contain a specific string, in my case 'no_data'.\nI have data from an outside source that imputes na's with 'no_data'\nan example is this:\n time |speed |wheels\n1:00 |30 |no_data\n2:00 |no_data|18\nno_data|no_data|no_data\n3:00 |50 |18\n\nI want to go through the data and remove each row containing this 'no_data' string in any column. I have had a lot of trouble figuring this out. I have tried an sapply, filter, grep and combinations of the three. I am by no means an r expert so it could just be me incorrectly using these. Any help would be appreciated.\n\nA: You can read the data using na.strings = 'no_data' to set them as NA and then simply omit NAs (or take complete.cases), i.e. (Using @akrun's data set)\nd1 <- read.table(text = 'time speed wheels\n 1 1:00 30 no_data\n 2 2:00 no_data 18\n 3 no_data no_data no_data\n 4 3:00 50 18', na.strings = 'no_data', h=TRUE)\n\nd1[complete.cases(d1),]\n# time speed wheels\n#4 3:00 50 18\n\n#OR\n\nna.omit(d1)\n# time speed wheels\n#4 3:00 50 18\n\n\nA: edit update to the filter(if_all/if_any) syntax (dplyr vs. 1.0.10), formerly using across (now deprecated) and even before that filter_all or filter_any (superseded).\nHere a dplyr option: (using Akrun's data)\nlibrary(dplyr)\n\ndf1 <- structure(list(time = c(\"1:00\", \"2:00\", \"no_data\", \"3:00\"), speed = c(\"30\", \"no_data\", \"no_data\", \"50\"), wheels = c(\"no_data\", \"18\", \"no_data\", \"18\")), .Names = c(\"time\", \"speed\", \"wheels\"), class = \"data.frame\", row.names = c(NA, -4L))\n\n## with if_any\ndf1 %>% filter(if_any(everything(), ~ grepl(\"no_data\", .)))\n#> time speed wheels\n#> 1 1:00 30 no_data\n#> 2 2:00 no_data 18\n#> 3 no_data no_data no_data\n\n## or with if_all\ndf1 %>% filter(if_all(everything(), ~ !grepl(\"no_data\", .)))\n#> time speed wheels\n#> 1 3:00 50 18\n\n## to GET all rows that fulfil condition, use\ndf1 %>% filter(if_any(everything(), ~ grepl(\"no_data\", .)))\n#> time speed wheels\n#> 1 1:00 30 no_data\n#> 2 2:00 no_data 18\n#> 3 no_data no_data no_data\n\n\nA: akrun answer is quick, correct and simply as much is it can :)\nhowever if you like to make your life more complex you can also do:\ndat\n time speed wheels\n1 1:00 30 no_data\n2 2:00 no_data 18\n3 no_data no_data no_data\n4 3:00 50 18\n\ndat$new <- apply(dat[,1:3], 1, function(x) any(x %in% c(\"no_data\")))\ndat <- dat[!(dat$new==TRUE),]\ndat$new <- NULL\n\ndat\n time speed wheels\n4 3:00 50 18\n\n\nA: We can use rowSums to create a logical vector and subset based on it\ndf1[rowSums(df1 == \"no_data\")==0, , drop = FALSE]\n# time speed wheels\n#4 3:00 50 18\n\ndata\ndf1 <- structure(list(time = c(\"1:00\", \"2:00\", \"no_data\", \"3:00\"), speed = c(\"30\", \n\"no_data\", \"no_data\", \"50\"), wheels = c(\"no_data\", \"18\", \"no_data\", \n\"18\")), .Names = c(\"time\", \"speed\", \"wheels\"), class = \"data.frame\", \nrow.names = c(NA, -4L))\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 474,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865571\",\n \"question_score\": \"14\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544596\"\n}"}}},{"rowIdx":1706745,"cells":{"id":{"kind":"string","value":"6cfba4f7e375dba3d69503142c866793cb961002"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Remove ToastNotification from ActionCenter I have a desktop application running in Windows 10 which creates ToastNotifications that are also being stored in the Action Center. I noticed, that when I reboot the computer the Notifications are still present in the Action Center so I wanted to remove them through my Application when they're not necessary anymore.\nI wanted to use the ToastNotificationHistory Remove method for this.\nMy code looks like this: \npublic static void RemoveNotificationByTag(string toastTag)\n{\n ToastNotificationManager.History.Remove(toastTag, \"TEST\");\n}\n\nBut this leads to this exception: System.Exception: 'Element not found. (Exception from HRESULT: 0x80070490)' \nThe notification I've been sending priorly has a Tag and a Group value. \nI get the same exception when calling the RemoveGroup or GetHistory method. Basically it seems like I cannot call any method from the History class without getting the same exception\n\nA: On Windows 10 it is necessary to provide the applicationId parameter to each of the methods. Also you must specify not only a toast tag, but its group as well.\nCalling the method like this works:\nToastNotificationManager.History.Remove(toastTag, \"TEST\", appId);\n\n"},"original_text":{"kind":"string","value":"Q: Remove ToastNotification from ActionCenter I have a desktop application running in Windows 10 which creates ToastNotifications that are also being stored in the Action Center. I noticed, that when I reboot the computer the Notifications are still present in the Action Center so I wanted to remove them through my Application when they're not necessary anymore.\nI wanted to use the ToastNotificationHistory Remove method for this.\nMy code looks like this: \npublic static void RemoveNotificationByTag(string toastTag)\n{\n ToastNotificationManager.History.Remove(toastTag, \"TEST\");\n}\n\nBut this leads to this exception: System.Exception: 'Element not found. (Exception from HRESULT: 0x80070490)' \nThe notification I've been sending priorly has a Tag and a Group value. \nI get the same exception when calling the RemoveGroup or GetHistory method. Basically it seems like I cannot call any method from the History class without getting the same exception\n\nA: On Windows 10 it is necessary to provide the applicationId parameter to each of the methods. Also you must specify not only a toast tag, but its group as well.\nCalling the method like this works:\nToastNotificationManager.History.Remove(toastTag, \"TEST\", appId);\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 178,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865582\",\n \"question_score\": \"5\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544624\"\n}"}}},{"rowIdx":1706746,"cells":{"id":{"kind":"string","value":"483359f190682ad59141ad72e039414dc2e01e6b"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: ionic using get previous page name I am using ionic 2.\nI need get previous page name.\nhere is my code.\n @ViewChild(Nav) nav:Nav\n constructor() {\n this.nav_app.viewDidEnter.subscribe(\n view => console.log(\"Current opened view is : \" + view.name);\n )\n }\n\nstill i am getting \nCurrent opened view is : t\n\nHow can i get previous page name.\nKindly advice me,\nThanks\n\nA: In ionic +2 you can simply use:\nthis.navCtrl.last().name\n\nHere is a simple example to log the name\nconstructor(public navCtrl:NavController){\n console.log(\"Previous Page is called = \" + this.navCtrl.last().name);\n}\n\n"},"original_text":{"kind":"string","value":"Q: ionic using get previous page name I am using ionic 2.\nI need get previous page name.\nhere is my code.\n @ViewChild(Nav) nav:Nav\n constructor() {\n this.nav_app.viewDidEnter.subscribe(\n view => console.log(\"Current opened view is : \" + view.name);\n )\n }\n\nstill i am getting \nCurrent opened view is : t\n\nHow can i get previous page name.\nKindly advice me,\nThanks\n\nA: In ionic +2 you can simply use:\nthis.navCtrl.last().name\n\nHere is a simple example to log the name\nconstructor(public navCtrl:NavController){\n console.log(\"Previous Page is called = \" + this.navCtrl.last().name);\n}\n\n\nA: You can try\nimport { Component, ViewChild } from '@angular/core';\nimport { NavController } from 'ionic-angular';\nexport class MyApp {\n\n constructor(public navCtrl:NavController){\n var val=this.navCtrl.last();\n console.log(\"VAL\");\n console.log(val);\n }\n}\n\n\nA: if you want a history/previous page name in ionic you can use this.\n\nthis.navCtrl.getPrevious().name;\n\nor\n\nthis.nav.getPrevious().name;\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 135,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865586\",\n \"question_score\": \"8\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544646\"\n}"}}},{"rowIdx":1706747,"cells":{"id":{"kind":"string","value":"afe7dbc68f92030f383e756651806f1cbdeda84f"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: SourceTree Error: 'git status' failed with code 128: error: inflate: data stream error (incorrect header check) \n$ git fsck --full\nerror: inflate: data stream error (incorrect header check)\nerror: unable to unpack 06c147f2771e280dfb4758c9a83b94346993d172 header\nerror: inflate: data stream error (incorrect header check)\nfatal: loose object 06c147f2771e280dfb4758c9a83b94346993d172 (stored in .git/objects/06/c147f2771e280dfb4758c9a83b94346993d172) is corrupt\n\nalso, try this, and remove the all corrupted objects. after removing objects i write this command,\n$ git reset --hard\nerror: unable to read sha1 file of 3X/3X.Core/Resources/Resource.Designer.cs (d46f74436ae02ec61a659a8a487aee5747e2feda)\nerror: unable to read sha1 file of 3X/3X.Core/Resources/Resource.resx (63342162564404ccae4917489dc78ebb65075f8a)\nerror: unable to read sha1 file of 3X/3X.Web/Views/Job/ConfirmationAdvice.cshtml (ff39e42f5cf0e0703bd9dfe84a4b746ff91eea40)\nerror: unable to read sha1 file of 3X/3X.Web/Views/Job/Create.cshtml (3a97827faac6c62fd24f347dd0b0951c27c03751)\nerror: unable to read sha1 file of 3X/3X.Web/Views/Job/DataEntry.cshtml (89f381bafaeff53eeaf64a26d8c9608e9e86b6a1)\nerror: unable to read sha1 file of 3X/3X.Web/wwwroot/js/viewjs/Job/create.js (1b62c618c31add2ca28d107c1a49604492409ecf)\nfatal: Could not reset index file to revision 'HEAD'.\n\nand got above error\n\nA: Try with removing your index file which is in .git folder\nWindows System:\ndel .git\\index\ngit reset\n\nLinux System:\nrm -f .git/index\ngit reset\n\nAnd if you have deleted index file manually then you need to do \ngit reset\n\n"},"original_text":{"kind":"string","value":"Q: SourceTree Error: 'git status' failed with code 128: error: inflate: data stream error (incorrect header check) \n$ git fsck --full\nerror: inflate: data stream error (incorrect header check)\nerror: unable to unpack 06c147f2771e280dfb4758c9a83b94346993d172 header\nerror: inflate: data stream error (incorrect header check)\nfatal: loose object 06c147f2771e280dfb4758c9a83b94346993d172 (stored in .git/objects/06/c147f2771e280dfb4758c9a83b94346993d172) is corrupt\n\nalso, try this, and remove the all corrupted objects. after removing objects i write this command,\n$ git reset --hard\nerror: unable to read sha1 file of 3X/3X.Core/Resources/Resource.Designer.cs (d46f74436ae02ec61a659a8a487aee5747e2feda)\nerror: unable to read sha1 file of 3X/3X.Core/Resources/Resource.resx (63342162564404ccae4917489dc78ebb65075f8a)\nerror: unable to read sha1 file of 3X/3X.Web/Views/Job/ConfirmationAdvice.cshtml (ff39e42f5cf0e0703bd9dfe84a4b746ff91eea40)\nerror: unable to read sha1 file of 3X/3X.Web/Views/Job/Create.cshtml (3a97827faac6c62fd24f347dd0b0951c27c03751)\nerror: unable to read sha1 file of 3X/3X.Web/Views/Job/DataEntry.cshtml (89f381bafaeff53eeaf64a26d8c9608e9e86b6a1)\nerror: unable to read sha1 file of 3X/3X.Web/wwwroot/js/viewjs/Job/create.js (1b62c618c31add2ca28d107c1a49604492409ecf)\nfatal: Could not reset index file to revision 'HEAD'.\n\nand got above error\n\nA: Try with removing your index file which is in .git folder\nWindows System:\ndel .git\\index\ngit reset\n\nLinux System:\nrm -f .git/index\ngit reset\n\nAnd if you have deleted index file manually then you need to do \ngit reset\n\n\nA: It should be corrupted. Try removing this .git/objects/06/c147f2771e280dfb4758c9a83b94346993d172\nIf you are getting same error with another object try removing all those and fetch again.\n\nA: Here is the solution that worked for me\ni opened my server and went to .git/ and downloaded index file from there then deleted the local .git/index file manually and replace the file with the downloaded index file\n\nA: Tried all answers and none worked with me.\nFinally figured out that the problem is that you have probably configured your Source Tree repo to be located at repo_local_url/.git\nThe solution is to make it point at repo_local_url instead\n\nA: I got this issue because I accidentally removed the git/objects folder. When I restored it from the Recycle Bin it worked again.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 306,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865598\",\n \"question_score\": \"6\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544688\"\n}"}}},{"rowIdx":1706748,"cells":{"id":{"kind":"string","value":"b9ecbd57f5aceed58f76e0e126b3553b7cc6587b"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Python PPTX workaround function for rotating chart data labels I intend to create the following chart using Python PPTX.\nBelow code achieve the color setting, font size and number format. However, I am not yet able to rotate the data label, as I believe this API is not yet available in python-pptx 0.6.5\nlbl = plot.data_labels\nlbl.font.size = config[\"DATA_LABEL_FONT_SIZE\"]\nlbl.font.color.rgb = config[\"DATA_LABEL_FONT_COLOR\"]\nlbl.number_format = config[\"DATA_LABEL_NUMBER_FORMAT\"]\nlbl.position = config[\"DATA_LABEL_POSITION\"]\n\nTo get started, I have created two minimal slides before and after rotating, and use opc-diag tool to find the diff.\n\\n \n\\n \\n\n\nI believe I need to add rot=\"-5400000\" XML element to lbl (plot.data_labels), but not clear on how to achieve this. I have used dir(), ._element and .xml on the chart and its children but not able to find tag.\n\nA: I tried below and it works.\nif config[\"DATA_LABEL_VERTICAL\"]:\n txPr = lbl._element.get_or_add_txPr()\n txPr.bodyPr.set('rot','-5400000')\n\n"},"original_text":{"kind":"string","value":"Q: Python PPTX workaround function for rotating chart data labels I intend to create the following chart using Python PPTX.\nBelow code achieve the color setting, font size and number format. However, I am not yet able to rotate the data label, as I believe this API is not yet available in python-pptx 0.6.5\nlbl = plot.data_labels\nlbl.font.size = config[\"DATA_LABEL_FONT_SIZE\"]\nlbl.font.color.rgb = config[\"DATA_LABEL_FONT_COLOR\"]\nlbl.number_format = config[\"DATA_LABEL_NUMBER_FORMAT\"]\nlbl.position = config[\"DATA_LABEL_POSITION\"]\n\nTo get started, I have created two minimal slides before and after rotating, and use opc-diag tool to find the diff.\n\\n \n\\n \\n\n\nI believe I need to add rot=\"-5400000\" XML element to lbl (plot.data_labels), but not clear on how to achieve this. I have used dir(), ._element and .xml on the chart and its children but not able to find tag.\n\nA: I tried below and it works.\nif config[\"DATA_LABEL_VERTICAL\"]:\n txPr = lbl._element.get_or_add_txPr()\n txPr.bodyPr.set('rot','-5400000')\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 157,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865602\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544701\"\n}"}}},{"rowIdx":1706749,"cells":{"id":{"kind":"string","value":"ae745bf6069e7b78147c81eb5c5ea15e66c89427"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Inherit from collections.Counter: 'fromkeys' is abstract I have a python class that inherit from collections.Counter:\nclass Analyzer(collections.Counter):\n pass\n\nWhen I use pylint on this code, its answer is: \n\nW: Method 'fromkeys' is abstract in class 'Counter' but is not overridden (abstract-method)\n\nI checked the implementation of collections.Counter on my machine, and effectively, this method is not implemented (and a comment helps to understand why):\nclass Counter(dict):\n ...\n @classmethod\n def fromkeys(cls, iterable, v=None):\n # There is no equivalent method for counters because setting v=1\n # means that no element can have a count greater than one.\n raise NotImplementedError(\n 'Counter.fromkeys() is undefined. Use Counter(iterable) instead.')\n\nHowever, I don't really know how to implement this method, if Counter itself does not…\nWhat is the way to solve this warning in this situation?\n\nA: This question should answer some of the questions here. Basically, pylint checks for NotImplementedError exceptions being raised to determine whether a method is abstract (a false positive in this case). Adding the comment #pylint: disable=W0223 will disable this check.\nA similar issue is also raised in this question.\n"},"original_text":{"kind":"string","value":"Q: Inherit from collections.Counter: 'fromkeys' is abstract I have a python class that inherit from collections.Counter:\nclass Analyzer(collections.Counter):\n pass\n\nWhen I use pylint on this code, its answer is: \n\nW: Method 'fromkeys' is abstract in class 'Counter' but is not overridden (abstract-method)\n\nI checked the implementation of collections.Counter on my machine, and effectively, this method is not implemented (and a comment helps to understand why):\nclass Counter(dict):\n ...\n @classmethod\n def fromkeys(cls, iterable, v=None):\n # There is no equivalent method for counters because setting v=1\n # means that no element can have a count greater than one.\n raise NotImplementedError(\n 'Counter.fromkeys() is undefined. Use Counter(iterable) instead.')\n\nHowever, I don't really know how to implement this method, if Counter itself does not…\nWhat is the way to solve this warning in this situation?\n\nA: This question should answer some of the questions here. Basically, pylint checks for NotImplementedError exceptions being raised to determine whether a method is abstract (a false positive in this case). Adding the comment #pylint: disable=W0223 will disable this check.\nA similar issue is also raised in this question.\n\nA: There is two separate way of thinking.\n\n\n*\n\n*Consider Counter as abstract (as pylint does, as Jared explained). Then, the class Analyzer must implement fromkeys or also be abstract. But then, one should not be able to instanciate Counter.\n\n*Consider Counter as concrete, even if you cannot use its fromkeys method. Then, pylint's warning must be disabled (as it is wrong in this case, see Jared's answer to kown how), and the class Analyzer is also concrete and does not need to implement this method.\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 265,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865632\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544806\"\n}"}}},{"rowIdx":1706750,"cells":{"id":{"kind":"string","value":"227564b88fcb334acf523ec668a1c39db6a66ef7"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Deprecated FacebookSdk method throws RuntimeException I have FacebookSdk.sdkInitialize(getApplicationContext()) where sdkInitialize() is displayed as deprecated. According to this article we can just delete that line. But then I get following error for the line after AppEventsLogger.activateApp(this) :\nAndroidRuntime: FATAL EXCEPTION: main Process: com.daimler.moovel.android:auth, PID: 4011 java.lang.RuntimeException: Unable to create application com.daimler.moovel.android.DebugApplication: The Facebook sdk must be initialized before calling activateApp at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5879) at android.app.ActivityThread.-wrap3(ActivityThread.java)\nat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)\nat android.os.Handler.dispatchMessage(Handler.java:102)\nat android.os.Looper.loop(Looper.java:154)\nat android.app.ActivityThread.main(ActivityThread.java:6682)\nat java.lang.reflect.Method.invoke(Native Method)\nat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)\nat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)\nCaused by: The Facebook sdk must be initialized before calling activateApp\nat com.facebook.appevents.AppEventsLogger.activateApp(AppEventsLogger.java:226)\nat com.facebook.appevents.AppEventsLogger.activateApp(AppEventsLogger.java:208)\n\nSo what am I missing?\n\nA: No need of AppEventsLogger.activateApp(this); now it is not required if you have set up facebook_id in manifest.xml \nu just have to add following in Application tag in manifest.xml\n \n\nwhere facebook_app_id is defined in string.xml\n"},"original_text":{"kind":"string","value":"Q: Deprecated FacebookSdk method throws RuntimeException I have FacebookSdk.sdkInitialize(getApplicationContext()) where sdkInitialize() is displayed as deprecated. According to this article we can just delete that line. But then I get following error for the line after AppEventsLogger.activateApp(this) :\nAndroidRuntime: FATAL EXCEPTION: main Process: com.daimler.moovel.android:auth, PID: 4011 java.lang.RuntimeException: Unable to create application com.daimler.moovel.android.DebugApplication: The Facebook sdk must be initialized before calling activateApp at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5879) at android.app.ActivityThread.-wrap3(ActivityThread.java)\nat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)\nat android.os.Handler.dispatchMessage(Handler.java:102)\nat android.os.Looper.loop(Looper.java:154)\nat android.app.ActivityThread.main(ActivityThread.java:6682)\nat java.lang.reflect.Method.invoke(Native Method)\nat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)\nat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)\nCaused by: The Facebook sdk must be initialized before calling activateApp\nat com.facebook.appevents.AppEventsLogger.activateApp(AppEventsLogger.java:226)\nat com.facebook.appevents.AppEventsLogger.activateApp(AppEventsLogger.java:208)\n\nSo what am I missing?\n\nA: No need of AppEventsLogger.activateApp(this); now it is not required if you have set up facebook_id in manifest.xml \nu just have to add following in Application tag in manifest.xml\n \n\nwhere facebook_app_id is defined in string.xml\n\nA: That is because you upgraded your Facebook SDK and you are trying to use implemention of AppEventsLogger providinig this as Context:\nAppEventsLogger.activateApp(this);\nand that is replaced from SDK 4.19 and above with: \nAppEventsLogger.activateApp(getApplication());\nDocumentation about this says: \n\nNotifies the events system that the app has launched and activate and deactivate events should start being logged automatically. This should be called from the OnCreate method of you application.\n\nThat have logic if Facebook SDK now is auto initialized on Application start.\nTry that I hope this will solve your problem.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 228,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865652\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544866\"\n}"}}},{"rowIdx":1706751,"cells":{"id":{"kind":"string","value":"3d67bf0ed42cfd0b45b56185dea3cc1475f5abc0"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Read all lines from FileChannel to Stream of strings For my specific task, I need to read the data from FileChannel to a Stream (or Collection) of String's.\nIn a regular NIO for a Path we can use a convenient method Files.lines(...) which returns a Stream. I need to get a same result, but from a FileChannel instead of Path:\npublic static Stream lines(final FileChannel channel) {\n//...\n}\n\nAny ideas how to do that?\n\nA: I assume you want the channel to be closed when the returned Stream is closed, so the simplest approach would be\npublic static Stream lines(FileChannel channel) {\n BufferedReader br = new BufferedReader(Channels.newReader(channel, \"UTF-8\"));\n return br.lines().onClose(() -> {\n try { br.close(); }\n catch (IOException ex) { throw new UncheckedIOException(ex); }\n });\n}\n\nIt doesn’t actually require a FileChannel as input, a ReadableByteChannel is sufficient.\nNote that this also belongs to “regular NIO”; java.nio.file is sometimes referred to as “NIO.2”.\n"},"original_text":{"kind":"string","value":"Q: Read all lines from FileChannel to Stream of strings For my specific task, I need to read the data from FileChannel to a Stream (or Collection) of String's.\nIn a regular NIO for a Path we can use a convenient method Files.lines(...) which returns a Stream. I need to get a same result, but from a FileChannel instead of Path:\npublic static Stream lines(final FileChannel channel) {\n//...\n}\n\nAny ideas how to do that?\n\nA: I assume you want the channel to be closed when the returned Stream is closed, so the simplest approach would be\npublic static Stream lines(FileChannel channel) {\n BufferedReader br = new BufferedReader(Channels.newReader(channel, \"UTF-8\"));\n return br.lines().onClose(() -> {\n try { br.close(); }\n catch (IOException ex) { throw new UncheckedIOException(ex); }\n });\n}\n\nIt doesn’t actually require a FileChannel as input, a ReadableByteChannel is sufficient.\nNote that this also belongs to “regular NIO”; java.nio.file is sometimes referred to as “NIO.2”.\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 155,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865679\",\n \"question_score\": \"11\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544945\"\n}"}}},{"rowIdx":1706752,"cells":{"id":{"kind":"string","value":"ec135cb93997928eaba6c5c056418d2b47d113d2"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to access a method in controller in laravel scheduler? I need to access a method of my UserController in laravel scheduler function,\nprotected function schedule(Schedule $schedule)\n{\n $schedule->command('foo')\n ->hourly();\n}\n\nIs it possible?\n\nA: try his:\n$schedule->call('Full\\Namespace\\YourController@method')\n ->hourly();\n\n"},"original_text":{"kind":"string","value":"Q: How to access a method in controller in laravel scheduler? I need to access a method of my UserController in laravel scheduler function,\nprotected function schedule(Schedule $schedule)\n{\n $schedule->command('foo')\n ->hourly();\n}\n\nIs it possible?\n\nA: try his:\n$schedule->call('Full\\Namespace\\YourController@method')\n ->hourly();\n\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 40,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865689\",\n \"question_score\": \"3\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44544979\"\n}"}}},{"rowIdx":1706753,"cells":{"id":{"kind":"string","value":"63062f2a8c830f257950e78794752dc400471e70"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: docker add \"requires at least one argument\" error I have a folder which contains all the necessary components for an app, which I want to make a container of. I have everything set up so far, with the directory /home/user/Documents/App in the Dockerfile under the ADD heading. Then when Idocker build . in the App directory I get this\n\nADD /home/user/Documents/App\n ADD requires at least one argument\n\nI realize that this is probably a simple fix but I am new to this so any help would be greatly appreciated. Thank you\nFROM alpine\nADD \nWORKDIR /code\nRUN pip install -r requirements.txt\nEXPPOSE 8080\nCMD [\"python\", \"app.py\"]\n\n\nA: You need a source and destination for the ADD command. The source here is the app folder path. The destination should be where you want the dockerfile is run.\nTry this I think it might work\n"},"original_text":{"kind":"string","value":"Q: docker add \"requires at least one argument\" error I have a folder which contains all the necessary components for an app, which I want to make a container of. I have everything set up so far, with the directory /home/user/Documents/App in the Dockerfile under the ADD heading. Then when Idocker build . in the App directory I get this\n\nADD /home/user/Documents/App\n ADD requires at least one argument\n\nI realize that this is probably a simple fix but I am new to this so any help would be greatly appreciated. Thank you\nFROM alpine\nADD \nWORKDIR /code\nRUN pip install -r requirements.txt\nEXPPOSE 8080\nCMD [\"python\", \"app.py\"]\n\n\nA: You need a source and destination for the ADD command. The source here is the app folder path. The destination should be where you want the dockerfile is run.\nTry this I think it might work\n\nA: ADD defined in Dockerfile has the following structure\nADD sourceJarName destinationJarName\n\ne.g.\nADD target/spring-boot-rest-docker-example-0.0.1-SNAPSHOT.jar app.jar\n\nchange your ADD likewise and try it will work\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 171,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865699\",\n \"question_score\": \"4\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44545007\"\n}"}}},{"rowIdx":1706754,"cells":{"id":{"kind":"string","value":"c2933d4ac188fc50cdc62fd17d2b6e383714a4d9"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: Basic FlatList code throws Warning - React Native FlatList does not seem to be working. I get this warning.\nVirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor. \nCode:\n {item.name}\n } \n key={Math.random().toString()} />\n\n\nA: Have an 'id' in your data\nconst data = [\n{\n name: 'a',\n id: 1\n},\n{\n name: 'b',\n id: 2\n}];\n\n {item.name}\n } \n keyExtractor={item => item.id}\n/>\n\nHope this helps !!!\n"},"original_text":{"kind":"string","value":"Q: Basic FlatList code throws Warning - React Native FlatList does not seem to be working. I get this warning.\nVirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor. \nCode:\n {item.name}\n } \n key={Math.random().toString()} />\n\n\nA: Have an 'id' in your data\nconst data = [\n{\n name: 'a',\n id: 1\n},\n{\n name: 'b',\n id: 2\n}];\n\n {item.name}\n } \n keyExtractor={item => item.id}\n/>\n\nHope this helps !!!\n\nA: You don't need to use keyExtractor. The React Native docs are a little unclear but the key property should go in each element of the data array rather than in the rendered child component. So rather than\n }\n/>\n// React will give you a warning about there being no key prop\n\nwhich is what you'd expect, you just need to put a key field in each element of the data array:\n }\n/>\n// React is happy!\n\nAnd definitely don't put a random string as the key.\n\nA: Simply do this:\n {item.name}\n } \n keyExtractor={(item, index) => index.toString()}\n/>\n\nSource: here\n\nA: This did not give any warning (transforming the index to a string):\n index+\"\" }\n renderItem={\n (item) => {item.name}\n } \n/>\n\n\nA: A simple solution is to just give each entry a unique key before rendering with FlatList, since that's what the underlying VirtualizedList needs to track each entry.\n users.forEach((user, i) => {\n user.key = i + 1;\n });\n\nThe warning does advice doing this first, or provide a custom key extractor.\n\nA: this code work for me :\n\n\nconst content = [\r\n {\r\n name: 'Marta',\r\n content: 'Payday in November: Rp. 987.654.321',\r\n },]\r\n \r\n (\r\n \r\n {item.name}\r\n {item.content}\r\n \r\n />\r\n )}\r\n keyExtractor={(item,index) => item.content}\r\n />\n\n\n\nA: This worked for me: \n index.toString()}\n/>\n\n\nA: You can use\n index.toString()} \n />\n\nNOTE : Using index.toString() i.e expected to be string.\n\nA: in case your Data is not an object :\n[in fact it is using each item index (in the array) as a key]\n data: ['name1','name2'] //declared in constructor\n {item}}\n ItemSeparatorComponent={this.renderSeparator}\nkeyExtractor={(item, index) => index.toString()}\n/>\n\n\nA: Tried Ray's answer but then got an warning that \"the key must be an string\". The following modified version works well to suppress the original and this string key warning if you don't have a good unique key on the item itself:\nkeyExtractor={(item, index) => item + index}\n\nOf course if you do have an obvious and good unique key on the item itself you can just use that.\n\nA: Make sure to write return statement otherwise it will return nothing..Happened with me.\n\nA: This worked for me:\n {\n return new Date().getTime().toString() + (Math.floor(Math.random() * Math.floor(new Date().getTime()))).toString(); };\n/>\n\n\nA: This worked for me:\n {title} }}\n keyExtractor={() => Math.random().toString(36).substr(2, 9)} />\n\nTurning the keyExtractor into a string but instead of using index use a random generated number.\nWhen I used keyExtractor={(item, index) => index.toString()}, It never worked and still kicked out a warning. But maybe this works for someone?\n"},"subdomain":{"kind":"string","value":"stackoverflow"},"metadata":{"kind":"string","value":"{\n \"language\": \"en\",\n \"length\": 600,\n \"provenance\": \"stackexchange_0000F.jsonl.gz:865744\",\n \"question_score\": \"161\",\n \"source\": \"stackexchange\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"url\": \"https://stackoverflow.com/questions/44545148\"\n}"}}},{"rowIdx":1706755,"cells":{"id":{"kind":"string","value":"17c66164260b4e5057ae5ae18c7be2a385293421"},"text":{"kind":"string","value":"Stackoverflow Stackexchange\n\nQ: How to add stylesheet dynamically in Angular 2? Is there a way to add stylesheet url or dynamically in Angular2 ? \nFor example, if my variable is isModalOpened is true, I would like to add some CSS to few elements outside my root component. Like the body or html. \nIt's possible to do it with the DOM or jQuery but I would like to do this with Angular 2.\nPossible ? \nThanks\n\nA: You can create a dynamically in Angular2 ? \nFor example, if my variable is isModalOpened is true, I would like to add some CSS to few elements outside my root component. Like the body or html. \nIt's possible to do it with the DOM or jQuery but I would like to do this with Angular 2.\nPossible ? \nThanks\n\nA: You can create a