{ // 获取包含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\nA: You are using ms instead of s. Your animation is working, but it finishes so fast that you just can't see it. Therefore, you should give it a longer duration.\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/67900854\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"-1\"\n}"}}},{"rowIdx":337,"cells":{"text":{"kind":"string","value":"Q: Export data from database to sql file with PHP I need to export data (only the data, not the tables nor database) from the database to a SQL file and save it. How to write a PHP function that does that? I want to call this function in specific circumstances when running specific queries (updating a blog post, for example).\nSomething like:\n/*\n* Get the data from the database (already specified) and export it to a SQL file\n*\n* @param string $dir Where to store the SQL file. Must be a full path.\n* @return void\n*/\nfunction export_database_data(string $dir) {\n // some code that gets the data and store it in $data\n // don't know what to do here\n\n // create/update the file\n file_put_contents(\"$dir/data_backup.sql\", $data);\n}\n\nWhy this? \n(You don't need to read the following to help me solve the problem. I'm including this because I'm sure if don't include this, someone will ask it).\nI want to do that because I want to have a backup of the data (only the data; the tables do not matter because I already know how to handle them for backup). \nI'm doing this because I will use the PHP function exec to run git commands and commit the change in the SQL file. The end goal is to keep track of the data in the database, which won't be updated often. I need the data in a SQL file and I aim to use git because it is easy to access and to collaborate with others (I could not think a better solution, and creating my own tracking system would require a lot of work and time).\n\nA: You can run a mysqldump command using PHP exec function to only export data. Ex:\nexec('mysqldump -u [user] -p[pass] --no-create-info mydb > mydb.sql');\n\nMore info:\n\n\n*\n\n*mysqldump data only\n\n*Using a .php file to generate a MySQL dump\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/57632218\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"1\"\n}"}}},{"rowIdx":338,"cells":{"text":{"kind":"string","value":"Q: Error while unzipping JSON file (Firefox) in my Node.js application I have a route where I am fetching a big chunk of JSON data from database (Postgres) and sending it in compressed format in a response. I am using Zlib module to gzip this data. I am setting Content-Type: application/gzip and Content-Encoding: gzip before sending a response. Now all this set up works well with Chrome and Safari browsers (unzipping data successfully) but for some reason this is not working in Firefox. Request header contains Accept-Encoding: gzip, deflate. \nIn browser(Firefox) console I see following errors\nAttempt to set a forbidden header was denied: Accept-Encoding and\nSyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data\nCan anybody please guide me what this issue is and how can I solve it? Thanks!\n\nA: Ok, I will answer my question with what worked for me.\nOn server side, I changed the way I was compressing the data. I am using deflate method of Zlib module instead of gzip. Also changed the response header with these values. \nContent-Encoding: deflate and Content-Type: application/deflate\nI am still not sure why gzip does not work (or at least did not work for me) but because of time constraint I am going with deflate for now.\nAlso gzip and deflate uses same compression algorithm and deflate is faster in encoding and decoding. I hope this helps and please correct me if I'm wrong at any place. Thanks!\n\nA: In modern browsers, according to https://developer.mozilla.org/en-US/docs/Web/API/Headers,\n\nFor security reasons, some headers can only be controlled by the user agent. These headers include the forbidden header names and forbidden response header names.\n\nForbidden header names include \"Accept-Encoding\".\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/46108399\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"0\"\n}"}}},{"rowIdx":339,"cells":{"text":{"kind":"string","value":"Q: What is the Thingsboard IoT platform's default system administrator account? What is the Thingsboard IoT platform's (https://thingsboard.io) default system administrator account after a fresh (Raspberry Pi) installation?\nThe existing documentation only refers to default \"tenant\" account, which is ok on my setup.\nThanks in advance.\n\nA: Default system administrator account:\n\n*\n\n*login - sysadmin@thingsboard.org\n\n*password - sysadmin\n\nDefault demo tenant administrator account:\n\n*\n\n*login - tenant@thingsboard.org.\n\n*password - tenant.\n\nDemo tenant customers:\nCustomer A user: customerA@thingsboard.org.\nCustomer B user: customerB@thingsboard.org.\nCustomer C user: customerC@thingsboard.org.\nall users have “customer” password.\nTake a look at demo-account documentation page for more information.\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/41832556\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"8\"\n}"}}},{"rowIdx":340,"cells":{"text":{"kind":"string","value":"Q: How to Directly Upload file to other server So I have a project in which i want to upload video to dailymotion using api \nSo i want to Upload video directly to dailymotion server without uploading it to my local server\nMy Action\n [HttpPost]\n public async Task Add(Video Videos)\n {\n var fileToUpload = @\"E:\\Courses\\[FreeCourseLab.com] Udemy - C# Intermediate Classes, Interfaces and OOP\\5. Polymorphism Third Pillar of OOP\\3. Sealed Classes and Members.mp4\";\n return RedirectToAction(\"AddVideo\", \"Admin\");\n }\n\nmy View\n@using (Html.BeginForm(\"Add\", \"Admin\", FormMethod.Post, new { @class = \"px-lg-4\", role = \"form\" }))\n{\n @Html.AntiForgeryToken()\n @Html.ValidationSummary(\"\", new { @class = \"text-danger\" })\n\n
\n
\n @Html.TextBoxFor(m => m.Videos.File, new {@type=\"file\" })\n
\n \n}\n\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/57901771\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"1\"\n}"}}},{"rowIdx":341,"cells":{"text":{"kind":"string","value":"Q: C fork - how to wait for all children before starting workload? I am trying to get fork() to create multiple processes all of which do the same work. I need all of them to get created first, and then at the same time start doing work. That is, I want all of the processes to wait for all of the other ones to get created, and once they are all ready, start doing the work at the same exact time.\nIs this possible? Thanks.\n\nA: The simplest approach would be simply using signals, do note however that there is no way to actually guarantee that the processes will indeed run in parallel.\nThat's for the OS to decide.\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/19210566\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"0\"\n}"}}},{"rowIdx":342,"cells":{"text":{"kind":"string","value":"Q: OpenGL orientation. (Identity rotation looking in negative z) I'm implementing a renderer that handles every translation- / view- / model- / projection-matrix (I don't use glRotate / glTranslate etc.).\nI have placed several blue objects along the positive z-axis and some red objects on the positive x-axis (So I should be able to see the red objects to my left and the blue ones straight ahead using identity rotation on my camera). It is right-hand-orientation, right?\nThe problem is that I have to turn 180 deg around the y-axis to see my objects. It appears as the identity rotation is looking in -z. \nI'm constructing my View matrix by taking the inverse of the cameras matrix [Rot Tr] and then I put it in a array column-wise and pass it to my shader.\nFor the objects (World matrix) I just pass the matrix [Rot Tr] column-wise to the shader. Should I negate the translation? \nThe projection matrix is for now constructed in the vertex shader as I am working my way through. As you can se below I'm doing \nposition = proj*view*model*gl_Vertex;\n\nAt the moment I use gl_Vertex (I use glutSolidCube after loading identity matrix as my scene objects).\nuniform mat4 view;\nuniform mat4 model;\n\nvarying vec4 pos;\n\nvoid main()\n{ \n\npos = gl_Vertex;\n\n\nfloat aspect = 1.0;\nfloat fovy = 1.5;\nfloat f = 1.0 / tan(fovy * 0.5);\nfloat near = 1.0;\nfloat far = 100.0;\nfloat tt = 1.0 / (near - far);\n\nmat4 proj = mat4(f/aspect, 0.0, 0.0, 0.0,\n 0.0, f, 0.0, 0.0,\n 0.0, 0.0, (near+far)*tt, -1.0,\n 0.0, 0.0, 2.0*near*far*tt, 0.0);\n\ngl_Position = proj * view * model * pos;\n}\n\nIn my fragment shader I set the color = pos so that I can see the color of the axis and the colors appears correct. I think the objects are correctly placed in the scene but with Identity matrix as rotation I'm still looking the opposite way.\nWhat could I have missed? Am I passing the correct matrices in a correct manner?\n\nA: A right-handed coordinate system always looks down the -Z axis. If +X goes right, and +Y goes up (which is how all of OpenGL works), and the view is aligned to the Z axis, then +Z must go towards the viewer. If the view was looking down the +Z axis, then the space would be left-handed.\n\nA: \nThe problem is that I have to turn 180 deg around the y-axis to see my objects. It appears as the identity rotation is looking in -z.\n\nYes it is. The coordinate systems provided yb OpenGL in form for glOrtho and glFrustum are right handed (take your right hand, let the thumb towards the right, the index finger up, then the index finger will point toward you). If you modeled your matrix calculations along those, then you'll get a right handed system as well.\n\nA: Alright completely rewrote this last night and I hope you find it useful if you haven't already came up with your own solutions or someone else who comes along with a similar question.\nBy default your forward vector looks down the -Z, right vector looks down the +X, and up vector looks down the +Y.\nWhen you decide to construct your world it really doesn't matter where you look if you have a 128x128 X,Z world and you are positioned in the middle at 64x64 how would any player know they are rotated 0 degrees or 180 degrees. They simply would not.\nNow you mentioned you dislike the glRotatef and glTranslatef. I as well will not use methods that handle the vector and matrix math. Firstly I use a way where I keep track of the Forward, Up, and Right Vectors. So imagine yourself spinning around in a circle this is you rotating your forward vector. So when a player wants to let's say Run Straight ahead. you will move them along the X,Z of your Forward vector, but let's say they also want to strafe to the right. Well you will still move them along the forward vector, but imagine 90 degrees taken off the forward vector. So if we are facing 45 degrees we are pointing to the -Z and -X quadrant. So strafing will move us in the -Z and +X quadrant. To do this you simple do negate the sin value. Examples of both below, but this can be done differently the below is rough example to better explain the above.\nPosition.X -= Forward.X; //Run Forward.\nPosition.Z -= Forward.Z;\n\nPosition.X += Forward.Z; //Run Backwards.\nPosition.Z += Forward.Z \n\nPosition.X += Forward.X; //Strafe Right.\nPosition.Z -= Forward.Z;\n\nPosition.X -= Forward.X; //Strafe Left.\nPosition.Z += Forward.Z;\n\nBelow is how I initialize my view matrix. These are to only be performed one time do not put this in any looping code.\nglMatrixMode(GL_MODELVIEW);\n\nview_matrix[4] = 0.0f; //UNUSED.\n\nview_matrix[3] = 0.0F; //UNUSED. \nview_matrix[7] = 0.0F; //UNUSED. \nview_matrix[11] = 0.0F; //UNUSED. \nview_matrix[15] = 1.0F; //UNUSED.\n\nupdate_view();\nglLoadMatrix(view_matrix);\n\nThen this is the update_view() method. This is to only to be called during a change in the view matrix.\npublic void update_view()\n{\n view_matrix[0] = Forward[0];\n view_matrix[1] = Up[1] * Forward[1];\n view_matrix[2] = Up[0] * -Forward[1];\n\n view_matrix[5] = Up[0];\n view_matrix[6] = Up[1];\n\n view_matrix[8] = Forward[1];\n view_matrix[9] = Up[1] * -Forward[0];\n view_matrix[10] = Up[0] * Forward[0];\n}\n\nThe Position vectors are matricies [12], [13], and [14] and are negated. You can choose to store these or just use matrix[12], [13], [14] as the vector for position.\nview_matrix[12] = -Position.x;\nview_matrix[13] = -Position.y;\nview_matrix[14] = -Position.z;\n\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/9448885\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"1\"\n}"}}},{"rowIdx":343,"cells":{"text":{"kind":"string","value":"Q: uploading an array to server in swift using Alamofire This is how I'm saving the data successfully to model class when user login\nvar isLogin: IsLogin!\nvar loginDetail: LoginDetail!\nvar myDetail: MyDetail!\n\nlet decoder = JSONDecoder()\ndo{\n isLogin = try decoder.decode(IsLogin.self, from: response.data!)\n loginDetail = isLogin.success\n myDetail = loginDetail.user\n}catch{\n print(error)\n}\n\nhere is my model class where I'm saving response from the request\nstruct IsLogin: Decodable {\n var success: LoginDetail\n}\nstruct LoginDetail: Decodable {\n var user: MyDetail\n}\n\nstruct MyDetail: Decodable {\n var id: Int\n var emergency_contacts: [EmergencyContacts]?\n}\nstruct EmergencyContacts: Decodable {\n var user_id : Int\n var number : String\n}\n\nI want to post EmergencyContacts in another request how do I do that? This is how im trying but in response array of EmergencyContacts is always empty\nmultipartFormData.append(\"\\(myDetail.emergency_contacts!)\".data(using: .utf8,allowLossyConversion: false)!,\n`enter code here`withName: \"emergency_contacts\")\n\nI have print all the values from model class and they are fine but guide me about how to send an array in a post request.Please suggest my some method using multipartformdara because I have been using this to send other parameters as well.below is the postman screenshot where If I send parameters like this then I can get the emergencycontacts in response 13 is the id of emergency contact\n\n"},"meta":{"kind":"string","value":"{\n \"language\": \"en\",\n \"url\": \"https://stackoverflow.com/questions/63713852\",\n \"timestamp\": \"2023-03-29T00:00:00\",\n \"source\": \"stackexchange\",\n \"question_score\": \"0\"\n}"}}},{"rowIdx":344,"cells":{"text":{"kind":"string","value":"Q: How to use a template template argument from a member templated type alias of a struct I'm trying to use a template template argument coming from a member type alias of a struct, but I can't find the right syntax:\nstruct A\n{\n template \n using type = int;\n};\n\ntemplate