{ // 获取包含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# 1. 데이터 파서하기\nsoup = BeautifulSoup(html, \"html.parser\")\n\n# 2. 원하는 요소 접근하기\nh1 = soup.html.body.h1\nprint(h1)\nprint(h1.text) # 문자열만 출력하고 싶을땐 .text, .string을 이용하여 출력\nprint(h1.string)\n\n# 3. p요소의 내용 추출하기\np = soup.find_all(\"p\")\nprint(p)\nfor i in p: # list형식은 for문을 이용하여 출력\n print(i.text)\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1172,"string":"1,172"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":453,"string":"453"},"filename":{"kind":"string","value":"Ex01_element.py"},"num_lang_files":{"kind":"number","value":89,"string":"89"},"alphanum_fraction":{"kind":"number","value":0.5412621359223301,"string":"0.541262"},"alpha_fraction":{"kind":"number","value":0.5254854368932039,"string":"0.525485"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":40,"string":"40"},"avg_line_length":{"kind":"number","value":19.6,"string":"19.6"},"max_line_length":{"kind":"number","value":57,"string":"57"}}},{"rowIdx":534,"cells":{"repo_name":{"kind":"string","value":"ilyakonstantinov95/DjBlog"},"__id__":{"kind":"number","value":14285061231926,"string":"14,285,061,231,926"},"blob_id":{"kind":"string","value":"93264ebec8e665233eb75c2148ac066085e57ed8"},"directory_id":{"kind":"string","value":"e2890e6ef04220a09d150aa922376db39bb7853e"},"path":{"kind":"string","value":"/emplist/migrations/0001_initial.py"},"content_id":{"kind":"string","value":"693d522e4c0b73b7c98ebae63dbb1ccbeeb932f7"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/ilyakonstantinov95/DjBlog"},"snapshot_id":{"kind":"string","value":"da243ecbb8c49f6a2a7c42a644791f68d413942b"},"revision_id":{"kind":"string","value":"3ab34bed10d7a0f58d19dfee90e836daf7bf6ff7"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2017-12-06T10:14:59.004524","string":"2017-12-06T10:14:59.004524"},"revision_date":{"kind":"timestamp","value":"2017-01-26T08:24:15","string":"2017-01-26T08:24:15"},"committer_date":{"kind":"timestamp","value":"2017-01-26T08:24:15","string":"2017-01-26T08:24:15"},"github_id":{"kind":"number","value":80039147,"string":"80,039,147"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# -*- coding: utf-8 -*-\n# Generated by Django 1.10.5 on 2017-01-23 10:13\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Migration(migrations.Migration):\n\n initial = True\n\n dependencies = [\n ]\n\n operations = [\n migrations.CreateModel(\n name='Employee',\n fields=[\n ('id_emp', models.AutoField(primary_key=True, serialize=False, unique=True, verbose_name='Идентификатор')),\n ('first_name', models.CharField(db_index=True, max_length=25, verbose_name='Имя')),\n ('second_name', models.CharField(db_index=True, max_length=25, verbose_name='Фамилия')),\n ('third_name', models.CharField(db_index=True, max_length=25, verbose_name='Отчество')),\n ('birthday', models.DateField(db_index=True, verbose_name='Дата рождения')),\n ('date_start', models.DateField(auto_now_add=True, db_index=True, verbose_name='Дата принятия')),\n ('date_end', models.DateField(blank=True, null=True, verbose_name='Дата увольнения')),\n ],\n options={\n 'verbose_name': 'Сотрудник',\n 'verbose_name_plural': 'Сотрудники',\n 'ordering': ['first_name', 'second_name', 'third_name', 'birthday', 'sex', 'status', 'post', '-date_start', 'date_end'],\n },\n ),\n migrations.CreateModel(\n name='Post',\n fields=[\n ('id_post', models.AutoField(primary_key=True, serialize=False, unique=True, verbose_name='Идентификатор')),\n ('name', models.CharField(db_index=True, max_length=50, unique=True, verbose_name='Должность')),\n ],\n options={\n 'verbose_name': 'Должность',\n 'verbose_name_plural': 'Должности',\n 'ordering': ['name'],\n },\n ),\n migrations.CreateModel(\n name='Sex',\n fields=[\n ('id_sex', models.AutoField(primary_key=True, serialize=False, unique=True, verbose_name='Идентификатор')),\n ('type', models.CharField(db_index=True, max_length=7, verbose_name='Пол')),\n ],\n options={\n 'verbose_name': 'Пол',\n 'verbose_name_plural': 'Пол',\n 'ordering': ['type'],\n },\n ),\n migrations.CreateModel(\n name='Status',\n fields=[\n ('id_status', models.AutoField(primary_key=True, serialize=False, unique=True, verbose_name='Идентификатор')),\n ('status', models.CharField(db_index=True, max_length=30, unique=True, verbose_name='Статус')),\n ],\n options={\n 'verbose_name': 'Статус',\n 'verbose_name_plural': 'Статусы',\n 'ordering': ['status'],\n },\n ),\n migrations.AlterUniqueTogether(\n name='status',\n unique_together=set([('id_status', 'status')]),\n ),\n migrations.AlterUniqueTogether(\n name='sex',\n unique_together=set([('id_sex', 'type')]),\n ),\n migrations.AlterUniqueTogether(\n name='post',\n unique_together=set([('id_post', 'name')]),\n ),\n migrations.AddField(\n model_name='employee',\n name='post',\n field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='emplist.Post', verbose_name='Должность'),\n ),\n migrations.AddField(\n model_name='employee',\n name='sex',\n field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='emplist.Sex', verbose_name='Пол'),\n ),\n migrations.AddField(\n model_name='employee',\n name='status',\n field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='emplist.Status', verbose_name='Статус'),\n ),\n migrations.AlterUniqueTogether(\n name='employee',\n unique_together=set([('first_name', 'second_name', 'third_name', 'birthday', 'sex')]),\n ),\n ]\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":4460,"string":"4,460"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":17,"string":"17"},"filename":{"kind":"string","value":"0001_initial.py"},"num_lang_files":{"kind":"number","value":11,"string":"11"},"alphanum_fraction":{"kind":"number","value":0.5410798122065728,"string":"0.54108"},"alpha_fraction":{"kind":"number","value":0.5345070422535211,"string":"0.534507"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":101,"string":"101"},"avg_line_length":{"kind":"number","value":41.17821782178218,"string":"41.178218"},"max_line_length":{"kind":"number","value":150,"string":"150"}}},{"rowIdx":535,"cells":{"repo_name":{"kind":"string","value":"Yun-Jongwon/TIL"},"__id__":{"kind":"number","value":11605001651736,"string":"11,605,001,651,736"},"blob_id":{"kind":"string","value":"b3f65b69e00c8a9f6f48a8c3daa3b050ff4a4345"},"directory_id":{"kind":"string","value":"1346ea1f255d3586442c8fc1afc0405794206e26"},"path":{"kind":"string","value":"/알고리즘/day15/picnic.py"},"content_id":{"kind":"string","value":"a0675c0839036358fd7ba4ab78d78e7ec1e146dd"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/Yun-Jongwon/TIL"},"snapshot_id":{"kind":"string","value":"737b634b6e75723ac0043cda9c4f9acbc2a24686"},"revision_id":{"kind":"string","value":"a3fc624ec340643cdbf98974bf6e6144eb06a42f"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-04-12T00:41:03.985080","string":"2020-04-12T00:41:03.985080"},"revision_date":{"kind":"timestamp","value":"2019-05-01T07:55:25","string":"2019-05-01T07:55:25"},"committer_date":{"kind":"timestamp","value":"2019-05-01T07:55:25","string":"2019-05-01T07:55:25"},"github_id":{"kind":"number","value":162208477,"string":"162,208,477"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"def dfs(couple):\n global m\n global count\n if sum(visited)==len(visited):\n count+=1\n return\n for V in range(n):\n if visited[V]==0:\n visited[V]=1\n v=V\n break\n for w in range(n):\n if total_map[v][w]==1 and visited[w]==0:\n visited[w]=1\n dfs(couple+1)\n visited[w]=0\n visited[V]=0\n\n\nT=int(input())\nfor t in range(T):\n n,m=map(int,input().split())\n visited=[0]*n\n data=list(map(int,input().split()))\n total_map=[[0]*n for i in range(n)]\n count=0\n for M in range(m):\n a=data[2*M]\n b=data[2*M+1]\n total_map[a][b]=1\n total_map[b][a]=1\n dfs(0)\n print(count)\n # print(total_map)\n\n\n\n\n\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":739,"string":"739"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":220,"string":"220"},"filename":{"kind":"string","value":"picnic.py"},"num_lang_files":{"kind":"number","value":189,"string":"189"},"alphanum_fraction":{"kind":"number","value":0.4776725304465494,"string":"0.477673"},"alpha_fraction":{"kind":"number","value":0.45331529093369416,"string":"0.453315"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":34,"string":"34"},"avg_line_length":{"kind":"number","value":20.58823529411765,"string":"20.588235"},"max_line_length":{"kind":"number","value":48,"string":"48"}}},{"rowIdx":536,"cells":{"repo_name":{"kind":"string","value":"RussellSk/grokking_algorithms"},"__id__":{"kind":"number","value":13185549612182,"string":"13,185,549,612,182"},"blob_id":{"kind":"string","value":"f57a5ab516edeb1b8dc6d04c6ffab4f028a08c66"},"directory_id":{"kind":"string","value":"dfa7aaaefb5ccff7fcc016ac1740d52cfbe20caf"},"path":{"kind":"string","value":"/Chapter4/Exercise4.1.py"},"content_id":{"kind":"string","value":"7749abba16a976aa7f3b90cd4796ee5356d9c9d6"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/RussellSk/grokking_algorithms"},"snapshot_id":{"kind":"string","value":"97ecd387b614b8b7f413c24467b97e2c704a1af8"},"revision_id":{"kind":"string","value":"88a2b9c5f21d06d1cba3526c26b68b56dc40e399"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2021-04-14T04:59:44.421724","string":"2021-04-14T04:59:44.421724"},"revision_date":{"kind":"timestamp","value":"2020-04-16T11:44:01","string":"2020-04-16T11:44:01"},"committer_date":{"kind":"timestamp","value":"2020-04-16T11:44:01","string":"2020-04-16T11:44:01"},"github_id":{"kind":"number","value":249208424,"string":"249,208,424"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# Exercises 4.1\n# Write out the code for the earlier sum function\n\n\ndef sum(arr):\n if not arr:\n return 0\n else:\n return arr.pop() + sum(arr)\n\n\nif __name__ == \"__main__\":\n print(sum([2, 4, 6]))\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":216,"string":"216"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":9,"string":"9"},"filename":{"kind":"string","value":"Exercise4.1.py"},"num_lang_files":{"kind":"number","value":9,"string":"9"},"alphanum_fraction":{"kind":"number","value":0.5416666666666666,"string":"0.541667"},"alpha_fraction":{"kind":"number","value":0.5138888888888888,"string":"0.513889"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":13,"string":"13"},"avg_line_length":{"kind":"number","value":15.615384615384615,"string":"15.615385"},"max_line_length":{"kind":"number","value":49,"string":"49"}}},{"rowIdx":537,"cells":{"repo_name":{"kind":"string","value":"tuananh1007/Picasso"},"__id__":{"kind":"number","value":12850542195905,"string":"12,850,542,195,905"},"blob_id":{"kind":"string","value":"2d4d18f85a1bc1ccc056b60d74d5fc204c2b33e7"},"directory_id":{"kind":"string","value":"2e11bf9a4499a962bacd89a742d9dc0ed7108747"},"path":{"kind":"string","value":"/tf_ops/mesh/unpooling/tf_mesh_unpool3d.py"},"content_id":{"kind":"string","value":"7b3864db5d3f04053014653a6149dabb63a57a43"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/tuananh1007/Picasso"},"snapshot_id":{"kind":"string","value":"df914332a02bf7940d28d5bae80be1601d59cb0c"},"revision_id":{"kind":"string","value":"5009dd2312ad88635748788696ecc953d5e55116"},"branch_name":{"kind":"string","value":"refs/heads/main"},"visit_date":{"kind":"timestamp","value":"2023-03-30T02:52:51.600705","string":"2023-03-30T02:52:51.600705"},"revision_date":{"kind":"timestamp","value":"2021-03-30T11:44:30","string":"2021-03-30T11:44:30"},"committer_date":{"kind":"timestamp","value":"2021-03-30T11:44:30","string":"2021-03-30T11:44:30"},"github_id":{"kind":"null"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"import tensorflow as tf\nimport sys, os\n\nbase_dir = os.path.dirname(os.path.abspath(__file__))\nsys.path.append(base_dir)\nunpool3d_module = tf.load_op_library(os.path.join(base_dir, 'tf_unpool3d_so.so'))\n\n\ndef mesh_interpolate(input, vt_replace, vt_map):\n '''\n During the decimation, we record the vertex clusters in vt_map.\n In unpooling within decoders, we interpolate features for vertices in the\n before-decimation mesh from vertex features of its successive decimated mesh.\n Here we perform average interpolation to get feature, which means that\n the unpooled feature of each output vertex is 1/Nc of that from its input vertex.\n Nc is the related vertex cluster size in decimation.\n '''\n return unpool3d_module.mesh_interpolate(input, vt_replace, vt_map)\n@tf.RegisterGradient(\"MeshInterpolate\")\ndef _mesh_interpolate_grad(op, grad_output):\n input = op.inputs[0]\n vt_replace = op.inputs[1]\n vt_map = op.inputs[2]\n grad_input = unpool3d_module.mesh_interpolate_grad(input, grad_output, vt_replace, vt_map)\n return [grad_input, None, None]\n\n\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1109,"string":"1,109"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":28,"string":"28"},"filename":{"kind":"string","value":"tf_mesh_unpool3d.py"},"num_lang_files":{"kind":"number","value":19,"string":"19"},"alphanum_fraction":{"kind":"number","value":0.7141568981064021,"string":"0.714157"},"alpha_fraction":{"kind":"number","value":0.7069431920649234,"string":"0.706943"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":25,"string":"25"},"avg_line_length":{"kind":"number","value":43.28,"string":"43.28"},"max_line_length":{"kind":"number","value":94,"string":"94"}}},{"rowIdx":538,"cells":{"repo_name":{"kind":"string","value":"thiago-allue/portfolio"},"__id__":{"kind":"number","value":11089605580602,"string":"11,089,605,580,602"},"blob_id":{"kind":"string","value":"697ff03e063255a0200112804cf3ef495e02b7bf"},"directory_id":{"kind":"string","value":"baf3996414315ffb60470c40c7ad797bf4e6897f"},"path":{"kind":"string","value":"/17_boilerplates/prototypes-master/examples/src/elastic/src/old/guide.py"},"content_id":{"kind":"string","value":"aaaf2aeadce59a30109e14b385347719f1ae7efd"},"detected_licenses":{"kind":"list like","value":["MIT"],"string":"[\n \"MIT\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/thiago-allue/portfolio"},"snapshot_id":{"kind":"string","value":"8fbbecca7ce232567aebe97c19944f444508b7f4"},"revision_id":{"kind":"string","value":"0acd8253dc7c5150fef9b2d46eead3db83ca42de"},"branch_name":{"kind":"string","value":"refs/heads/main"},"visit_date":{"kind":"timestamp","value":"2023-03-15T22:10:21.109707","string":"2023-03-15T22:10:21.109707"},"revision_date":{"kind":"timestamp","value":"2022-09-14T17:04:35","string":"2022-09-14T17:04:35"},"committer_date":{"kind":"timestamp","value":"2022-09-14T17:04:35","string":"2022-09-14T17:04:35"},"github_id":{"kind":"number","value":207919073,"string":"207,919,073"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"bool","value":false,"string":"false"},"gha_event_created_at":{"kind":"timestamp","value":"2019-11-13T18:18:23","string":"2019-11-13T18:18:23"},"gha_created_at":{"kind":"timestamp","value":"2019-09-11T22:40:46","string":"2019-09-11T22:40:46"},"gha_updated_at":{"kind":"timestamp","value":"2019-09-14T03:15:26","string":"2019-09-14T03:15:26"},"gha_pushed_at":{"kind":"timestamp","value":"2019-11-13T18:18:21","string":"2019-11-13T18:18:21"},"gha_size":{"kind":"number","value":180926,"string":"180,926"},"gha_stargazers_count":{"kind":"number","value":0,"string":"0"},"gha_forks_count":{"kind":"number","value":0,"string":"0"},"gha_open_issues_count":{"kind":"number","value":0,"string":"0"},"gha_language":{"kind":"string","value":"Python"},"gha_archived":{"kind":"bool","value":false,"string":"false"},"gha_disabled":{"kind":"bool","value":false,"string":"false"},"content":{"kind":"string","value":"import requests\n\nr = requests.get(\n \"http://api.tvmaze.com/singlesearch/shows?q=big-bang-theory&embed=episodes\"\n)\n\nimport json\n\njd = json.loads(r.content)\nprint(jd[\"_embedded\"][\"episodes\"][0])\n\nimport re\n\nldocs = []\nfor jo in jd[\"_embedded\"][\"episodes\"][0:200]:\n d = {}\n d[\"id\"] = jo[\"id\"]\n d[\"season\"] = jo[\"season\"]\n d[\"episode\"] = jo[\"number\"]\n d[\"name\"] = jo[\"name\"]\n d[\"summary\"] = re.sub(\"<[^<]+?>\", \"\", jo[\"summary\"])\n ldocs.append(d)\n\nfrom elasticsearch import Elasticsearch\n\nes = Elasticsearch([{\"host\": \"localhost\", \"port\": 9200}])\n\n\nimport json\n\n# iterate through documents indexing them\nfor doc in ldocs:\n es.index(index=\"tvshows\", doc_type=\"bigbang\", id=doc[\"id\"], body=json.dumps(doc))\n\nes.get(index=\"tvshows\", doc_type=\"bigbang\", id=2915)\n\nes.search(\n index=\"tvshows\",\n doc_type=\"bigbang\",\n body={\"query\": {\"match\": {\"summary\": \"rivalry\"}}},\n)\n\nes.search(\n index=\"tvshows\", doc_type=\"bigbang\", body={\"query\": {\"fuzzy\": {\"summary\": \"rival\"}}}\n)\n\nes.indices.delete(index=\"bigbang\", ignore=[400, 404])\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1053,"string":"1,053"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":991,"string":"991"},"filename":{"kind":"string","value":"guide.py"},"num_lang_files":{"kind":"number","value":679,"string":"679"},"alphanum_fraction":{"kind":"number","value":0.6163342830009497,"string":"0.616334"},"alpha_fraction":{"kind":"number","value":0.5982905982905983,"string":"0.598291"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":47,"string":"47"},"avg_line_length":{"kind":"number","value":21.404255319148938,"string":"21.404255"},"max_line_length":{"kind":"number","value":88,"string":"88"}}},{"rowIdx":539,"cells":{"repo_name":{"kind":"string","value":"duncandc/mb2_python"},"__id__":{"kind":"number","value":274877916344,"string":"274,877,916,344"},"blob_id":{"kind":"string","value":"296a16ac9b6b20e78694fa5bdeab81caf614593b"},"directory_id":{"kind":"string","value":"8e4da43aa0a8af1167482c9cbc1ac3ff4410e95e"},"path":{"kind":"string","value":"/groupcat.py"},"content_id":{"kind":"string","value":"79b4d4cb8be334b007ce94c98765f85df446de7d"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/duncandc/mb2_python"},"snapshot_id":{"kind":"string","value":"ef8d93548926368a8d230f2d89ed2232659daae3"},"revision_id":{"kind":"string","value":"812f9e7c41083e66c77b9ce5d453b25e286685ea"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-06-18T10:27:08.322401","string":"2020-06-18T10:27:08.322401"},"revision_date":{"kind":"timestamp","value":"2019-08-02T20:04:07","string":"2019-08-02T20:04:07"},"committer_date":{"kind":"timestamp","value":"2019-08-02T20:04:07","string":"2019-08-02T20:04:07"},"github_id":{"kind":"number","value":196270866,"string":"196,270,866"},"star_events_count":{"kind":"number","value":2,"string":"2"},"fork_events_count":{"kind":"number","value":2,"string":"2"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"\"\"\"\nFile I/O related to the MBII (sub-)halo catalogs\n\"\"\"\n\nfrom __future__ import print_function, division\nfrom mb2_python.utils import packarray\nfrom mb2_python.data import subdtype, groupdtype\nimport numpy as np\n\n__all__=['gcPath', 'shPath']\n__author__=['Duncan Campbell']\n\n\ndef gcPath(basePath, snapNum):\n \"\"\" \n Return absolute path to a group catalog.\n \"\"\"\n gcPath = basePath + '/subhalos'\n gcPath += '/' + str(snapNum).zfill(3) + '/'\n filePath = gcPath + 'grouphalotab.raw'\n return filePath\n\n\ndef shcPath(basePath, snapNum):\n \"\"\"\n Return absolute path to a subhalo catalog. \n \"\"\"\n shcPath = basePath + '/subhalos'\n shcPath += '/' + str(snapNum).zfill(3) + '/'\n filePath = shcPath + 'subhalotab.raw'\n return filePath\n\n\ndef readshc(basePath, snapNum):\n \"\"\" \n Read the basic subhalo catelog.\n \"\"\"\n\n subhalofile = shcPath(basePath, snapNum)\n return np.memmap(subhalofile, mode='r', dtype=subdtype)\n\n\ndef readgc(basePath, snapNum):\n \"\"\" \n read the basic group catelog.\n \"\"\"\n\n groupfile = gcPath(basePath, snapNum)\n return np.memmap(groupfile, mode='r', dtype=groupdtype)"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1141,"string":"1,141"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":13,"string":"13"},"filename":{"kind":"string","value":"groupcat.py"},"num_lang_files":{"kind":"number","value":10,"string":"10"},"alphanum_fraction":{"kind":"number","value":0.6468010517090271,"string":"0.646801"},"alpha_fraction":{"kind":"number","value":0.6432953549517967,"string":"0.643295"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":49,"string":"49"},"avg_line_length":{"kind":"number","value":22.306122448979593,"string":"22.306122"},"max_line_length":{"kind":"number","value":59,"string":"59"}}},{"rowIdx":540,"cells":{"repo_name":{"kind":"string","value":"joaogomesufal/scrapping_articles"},"__id__":{"kind":"number","value":11965778902839,"string":"11,965,778,902,839"},"blob_id":{"kind":"string","value":"90534afcdea2f681a4b95e128c9c47c8a6bf645b"},"directory_id":{"kind":"string","value":"95ce37521e81309df5faaf18bd38117db9fa8278"},"path":{"kind":"string","value":"/main.py"},"content_id":{"kind":"string","value":"f518cd1d4cc3f8a403560226b24c0f6b9e591d18"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/joaogomesufal/scrapping_articles"},"snapshot_id":{"kind":"string","value":"58bf2d2f4ccc800627063c1ab9ac9413bcc638c3"},"revision_id":{"kind":"string","value":"bf6715062127330c6a89a575b273dd88034dfda5"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-04-24T07:33:53.263967","string":"2020-04-24T07:33:53.263967"},"revision_date":{"kind":"timestamp","value":"2019-02-26T12:16:15","string":"2019-02-26T12:16:15"},"committer_date":{"kind":"timestamp","value":"2019-02-26T12:16:15","string":"2019-02-26T12:16:15"},"github_id":{"kind":"number","value":171802698,"string":"171,802,698"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"from _classes.ScrappingArticle import ScrappingArticle\n\nscrapping = ScrappingArticle('https://scholar.google.com.br/scholar', 'data mining', 2015, 2019, 2, 4)\n\nprint(\"Lista de URLs:\")\nurl_list = scrapping.get_url_list()\nprint(url_list)\n\nprint(\"Lista de Arquivos:\")\nfile_list = scrapping.get_file_list(url_list)\nprint(file_list)\n\nprint(\"Download de Arquivos:\")\nscrapping.download_files(file_list)\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":397,"string":"397"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":5,"string":"5"},"filename":{"kind":"string","value":"main.py"},"num_lang_files":{"kind":"number","value":3,"string":"3"},"alphanum_fraction":{"kind":"number","value":0.7531486146095718,"string":"0.753149"},"alpha_fraction":{"kind":"number","value":0.7279596977329975,"string":"0.72796"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":14,"string":"14"},"avg_line_length":{"kind":"number","value":27.357142857142858,"string":"27.357143"},"max_line_length":{"kind":"number","value":102,"string":"102"}}},{"rowIdx":541,"cells":{"repo_name":{"kind":"string","value":"zhoutian0930ru/StockPredictionApplication"},"__id__":{"kind":"number","value":15728170260006,"string":"15,728,170,260,006"},"blob_id":{"kind":"string","value":"410bf801ede64d99e54b2a8c14b72a6f67b72711"},"directory_id":{"kind":"string","value":"2e00911d07417094f9fd4015be7bf7c94ead0c7f"},"path":{"kind":"string","value":"/venv1/lib/python3.6/site-packages/intriniorealtime/client.py"},"content_id":{"kind":"string","value":"282faa2e415e3872e02432dc466844d44501c05b"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/zhoutian0930ru/StockPredictionApplication"},"snapshot_id":{"kind":"string","value":"005c2b0519bf0b1c8fef26357f818726effe223d"},"revision_id":{"kind":"string","value":"d0c67f4c2cf4a033dee9d412dc30f10dab0a55be"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-05-04T03:37:38.274093","string":"2020-05-04T03:37:38.274093"},"revision_date":{"kind":"timestamp","value":"2019-07-28T14:15:24","string":"2019-07-28T14:15:24"},"committer_date":{"kind":"timestamp","value":"2019-07-28T14:15:24","string":"2019-07-28T14:15:24"},"github_id":{"kind":"number","value":178950193,"string":"178,950,193"},"star_events_count":{"kind":"number","value":1,"string":"1"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"import time\nimport base64\nimport requests\nimport threading\nimport websocket\nimport json\nimport logging\nimport queue\n\nSELF_HEAL_TIME = 1\nHEARTBEAT_TIME = 3\nIEX = \"iex\"\nQUODD = \"quodd\"\nPROVIDERS = [IEX, QUODD]\nMAX_QUEUE_SIZE = 10000\n\nclass IntrinioRealtimeClient:\n def __init__(self, options):\n if options is None:\n raise ValueError(\"Options parameter is required\")\n \n self.options = options\n self.username = options['username']\n self.password = options['password']\n self.provider = options['provider']\n \n if 'channels' in options:\n self.channels = set(options['channels'])\n else:\n self.channels = set()\n \n if 'logger' in options:\n self.logger = options['logger']\n else:\n log_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')\n log_handler = logging.StreamHandler()\n log_handler.setFormatter(log_formatter)\n self.logger = logging.getLogger('intrinio_realtime')\n if 'debug' in options and options['debug'] == True:\n self.logger.setLevel(logging.DEBUG)\n else:\n self.logger.setLevel(logging.INFO)\n self.logger.addHandler(log_handler)\n \n if 'max_queue_size' in options:\n self.quotes = queue.Queue(maxsize=options['max_queue_size'])\n else:\n self.quotes = queue.Queue(maxsize=MAX_QUEUE_SIZE)\n \n if not self.username:\n raise ValueError(\"Parameter 'username' must be specified\") \n \n if not self.password:\n raise ValueError(\"Parameter 'password' must be specified\")\n \n if 'on_quote' in options:\n if not callable(options['on_quote']):\n raise ValueError(\"Parameter 'on_quote' must be a function\")\n else:\n self.on_quote = options['on_quote']\n else:\n self.on_quote = None\n \n if self.provider not in PROVIDERS:\n raise ValueError(f\"Parameter 'provider' is invalid, use one of {PROVIDERS}\")\n \n self.ready = False\n self.token = None\n self.ws = None\n self.quote_receiver = None\n self.quote_handler = None\n self.joined_channels = set()\n self.last_queue_warning_time = 0\n \n QuoteHandler(self).start()\n Heartbeat(self).start()\n\n def auth_url(self):\n if self.provider == IEX:\n return \"https://realtime.intrinio.com/auth\"\n elif self.provider == QUODD:\n return \"https://api.intrinio.com/token?type=QUODD\"\n \n def websocket_url(self):\n if self.provider == IEX:\n return \"wss://realtime.intrinio.com/socket/websocket?vsn=1.0.0&token=\" + self.token\n elif self.provider == QUODD:\n return \"wss://www5.quodd.com/websocket/webStreamer/intrinio/\" + self.token\n \n def connect(self):\n self.logger.info(\"Connecting...\")\n \n self.ready = False\n self.joined_channels = set()\n \n if self.ws:\n self.ws.close()\n time.sleep(1)\n \n try:\n self.refresh_token()\n self.refresh_websocket()\n except Exception as e:\n self.logger.error(f\"Cannot connect: {e}\")\n return self.self_heal()\n \n def disconnect(self):\n self.ready = False\n self.joined_channels = set()\n \n if self.ws:\n self.ws.close()\n time.sleep(1)\n \n def keep_alive(self):\n while True:\n pass\n\n def refresh_token(self):\n response = requests.get(self.auth_url(), auth=(self.username, self.password))\n \n if response.status_code != 200:\n raise RuntimeError(\"Auth failed\")\n \n self.token = response.text\n self.logger.info(\"Authentication successful!\")\n\n def refresh_websocket(self):\n self.quote_receiver = QuoteReceiver(self)\n self.quote_receiver.start()\n\n def self_heal(self):\n time.sleep(SELF_HEAL_TIME)\n self.connect()\n \n def on_connect(self):\n self.ready = True\n self.refresh_channels()\n \n def on_queue_full(self):\n if time.time() - self.last_queue_warning_time > 1:\n self.logger.error(\"Quote queue is full! Dropped some new quotes\")\n self.last_queue_warning_time = time.time()\n\n def join(self, channels):\n if isinstance(channels, str):\n channels = [channels]\n \n self.channels = self.channels | set(channels)\n self.refresh_channels()\n\n def leave(self, channels):\n if isinstance(channels, str):\n channels = [channels]\n \n self.channels = self.channels - set(channels)\n self.refresh_channels()\n\n def leave_all(self):\n self.channels = set()\n self.refresh_channels()\n\n def refresh_channels(self):\n if self.ready != True:\n return\n\n # Join new channels\n new_channels = self.channels - self.joined_channels\n self.logger.debug(f\"New channels: {new_channels}\")\n for channel in new_channels:\n msg = self.join_message(channel)\n self.ws.send(json.dumps(msg))\n self.logger.info(f\"Joined channel {channel}\")\n \n # Leave old channels\n old_channels = self.joined_channels - self.channels\n self.logger.debug(f\"Old channels: {old_channels}\")\n for channel in old_channels:\n msg = self.leave_message(channel)\n self.ws.send(json.dumps(msg))\n self.logger.info(f\"Left channel {channel}\")\n \n self.joined_channels = self.channels.copy()\n self.logger.debug(f\"Current channels: {self.joined_channels}\")\n \n def join_message(self, channel):\n if self.provider == IEX:\n return {\n 'topic': self.parse_iex_topic(channel),\n 'event': 'phx_join',\n 'payload': {},\n 'ref': None\n }\n elif self.provider == QUODD:\n return {\n 'event': 'subscribe',\n 'data': {\n 'ticker': channel,\n 'action': 'subscribe'\n }\n }\n \n def leave_message(self, channel):\n if self.provider == IEX:\n return {\n 'topic': self.parse_iex_topic(channel),\n 'event': 'phx_leave',\n 'payload': {},\n 'ref': None\n }\n elif self.provider == QUODD:\n return {\n 'event': 'unsubscribe',\n 'data': {\n 'ticker': channel,\n 'action': 'unsubscribe'\n }\n }\n \n def parse_iex_topic(self, channel):\n if channel == \"$lobby\":\n return \"iex:lobby\"\n elif channel == \"$lobby_last_price\":\n return \"iex:lobby:last_price\"\n else:\n return f\"iex:securities:{channel}\"\n \nclass QuoteReceiver(threading.Thread):\n def __init__(self, client):\n threading.Thread.__init__(self, args=(), kwargs=None)\n self.daemon = True\n self.client = client\n self.enabled = True\n\n def run(self):\n self.client.ws = websocket.WebSocketApp(\n self.client.websocket_url(), \n on_open = self.on_open, \n on_close = self.on_close,\n on_message = self.on_message, \n on_error = self.on_error\n )\n \n self.client.logger.debug(\"QuoteReceiver ready\")\n self.client.ws.run_forever()\n self.client.logger.debug(\"QuoteReceiver exiting\")\n \n def on_open(self, ws):\n self.client.logger.info(\"Websocket opened!\")\n if self.client.provider == IEX:\n self.client.on_connect()\n\n def on_close(self, ws):\n self.client.logger.info(\"Websocket closed!\")\n\n def on_error(self, ws, error):\n self.client.logger.error(f\"Websocket ERROR: {error}\")\n self.client.self_heal()\n \n def on_message(self, ws, message):\n message = json.loads(message)\n self.client.logger.debug(f\"Received message: {message}\")\n quote = None\n \n if self.client.provider == IEX:\n if message['event'] == \"quote\":\n quote = message['payload']\n elif self.client.provider == QUODD:\n if message['event'] == 'info' and message['data']['message'] == 'Connected':\n self.client.on_connect()\n if message['event'] == 'quote' or message['event'] == 'trade':\n quote = message['data']\n \n if quote:\n try:\n self.client.quotes.put_nowait(quote)\n except queue.Full:\n self.client.on_queue_full()\n\nclass QuoteHandler(threading.Thread):\n def __init__(self, client):\n threading.Thread.__init__(self, args=(), kwargs=None)\n self.daemon = True\n self.client = client\n\n def run(self):\n self.client.logger.debug(\"QuoteHandler ready\")\n while True:\n item = self.client.quotes.get()\n backlog_len = self.client.quotes.qsize()\n if callable(self.client.on_quote):\n try:\n self.client.on_quote(item, backlog_len)\n except Exception as e:\n self.client.logger.error(e)\n \nclass Heartbeat(threading.Thread):\n def __init__(self, client):\n threading.Thread.__init__(self, args=(), kwargs=None)\n self.daemon = True\n self.client = client\n\n def run(self):\n self.client.logger.debug(\"Heartbeat ready\")\n while True:\n time.sleep(HEARTBEAT_TIME)\n if self.client.ready and self.client.ws:\n msg = None\n \n if self.client.provider == IEX:\n msg = {'topic': 'phoenix', 'event': 'heartbeat', 'payload': {}, 'ref': None}\n elif self.client.provider == QUODD:\n msg = {'event': 'heartbeat', 'data': {'action': 'heartbeat', 'ticker': int(time.time()*1000)}}\n \n if msg:\n self.client.logger.debug(msg)\n self.client.ws.send(json.dumps(msg))\n self.client.logger.debug(\"Heartbeat!\")\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":10537,"string":"10,537"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":22,"string":"22"},"filename":{"kind":"string","value":"client.py"},"num_lang_files":{"kind":"number","value":14,"string":"14"},"alphanum_fraction":{"kind":"number","value":0.5307013381417861,"string":"0.530701"},"alpha_fraction":{"kind":"number","value":0.5284236499952548,"string":"0.528424"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":318,"string":"318"},"avg_line_length":{"kind":"number","value":32.13522012578616,"string":"32.13522"},"max_line_length":{"kind":"number","value":114,"string":"114"}}},{"rowIdx":542,"cells":{"repo_name":{"kind":"string","value":"jiewu-stanford/leetcode"},"__id__":{"kind":"number","value":14250701521205,"string":"14,250,701,521,205"},"blob_id":{"kind":"string","value":"6f8feacc8be74cd5382cebdf629582765db1b75d"},"directory_id":{"kind":"string","value":"e90a772733e73e45b4cdbb5f240ef3b4a9e71de1"},"path":{"kind":"string","value":"/443. String Compression.py"},"content_id":{"kind":"string","value":"7b3c99181fa20c5abbb7b9dbcb358cb76b759b88"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/jiewu-stanford/leetcode"},"snapshot_id":{"kind":"string","value":"102829fcbcace17909e4de49c01c3d705b6e6e3a"},"revision_id":{"kind":"string","value":"cbd47f713d3307f900daf55c8f27301c70542fc4"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-05-28T18:25:00.885047","string":"2022-05-28T18:25:00.885047"},"revision_date":{"kind":"timestamp","value":"2022-05-18T05:16:22","string":"2022-05-18T05:16:22"},"committer_date":{"kind":"timestamp","value":"2022-05-18T05:16:22","string":"2022-05-18T05:16:22"},"github_id":{"kind":"number","value":214486622,"string":"214,486,622"},"star_events_count":{"kind":"number","value":2,"string":"2"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"'''\nTitle : 443. String Compression\nProblem : https://leetcode.com/problems/string-compression/\n'''\n'''\ntwo-pointer strategy, one read pointer (i) + one write pointer (j)\nReference: https://leetcode.com/problems/string-compression/discuss/92568/Python-Two-Pointers-O(n)-time-O(1)-space\n'''\nclass Solution:\n def compress(self, chars: List[str]) -> int:\n i = j = 0\n while i < len(chars):\n c, freq = chars[i], 0\n while i < len(chars) and chars[i] == c:\n i, freq = i+1, freq+1\n chars[j], j = c, j+1\n if freq > 1:\n for digit in str(freq):\n chars[j], j = digit, j+1\n return j"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":692,"string":"692"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":371,"string":"371"},"filename":{"kind":"string","value":"443. String Compression.py"},"num_lang_files":{"kind":"number","value":370,"string":"370"},"alphanum_fraction":{"kind":"number","value":0.5447976878612717,"string":"0.544798"},"alpha_fraction":{"kind":"number","value":0.5216763005780347,"string":"0.521676"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":20,"string":"20"},"avg_line_length":{"kind":"number","value":33.65,"string":"33.65"},"max_line_length":{"kind":"number","value":114,"string":"114"}}},{"rowIdx":543,"cells":{"repo_name":{"kind":"string","value":"knowledgetranslation/citation-dedupe"},"__id__":{"kind":"number","value":8203387555402,"string":"8,203,387,555,402"},"blob_id":{"kind":"string","value":"beaf6b2776fc050213f9f6ccb5aa7d9558d3c6c2"},"directory_id":{"kind":"string","value":"59623891733df19652c97f45b221ea5282f74c77"},"path":{"kind":"string","value":"/parser.py"},"content_id":{"kind":"string","value":"efda106c18c0cd72826d3ec70b3d1d00242d666b"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/knowledgetranslation/citation-dedupe"},"snapshot_id":{"kind":"string","value":"b9c4784c7909749b50907f3a51f3d12a5738bea1"},"revision_id":{"kind":"string","value":"7c102bda9bfe0b920830421557c85c887abdb74a"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-04-10T14:56:52.701882","string":"2020-04-10T14:56:52.701882"},"revision_date":{"kind":"timestamp","value":"2015-06-10T19:09:05","string":"2015-06-10T19:09:05"},"committer_date":{"kind":"timestamp","value":"2015-06-10T19:09:05","string":"2015-06-10T19:09:05"},"github_id":{"kind":"number","value":32325476,"string":"32,325,476"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"#!/usr/bin/python3.4\n# -*- coding: utf-8 -*-\nimport os, sys\nimport mysql.connector\nfrom lxml import etree, objectify\nimport logging\nimport json\n# import lxml.usedoctest\n# import xml.etree.cElementTree as ET\n\n# FILES VARS\nPATH = os.path.abspath('.') +'/'\nXML_FILE = PATH + 'lite_sample4.xml' # 'CS Lit Search Comp - all [12530].xml' # 'lite_sample.xml'\nSCHEMA_FILE = PATH + 'xml.xsd' # 'xml_doll_smart.txt' #\n\nPARAMS_FILE = PATH + 'xml_parameters.json'\nMYSQL_CONFIG = PATH + 'db.cnf'\n\n\nclass parser(object):\n # noinspection PyPep8Naming,PyPep8Naming,PyPep8Naming\n def __init__(self, inFile=XML_FILE, tabName='', paramsFile=PARAMS_FILE):\n self.tableName = tabName\n if not self.getParameters(paramsFile):\n logging.warning('WARNING! Please, choose other Parameters file against %s' % paramsFile)\n self.resetExport()\n # sys.exit(0)\n quit\n # return None\n\n # print( self.tableName)\n self.recCount = 0\n self.xmlFile = inFile\n\n self.con = self.connectDB(MYSQL_CONFIG)\n self.cursor = self.con.cursor(buffered = False)\n self.cursor.execute(\"SET net_write_timeout = 3600\")\n\n # noinspection PyPep8Naming,PyPep8Naming\n def startParse(self):\n xml = self.loadXml(self.xmlFile, SCHEMA_FILE)\n\n if xml is not None:\n logging.info('Creating Data table')\n self.createDataTable() # Create Data table\n\n logging.info('Start parsing')\n isParsed = self.parseXml(xml) # Parsing XML and load into Data table\n\n if isParsed:\n logging.info('Data uploaded into DB')\n self.closeAllConnections()\n return True\n else:\n logging.warning('Error! Data wasn\\'t uploaded into DB')\n self.closeAllConnections()\n return False\n else:\n logging.warning('Cannot read XML data from %s' % XML_FILE)\n self.resetParser()\n return False\n\n # noinspection PyPep8Naming,PyPep8Naming,PyPep8Naming\n @staticmethod\n def loadXml(inFile, schemaFile = SCHEMA_FILE):\n # schema = etree.XMLSchema(file=schemaFile)\n # parser = objectify.makeparser(schema=schema)\n\n # if True:# validateXml(inFile, parser):\n try:\n # doctree = objectify.parse(inFile, parser=parser)\n doctree = objectify.parse(inFile) \n except Exception as e: #XMLSyntaxError:\n # else:\n return None\n \n try:\n root = doctree.getroot()\n return root\n except Exception as e: #ValueError:\n return None\n\n # noinspection PyPep8Naming,PyPep8Naming,PyPep8Naming\n def parseXml(self, xmlObject):\n # data = {}\n columnMapInverted = {self.mapColumnToXml[k] : k for k in self.mapColumnToXml}\n\n for r in xmlObject.records.record:\n d = dict((k,'') for k in self.dataElements) # Create dictionary for\n\n for e in r.getchildren():\n if e.tag in self.dataElements:\n if e.text is not None:\n d[e.tag] = e.text\n else:\n try:\n # d[e.tag] = str(e.getchildren()[0]).encode('unicode-escape')\n d[e.tag] = e.findtext('*').encode('unicode-escape')\n except:\n d[e.tag] = ''\n\n elif e.tag in self.groupedElements.values(): # Check if element is Parent for Group\n values_list = []\n\n for s in e.getchildren():\n if s.tag in [self.groupedElements[v] for v in self.listElements]: # Check if element within Group should be in a List\n for aa in s.getiterator(self.listElements): # Select the elements which should be in a List\n values_list.append(aa.findtext('*')) # Get first text in tag 'style' element\n\n d[aa.tag] = self.lineSeparator.join(values_list) # Set Column value = List converted into string with line separator\n\n elif s.tag in self.dataElements:\n # if s.hasattr \n try:\n d[s.tag] = s.findtext('*').encode('unicode-escape')\n # d[s.tag] = str(s.getchildren()[0]).encode('unicode-escape')\n except:\n d[s.tag] = ''\n\n self.loadDataIntoDb(d, r)\n self.recCount += 1\n return True\n\n # noinspection PyPep8Naming,PyPep8Naming\n def loadDataIntoDb(self, dataObject, xml):\n # q_columns = ''\n # q_empty = ''\n\n # Generate Columns list for insert into table\n q_columns = ', '.join(['%s' % self.mapColumnToXml.get(k, k) for k in dataObject.keys()])\n\n # Generate '%s' list for parametric insert into table\n q_empty = ', '.join(['%s' for k in dataObject.keys()])\n\n values = list(dataObject.values())\n\n if self.saveOriginalXml:\n q_columns += ', %s' % self.originalXml\n q_empty += ', %s'\n values.append(etree.tostring(xml))\n\n q = \"insert into %s (%s) values(%s)\" % (self.tableName, q_columns, q_empty) # Prepare sql query\n self.cursor.execute (q, values) # Run sql query\n self.con.commit()\n\n # noinspection PyPep8Naming,PyPep8Naming,PyPep8Naming\n def createDataTable(self):\n # tabFields = ''\n\n # Generate Columns list for new Table\n tabFields = ', '.join(['%s %s' % (field, 'INTEGER' if field in self.integerColumns else 'MEDIUMTEXT') for field in self.columns]) #fields.split(', ')])\n\n q = \"DROP TABLE IF EXISTS %s\" % self.tableName\n self.cursor.execute(q)\n\n q = \"CREATE TABLE %s (%s) CHARACTER SET utf8 COLLATE %s\" % (self.tableName, tabFields, self.tableCollate)\n self.cursor.execute(q)\n\n # noinspection PyPep8Naming,PyPep8Naming\n def getParameters(self, parametersFile):\n \"\"\" Define the Performance parameters and Database source table. \"\"\"\n if os.path.exists(parametersFile):\n logging.info('reading data structure from %s' % parametersFile)\n with open(parametersFile) as df :\n data = json.load(df)\n\n params = data['source_db']\n self.tableCollate = params['collate']\n if self.tableName == '': # added for web API v1\n self.tableName = params['tab_name']\n self.tablePK = params['tab_PK']\n self.columns = params['tab_columns'] # ENDNOTE_COLUMNS\n self.originalXml = params['original_xml_column']\n\n self.saveOriginalXml = data['parser']['save_original_xml']\n\n self.groupedElements = data['grouped_elements']\n self.mapColumnToXml = data['map_column_to_xml']\n self.listElements = data['list_elements']\n self.dataElements = data['data_elements']\n self.integerColumns = data['integer_columns']\n self.lineSeparator = data['line_separator']\n\n return True\n else:\n logging.warning('WARNING! Could not read Parameters from %s' % parametersFile)\n return False\n\n # noinspection PyPep8Naming,PyPep8Naming\n @staticmethod\n def connectDB(dbOptionsFile):\n \"\"\" You need to fill option file `db.cnf` with your mysql database information \"\"\"\n return mysql.connector.connect(option_files = dbOptionsFile)\n\n # noinspection PyPep8Naming\n def closeAllConnections(self):\n if hasattr(self, 'cursor'):\n self.cursor.close()\n\n if hasattr(self, 'con'):\n self.con.close()\n\n # noinspection PyPep8Naming\n def resetParser(self):\n self.recCount = 0\n self.closeAllConnections\n\n\n# noinspection PyPep8Naming\ndef start(xmlFile = XML_FILE):\n global parser\n log_level = logging.WARNING\n initLogging(log_level)\n\n print('Parsering in progress...')\n parser = parser(xmlFile) # initiate analyser\n parser.startParse()\n print('%s records were uploaded' % parser.recCount)\n\ndef reset():\n parser.resetParser()\n\n\n# noinspection PyPep8Naming\ndef initLogging(log_level = logging.WARNING):\n logging.getLogger().setLevel(log_level)\n\n\n# noinspection PyPep8Naming,PyPep8Naming\ndef validateXml(xmlFile, parser):\n # schema = etree.XMLSchema(file=schemaFile)\n # parser = objectify.makeparser(schema=schema)\n try:\n with open(xmlFile, 'r') as f:\n etree.fromstring(f.read(), parser)\n\n logging.info('File validation was successful.')\n return True\n except:\n logging.warning('WARNING! File %s validation was fail.' % xmlFile) #parametersFile)\n return False\n # return objectify.parse(xmlFile, parser=parser)\n\nif __name__ == '__main__':\n start('lite_sample4.xml') #'CS Lit Search Comp - all [12530].xml')"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":9306,"string":"9,306"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":23,"string":"23"},"filename":{"kind":"string","value":"parser.py"},"num_lang_files":{"kind":"number","value":9,"string":"9"},"alphanum_fraction":{"kind":"number","value":0.5646894476681711,"string":"0.564689"},"alpha_fraction":{"kind":"number","value":0.5589941972920697,"string":"0.558994"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":245,"string":"245"},"avg_line_length":{"kind":"number","value":36.987755102040815,"string":"36.987755"},"max_line_length":{"kind":"number","value":159,"string":"159"}}},{"rowIdx":544,"cells":{"repo_name":{"kind":"string","value":"jdleo/Leetcode-Solutions"},"__id__":{"kind":"number","value":609885367083,"string":"609,885,367,083"},"blob_id":{"kind":"string","value":"8b087c2d7ca5930b71315c2e106d1ad80f00bfca"},"directory_id":{"kind":"string","value":"d62d21ea827d5d352515afb07623160ef48c0343"},"path":{"kind":"string","value":"/solutions/1748/main.py"},"content_id":{"kind":"string","value":"b3eab5ea55f47155a96762d9843906f491ef0677"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/jdleo/Leetcode-Solutions"},"snapshot_id":{"kind":"string","value":"e53e77404e358bfa303bb0f873ed9cfe6cb575c0"},"revision_id":{"kind":"string","value":"cf35874b4ca7fdcdc3e0e7beb0a255d8e98d2385"},"branch_name":{"kind":"string","value":"refs/heads/main"},"visit_date":{"kind":"timestamp","value":"2023-03-04T12:26:04.093126","string":"2023-03-04T12:26:04.093126"},"revision_date":{"kind":"timestamp","value":"2021-02-20T05:40:55","string":"2021-02-20T05:40:55"},"committer_date":{"kind":"timestamp","value":"2021-02-20T05:40:55","string":"2021-02-20T05:40:55"},"github_id":{"kind":"number","value":326497152,"string":"326,497,152"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"class Solution:\n def sumOfUnique(self, nums: list[int]) -> int:\n # array to hold count for each num 1 <= nums[i] <= 100\n counts = [0] * 101\n # fill counts\n for num in nums: counts[num] += 1\n # result (sum of uniques)\n res = 0\n # go thru counts\n for i in range(len(counts)):\n # if this is a unique number, add number to res\n if counts[i] == 1: res += i\n return res"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":451,"string":"451"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":136,"string":"136"},"filename":{"kind":"string","value":"main.py"},"num_lang_files":{"kind":"number","value":135,"string":"135"},"alphanum_fraction":{"kind":"number","value":0.5188470066518847,"string":"0.518847"},"alpha_fraction":{"kind":"number","value":0.49445676274944567,"string":"0.494457"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":13,"string":"13"},"avg_line_length":{"kind":"number","value":33.76923076923077,"string":"33.769231"},"max_line_length":{"kind":"number","value":62,"string":"62"}}},{"rowIdx":545,"cells":{"repo_name":{"kind":"string","value":"kaituoxu/PyTorch-ASR-AM"},"__id__":{"kind":"number","value":13125420090203,"string":"13,125,420,090,203"},"blob_id":{"kind":"string","value":"670260cef3b9474a8776f4c99c460a65b58127ae"},"directory_id":{"kind":"string","value":"475a7a542514167d27e22a51003ac83bb3fd933f"},"path":{"kind":"string","value":"/kaldi-python/scripts/compute-global-cmvn-stats.py"},"content_id":{"kind":"string","value":"f0362cc152a45353a5aeeb95370e147e503d9f0b"},"detected_licenses":{"kind":"list like","value":["Apache-2.0"],"string":"[\n \"Apache-2.0\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/kaituoxu/PyTorch-ASR-AM"},"snapshot_id":{"kind":"string","value":"ee13061bbfd5e57aba4f60f6e0093855d022656c"},"revision_id":{"kind":"string","value":"2ea24e9f49b89741979e517cbb6c517f79122c6b"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2021-03-27T14:04:45.185189","string":"2021-03-27T14:04:45.185189"},"revision_date":{"kind":"timestamp","value":"2017-11-30T08:27:36","string":"2017-11-30T08:27:36"},"committer_date":{"kind":"timestamp","value":"2017-11-30T08:27:36","string":"2017-11-30T08:27:36"},"github_id":{"kind":"number","value":104466718,"string":"104,466,718"},"star_events_count":{"kind":"number","value":4,"string":"4"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"#!/usr/bin/env python\n\n'''\nCreated on Aug 6, 2014\n\n@author: chorows\n'''\n\nimport os\nimport sys\nimport logging\nimport argparse\n\nimport numpy as np\n\nimport kaldi_io\n\nif __name__ == '__main__':\n print >>sys.stderr, os.path.basename(sys.argv[0]), \" \".join(sys.argv[1:])\n logging.basicConfig(level=logging.INFO)\n \n parser = argparse.ArgumentParser(description='Accumulate global stats for feature normalization: mean and std')\n parser.add_argument('in_rxfilename')\n parser.add_argument('out_wxfilename')\n args = parser.parse_args()\n \n sum = None\n sum_sq = None\n n = 0\n \n with kaldi_io.SequentialBaseFloatMatrixReader(args.in_rxfilename) as reader:\n for name,feats in reader:\n nframes, nfeats = feats.shape\n n += nframes\n if sum is None:\n sum = np.zeros((nfeats,))\n sum_sq = np.zeros((nfeats,))\n \n sum += feats.sum(0)\n sum_sq += (feats*feats).sum(0) \n \n mean = np.asarray(sum/n, dtype=kaldi_io.KALDI_BASE_FLOAT())\n std = np.asarray(np.sqrt(sum_sq/n - mean**2), \n dtype=kaldi_io.KALDI_BASE_FLOAT())\n \n with kaldi_io.BaseFloatVectorWriter(args.out_wxfilename) as w:\n w['mean'] = mean\n w['std'] = std\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1286,"string":"1,286"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":27,"string":"27"},"filename":{"kind":"string","value":"compute-global-cmvn-stats.py"},"num_lang_files":{"kind":"number","value":21,"string":"21"},"alphanum_fraction":{"kind":"number","value":0.588646967340591,"string":"0.588647"},"alpha_fraction":{"kind":"number","value":0.5800933125972006,"string":"0.580093"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":48,"string":"48"},"avg_line_length":{"kind":"number","value":25.791666666666668,"string":"25.791667"},"max_line_length":{"kind":"number","value":115,"string":"115"}}},{"rowIdx":546,"cells":{"repo_name":{"kind":"string","value":"xelaxela13/stock"},"__id__":{"kind":"number","value":11390253314229,"string":"11,390,253,314,229"},"blob_id":{"kind":"string","value":"bcb441ad040031a8625079686930dbe0dfa0e118"},"directory_id":{"kind":"string","value":"b3452d0dc1650ac75a551ce93e345d79df01c309"},"path":{"kind":"string","value":"/set_env_vars.py"},"content_id":{"kind":"string","value":"3feb571a066300989f21ddee3242adfa2b7fbd44"},"detected_licenses":{"kind":"list like","value":["MIT"],"string":"[\n \"MIT\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/xelaxela13/stock"},"snapshot_id":{"kind":"string","value":"149bf10e93217d7efece76b3ac5ac2498c0ddca7"},"revision_id":{"kind":"string","value":"ef7df50194be340e7faff915e9de4e3b1ade4eca"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-08-13T16:19:09.551752","string":"2022-08-13T16:19:09.551752"},"revision_date":{"kind":"timestamp","value":"2020-02-07T17:55:17","string":"2020-02-07T17:55:17"},"committer_date":{"kind":"timestamp","value":"2020-02-07T17:55:17","string":"2020-02-07T17:55:17"},"github_id":{"kind":"number","value":169874047,"string":"169,874,047"},"star_events_count":{"kind":"number","value":1,"string":"1"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"string","value":"MIT"},"gha_fork":{"kind":"bool","value":false,"string":"false"},"gha_event_created_at":{"kind":"timestamp","value":"2022-04-22T22:25:21","string":"2022-04-22T22:25:21"},"gha_created_at":{"kind":"timestamp","value":"2019-02-09T14:17:25","string":"2019-02-09T14:17:25"},"gha_updated_at":{"kind":"timestamp","value":"2020-04-04T10:55:08","string":"2020-04-04T10:55:08"},"gha_pushed_at":{"kind":"timestamp","value":"2022-04-22T22:25:18","string":"2022-04-22T22:25:18"},"gha_size":{"kind":"number","value":10479,"string":"10,479"},"gha_stargazers_count":{"kind":"number","value":1,"string":"1"},"gha_forks_count":{"kind":"number","value":0,"string":"0"},"gha_open_issues_count":{"kind":"number","value":1,"string":"1"},"gha_language":{"kind":"string","value":"CSS"},"gha_archived":{"kind":"bool","value":false,"string":"false"},"gha_disabled":{"kind":"bool","value":false,"string":"false"},"content":{"kind":"string","value":"import random\nimport string\nimport os.path\n\n\ndef run():\n config = {}\n while True:\n try:\n config['SETTINGS'] = {\n 'SECRET_KEY': random_string(),\n 'ALLOWED_HOSTS': '*',\n 'DEBUG': True,\n 'IPSTACK_ACCESS_KEY': '0e3e331a2e84afc272c53c97982cc67c',\n 'GMAIL_PASSWORD': '',\n 'GMAIL_USER': '',\n 'MEMCACHED_HOST': 'memcached',\n 'MEMCACHED_PORT': '11211'\n\n }\n config['DB'] = {\n 'name': 'postgres',\n 'USER': 'postgres',\n 'HOST': 'db',\n 'PORT': '5432'\n }\n config['common'] = {\n 'PROJECT_ROOT': '/home/user/stock',\n 'IMAGE': 'xelaxela13/stock:latest'\n }\n break\n except ValueError:\n continue\n file = '.env'\n if os.path.isfile(file):\n print('File {} already exist, cannot rewrite it. '.format(file))\n return\n try:\n with open(file, 'w') as f:\n\n for title, conf in config.items():\n f.writelines('[' + str(title).upper() + ']\\n')\n for key, value in conf.items():\n f.writelines('\\t' + str(key).upper() + '=' + str(value) + '\\n')\n print('Config file was created success')\n return\n except Exception as err:\n if os.path.isfile(file):\n os.remove(file)\n print(err)\n return\n\n\ndef random_string():\n return \"\".join(\n [random.SystemRandom().choice(\"{}{}{}\".format(string.ascii_letters, string.digits, string.punctuation))\n for _ in range(50)])\n\n\nif __name__ == '__main__':\n run()\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1736,"string":"1,736"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":70,"string":"70"},"filename":{"kind":"string","value":"set_env_vars.py"},"num_lang_files":{"kind":"number","value":39,"string":"39"},"alphanum_fraction":{"kind":"number","value":0.45622119815668205,"string":"0.456221"},"alpha_fraction":{"kind":"number","value":0.4372119815668203,"string":"0.437212"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":61,"string":"61"},"avg_line_length":{"kind":"number","value":27.459016393442624,"string":"27.459016"},"max_line_length":{"kind":"number","value":111,"string":"111"}}},{"rowIdx":547,"cells":{"repo_name":{"kind":"string","value":"oscar503sv/basicos_python"},"__id__":{"kind":"number","value":42949694097,"string":"42,949,694,097"},"blob_id":{"kind":"string","value":"9fa414230d69fde6199564caacce53427599d5c5"},"directory_id":{"kind":"string","value":"2cf50a2ff667e6fb686de55baf0e1329b386c777"},"path":{"kind":"string","value":"/01-ejercicios/triangulo.py"},"content_id":{"kind":"string","value":"4675a323640099e85b9fe5f6c11f6f9f09af15e8"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/oscar503sv/basicos_python"},"snapshot_id":{"kind":"string","value":"d41c5baaa425e18c47bb8693301e4020033a3c92"},"revision_id":{"kind":"string","value":"dc1ebf240d099ef2de92e238fcd095ab29decc9e"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-06-30T02:26:59.080959","string":"2022-06-30T02:26:59.080959"},"revision_date":{"kind":"timestamp","value":"2020-05-14T05:51:56","string":"2020-05-14T05:51:56"},"committer_date":{"kind":"timestamp","value":"2020-05-14T05:51:56","string":"2020-05-14T05:51:56"},"github_id":{"kind":"number","value":263519570,"string":"263,519,570"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"#Dado de los valores ingresados por el usuario (base, altura) calcular y mostrar en pantalla el área de un triángulo.\n\nprint(\"**********CALCULO DE AREA DE UN TRIANGULO**********\")\nprint(\"Ingresa la base del triángulo:\")\nbase = float(input())\nprint (\"Ingresa la altura del triángulo:\")\naltura = float(input())\n\narea = (base*altura)/2\n\nprint(\"Área:\",area)\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":359,"string":"359"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":60,"string":"60"},"filename":{"kind":"string","value":"triangulo.py"},"num_lang_files":{"kind":"number","value":58,"string":"58"},"alphanum_fraction":{"kind":"number","value":0.6892655367231638,"string":"0.689266"},"alpha_fraction":{"kind":"number","value":0.6864406779661016,"string":"0.686441"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":11,"string":"11"},"avg_line_length":{"kind":"number","value":31.181818181818183,"string":"31.181818"},"max_line_length":{"kind":"number","value":117,"string":"117"}}},{"rowIdx":548,"cells":{"repo_name":{"kind":"string","value":"JokerWDL/PyAnomaly"},"__id__":{"kind":"number","value":3023657007622,"string":"3,023,657,007,622"},"blob_id":{"kind":"string","value":"681750dbf489a6a32e9ef1d6f64d493cc252b272"},"directory_id":{"kind":"string","value":"f6c69a7f7f1bbae5fd5473dfaac5ef5fad840d58"},"path":{"kind":"string","value":"/lib/datatools/build/__init__.py"},"content_id":{"kind":"string","value":"2dcefc70c84d3f4061e0e716788bdf5dca8ba63f"},"detected_licenses":{"kind":"list like","value":["Apache-2.0"],"string":"[\n \"Apache-2.0\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/JokerWDL/PyAnomaly"},"snapshot_id":{"kind":"string","value":"8c5ca4ca705a1251c70ff1f36c908c8f6f75e7d8"},"revision_id":{"kind":"string","value":"cf93437e5d7ae87fa916141cf4b5cc2e929b8199"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-11-05T11:31:42.345422","string":"2022-11-05T11:31:42.345422"},"revision_date":{"kind":"timestamp","value":"2020-06-22T17:21:20","string":"2020-06-22T17:21:20"},"committer_date":{"kind":"timestamp","value":"2020-06-22T17:21:20","string":"2020-06-22T17:21:20"},"github_id":{"kind":"number","value":274295638,"string":"274,295,638"},"star_events_count":{"kind":"number","value":1,"string":"1"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"string","value":"Apache-2.0"},"gha_fork":{"kind":"bool","value":true,"string":"true"},"gha_event_created_at":{"kind":"timestamp","value":"2020-06-23T03:04:32","string":"2020-06-23T03:04:32"},"gha_created_at":{"kind":"timestamp","value":"2020-06-23T03:04:31","string":"2020-06-23T03:04:31"},"gha_updated_at":{"kind":"timestamp","value":"2020-06-23T03:04:30","string":"2020-06-23T03:04:30"},"gha_pushed_at":{"kind":"timestamp","value":"2020-06-22T17:22:06","string":"2020-06-22T17:22:06"},"gha_size":{"kind":"number","value":5820,"string":"5,820"},"gha_stargazers_count":{"kind":"number","value":0,"string":"0"},"gha_forks_count":{"kind":"number","value":0,"string":"0"},"gha_open_issues_count":{"kind":"number","value":0,"string":"0"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"bool","value":false,"string":"false"},"gha_disabled":{"kind":"bool","value":false,"string":"false"},"content":{"kind":"string","value":"from .. import dataclass # trigger the register in the dataclass package\r\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":74,"string":"74"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":80,"string":"80"},"filename":{"kind":"string","value":"__init__.py"},"num_lang_files":{"kind":"number","value":67,"string":"67"},"alphanum_fraction":{"kind":"number","value":0.7837837837837838,"string":"0.783784"},"alpha_fraction":{"kind":"number","value":0.7837837837837838,"string":"0.783784"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":1,"string":"1"},"avg_line_length":{"kind":"number","value":72,"string":"72"},"max_line_length":{"kind":"number","value":72,"string":"72"}}},{"rowIdx":549,"cells":{"repo_name":{"kind":"string","value":"nilswiersma/dfaplayground"},"__id__":{"kind":"number","value":5523327977312,"string":"5,523,327,977,312"},"blob_id":{"kind":"string","value":"a35e82a2a68b5261aef5bdc9e7bd7bc9cce200e5"},"directory_id":{"kind":"string","value":"bd3aa6c6847f67597642ce8c9c7e8f9d1cd7580f"},"path":{"kind":"string","value":"/classic.py"},"content_id":{"kind":"string","value":"ea897e27b2bb9e5c22e774053afeff006439919c"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/nilswiersma/dfaplayground"},"snapshot_id":{"kind":"string","value":"4c223620f5457e7cd75d0ab21cd5107be7e80f9b"},"revision_id":{"kind":"string","value":"f87baf2c3c1a9144a6d9d756409614c41e642317"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-07-19T18:48:18.560203","string":"2022-07-19T18:48:18.560203"},"revision_date":{"kind":"timestamp","value":"2020-05-13T14:44:28","string":"2020-05-13T14:44:28"},"committer_date":{"kind":"timestamp","value":"2020-05-13T14:44:28","string":"2020-05-13T14:44:28"},"github_id":{"kind":"number","value":257861193,"string":"257,861,193"},"star_events_count":{"kind":"number","value":5,"string":"5"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"from submod.aes.aes import AES, matrix2bytes\r\nfrom submod.JeanGrey.phoenixAES import phoenixAES\r\nimport random, os\r\nimport faultmodels\r\n\r\n\r\nintermediates = [\r\n # 'input',\r\n # 'ark0',\r\n # 'sb1',\r\n # 'sr1',\r\n # 'mc1',\r\n # 'ark1',\r\n # 'sb2',\r\n # 'sr2',\r\n # 'mc2',\r\n # 'ark2',\r\n # 'sb3',\r\n # 'sr3',\r\n # 'mc3',\r\n # 'ark3',\r\n # 'sb4',\r\n # 'sr4',\r\n # 'mc4',\r\n # 'ark4',\r\n # 'sb5',\r\n # 'sr5',\r\n # 'mc5',\r\n # 'ark5',\r\n # 'sb6',\r\n # 'sr6',\r\n\r\n # 'mc6',\r\n # 'ark6',\r\n # 'sb7',\r\n # 'sr7',\r\n\r\n 'mc7',\r\n 'ark7',\r\n 'sb8',\r\n 'sr8',\r\n\r\n 'mc8',\r\n 'ark8',\r\n 'sb9',\r\n 'sr9',\r\n \r\n # 'mc9',\r\n # 'ark9',\r\n # 'sb10',\r\n # 'sr10',\r\n # 'ark10',\r\n ]\r\n\r\nkey = b'SiDeChaNneLMarVl'\r\nmessage = b'sUpErSEcREtmESsG'\r\nctx = AES(bytes(key))\r\nciphertext = ctx.encrypt_block(bytes(message))\r\niks = [b''.join(map(lambda x: bytes(x), ik)) for ik in ctx._key_matrices]\r\n\r\nprint(f'key : {key.hex()}')\r\nprint(f'message : {message.hex()}')\r\nprint(f'ciphertext : {ciphertext.hex()}')\r\nctr = 0\r\nfor ik in iks:\r\n print(f'ik{ctr:02} : {ik.hex()}')\r\n ctr += 1\r\n\r\nprint('--encrypt--')\r\nfor intermediate in intermediates:\r\n print(f'--{intermediate}--')\r\n faulted = []\r\n for _ in range(10):\r\n faulted.append(os.urandom(16))\r\n for _ in range(200):\r\n faulted.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=faultmodels.single_bit_flip))\r\n # faulted.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=single_byte_corruption))\r\n # faulted.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=single_col_corruption))\r\n # faulted.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=single_byte_multi_bit_flip))\r\n # faulted.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=double_byte_multi_bit_flip))\r\n # faulted.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=triple_byte_multi_bit_flip))\r\n # print(f'faulted : {faulted[-1].hex()}')\r\n random.shuffle(faulted)\r\n # roundkey, idx, candidates = phoenixAES.crack_bytes(faulted, ciphertext, verbose=0, encrypt=True)\r\n # print(f\"roundkey : {''.join(['%02x' % x if x is not None else '..' for x in roundkey])} ({idx}, {intermediate})\")\r\n roundkey, idx, candidates = phoenixAES.crack_bytes(faulted, ciphertext, verbose=0, encrypt=True)\r\n print(f\"roundkey : {''.join(['%02x' % x if x is not None else '..' for x in roundkey])} ({idx}, {intermediate})\")\r\n if None in roundkey:\r\n # roundkey, idx, candidates = phoenixAES.crack_bytes(\r\n # phoenixAES.convert_r8faults_bytes(faulted, ciphertext), ciphertext, verbose=0, encrypt=True)\r\n # print(f\"roundkey : {''.join(['%02x' % x if x is not None else '..' for x in roundkey])} ({idx}, {intermediate})\")\r\n roundkey, idx, candidates = phoenixAES.crack_bytes(\r\n phoenixAES.convert_r8faults_bytes(faulted, ciphertext), ciphertext, verbose=0, encrypt=True)\r\n print(f\"roundkey : {''.join(['%02x' % x if x is not None else '..' for x in roundkey])} ({idx}, {intermediate})\")\r\n # print(candidates)\r\n\r\n\r\n\r\n# print('--encrypt--')\r\n# for intermediate in intermediates:\r\n# print(f'--{intermediate}--')\r\n# output = []\r\n# candidates=[[], [], [], []]\r\n# recovered=[False, False, False, False]\r\n# key=[None]*16\r\n# prev=''\r\n# for ctr in range(int(1e6)):\r\n# r = random.randint(0,255)\r\n# if r == 0:\r\n# output.append(os.urandom(16))\r\n# elif r == 1:\r\n# output.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=single_bit_flip))\r\n# else:\r\n# output.append(ciphertext)\r\n\r\n# phoenixAES.crack_bytes_rolling(output[-1], ciphertext, candidates, recovered, key, verbose=0, encrypt=True)\r\n# new=''.join(['%02x' % x if x is not None else '..' for x in key])\r\n# if prev != new:\r\n# print(new, ctr)\r\n# prev = new\r\n# # print(recovered)\r\n# if not False in recovered:\r\n# break\r\n# print(ctr)\r\n# print(iks[-1].hex(), iks[-1].hex() == ''.join(['%02x' % x if x is not None else '..' for x in key]))\r\n\r\n# roundkey, idx, candidates = phoenixAES.crack_bytes(output, ciphertext, verbose=0, encrypt=True)\r\n# print(f\"roundkey : {''.join(['%02x' % x if x is not None else '..' for x in roundkey])} ({idx}, {intermediate})\")\r\n\r\n\r\n\r\n# print('--decrypt--')\r\n# for intermediate in intermediates:\r\n# faulted = []\r\n# for _ in range(50):\r\n# faulted.append(ctx.decrypt_block(bytes(ciphertext), glitch_at=intermediate))\r\n# # print(f'faulted : {faulted[-1].hex()}')\r\n# recovered, idx = phoenixAES.crack_bytes(faulted, message, verbose=0, encrypt=False)\r\n# if recovered:\r\n# print(f'recovered : {recovered.hex()} ({idx}, {intermediate})')\r\n\r\nfaulted = [\r\n bytes.fromhex('ab73e91362fc2db70d99cce0aa2deecf'),\r\n bytes.fromhex('abf73f13ff062db79a99cc3faa2d1eca'),\r\n bytes.fromhex('abf7745fff5330b769cbcc3f882d1e3f'),\r\n bytes.fromhex('ab06eb13e8742db74a99ccbdaa2db4e9'),\r\n bytes.fromhex('abdbe9ef62fc87b70dbccc9c5e2d49cf'),\r\n bytes.fromhex('abcee9139dfc2db70d99ccadaa2d0bcf'),\r\n bytes.fromhex('abf74741ff2e0fb76e55cc3f772d1eab'),\r\n bytes.fromhex('abf79613ff0a2db73899cc3faa2d1ecb'),\r\n bytes.fromhex('e1f7d613ffa82dc46c993d3faa8f1ec4'),\r\n bytes.fromhex('5af72013ff732dc41899013faa781ee0'),\r\n bytes.fromhex('abf7e970fffc1ab70d8ccc3f9f2d1ecf'),\r\n bytes.fromhex('ab18e923eefcb4b70db3cc81fa2d5fcf'),\r\n bytes.fromhex('8b36e9131afc2d970d99cf36aa8f49cf'),\r\n bytes.fromhex('ab4334130af12db78499ccd3aa2de639'),\r\n bytes.fromhex('aef7e913fffc2d8f0d99643faabe1ecf'),\r\n bytes.fromhex('abf7e15effbf55b730c8cc3f772d1e45'),\r\n bytes.fromhex('ab6ae9133afc2db70d99cc85aa2d52cf'),\r\n bytes.fromhex('417ce91322fc2d820d9965d8aa372ecf'),\r\n bytes.fromhex('b2f7e97efffc15a50dfac03f32561ecf'),\r\n bytes.fromhex('c7dbe91389fc2dc60d99cdcdaa8cd7cf'),\r\n bytes.fromhex('ab62e913d4fc2db70d99ccc8aa2de8cf'),\r\n bytes.fromhex('abf7e994fffc67b70d41cc3ff22d1ecf'),\r\n bytes.fromhex('ab9ee9b234fc70b70df2cc40862d9ecf'),\r\n bytes.fromhex('abf76713ffca2db70899cc3faa2d1ee7'),\r\n bytes.fromhex('c7f7e9cefffc12f00dffd83f19661ecf'),\r\n bytes.fromhex('ab657a133b192db7e499cc51aa2dc7e6'),\r\n bytes.fromhex('72f7e941fffc037a0d08373fb5591ecf'),\r\n bytes.fromhex('5af7e954fffca6c40d61013f90781ecf'),\r\n bytes.fromhex('ab52771305912db71099ccbfaa2dfa16'),\r\n bytes.fromhex('9da6e913c8fc2d180d99148caad236cf'),\r\n bytes.fromhex('da2fe913f0fc2ddb0d99f8e1aaa2fecf'),\r\n bytes.fromhex('abf72013ffdc2db78e99cc3faa2d1e84'),\r\n bytes.fromhex('21b2e91319fc2d440d994d8baa1852cf'),\r\n bytes.fromhex('00f7f713ff392d8acd992d3faa5d1e26'),\r\n bytes.fromhex('ab3de9136afc2db70d99cc0faa2d7ccf'),\r\n bytes.fromhex('8cf7f413ffc82ddbf399e03faa071e9d'),\r\n bytes.fromhex('abfb341381372db74799cce7aa2d2e74'),\r\n bytes.fromhex('11f79713ffdb2d8bbc99623faad51e05'),\r\n bytes.fromhex('abcec31309e42db72899ccd1aa2d2ebe'),\r\n bytes.fromhex('abae3f135aca2db7c299ccd3aa2d95ee'),\r\n bytes.fromhex('213be91325fc2d440d994d24aa18a0cf'),\r\n bytes.fromhex('ab949713a9612db78d99cceaaa2d2c7c'),\r\n bytes.fromhex('abf7e963fffc5cb70dd9cc3f8c2d1ecf'),\r\n bytes.fromhex('fa1ce913edfc2dfb0d9956b6aa45a9cf'),\r\n bytes.fromhex('8bd4e91332fc2da50d99ace8aa1bdfcf'),\r\n bytes.fromhex('daa6e913f1fc2d6c0d994de8aa8e1ccf'),\r\n bytes.fromhex('ab282713d37d2db7ab99cc73aa2dee6d'),\r\n bytes.fromhex('ab6096135a592db7aa99cc84aa2dee12'),\r\n bytes.fromhex('0ef7e95efffca0d20d55593f264f1ecf'),\r\n bytes.fromhex('daf73813ff282d445199d83faa0e1e6e'),\r\n bytes.fromhex('abfbbb1381f92db71a99cce7aa2d2e75'),\r\n bytes.fromhex('4620e9139dfc2dd80d9985e5aa3c54cf'),\r\n bytes.fromhex('abf765a5ffce57b73f60cc3f822d1e4a'),\r\n bytes.fromhex('ab9ee913f7fc2db70d99ccceaa2d45cf'),\r\n bytes.fromhex('c8a5e9136cfc2d8e0d99472faace0fcf'),\r\n bytes.fromhex('46ece91343fc2d170d9990a6aacc00cf'),\r\n bytes.fromhex('abf738d3ff5f45b794bccc3f742d1e47'),\r\n bytes.fromhex('6ff7e913fffc2d940d993c3faa0a1ecf'),\r\n bytes.fromhex('9bf7e9a9fffcb6be0d26793f73c41ecf'),\r\n bytes.fromhex('2dcde9135dfc2d330d999873aaa0f8cf'),\r\n bytes.fromhex('007fe913a6fc2d8a0d992d04aa5d40cf'),\r\n bytes.fromhex('abf7e9d1fffc88b70db6cc3f142d1ecf'),\r\n bytes.fromhex('11f7e9f2fffcfca20dde7a3fd8e31ecf'),\r\n bytes.fromhex('abf7f913ff322db7b299cc3faa2d1ec9'),\r\n bytes.fromhex('abc9e9411dfca0b70dc8ccc0e02dc2cf'),\r\n bytes.fromhex('cd7be913f8fc2dae0d9970d0aafef6cf'),\r\n bytes.fromhex('abf72a93ff2ed4b7499dcc3f0f2d1efc'),\r\n bytes.fromhex('abffe91333fc2db70d99cc12aa2de3cf'),\r\n bytes.fromhex('abf797c6ff3868b73903cc3f0d2d1eb3'),\r\n bytes.fromhex('93f7e9bffffcb6ef0dfac73f36ac1ecf'),\r\n bytes.fromhex('5df78813ff742dc4a799cf3faaa51ed3'),\r\n bytes.fromhex('abf75e11ff50b1b73660cc3f6b2d1e66'),\r\n bytes.fromhex('abf7674eff0b4cb7af94cc3faf2d1eea'),\r\n bytes.fromhex('abf7e954fffc78b70d14cc3fd62d1ecf'),\r\n bytes.fromhex('93f7e613ff962dfa0099783faa051e32'),\r\n bytes.fromhex('83f7d613ffa82dc76c99be3faa421ec4'),\r\n bytes.fromhex('79f7e9d3fffc45860dbc203f74491ecf'),\r\n bytes.fromhex('abf731a1ff4aa6b76c43cc3fd12d1ebf'),\r\n bytes.fromhex('abf7cd64ff8480b70a71cc3f3f2d1ee6'),\r\n bytes.fromhex('abf7e940fffcc3b70d4ccc3fd02d1ecf'),\r\n bytes.fromhex('ab2f1513200b2db7bc99ccc5aa2d6e7c'),\r\n bytes.fromhex('21f7e913fffc2d290d99383faa9f1ecf'),\r\n bytes.fromhex('abf77a86ffd9c7b7c139cc3fde2d1e23'),\r\n bytes.fromhex('abc7e913dffc2db70d99cc9caa2dd7cf'),\r\n bytes.fromhex('34f7e923fffcf7ef0d72473f4d471ecf'),\r\n bytes.fromhex('ab6fe91305fc2db70d99cc13aa2d3dcf'),\r\n bytes.fromhex('abc5e93eb7fc45b70d33cc21a42dcacf'),\r\n bytes.fromhex('abf7778bff91ceb71054cc3f892d1e16'),\r\n bytes.fromhex('abf71013ff062db7b799cc3faa2d1ecc'),\r\n bytes.fromhex('abf78c13ff912db70d99cc3faa2d1e81'),\r\n bytes.fromhex('34f7e941fffc03fb0d08633fb5ce1ecf'),\r\n bytes.fromhex('ab8de913f3fc2db70d99cc61aa2d94cf'),\r\n bytes.fromhex('ab57e9b79cfc70b70d73cc6c202de3cf'),\r\n bytes.fromhex('b0f7e945fffcc0a60d84f23f52e01ecf'),\r\n bytes.fromhex('abf71792ff4213b7eb36cc3f2c2d1e58'),\r\n bytes.fromhex('abc4e9ed32fcfbb70d97cc2b492dddcf'),\r\n bytes.fromhex('abf7e919fffc26b70d04cc3ff52d1ecf'),\r\n bytes.fromhex('b7dbe91362fc2d2c0d99879caa2f49cf'),\r\n bytes.fromhex('2cf7e947fffc215b0dc8873f39a91ecf'),\r\n bytes.fromhex('abf7f72eff19a1b70828cc3f732d1e23'),\r\n bytes.fromhex('e3f7e913fffc2d1c0d99c83faa0f1ecf'),\r\n bytes.fromhex('abf7df47ff8ff7b79081cc3fce2d1ec4'),\r\n bytes.fromhex('ab93e9138ffc2db70d99ccb6aa2d88cf'),\r\n bytes.fromhex('9bf7e9a9fffca1020de5ec3f79491ecf'),\r\n bytes.fromhex('abf7061eff4507b77ececc3f172d1ef9'),\r\n bytes.fromhex('abf79813ff0a2db72599cc3faa2d1e2f'),\r\n]\r\n\r\n# print('--encrypt--')\r\n# for intermediate in ['sb9']:\r\n# print(f'--{intermediate}--')\r\n# # faulted = []\r\n# # # # for _ in range(10000):\r\n# # # # faulted.append(os.urandom(16))\r\n# # for _ in range(500):\r\n# # faulted.append(ctx.encrypt_block(bytes(message), glitch_at=intermediate, glitch=double_byte_multi_bit_flip))\r\n# # random.shuffle(faulted)\r\n# # for f in faulted:\r\n# # print(f\"bytes.fromhex('{f.hex()}'),\")\r\n# roundkey, idx, candidates = phoenixAES.crack_bytes(faulted[:200], ciphertext, verbose=0, encrypt=True)\r\n# print(f\"roundkey : {''.join(['%02x' % x if x is not None else '..' for x in roundkey])} ({idx}, {intermediate})\")\r\n# # print(candidates)\r\n\r\n# with open('tracefile', 'w') as t:\r\n# print(ciphertext.hex(), file=t)\r\n# for f in faulted:\r\n# print(f.hex(), file=t)\r\n\r\n# cracker = phoenixAES.ByteCracker(ciphertext, encrypt=True, verbose=0)\r\n# for faulty in faulted:\r\n# roundkey, idx, candidates = cracker.crack_bytes(faulty)\r\n# print(f\"roundkey : {''.join(['%02x' % x if x is not None else '..' for x in roundkey])} ({idx})\")"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":12095,"string":"12,095"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":8,"string":"8"},"filename":{"kind":"string","value":"classic.py"},"num_lang_files":{"kind":"number","value":6,"string":"6"},"alphanum_fraction":{"kind":"number","value":0.6747416287722199,"string":"0.674742"},"alpha_fraction":{"kind":"number","value":0.5284001653575858,"string":"0.5284"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":274,"string":"274"},"avg_line_length":{"kind":"number","value":42.14963503649635,"string":"42.149635"},"max_line_length":{"kind":"number","value":125,"string":"125"}}},{"rowIdx":550,"cells":{"repo_name":{"kind":"string","value":"yuhong270991/dp"},"__id__":{"kind":"number","value":11751030522333,"string":"11,751,030,522,333"},"blob_id":{"kind":"string","value":"3efcd53825acf6d3c987f1cd60afca8d3f5da20f"},"directory_id":{"kind":"string","value":"e70b5dab798c183eeb3b861ad96ca654ddafacfc"},"path":{"kind":"string","value":"/Python/KNN/knn.py"},"content_id":{"kind":"string","value":"2d197256ec4982988dd127decd5e3cdc2a9c5439"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/yuhong270991/dp"},"snapshot_id":{"kind":"string","value":"3054ddaca1bdf466647e5945f698c68da68435a1"},"revision_id":{"kind":"string","value":"b9107cb2aca129dec78f07d3e5da01764f020baf"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-04-08T19:37:43.616086","string":"2022-04-08T19:37:43.616086"},"revision_date":{"kind":"timestamp","value":"2020-03-05T04:59:50","string":"2020-03-05T04:59:50"},"committer_date":{"kind":"timestamp","value":"2020-03-05T04:59:50","string":"2020-03-05T04:59:50"},"github_id":{"kind":"number","value":149475644,"string":"149,475,644"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":1,"string":"1"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"import math\nimport numpy as np\nfrom operator import itemgetter\n\n#normalizes a given dataset X (where X is a n-D array. The last column is not normalized)\ndef dataNorm(X):\n num_col = X.shape[-1]\n last_column = X[:, num_col-1]\n X_norm = (X - X.min(axis = 0)) / (X.ptp(axis = 0))\n X_norm[:, num_col-1] = last_column\n return X_norm\n\n#split normalized dataset into training and test set, PercentTrain is the % of data for training\ndef splitTT(X_norm, PercentTrain):\n #shuffle the rows\n np.random.shuffle(X_norm)\n #find where to split\n sI = int(PercentTrain * len(X_norm))\n #training and test split (train set: everything until splitindex, test set: from split index to end)\n return X_norm[:sI], X_norm[sI:]\n\ndef splitCV(X_norm, K):\n #shuffle and split the n-D array into a list of K n-D arrays\n np.random.shuffle(X_norm)\n return np.array_split(X_norm, K)\n\n#generalizes euclidean/manhattan and minkowski into a single function\ndef minkow_dist(A, B, length, order):\n if(order == 2):\n return eucl_dist(A, B, length)\n else:\n distance = 0.0\n num_attribs = length - 1 #dont include rings\n for i in range(num_attribs):\n distance += pow(abs(A[i] - B[i]), order)\n return (distance ** 1.0/order)\n\n#finds the euclidean distance between 2 equal length tuples A and B given the number of elements in each tuple\ndef eucl_dist(A, B, length):\n distance = 0.0\n num_attribs = length - 1 #dont include rings\n for i in range(num_attribs):\n distance += pow((A[i] - B[i]), 2)\n return math.sqrt(distance) \n\ndef getKNN(testData, dataset, num_cols, K, order):\n distance_list = []\n #pair distance and data in a list and sort based on smallest distance, only add last col(rings)\n for i in range(len(dataset)):\n dist = minkow_dist(testData, dataset[i], num_cols, order)\n distance_list.append((dist, dataset[i][-1]))\n distance_list = sorted(distance_list, key=itemgetter(0))\n #get the first K neighbours after sorting\n neighbours = []\n for i in range(K):\n neighbours.append(distance_list[i][1])\n return neighbours\n\ndef predict(neighbours, K):\n #compute the count for each unique label in neighbours\n instances, counts = np.unique(neighbours, return_counts = True)\n countlist = []\n for i in range(len(counts)):\n countlist.append((counts[i], instances[i]))\n #reverse so highest count will be first value in dict\n countlist = sorted(countlist, key = itemgetter(0), reverse = True)\n #take the first value as the result\n return countlist[0][1]\n\ndef KNN(X_train, X_test, K):\n N = len(X_test)\n num_col = X_test.shape[-1]\n correct = 0.0\n for i in range(N):\n neighbours = getKNN(X_test[i], X_train, num_col, K, 2)\n result = predict(neighbours, K)\n # if number of rings are correct\n if result == X_test[i][-1]:\n correct += 1.0\n #return percentage of correct as accuracy\n return (correct / float(N)) * 100.0\n\ndef KNNManhattan(X_train, X_test, K):\n N = len(X_test)\n num_col = X_test.shape[-1]\n correct = 0.0\n for i in range(N):\n #order is 1 for manhattan dist\n neighbours = getKNN(X_test[i], X_train, num_col, K, 1)\n result = predict(neighbours, K)\n # if number of rings are correct\n if result == X_test[i][-1]:\n correct += 1.0\n #return percentage of correct as accuracy\n return (correct / float(N)) * 100.0\n\ndef KNNMinkow(X_train, X_test, K):\n N = len(X_test)\n num_col = X_test.shape[-1]\n correct = 0.0\n for i in range(N):\n #order is 3 for minkowski dist\n neighbours = getKNN(X_test[i], X_train, num_col, K, 3)\n result = predict(neighbours, K)\n # if number of rings are correct\n if result == X_test[i][-1]:\n correct += 1.0\n #return percentage of correct as accuracy\n return (correct / float(N)) * 100.0\n\n\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":3939,"string":"3,939"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":187,"string":"187"},"filename":{"kind":"string","value":"knn.py"},"num_lang_files":{"kind":"number","value":163,"string":"163"},"alphanum_fraction":{"kind":"number","value":0.6296014216806296,"string":"0.629601"},"alpha_fraction":{"kind":"number","value":0.6151307438436151,"string":"0.615131"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":109,"string":"109"},"avg_line_length":{"kind":"number","value":35.11926605504587,"string":"35.119266"},"max_line_length":{"kind":"number","value":110,"string":"110"}}},{"rowIdx":551,"cells":{"repo_name":{"kind":"string","value":"ska-telescope/skampi"},"__id__":{"kind":"number","value":17952963334781,"string":"17,952,963,334,781"},"blob_id":{"kind":"string","value":"f9778352cfe683055d4a79ad22df02b8ecd4daa6"},"directory_id":{"kind":"string","value":"0de83c64ff184ce999910782886851606e0b0634"},"path":{"kind":"string","value":"/tests/resources/models/mvp_model/states.py"},"content_id":{"kind":"string","value":"b4d389d18f48c16485d71e08a32496f3985a00a1"},"detected_licenses":{"kind":"list like","value":["BSD-3-Clause"],"string":"[\n \"BSD-3-Clause\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/ska-telescope/skampi"},"snapshot_id":{"kind":"string","value":"1ce33740389a0a7489bd58383fab47d5557dc6fc"},"revision_id":{"kind":"string","value":"3ee1e8df0d6612fda6822702561eae89dd7b9cdb"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2023-08-31T05:23:25.038516","string":"2023-08-31T05:23:25.038516"},"revision_date":{"kind":"timestamp","value":"2023-08-29T08:48:56","string":"2023-08-29T08:48:56"},"committer_date":{"kind":"timestamp","value":"2023-08-29T08:48:56","string":"2023-08-29T08:48:56"},"github_id":{"kind":"number","value":176765819,"string":"176,765,819"},"star_events_count":{"kind":"number","value":1,"string":"1"},"fork_events_count":{"kind":"number","value":2,"string":"2"},"gha_license_id":{"kind":"string","value":"BSD-3-Clause"},"gha_fork":{"kind":"bool","value":false,"string":"false"},"gha_event_created_at":{"kind":"timestamp","value":"2023-02-11T00:47:56","string":"2023-02-11T00:47:56"},"gha_created_at":{"kind":"timestamp","value":"2019-03-20T15:40:38","string":"2019-03-20T15:40:38"},"gha_updated_at":{"kind":"timestamp","value":"2022-11-03T12:16:30","string":"2022-11-03T12:16:30"},"gha_pushed_at":{"kind":"timestamp","value":"2023-02-11T00:47:56","string":"2023-02-11T00:47:56"},"gha_size":{"kind":"number","value":12961,"string":"12,961"},"gha_stargazers_count":{"kind":"number","value":5,"string":"5"},"gha_forks_count":{"kind":"number","value":1,"string":"1"},"gha_open_issues_count":{"kind":"number","value":6,"string":"6"},"gha_language":{"kind":"string","value":"Python"},"gha_archived":{"kind":"bool","value":false,"string":"false"},"gha_disabled":{"kind":"bool","value":false,"string":"false"},"content":{"kind":"string","value":"\"\"\"\nmodule containing values for interpreting enumerated values (e.g. ObsState)\n\"\"\"\n\nimport enum\n\n\nclass ObsState(enum.IntEnum):\n \"\"\"Representation of int ObsState as an Enum.\"\"\"\n\n EMPTY = 0\n RESOURCING = 1\n IDLE = 2\n CONFIGURING = 3\n READY = 4\n SCANNING = 5\n ABORTING = 6\n ABORTED = 7\n RESETTING = 8\n FAULT = 9\n RESTARTING = 10\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":365,"string":"365"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":225,"string":"225"},"filename":{"kind":"string","value":"states.py"},"num_lang_files":{"kind":"number","value":95,"string":"95"},"alphanum_fraction":{"kind":"number","value":0.6191780821917808,"string":"0.619178"},"alpha_fraction":{"kind":"number","value":0.5863013698630137,"string":"0.586301"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":21,"string":"21"},"avg_line_length":{"kind":"number","value":16.38095238095238,"string":"16.380952"},"max_line_length":{"kind":"number","value":75,"string":"75"}}},{"rowIdx":552,"cells":{"repo_name":{"kind":"string","value":"zhangbc07/Project"},"__id__":{"kind":"number","value":9801115409361,"string":"9,801,115,409,361"},"blob_id":{"kind":"string","value":"41cfa9b8ea2ca2de1a61b6361dfa8922cc68759f"},"directory_id":{"kind":"string","value":"c0859588f13a3ad9729bac5907dfd42b83a48a08"},"path":{"kind":"string","value":"/Mp_loan/Mp_loan.py"},"content_id":{"kind":"string","value":"0f579d81b1f23bd688379df8619f9311af71354c"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/zhangbc07/Project"},"snapshot_id":{"kind":"string","value":"25b9e7744fe2f0089bd92e1ab7252939bb47e1f7"},"revision_id":{"kind":"string","value":"68d7b411350e9fb04fd788fda38bbfa7865f1d24"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-07-23T19:04:19.914211","string":"2022-07-23T19:04:19.914211"},"revision_date":{"kind":"timestamp","value":"2019-11-14T11:11:55","string":"2019-11-14T11:11:55"},"committer_date":{"kind":"timestamp","value":"2019-11-14T11:11:55","string":"2019-11-14T11:11:55"},"github_id":{"kind":"null"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"#!/usr/bin/env python\n# coding: utf-8\n#数据下载:https://mirror.shileizcc.com/Other/LoanStats3a.csv\n# In[1]:\n\n\nimport pandas as pd\nimport warnings\nwarnings.filterwarnings('ignore')\nloans_2007=pd.read_csv('./LoanStats3a.csv',skiprows=1)\n#清除不必要的列\nhalf_count=len(loans_2007)/2\nloans_2007=loans_2007.dropna(thresh=half_count,axis=1)\nloans_2007=loans_2007.drop(['desc','url'],axis=1)\nloans_2007.to_csv('./loans_2007.csv',index=False)\n\n\n# In[2]:\n\n\nloans_2007=pd.read_csv('./loans_2007.csv')\n\n\n# In[3]:\n\n\nloans_2007.head()\n\n\n# In[4]:\n\n\n#清除无用数据\nloans_2007=loans_2007.drop(['id','member_id','funded_amnt','funded_amnt_inv','grade','sub_grade','emp_title','issue_d'],axis=1)\nloans_2007 = loans_2007.drop(['zip_code', 'out_prncp', 'out_prncp_inv', 'total_pymnt','total_pymnt_inv', 'total_rec_prncp'], axis=1)\nloans_2007 = loans_2007.drop(['total_rec_int', 'total_rec_late_fee','recoveries', 'collection_recovery_fee', 'last_pymnt_d', 'last_pymnt_amnt'], axis=1)\n\n\n# In[5]:\n\n\nprint(loans_2007.iloc[0])\nprint(loans_2007.shape[1])\n\n\n# In[6]:\n\n\nprint(loans_2007['loan_status'].value_counts())\n\n\n# In[7]:\n\n\nloans_2007=loans_2007[(loans_2007['loan_status']=='Fully Paid') | (loans_2007['loan_status']=='Charged Off')]\n\nstatus_replace={\n 'loan_status':{\n 'Fully Paid':1,\n 'Charged Off':0,\n }\n}\nloans_2007=loans_2007.replace(status_replace)\n\n\n# In[8]:\n\n\nloans_2007.head()\n\n\n# In[9]:\n\n\n#去除空数据\norig_columns=loans_2007.columns\ndrop_columns=[]\nfor col in orig_columns:\n col_series=loans_2007[col].dropna().unique( )\n if len(col_series)==1:\n drop_columns.append(col)\nloans_2007=loans_2007.drop(drop_columns,axis=1)\n\n\n# In[10]:\n\n\nloans_2007.to_csv('./filtered_loans_2007.csv',index=False)\n\n\n# In[11]:\n\n\n#统计缺失值\nloans=pd.read_csv('./filtered_loans_2007.csv')\nnull_counts=loans.isnull().sum()\n\n\n# In[12]:\n\n\nnull_counts\n\n\n# In[13]:\n\n\n#去掉缺失值较多的数据\nloans=loans.drop('pub_rec_bankruptcies',axis=1)\nloans=loans.dropna(axis=0)\n\n\n# In[14]:\n\n\nloans.dtypes.value_counts()\n\n\n# In[15]:\n\n\n#对object数据进行格式转换\nmapping_dict={\n 'emp_length':{\n '10+ years':10,\n '9 years':9,\n '8 years':8,\n '7 years':7,\n '6 years':6,\n '5 years':5,\n '4 years':4,\n '3 years':3,\n '2 years':2,\n '1 year':1,\n 'n/a':0\n }\n}\nloans=loans.drop(['last_credit_pull_d','earliest_cr_line','addr_state','title'],axis=1)\nloans['int_rate']=loans['int_rate'].str.rstrip('%').astype('float')\nloans['revol_util']=loans['revol_util'].str.rstrip('%').astype('float')\nloans=loans.replace(mapping_dict)\n\n\n# In[16]:\n\n\ncat_columns=['home_ownership','verification_status','emp_length','purpose','term']\ndummy_df=pd.get_dummies(loans[cat_columns])\nloans=pd.concat([loans,dummy_df],axis=1)\nloans=loans.drop(cat_columns,axis=1)\nloans=loans.drop('pymnt_plan',axis=1)\n\nloans.to_csv('./cleaned_loans2007.csv',index=False)\n\n\n# In[17]:\n\n\nloans=pd.read_csv('./cleaned_loans2007.csv')\n\n\n# In[18]:\n\n\nloans.info()\n\n\n# In[19]:\n\n\nfrom sklearn.linear_model import LogisticRegression\nlr=LogisticRegression()\ncols = loans.columns\ntrain_cols = cols.drop('loan_status')\n#得到特征\nfeatures = loans[train_cols]\n#得到标签\ntarget = loans['loan_status']\nlr.fit(features, target)\npredictions = lr.predict(features)\n\n\n# In[20]:\n\n\n#第一次测试——使用逻辑回归测试\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.model_selection import cross_val_predict,KFold\nlr = LogisticRegression()\nkf = KFold()\npredictions = cross_val_predict(lr, features, target, cv=kf)\npredictions = pd.Series(predictions)\n\n#定义指标\n#True positives \ntp_filter = (predictions == 1) & (loans['loan_status']== 1) \ntp = len(predictions[tp_filter])\n#False positives\nfp_filter = (predictions == 1) & (loans['loan_status']== 0) \nfp = len(predictions[fp_filter])\n#True negatives \ntn_filter = (predictions == 0) & (loans['loan_status']== 0) \ntn = len(predictions[tn_filter])\n#False negatives \nfn_filter = (predictions == 0) & (loans['loan_status'] == 1) \nfn = len(predictions[fn_filter])\n# Rates\ntpr = tp / float((tp + fn))\nfpr = fp / float((fp + tn))\n\nprint(tpr)\nprint(fpr)\n\n\n# In[22]:\n\n\n#第二次测试——添加权重项,平衡数据的权重和\nlr=LogisticRegression(class_weight='balanced')\nkf=KFold()\npredictions=cross_val_predict(lr,features,target,cv=kf)\npredictions=pd.Series(predictions)\n\n#True positives \ntp_filter = (predictions == 1) & (loans['loan_status']== 1) \ntp = len(predictions[tp_filter])\n#False positives\nfp_filter = (predictions == 1) & (loans['loan_status']== 0) \nfp = len(predictions[fp_filter])\n#True negatives \ntn_filter = (predictions == 0) & (loans['loan_status']== 0) \ntn = len(predictions[tn_filter])\n#False negatives \nfn_filter = (predictions == 0) & (loans['loan_status'] == 1) \nfn = len(predictions[fn_filter])\n# Rates\ntpr = tp / float((tp + fn))\nfpr = fp / float((fp + tn))\n\nprint(tpr)\nprint(fpr)\n\n\n# In[23]:\n\n\n#第三次测试——自定义权重项\npenalty={\n 0:5,\n 1:1\n}\nlr=LogisticRegression(class_weight=penalty)\nkf=KFold()\npredictions=cross_val_predict(lr,features,target,cv=kf)\npredictions=pd.Series(predictions)\n\n#True positives \ntp_filter = (predictions == 1) & (loans['loan_status']== 1) \ntp = len(predictions[tp_filter])\n#False positives\nfp_filter = (predictions == 1) & (loans['loan_status']== 0) \nfp = len(predictions[fp_filter])\n#True negatives \ntn_filter = (predictions == 0) & (loans['loan_status']== 0) \ntn = len(predictions[tn_filter])\n#False negatives \nfn_filter = (predictions == 0) & (loans['loan_status'] == 1) \nfn = len(predictions[fn_filter])\n# Rates\ntpr = tp / float((tp + fn))\nfpr = fp / float((fp + tn))\n\nprint(tpr)\nprint(fpr)\n\n\n# In[24]:\n\n\n#第四次测试——随机森林\nfrom sklearn.ensemble import RandomForestClassifier\nrf=RandomForestClassifier(n_estimators=10,class_weight='balanced',random_state=1)\nkf=KFold()\npredictions=cross_val_predict(lr,features,target,cv=kf)\npredictions=pd.Series(predictions)\n\n#True positives \ntp_filter = (predictions == 1) & (loans['loan_status']== 1) \ntp = len(predictions[tp_filter])\n#False positives\nfp_filter = (predictions == 1) & (loans['loan_status']== 0) \nfp = len(predictions[fp_filter])\n#True negatives \ntn_filter = (predictions == 0) & (loans['loan_status']== 0) \ntn = len(predictions[tn_filter])\n#False negatives \nfn_filter = (predictions == 0) & (loans['loan_status'] == 1) \nfn = len(predictions[fn_filter])\n# Rates\ntpr = tp / float((tp + fn))\nfpr = fp / float((fp + tn))\n\nprint(tpr)\nprint(fpr)\n\n\n\n\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":6518,"string":"6,518"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":8,"string":"8"},"filename":{"kind":"string","value":"Mp_loan.py"},"num_lang_files":{"kind":"number","value":6,"string":"6"},"alphanum_fraction":{"kind":"number","value":0.66671974522293,"string":"0.66672"},"alpha_fraction":{"kind":"number","value":0.6245222929936306,"string":"0.624522"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":304,"string":"304"},"avg_line_length":{"kind":"number","value":19.644736842105264,"string":"19.644737"},"max_line_length":{"kind":"number","value":152,"string":"152"}}},{"rowIdx":553,"cells":{"repo_name":{"kind":"string","value":"Lackadaisica1/pre-college-dump"},"__id__":{"kind":"number","value":3762391394374,"string":"3,762,391,394,374"},"blob_id":{"kind":"string","value":"6cc9757a4f47d73b6cea60188074f73dbe2ea7f8"},"directory_id":{"kind":"string","value":"f72ff978288a570ea5d0263c830913c67f47b622"},"path":{"kind":"string","value":"/starting-out-with-python/chapter-11/2 - Car Class.py"},"content_id":{"kind":"string","value":"f229f15a09b8bd02f33c9824a6e5f2fd134869f8"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/Lackadaisica1/pre-college-dump"},"snapshot_id":{"kind":"string","value":"2feceb37ded8e092f77f275c6de6ddc03ceb54fc"},"revision_id":{"kind":"string","value":"d99fa2e11124bff6d2f313c03f4561298fd832d9"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-05-07T10:01:50.633289","string":"2020-05-07T10:01:50.633289"},"revision_date":{"kind":"timestamp","value":"2019-06-12T01:35:14","string":"2019-06-12T01:35:14"},"committer_date":{"kind":"timestamp","value":"2019-06-12T01:35:14","string":"2019-06-12T01:35:14"},"github_id":{"kind":"number","value":180401902,"string":"180,401,902"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"bool","value":false,"string":"false"},"gha_event_created_at":{"kind":"timestamp","value":"2019-04-09T16:00:37","string":"2019-04-09T16:00:37"},"gha_created_at":{"kind":"timestamp","value":"2019-04-09T15:53:15","string":"2019-04-09T15:53:15"},"gha_updated_at":{"kind":"timestamp","value":"2019-04-09T15:57:24","string":"2019-04-09T15:57:24"},"gha_pushed_at":{"kind":"timestamp","value":"2019-04-09T16:00:37","string":"2019-04-09T16:00:37"},"gha_size":{"kind":"number","value":0,"string":"0"},"gha_stargazers_count":{"kind":"number","value":0,"string":"0"},"gha_forks_count":{"kind":"number","value":0,"string":"0"},"gha_open_issues_count":{"kind":"number","value":0,"string":"0"},"gha_language":{"kind":"string","value":"Python"},"gha_archived":{"kind":"bool","value":false,"string":"false"},"gha_disabled":{"kind":"bool","value":false,"string":"false"},"content":{"kind":"string","value":"# A program which creates a Car class, and then creates a couple of functions for\r\n# that object\r\nclass Car:\r\n def __init__(self, year_model, make, speed):\r\n self.__year_model = year_model\r\n self.__make = make\r\n self.__speed = 0\r\n def set_make(self, make):\r\n self.__make = self\r\n def set_model_year(self, year_model):\r\n self.__year_model = year_model\r\n def accelerate(self, speed):\r\n self.__speed += 5\r\n def brake(self, speed):\r\n self.__speed -= 5\r\n def get_speed(self):\r\n return self.__speed\r\n\r\nmodel = 1997\r\nmake = 'Toyota'\r\nspeed = 0\r\ncar = Car(model, make, speed)\r\nfor i in range(5):\r\n car.accelerate(speed)\r\n print(\"Here is the car's speed in miles per hour:\", car.get_speed())\r\nfor i in range(5):\r\n car.brake(speed)\r\n print(\"Here is the car's speed in miles per hour:\", car.get_speed())\r\n \r\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":886,"string":"886"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":70,"string":"70"},"filename":{"kind":"string","value":"2 - Car Class.py"},"num_lang_files":{"kind":"number","value":57,"string":"57"},"alphanum_fraction":{"kind":"number","value":0.5869074492099323,"string":"0.586907"},"alpha_fraction":{"kind":"number","value":0.5756207674943566,"string":"0.575621"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":28,"string":"28"},"avg_line_length":{"kind":"number","value":29.428571428571427,"string":"29.428571"},"max_line_length":{"kind":"number","value":81,"string":"81"}}},{"rowIdx":554,"cells":{"repo_name":{"kind":"string","value":"JANMAY007/python_practice"},"__id__":{"kind":"number","value":5909875000938,"string":"5,909,875,000,938"},"blob_id":{"kind":"string","value":"1449c49afebdbc8bb38b2a15c8aae62433ea073f"},"directory_id":{"kind":"string","value":"b6170903be7a09372f92bf8eb22bac8af200f1ef"},"path":{"kind":"string","value":"/Python language practice/code jam solutions/codejam2.py"},"content_id":{"kind":"string","value":"a7c8a13a0b5ab3258c7db84c1eb1892791c756ae"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/JANMAY007/python_practice"},"snapshot_id":{"kind":"string","value":"17b1fc3e4416ff2093ef25b759c41d062cf8195f"},"revision_id":{"kind":"string","value":"f087a1d4404a135dc6ae3bc79b7da52357f302d1"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-04-24T12:10:05.074731","string":"2022-04-24T12:10:05.074731"},"revision_date":{"kind":"timestamp","value":"2020-04-28T12:15:47","string":"2020-04-28T12:15:47"},"committer_date":{"kind":"timestamp","value":"2020-04-28T12:15:47","string":"2020-04-28T12:15:47"},"github_id":{"kind":"number","value":259626954,"string":"259,626,954"},"star_events_count":{"kind":"number","value":1,"string":"1"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"import numpy as np\r\nT = int(input())\r\nfor o in range(1,T+1):\r\n N = int(input())\r\n a = [[int(q) for q in input().split()] for p in range(0,N)]\r\n result = []\r\n x = np.trace(a)\r\n def func(a):\r\n count1=0\r\n for k in range(N):\r\n d = set(a[k])\r\n if len(d) < N:\r\n count1+=1\r\n return(count1) \r\n result = list(map(list, zip(*a)))#transposing a \r\n print ('%s #%d: %d %d %d' % ('Case',o,x,func(a),func(result)))"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":433,"string":"433"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":77,"string":"77"},"filename":{"kind":"string","value":"codejam2.py"},"num_lang_files":{"kind":"number","value":76,"string":"76"},"alphanum_fraction":{"kind":"number","value":0.5057736720554272,"string":"0.505774"},"alpha_fraction":{"kind":"number","value":0.48729792147806006,"string":"0.487298"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":16,"string":"16"},"avg_line_length":{"kind":"number","value":25.1875,"string":"25.1875"},"max_line_length":{"kind":"number","value":64,"string":"64"}}},{"rowIdx":555,"cells":{"repo_name":{"kind":"string","value":"zopepy/leetcode"},"__id__":{"kind":"number","value":6708738925650,"string":"6,708,738,925,650"},"blob_id":{"kind":"string","value":"2cbb7a251b0a13266f85ffa14a9564b700620c15"},"directory_id":{"kind":"string","value":"0d4ec25fb2819de88a801452f176500ccc269724"},"path":{"kind":"string","value":"/remove_k_digits.py"},"content_id":{"kind":"string","value":"e01ac81dfa6f86a3bf70982113d95878c5953047"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/zopepy/leetcode"},"snapshot_id":{"kind":"string","value":"7f4213764a6a079f58402892bd0ede0514e06fcf"},"revision_id":{"kind":"string","value":"3bfee704adb1d94efc8e531b732cf06c4f8aef0f"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-01-09T16:13:09.399620","string":"2022-01-09T16:13:09.399620"},"revision_date":{"kind":"timestamp","value":"2019-05-29T20:00:11","string":"2019-05-29T20:00:11"},"committer_date":{"kind":"timestamp","value":"2019-05-29T20:00:11","string":"2019-05-29T20:00:11"},"github_id":{"kind":"null"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"class Solution:\n def removeKdigits(self, num, k):\n \"\"\"\n :type num: str\n :type k: int\n :rtype: str\n \"\"\"\n def remove_digit(num):\n \tnumlist = list(str(num))\n \tif not numlist or not num:\n \t\treturn \"0\"\n \tl = len(numlist)\n \tfound = False\n \tfor i in range(0, l-1):\n \t\tif numlist[i] > numlist[i+1]:\n \t\t\tfound = True\n \t\t\tbreak\n \tif not found:\n \t\tmax_val = max(numlist, key=lambda x: int(x))\n \t\tfor j,v in enumerate(numlist):\n \t\t\tif v == max_val:\n \t\t\t\tbreak\n \t\tdel numlist[j]\n \t\tif not numlist:\n \t\t\treturn \"0\"\n \t\treturn \"\".join(numlist)\n\n \telse:\n \t\tdel numlist[i]\n \t\tif not numlist:\n \t\t\treturn \"0\"\n \t\treturn \"\".join(numlist)\n\n for i in range(0, k):\n \tnum = int(remove_digit(num))\n \tif not num:\n \t\tbreak\n return num\n\n\ns = Solution()\nprint(s.removeKdigits(9, 1))\n\n\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":994,"string":"994"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":799,"string":"799"},"filename":{"kind":"string","value":"remove_k_digits.py"},"num_lang_files":{"kind":"number","value":798,"string":"798"},"alphanum_fraction":{"kind":"number","value":0.45472837022132795,"string":"0.454728"},"alpha_fraction":{"kind":"number","value":0.44567404426559354,"string":"0.445674"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":42,"string":"42"},"avg_line_length":{"kind":"number","value":22.61904761904762,"string":"22.619048"},"max_line_length":{"kind":"number","value":54,"string":"54"}}},{"rowIdx":556,"cells":{"repo_name":{"kind":"string","value":"Nimitz14/HR_temp_prediction"},"__id__":{"kind":"number","value":2310692421184,"string":"2,310,692,421,184"},"blob_id":{"kind":"string","value":"6827b9b7d177e7dca03f7a6d874e6240a3262781"},"directory_id":{"kind":"string","value":"10817baf530eed2442040eed8d68a4b2b698d4a1"},"path":{"kind":"string","value":"/predict_temp.py"},"content_id":{"kind":"string","value":"833e734b525c301110dce00df74d67c53b2ea625"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/Nimitz14/HR_temp_prediction"},"snapshot_id":{"kind":"string","value":"4e94e2384e5fda0e370172c2262019376623f7d9"},"revision_id":{"kind":"string","value":"da400ff6dd7231b403813238691e4f14fa7ed93b"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2017-12-01T08:52:18.139494","string":"2017-12-01T08:52:18.139494"},"revision_date":{"kind":"timestamp","value":"2016-08-09T16:55:56","string":"2016-08-09T16:55:56"},"committer_date":{"kind":"timestamp","value":"2016-08-09T16:55:56","string":"2016-08-09T16:55:56"},"github_id":{"kind":"number","value":63858731,"string":"63,858,731"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"from __future__ import division\nimport numpy as np\nimport fileinput\n\n'''\n\t\tSee main() at the bottom for top level overview (or read the README).\n'''\n\n\ndef get_from_stdin():\n\t'''\n\tAssumes data is being input via stdin. Replaces month names with number. Then creates a by month date-format.\n\tClean data is then created in the format (?, [month, max_temp, min_temp]) = 2D.\n\tData with missing values has format (?, [month, known_temp, is_known_temp_max]) = 2D.\n\tReturns them both in ndarray.\n\t'''\n\n\t# Read in from stdin.\n\tdata_clean = []\n\tdata_missing = []\n\tct = 0\n\tfor line in fileinput.input():\n\t\tif ct == 0 or ct == 1: # To skip first 2 lines\n\t\t\tct += 1\n\t\t\tcontinue\n\t\tif \"Missing\" in line:\n\t\t\tdata_missing.append([c for c in line.strip().split()])\n\t\telse:\n\t\t\tdata_clean.append([c for c in line.strip().split()])\n\n\t# Replace month names with a number string.\n\tmonth2num_dict = {'January': '1', 'February': '2', 'March': '3', 'April': '4', 'May': '5', 'June': '6', 'July': '7',\n\t\t\t\t\t 'August': '8', 'September': '9', 'October': '10', 'November': '11', 'December': '12'}\n\n\tdata_clean = np.array(data_clean)\n\tfor i, c in enumerate(data_clean[:, 1]):\n\t\tdata_clean[i, 1] = month2num_dict[c]\n\n\tdata_missing = np.array(data_missing)\n\tfor i, c in enumerate(data_missing[:, 1]):\n\t\t\tdata_missing[i, 1] = month2num_dict[c]\n\n\t# Handle clean data.\n\tdata_clean = data_clean.astype(np.float32)\n\n\tstart_year = np.min(data_clean[:, 0])\n\tdata_clean = np.c_[(data_clean[:, 0] - start_year)*12 + data_clean[:, 1], data_clean[:, 2], data_clean[:, 3]]\n\n\t# Handling data with missing values.\n\tdata_missing_float = []\n\tfor line in data_missing:\n\t\ttmp_array = []\n\t\ttmp_date = 0\n\t\tis_max = None\n\t\tfor i, c in enumerate(line):\n\t\t\tif i == 0:\n\t\t\t\ttmp_date = (float(c) - start_year)*12\n\t\t\telif i == 1:\n\t\t\t\ttmp_date += float(c)\n\t\t\t\ttmp_array.append(tmp_date)\n\t\t\telif \"Missing\" in c:\n\t\t\t\tif i == 2:\n\t\t\t\t\tis_max = 1\n\t\t\t\telif i == 3:\n\t\t\t\t\tis_max = 0\n\t\t\telse:\n\t\t\t\ttmp_array.append(float(c))\n\t\ttmp_array.append(is_max)\n\t\tdata_missing_float.append(tmp_array)\n\n\treturn data_clean, np.asarray(data_missing_float)\n\n\ndef normal_equation_fit(x, y):\n\t'''\n\tNormal equation formula with offset, linear and sinus term.\n\t'''\n\tmat_A = np.c_[np.ones_like(x), x, custom_sin(x)]\n\tparams = np.linalg.inv(mat_A.T.dot(mat_A)).dot(mat_A.T).dot(y.T)\n\treturn params\n\n\ndef hypothesis(x, params, phase_sh=4):\n\treturn params[0] + params[1]*x + params[2]*custom_sin(x, phase_sh)\n\n\ndef custom_sin(x, phase_sh = 4):\n\t# 2/12 = 1/6.\n\treturn np.sin(np.pi*(x-phase_sh)/6)\n\n\ndef predict_temps(data_missing, params_max_t, params_min_t, averages, phase_sh):\n\t'''\n\tFor data with missing terms calculate a prediction and adjust by the difference between the known value\n\tand the average value of that month.\n\tTo know which average to use, takes the month number modulo 12.\n\t'''\n\n\tdata_by_month = (data_missing[:, 0]-1) % 12\n\n\tfor i, line in enumerate(data_missing):\n\t\tif line[-1] == 1:\n\t\t\tsin_pred = hypothesis(line[0], params_max_t, phase_sh)\n\t\t\tfinal_pred = sin_pred + (line[1] - averages[data_by_month[i], 1])\n\t\t\tprint(final_pred)\n\n\t\telif line[-1] == 0:\n\t\t\tsin_pred = hypothesis(line[0], params_min_t, phase_sh)\n\t\t\tfinal_pred = sin_pred + (line[1] - averages[data_by_month[i], 0])\n\t\t\tprint(final_pred)\n\n\ndef calc_averages(data):\n\t'''\n\tCalculates average max/min temperature of the 12 months in a year.\n\t'''\n\taverages = [] \t# shape: (month,[max,min])\n\tdata_by_month = (data[:, 0]-1) % 12\n\tfor i in xrange(0, 12):\n\t\taverages.append([])\n\t\tbool_mask = (data_by_month == i)\n\t\taverages[i].append(np.mean(data[bool_mask][:, 1]))\n\t\taverages[i].append(np.mean(data[bool_mask][:, 2]))\n\treturn np.asarray(averages)\n\n\ndef calc_optimal_phase(data, params_max):\n\t'''\n\tAutocorrelation implementation to find the best phase shift.\n\tCuts the two waveforms to 40 samples because in that bound the data waveform is well behaved.\n\tShifts hypothesis waveform and each time uses the minimum of the two waveforms to find 'area' underneath both.\n\tIs assumed result would be same whether using max or min waveforms (max used).\n\t'''\n\tdata_wave = data[:40, 1]\n\tautocorr_func = []\n\tfor phase in np.arange(3, 5, 0.005):\n\t\thypo_wave = hypothesis(data[:40, 0], params_max, phase)\n\t\tautocorr_func.append([phase, np.sum(np.min(np.c_[data_wave, hypo_wave], axis=1))])\n\tautocorr_func = np.asarray(autocorr_func)\n\treturn autocorr_func[np.argmax(autocorr_func[:, 1]), 0]\n\n\ndef main():\n\n\tdata, data_missing = get_from_stdin()\n\n\taverages = calc_averages(data)\n\n\tparams_max_t = normal_equation_fit(data[:, 0], data[:, 1])\n\tparams_min_t = normal_equation_fit(data[:, 0], data[:, 2])\n\n\tbest_phase_shift = calc_optimal_phase(data, params_max_t)\n\n\t# Outputs to stdout.\n\tpredict_temps(data_missing, params_max_t, params_min_t, averages, best_phase_shift)\n\n\nmain()\n\n\n\n\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":4753,"string":"4,753"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":2,"string":"2"},"filename":{"kind":"string","value":"predict_temp.py"},"num_lang_files":{"kind":"number","value":1,"string":"1"},"alphanum_fraction":{"kind":"number","value":0.6549547654113191,"string":"0.654955"},"alpha_fraction":{"kind":"number","value":0.6326530612244898,"string":"0.632653"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":158,"string":"158"},"avg_line_length":{"kind":"number","value":29.056962025316455,"string":"29.056962"},"max_line_length":{"kind":"number","value":117,"string":"117"}}},{"rowIdx":557,"cells":{"repo_name":{"kind":"string","value":"shashank231/Programming-quiz"},"__id__":{"kind":"number","value":18253611034339,"string":"18,253,611,034,339"},"blob_id":{"kind":"string","value":"f6274f2a277a07f62c2a8ab8bbd794bc3501f339"},"directory_id":{"kind":"string","value":"4b0d68860631717f2e0321a8f02bf9ccc13b1432"},"path":{"kind":"string","value":"/namo/migrations/0003_subject_card_pic.py"},"content_id":{"kind":"string","value":"8990b2f10a0a56a8ce9541818b374aedb9e5e1bf"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/shashank231/Programming-quiz"},"snapshot_id":{"kind":"string","value":"0adc8f55f5badd136a92385fce90407a6e7898f1"},"revision_id":{"kind":"string","value":"630ab458d447cfee16b900a43efe83585cb306b5"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2022-11-07T18:11:00.081969","string":"2022-11-07T18:11:00.081969"},"revision_date":{"kind":"timestamp","value":"2020-06-22T13:19:54","string":"2020-06-22T13:19:54"},"committer_date":{"kind":"timestamp","value":"2020-06-22T13:19:54","string":"2020-06-22T13:19:54"},"github_id":{"kind":"number","value":274135865,"string":"274,135,865"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# Generated by Django 3.0.6 on 2020-06-13 10:47\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('namo', '0002_subject_info'),\n ]\n\n operations = [\n migrations.AddField(\n model_name='subject',\n name='card_pic',\n field=models.ImageField(blank=True, null=True, upload_to=''),\n ),\n ]\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":401,"string":"401"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":21,"string":"21"},"filename":{"kind":"string","value":"0003_subject_card_pic.py"},"num_lang_files":{"kind":"number","value":15,"string":"15"},"alphanum_fraction":{"kind":"number","value":0.5810473815461347,"string":"0.581047"},"alpha_fraction":{"kind":"number","value":0.5336658354114713,"string":"0.533666"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":18,"string":"18"},"avg_line_length":{"kind":"number","value":21.27777777777778,"string":"21.277778"},"max_line_length":{"kind":"number","value":73,"string":"73"}}},{"rowIdx":558,"cells":{"repo_name":{"kind":"string","value":"keepalive555/export"},"__id__":{"kind":"number","value":7559142484736,"string":"7,559,142,484,736"},"blob_id":{"kind":"string","value":"d8c6f6f615266c3c0ac1dccdb5e033443a85a3f6"},"directory_id":{"kind":"string","value":"2ce198c323a3a09ae79f565d6cacb49258a32b5d"},"path":{"kind":"string","value":"/crawlers/util/cache.py"},"content_id":{"kind":"string","value":"1ba3e3bd9f4ff76c616a9f90588014441e19deb5"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/keepalive555/export"},"snapshot_id":{"kind":"string","value":"030a6f61f358d7a29ce902f261a9769652182866"},"revision_id":{"kind":"string","value":"2d12198ae96c995b723488e5525c89fb32698d07"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2017-12-17T06:31:09.896102","string":"2017-12-17T06:31:09.896102"},"revision_date":{"kind":"timestamp","value":"2017-11-13T15:00:06","string":"2017-11-13T15:00:06"},"committer_date":{"kind":"timestamp","value":"2017-11-13T15:00:06","string":"2017-11-13T15:00:06"},"github_id":{"kind":"number","value":77551081,"string":"77,551,081"},"star_events_count":{"kind":"number","value":1,"string":"1"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# -*- coding: utf-8 -*-\n\nimport os\nimport shelve\n\nfrom core.metaclass import Final\n\n\nclass CacheFile(object):\n \"\"\"缓存文件对象。\n\n Args:\n cache_dir (str): 文件所在目录。\n cache_file_name (str): 文件名称,不带扩展名。\n\n Returns:\n None\n \"\"\"\n def __init__(self, cache_dir, cache_file_name):\n self._cache_dir = cache_dir\n self._cache_file_name = cache_file_name\n self._cache = shelve.open(\n os.path.join(cache_dir, cache_file_name),\n flag='c', protocol=2, writeback=True,\n )\n\n def flush(self):\n \"\"\"将数据刷新到缓存文件中。 \"\"\"\n self._cache.sync()\n\n def __getattr__(self, attr):\n \"\"\"支持通过'.'访问成员。\"\"\"\n return self._cache[attr]\n\n def __setattr__(self, attr, value):\n \"\"\"支持通过'.'设置成员值。\"\"\"\n if attr.startswith('_'):\n super(CacheFile, self).__setattr__(attr, value)\n else:\n self._cache[attr] = value\n\n def __setitem__(self, k, v):\n \"\"\"代理shevle。\"\"\"\n self._cache[k] = v\n\n def __getitem__(self, k):\n \"\"\"代理shevle。 \"\"\"\n return self._cache.get(k)\n\n def __del__(self):\n \"\"\"关闭Cache文件。 \"\"\"\n self._cache.close()\n\n\nclass Cache(object):\n\n __metaclass__ = Final\n\n def __init__(self, cache_dir=\"./\"):\n cache_dir = os.path.join(os.path.abspath(cache_dir), '.cache')\n if not os.path.exists(cache_dir):\n os.mkdir(cache_dir, 744)\n self._cache_dir = cache_dir\n self._object_cache = dict()\n\n def __getattr__(self, attr):\n \"\"\"通过属性来访问相应APP。\n\n Args:\n attr (str): 属性名,一般是爬虫APP名,如itjuzi。\n\n Returns:\n None\n \"\"\"\n if attr in self._object_cache:\n return self._object_cache[attr]\n else:\n cache = CacheFile(self._cache_dir, attr)\n self._object_cache[attr] = cache\n return cache\n\n def clear(self, cache=None, ignore_error=False):\n \"\"\"清除缓存。\n\n Args:\n cache (str): 待清除缓存的名称,例如itjuzi,默认清除全部。\n ignore_error(bool): 是否忽略异常。\n\n Returns:\n None\n\n Raises:\n IOError: 待删除的缓存不存在。\n \"\"\"\n if cache is None:\n for _, v in self._object_cache.items():\n del v\n __import__('shutil').rmtree(self._cache_dir)\n else:\n try:\n v = self._object_cache.get(cache)\n if v is not None:\n del v\n os.remove(\n os.path.join(self._cache_dir, '%s.db' % cache))\n except IOError:\n if ignore_error is not True:\n raise\n\n def __del__(self):\n \"\"\"析构方法,关闭所有Cache文件。\"\"\"\n for _, v in self._object_cache.items():\n del v\n\n\nif __name__ == \"__main__\":\n pass\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":3082,"string":"3,082"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":17,"string":"17"},"filename":{"kind":"string","value":"cache.py"},"num_lang_files":{"kind":"number","value":13,"string":"13"},"alphanum_fraction":{"kind":"number","value":0.4842632331902718,"string":"0.484263"},"alpha_fraction":{"kind":"number","value":0.4824749642346209,"string":"0.482475"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":117,"string":"117"},"avg_line_length":{"kind":"number","value":22.897435897435898,"string":"22.897436"},"max_line_length":{"kind":"number","value":70,"string":"70"}}},{"rowIdx":559,"cells":{"repo_name":{"kind":"string","value":"ulti72/Credit_Saison"},"__id__":{"kind":"number","value":12146167530086,"string":"12,146,167,530,086"},"blob_id":{"kind":"string","value":"285b1572fac9547f4550743d2c40aa9ab2c9a947"},"directory_id":{"kind":"string","value":"4d29c074c432495b7013eaab34a29a7ecf45ec00"},"path":{"kind":"string","value":"/flaskapi/__init__.py"},"content_id":{"kind":"string","value":"9a239a9000286e173550c67a9fee36b9ad4f7d81"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/ulti72/Credit_Saison"},"snapshot_id":{"kind":"string","value":"b4fe8c81fda12980a2508644da9d8d6745dac429"},"revision_id":{"kind":"string","value":"28e46318c1392306905d159af7504d395a541954"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2023-05-12T17:07:45.342125","string":"2023-05-12T17:07:45.342125"},"revision_date":{"kind":"timestamp","value":"2021-05-29T16:22:51","string":"2021-05-29T16:22:51"},"committer_date":{"kind":"timestamp","value":"2021-05-29T16:22:51","string":"2021-05-29T16:22:51"},"github_id":{"kind":"number","value":371811076,"string":"371,811,076"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"from flask_sqlalchemy import SQLAlchemy \r\nfrom flask import Flask\r\n\r\n\r\napp = Flask(__name__)\r\napp.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False\r\napp.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite3'\r\ndb = SQLAlchemy(app)\r\n\r\n\r\nfrom flaskapi import routes"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":265,"string":"265"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":6,"string":"6"},"filename":{"kind":"string","value":"__init__.py"},"num_lang_files":{"kind":"number","value":4,"string":"4"},"alphanum_fraction":{"kind":"number","value":0.7283018867924528,"string":"0.728302"},"alpha_fraction":{"kind":"number","value":0.7245283018867924,"string":"0.724528"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":11,"string":"11"},"avg_line_length":{"kind":"number","value":22.272727272727273,"string":"22.272727"},"max_line_length":{"kind":"number","value":62,"string":"62"}}},{"rowIdx":560,"cells":{"repo_name":{"kind":"string","value":"adrianoff/ml_coursera"},"__id__":{"kind":"number","value":4492535802548,"string":"4,492,535,802,548"},"blob_id":{"kind":"string","value":"5730af8344b25dfd4f89f405bfebb2dd66e160e0"},"directory_id":{"kind":"string","value":"ddebe66cb75c86b580418947b823c2543aa318cb"},"path":{"kind":"string","value":"/final_projects/sentiment_analysis/week6/parser.py"},"content_id":{"kind":"string","value":"8ff38c1c1d9a65029c6cb3e4c8bf75ae39ee9f82"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/adrianoff/ml_coursera"},"snapshot_id":{"kind":"string","value":"5dae7ab8ceb98cf9a774f27c34597fe226dfacf5"},"revision_id":{"kind":"string","value":"cfdea088cc3417c6852b6266c66a01e08ede7674"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2021-01-19T11:18:21.392267","string":"2021-01-19T11:18:21.392267"},"revision_date":{"kind":"timestamp","value":"2018-09-17T15:20:18","string":"2018-09-17T15:20:18"},"committer_date":{"kind":"timestamp","value":"2018-09-17T15:20:18","string":"2018-09-17T15:20:18"},"github_id":{"kind":"number","value":87952932,"string":"87,952,932"},"star_events_count":{"kind":"number","value":2,"string":"2"},"fork_events_count":{"kind":"number","value":1,"string":"1"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# -*- coding: utf-8 -*-\n\nimport requests\nimport bs4 as bs4\nfrom tqdm import tqdm\nimport sys\n\nreload(sys)\nsys.setdefaultencoding('utf8')\n\n\ndef split_uppercase(string):\n x = ''\n k = 0\n for c in string:\n if k == 0:\n x += c\n elif c.isupper() and not string[k-1].isupper():\n x += ' %s' % c\n else:\n x += c\n k += 1\n\n return x.strip()\n\n\nsite = 'https://technopoint.ru'\nbase_url = 'https://technopoint.ru/catalog/17a75b8e16404e77/smartfony'\npages = []\n\nfor p in range(1, 33):\n pages.append(base_url + '/?p=' + str(p) + '&i=1&stock=0&order=4')\n\nproducts_link = []\nprint \"Get Pages:\\n\"\nfor page in tqdm(pages):\n req = requests.get(page)\n parser = bs4.BeautifulSoup(req.text, 'lxml')\n links = parser.findAll('a', attrs={'data-role': 'product-cart-link'})\n for link in links:\n products_link.append(site + link['href'] + 'opinion/')\n\n\nprint \"\\n\\nGet Pages With Comments:\\n\"\npages_with_comments = []\nfor link in tqdm(products_link):\n req = requests.get(link)\n parser = bs4.BeautifulSoup(req.text, 'lxml')\n ul_pagination = parser.find('ul', {\"class\": \"pagination\"})\n comments_pager_last_link = None\n if ul_pagination is not None:\n comments_pager_last_link = ul_pagination.find('li', {\"class\": \"last\"}).find('a')\n\n comments_pages_count = 1\n if comments_pager_last_link is not None:\n comments_pages_count = int(comments_pager_last_link[\"data-page\"]) + 1\n\n for page_with_comments in range(1, comments_pages_count + 1):\n pages_with_comments.append(link + str(page_with_comments) + '/')\n\ni = 1\nprint \"\\n\\nProceed Pages With Comments:\\n\"\nfor page_with_comments in tqdm(pages_with_comments):\n req = requests.get(page_with_comments)\n parser = bs4.BeautifulSoup(req.text, 'lxml')\n opinion_items = parser.find('div', {\"class\": \"opinion-container\"}).findAll('div', {\"class\": \"opinion-item\"})\n for opinion_item in opinion_items:\n description = str(opinion_item.find('div', {\"class\": \"descriptions\"})).replace(\"\\n\", ' ')\n description = split_uppercase(unicode(description))\n\n grade = opinion_item[\"data-grade\"]\n\n comment_file = open('./data/' + str(i) + '.txt', 'w')\n comment_file.write(page_with_comments + \"\\n\" + grade + \"\\n\" + description)\n comment_file.close()\n\n i += 1\n\nprint \"\\n\"\nprint \"Total comments: \" + str(i)\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":2392,"string":"2,392"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":150,"string":"150"},"filename":{"kind":"string","value":"parser.py"},"num_lang_files":{"kind":"number","value":39,"string":"39"},"alphanum_fraction":{"kind":"number","value":0.6141304347826086,"string":"0.61413"},"alpha_fraction":{"kind":"number","value":0.5994983277591973,"string":"0.599498"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":80,"string":"80"},"avg_line_length":{"kind":"number","value":28.9,"string":"28.9"},"max_line_length":{"kind":"number","value":112,"string":"112"}}},{"rowIdx":561,"cells":{"repo_name":{"kind":"string","value":"sdck139/ck-leetcode"},"__id__":{"kind":"number","value":19292993114820,"string":"19,292,993,114,820"},"blob_id":{"kind":"string","value":"c3f4cad4846ecc5907166c8d61586d81549b918d"},"directory_id":{"kind":"string","value":"88cb3315ecb89adc981c80a52cdedff8ac6189f3"},"path":{"kind":"string","value":"/537-ComplexNumberMultiplication.py"},"content_id":{"kind":"string","value":"90f4f8c9868c8d0d4f40a2f1b1648db681e7b59b"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/sdck139/ck-leetcode"},"snapshot_id":{"kind":"string","value":"b61ef40be0948dfd694097160939fbee5f1936b3"},"revision_id":{"kind":"string","value":"f43574dbb6a872e1c96d367f8948ed8c42b4fde1"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2021-01-20T00:24:11.542989","string":"2021-01-20T00:24:11.542989"},"revision_date":{"kind":"timestamp","value":"2017-11-01T08:56:47","string":"2017-11-01T08:56:47"},"committer_date":{"kind":"timestamp","value":"2017-11-01T08:56:47","string":"2017-11-01T08:56:47"},"github_id":{"kind":"number","value":89125640,"string":"89,125,640"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"class Solution(object):\n def complexNumberMultiply(self, a, b):\n \"\"\"\n :type a: str\n :type b: str\n :rtype: str\n \"\"\"\n a1, a2 = self.strToInt(a)\n b1, b2 = self.strToInt(b)\n return str(a1*b1-a2*b2) + \"+\" + str(a1*b2 + a2*b1) + \"i\"\n def strToInt(self, a):\n strs = a.split(\"+\")\n return int(strs[0]), int(strs[1][:-1])\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":388,"string":"388"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":60,"string":"60"},"filename":{"kind":"string","value":"537-ComplexNumberMultiplication.py"},"num_lang_files":{"kind":"number","value":60,"string":"60"},"alphanum_fraction":{"kind":"number","value":0.47680412371134023,"string":"0.476804"},"alpha_fraction":{"kind":"number","value":0.4381443298969072,"string":"0.438144"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":13,"string":"13"},"avg_line_length":{"kind":"number","value":28.846153846153847,"string":"28.846154"},"max_line_length":{"kind":"number","value":64,"string":"64"}}},{"rowIdx":562,"cells":{"repo_name":{"kind":"string","value":"tdnvl/PyCharm"},"__id__":{"kind":"number","value":7971459303251,"string":"7,971,459,303,251"},"blob_id":{"kind":"string","value":"20d654ff9390e40df30f8a3f72e677533b15b11c"},"directory_id":{"kind":"string","value":"6c77e86454e83f8676fb06740c82eff56f2672eb"},"path":{"kind":"string","value":"/Lessons Ray/2018-01-01-make-bricks.py"},"content_id":{"kind":"string","value":"94e9aaa2c98738f2f3c86e2786f36326110e17fb"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/tdnvl/PyCharm"},"snapshot_id":{"kind":"string","value":"7898c473c53853ccc94c42773efcd1fb734c2019"},"revision_id":{"kind":"string","value":"2d7ce8d707170fddd641c93fb7d4378beaeffa70"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2021-01-20T03:29:12.507434","string":"2021-01-20T03:29:12.507434"},"revision_date":{"kind":"timestamp","value":"2018-05-15T21:08:14","string":"2018-05-15T21:08:14"},"committer_date":{"kind":"timestamp","value":"2018-05-15T21:08:14","string":"2018-05-15T21:08:14"},"github_id":{"kind":"number","value":89544974,"string":"89,544,974"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"def make_bricks(small, big, goal):\n a = goal / 5\n # if a >= 1 we can use at least one big brick\n # if a < 1 we cannot use a big brick\n b = goal % 5\n # if b == 0 the goal is a multiple of 5\n # if b != 0 we need to check if we have enough small bricks\n # to reach the goal\n c = int(a)\n d = c*big + b*small\n\n if b == 0:\n if big >= a:\n return True\n elif big < a and ((a - big) * 5) <= small:\n return True\n elif big < a and (a - big)*5 > small:\n return False\n elif goal > small:\n return False\n elif goal <= small:\n return True\n elif b != 0:\n if big < a and small >= b:\n return True\n elif big < a and small < b:\n return False\n elif small == 0 and b == 0 and big >= a:\n return True\n elif small == 0 and b == 0 and big < a:\n return False\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":893,"string":"893"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":53,"string":"53"},"filename":{"kind":"string","value":"2018-01-01-make-bricks.py"},"num_lang_files":{"kind":"number","value":50,"string":"50"},"alphanum_fraction":{"kind":"number","value":0.49496080627099664,"string":"0.494961"},"alpha_fraction":{"kind":"number","value":0.47816349384098544,"string":"0.478163"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":31,"string":"31"},"avg_line_length":{"kind":"number","value":27.806451612903224,"string":"27.806452"},"max_line_length":{"kind":"number","value":63,"string":"63"}}},{"rowIdx":563,"cells":{"repo_name":{"kind":"string","value":"upendar245/python"},"__id__":{"kind":"number","value":8701603785179,"string":"8,701,603,785,179"},"blob_id":{"kind":"string","value":"e41215278aac9d4c9e1602ff4584f24982669131"},"directory_id":{"kind":"string","value":"4540c5e07a4a439eb8f5f1998be0d4ee1c9291a7"},"path":{"kind":"string","value":"/recursion.py"},"content_id":{"kind":"string","value":"f636695099787ca54bb7ad4a0b87605229fd612c"},"detected_licenses":{"kind":"list like","value":["Apache-2.0"],"string":"[\n \"Apache-2.0\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/upendar245/python"},"snapshot_id":{"kind":"string","value":"60dad510d2f64041340849617f87a5795e58cec7"},"revision_id":{"kind":"string","value":"ed4d5488b44d385f2d0f75e8558a5b7fc4563d38"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2021-01-25T09:21:05.951513","string":"2021-01-25T09:21:05.951513"},"revision_date":{"kind":"timestamp","value":"2020-11-08T07:35:21","string":"2020-11-08T07:35:21"},"committer_date":{"kind":"timestamp","value":"2020-11-08T07:35:21","string":"2020-11-08T07:35:21"},"github_id":{"kind":"number","value":93823129,"string":"93,823,129"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"def sample(x):\n if x == 0 or x == 1:\n return 1 \n else: \n return sample(x - 1) + sample(x - 2 )\n\nprint sample(6)\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":130,"string":"130"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":12,"string":"12"},"filename":{"kind":"string","value":"recursion.py"},"num_lang_files":{"kind":"number","value":11,"string":"11"},"alphanum_fraction":{"kind":"number","value":0.4846153846153846,"string":"0.484615"},"alpha_fraction":{"kind":"number","value":0.43846153846153846,"string":"0.438462"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":7,"string":"7"},"avg_line_length":{"kind":"number","value":17.571428571428573,"string":"17.571429"},"max_line_length":{"kind":"number","value":44,"string":"44"}}},{"rowIdx":564,"cells":{"repo_name":{"kind":"string","value":"zy20091082/trimesh"},"__id__":{"kind":"number","value":9912784522715,"string":"9,912,784,522,715"},"blob_id":{"kind":"string","value":"1be0294e2b9ccc7cf4b2da535d6550adf92a6b27"},"directory_id":{"kind":"string","value":"dfed9f12ec0893c5893789cdd91c8e2c3f254f9e"},"path":{"kind":"string","value":"/trimesh/version.py"},"content_id":{"kind":"string","value":"6915b25eb17e34bd367b7d46af0244670c476608"},"detected_licenses":{"kind":"list like","value":["MIT"],"string":"[\n \"MIT\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/zy20091082/trimesh"},"snapshot_id":{"kind":"string","value":"689e26fbd9232ebba1f56ad34fc22babafb3be03"},"revision_id":{"kind":"string","value":"c0a421771ec77ffe4e29731ed3ba340e1c800644"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-03-25T06:11:30.155310","string":"2020-03-25T06:11:30.155310"},"revision_date":{"kind":"timestamp","value":"2018-08-03T17:05:23","string":"2018-08-03T17:05:23"},"committer_date":{"kind":"timestamp","value":"2018-08-03T17:05:23","string":"2018-08-03T17:05:23"},"github_id":{"kind":"null"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"__version__ = '2.31.50'\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":24,"string":"24"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":1,"string":"1"},"filename":{"kind":"string","value":"version.py"},"num_lang_files":{"kind":"number","value":1,"string":"1"},"alphanum_fraction":{"kind":"number","value":0.5,"string":"0.5"},"alpha_fraction":{"kind":"number","value":0.2916666666666667,"string":"0.291667"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":1,"string":"1"},"avg_line_length":{"kind":"number","value":23,"string":"23"},"max_line_length":{"kind":"number","value":23,"string":"23"}}},{"rowIdx":565,"cells":{"repo_name":{"kind":"string","value":"Ludovic86/compta"},"__id__":{"kind":"number","value":3779571223961,"string":"3,779,571,223,961"},"blob_id":{"kind":"string","value":"b14bf27604384f4356b3ac4123b164de7b686720"},"directory_id":{"kind":"string","value":"e93cd698baaa26c9fb10511c354ce40b5d4e854f"},"path":{"kind":"string","value":"/migrations/versions/63634acbf78c_debits_table.py"},"content_id":{"kind":"string","value":"df769b88afd2a715e88dbc6ab6cb6090b8cc147e"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/Ludovic86/compta"},"snapshot_id":{"kind":"string","value":"e6776cddfc02aa141c52e93c28c70dd496df0830"},"revision_id":{"kind":"string","value":"0856a467e59803dae612b321fd54cea1cec5a153"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2023-03-22T22:40:34.802475","string":"2023-03-22T22:40:34.802475"},"revision_date":{"kind":"timestamp","value":"2021-03-21T14:47:43","string":"2021-03-21T14:47:43"},"committer_date":{"kind":"timestamp","value":"2021-03-21T14:47:43","string":"2021-03-21T14:47:43"},"github_id":{"kind":"number","value":347668966,"string":"347,668,966"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"\"\"\"debits table\n\nRevision ID: 63634acbf78c\nRevises: \nCreate Date: 2021-03-14 16:01:18.145628\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used by Alembic.\nrevision = '63634acbf78c'\ndown_revision = None\nbranch_labels = None\ndepends_on = None\n\n\ndef upgrade():\n # ### commands auto generated by Alembic - please adjust! ###\n op.create_table('debit',\n sa.Column('id', sa.Integer(), nullable=False),\n sa.Column('date', sa.Date(), nullable=True),\n sa.Column('amount', sa.Integer(), nullable=True),\n sa.PrimaryKeyConstraint('id')\n )\n op.create_index(op.f('ix_debit_amount'), 'debit', ['amount'], unique=False)\n op.create_index(op.f('ix_debit_date'), 'debit', ['date'], unique=False)\n # ### end Alembic commands ###\n\n\ndef downgrade():\n # ### commands auto generated by Alembic - please adjust! ###\n op.drop_index(op.f('ix_debit_date'), table_name='debit')\n op.drop_index(op.f('ix_debit_amount'), table_name='debit')\n op.drop_table('debit')\n # ### end Alembic commands ###\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1042,"string":"1,042"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":11,"string":"11"},"filename":{"kind":"string","value":"63634acbf78c_debits_table.py"},"num_lang_files":{"kind":"number","value":7,"string":"7"},"alphanum_fraction":{"kind":"number","value":0.6535508637236085,"string":"0.653551"},"alpha_fraction":{"kind":"number","value":0.6209213051823417,"string":"0.620921"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":37,"string":"37"},"avg_line_length":{"kind":"number","value":27.16216216216216,"string":"27.162162"},"max_line_length":{"kind":"number","value":79,"string":"79"}}},{"rowIdx":566,"cells":{"repo_name":{"kind":"string","value":"xdxie/WordArt"},"__id__":{"kind":"number","value":5712306512725,"string":"5,712,306,512,725"},"blob_id":{"kind":"string","value":"5ff2625c43f38e83811a5a6cf6249eec1b27a353"},"directory_id":{"kind":"string","value":"40b42ccf2b6959d6fce74509201781be96f04475"},"path":{"kind":"string","value":"/mmocr/models/textrecog/recognizer/__init__.py"},"content_id":{"kind":"string","value":"818df4996df8a4c1555ebda43e8bcce4f2acb697"},"detected_licenses":{"kind":"list like","value":["Apache-2.0"],"string":"[\n \"Apache-2.0\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/xdxie/WordArt"},"snapshot_id":{"kind":"string","value":"2f1414d8e4edaa89333353d0b28e5096e1f87263"},"revision_id":{"kind":"string","value":"89bf8a218881b250d0ead7a0287526c69586c92a"},"branch_name":{"kind":"string","value":"refs/heads/main"},"visit_date":{"kind":"timestamp","value":"2023-05-23T02:04:22.185386","string":"2023-05-23T02:04:22.185386"},"revision_date":{"kind":"timestamp","value":"2023-03-06T11:51:43","string":"2023-03-06T11:51:43"},"committer_date":{"kind":"timestamp","value":"2023-03-06T11:51:43","string":"2023-03-06T11:51:43"},"github_id":{"kind":"number","value":515485694,"string":"515,485,694"},"star_events_count":{"kind":"number","value":106,"string":"106"},"fork_events_count":{"kind":"number","value":12,"string":"12"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# Copyright (c) OpenMMLab. All rights reserved.\nfrom .abinet import ABINet\nfrom .base import BaseRecognizer\nfrom .crnn import CRNNNet\nfrom .encode_decode_recognizer import EncodeDecodeRecognizer\nfrom .master import MASTER\nfrom .nrtr import NRTR\nfrom .robust_scanner import RobustScanner\nfrom .sar import SARNet\nfrom .satrn import SATRN\nfrom .seg_recognizer import SegRecognizer\nfrom .corner_transformer import CornerTransformer\n\n__all__ = [\n 'BaseRecognizer', 'EncodeDecodeRecognizer', 'CRNNNet', 'SARNet', 'NRTR',\n 'SegRecognizer', 'RobustScanner', 'SATRN', 'ABINet', 'MASTER', 'CornerTransformer'\n]\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":607,"string":"607"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":198,"string":"198"},"filename":{"kind":"string","value":"__init__.py"},"num_lang_files":{"kind":"number","value":149,"string":"149"},"alphanum_fraction":{"kind":"number","value":0.7775947281713345,"string":"0.777595"},"alpha_fraction":{"kind":"number","value":0.7775947281713345,"string":"0.777595"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":17,"string":"17"},"avg_line_length":{"kind":"number","value":34.705882352941174,"string":"34.705882"},"max_line_length":{"kind":"number","value":86,"string":"86"}}},{"rowIdx":567,"cells":{"repo_name":{"kind":"string","value":"LsoaresA/Projetos-Django"},"__id__":{"kind":"number","value":13348758356448,"string":"13,348,758,356,448"},"blob_id":{"kind":"string","value":"9d7143da9986a10488a92b5825efe6f100eaf73e"},"directory_id":{"kind":"string","value":"7155b83b4bffa5fb6efb1a2317692f263e444b6b"},"path":{"kind":"string","value":"/LsoaresA/cadastro/urls.py"},"content_id":{"kind":"string","value":"5b8ca533681e0c7fe5f3a120d74afcf0648d9a3e"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/LsoaresA/Projetos-Django"},"snapshot_id":{"kind":"string","value":"bf5c31507c0acc52f6e4a6e2d5b3a61eab51536a"},"revision_id":{"kind":"string","value":"684dff09b31bdfce575563541f47ec588a29a5ad"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2021-09-23T12:05:54.457549","string":"2021-09-23T12:05:54.457549"},"revision_date":{"kind":"timestamp","value":"2018-09-22T13:22:46","string":"2018-09-22T13:22:46"},"committer_date":{"kind":"timestamp","value":"2018-09-22T13:22:46","string":"2018-09-22T13:22:46"},"github_id":{"kind":"number","value":108995746,"string":"108,995,746"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"from django.conf.urls import url, include\nfrom django.contrib import admin\nfrom cadastro.views import cadastro\n\nurlpatterns = [\n\turl(r'^cadastro/$', cadastro, name='cadastro'),\n url(r'^admin/', admin.site.urls),\n]\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":217,"string":"217"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":18,"string":"18"},"filename":{"kind":"string","value":"urls.py"},"num_lang_files":{"kind":"number","value":12,"string":"12"},"alphanum_fraction":{"kind":"number","value":0.728110599078341,"string":"0.728111"},"alpha_fraction":{"kind":"number","value":0.728110599078341,"string":"0.728111"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":8,"string":"8"},"avg_line_length":{"kind":"number","value":26.125,"string":"26.125"},"max_line_length":{"kind":"number","value":48,"string":"48"}}},{"rowIdx":568,"cells":{"repo_name":{"kind":"string","value":"DawnsonLi/Senorita"},"__id__":{"kind":"number","value":11605001676018,"string":"11,605,001,676,018"},"blob_id":{"kind":"string","value":"168d4364e3aa212bd92af1a280fd76ead26b3a98"},"directory_id":{"kind":"string","value":"50ee3f186a424e5801f6cbdeb053f43865c87898"},"path":{"kind":"string","value":"/common/__init__.py"},"content_id":{"kind":"string","value":"95dbc1c1ad6b1d49d57f8c5f9e22ad367000c779"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/DawnsonLi/Senorita"},"snapshot_id":{"kind":"string","value":"6303d9c626e3f98dbb811c0fd670a7493ba9637d"},"revision_id":{"kind":"string","value":"e09a0b28e21f51aade02072d1fbe3974278f803b"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-05-07T16:50:18.559534","string":"2020-05-07T16:50:18.559534"},"revision_date":{"kind":"timestamp","value":"2019-04-11T06:55:03","string":"2019-04-11T06:55:03"},"committer_date":{"kind":"timestamp","value":"2019-04-11T06:55:03","string":"2019-04-11T06:55:03"},"github_id":{"kind":"number","value":180701275,"string":"180,701,275"},"star_events_count":{"kind":"number","value":10,"string":"10"},"fork_events_count":{"kind":"number","value":1,"string":"1"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"__all__ = ['TSlist','visio']"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":28,"string":"28"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":12,"string":"12"},"filename":{"kind":"string","value":"__init__.py"},"num_lang_files":{"kind":"number","value":9,"string":"9"},"alphanum_fraction":{"kind":"number","value":0.5,"string":"0.5"},"alpha_fraction":{"kind":"number","value":0.5,"string":"0.5"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":1,"string":"1"},"avg_line_length":{"kind":"number","value":28,"string":"28"},"max_line_length":{"kind":"number","value":28,"string":"28"}}},{"rowIdx":569,"cells":{"repo_name":{"kind":"string","value":"miltonleal/MAC0110_Introduction_Computer_Science_IME_USP"},"__id__":{"kind":"number","value":5841155567076,"string":"5,841,155,567,076"},"blob_id":{"kind":"string","value":"374cef3109836a48b79d790952a6721d5083e74d"},"directory_id":{"kind":"string","value":"08e052c0c2ee4ad0cd4980fbc8a692c407118659"},"path":{"kind":"string","value":"/Ex. do Paca/Aula 14/P_14.6.py"},"content_id":{"kind":"string","value":"c58608177356f9c8a407f14209866e2358c8c550"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/miltonleal/MAC0110_Introduction_Computer_Science_IME_USP"},"snapshot_id":{"kind":"string","value":"6fad182f7fbb3e83403080800074bf57456cb0b5"},"revision_id":{"kind":"string","value":"b47936ce66e715dba79dff44779a750d795192a0"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2023-03-04T11:06:48.092980","string":"2023-03-04T11:06:48.092980"},"revision_date":{"kind":"timestamp","value":"2021-02-17T14:47:46","string":"2021-02-17T14:47:46"},"committer_date":{"kind":"timestamp","value":"2021-02-17T14:47:46","string":"2021-02-17T14:47:46"},"github_id":{"kind":"null"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# P14.6) Função Harmonico(epsilon) que recebe número epsilon > 0 bem pequeno (exemplo: 0.00001) e calcula a soma de todos os termos maiores ou iguais a epsilon.\n#Ou seja, calcular 1 + 1/2 + 1/3 + ... 1/k, tal que 1/i ≥ epsilon para i = 1, 2, ..., k e 1 / (k+1) < epsilon.\n\n\ndef harmonico(epsilon):\n\n h, k = 0, 1 # inicia a soma\n\n # Somar todos os termos maiores ou iguais a epsilon\n while 1 / k >= epsilon:\n h = h + 1 / k\n k = k + 1\n return h\n\nprint(harmonico(0.001))\n\n\n\n"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":502,"string":"502"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":206,"string":"206"},"filename":{"kind":"string","value":"P_14.6.py"},"num_lang_files":{"kind":"number","value":204,"string":"204"},"alphanum_fraction":{"kind":"number","value":0.6016096579476862,"string":"0.60161"},"alpha_fraction":{"kind":"number","value":0.5412474849094567,"string":"0.541247"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":15,"string":"15"},"avg_line_length":{"kind":"number","value":31.933333333333334,"string":"31.933333"},"max_line_length":{"kind":"number","value":160,"string":"160"}}},{"rowIdx":570,"cells":{"repo_name":{"kind":"string","value":"sholehanshori/PWDK_Modul_2"},"__id__":{"kind":"number","value":11012296155443,"string":"11,012,296,155,443"},"blob_id":{"kind":"string","value":"051f396085d6a3d21770b50386a5f8219ba171f1"},"directory_id":{"kind":"string","value":"356eefcb3be20771c459d98df87dc66a9451ddff"},"path":{"kind":"string","value":"/Day 27/27.py"},"content_id":{"kind":"string","value":"b2ba4c3bed3bb6287317d9f5ee7424c28a884ec6"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/sholehanshori/PWDK_Modul_2"},"snapshot_id":{"kind":"string","value":"4df9bb5c01046c3c63d5609f9677d47d04c5ef30"},"revision_id":{"kind":"string","value":"c12b8b8efa86d8158f18277ed0d43595adba4cc3"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2020-11-25T07:43:59.174589","string":"2020-11-25T07:43:59.174589"},"revision_date":{"kind":"timestamp","value":"2019-12-18T05:00:20","string":"2019-12-18T05:00:20"},"committer_date":{"kind":"timestamp","value":"2019-12-18T05:00:20","string":"2019-12-18T05:00:20"},"github_id":{"kind":"number","value":228561329,"string":"228,561,329"},"star_events_count":{"kind":"number","value":0,"string":"0"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"# ------------------------ Jumat, 29 November 2019 -----------------------------------\n\nimport numpy as np\nx = np.arange(1, 10).reshape(3, -1)\n# print(x)\n\n#----- Swaping -----\n# print(x[:, [1,0,2]]) # Berdasarkan index grup\n# print(x[:, [0,0,0]]) # Merubah semua kolom berdasarkan index pertama tiap row\n# # (x[ [row , column] ]) --- representasi dari bagian atas\n# print(x[[1,0,2], :])\n# print(x[[0,0,0], :])\n\n#----- Transpose -----\n# a b\n# c d = a c e\n# e f b d f\n\na = np.array([[1,2],[3,4],[5,6]])\n# print(a)\n# print(a.transpose())\n\n#---------------------------------------------\naa = np.loadtxt('0.csv', skiprows=1, delimiter=',') # Tidak bisa membaca 'string', hanya 'int' dan 'float'\nprint(aa)\nprint(type(aa))\n\nab = np.loadtxt('0.csv', skiprows=1, delimiter=',', unpack=True) # Penggunaan 'unpack' untuk mengelompokkan 'column'\nprint(ab)\n\nid, usia = np.loadtxt('0.csv', skiprows=1, delimiter=',', unpack=True)\nprint(id) # Memisahkan kolom secara langsung, berupa 2 data\nprint(usia)\n\n#-- Menggabungkan 2 kolom yg terpisah\nac = list(map(lambda a,b: [a,b], id, usia))\nprint(ac)\n\n\nnp.savetxt('1.csv', usia, fmt='%d', header='usia', comments='')\n# Penggunaan '%d' agar berupa digit biasa\n# Penggunaan comments='', karena secara default di depan header='usia', akan ada # di depan kata usia\n\n# -- Membuat file .csv dari data di atas, tapi formatnya sesuai\nnp.savetxt('2.csv', aa, fmt='%d', header='id,usia', comments='', delimiter=',')\nnp.savetxt('3.csv', ac, fmt='%d', header='id,usia', comments='', delimiter=',')\n# Penggunaan delimiter=',' agar ada pemisah ',' di antara kolom"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1628,"string":"1,628"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":60,"string":"60"},"filename":{"kind":"string","value":"27.py"},"num_lang_files":{"kind":"number","value":30,"string":"30"},"alphanum_fraction":{"kind":"number","value":0.5786240786240786,"string":"0.578624"},"alpha_fraction":{"kind":"number","value":0.5540540540540541,"string":"0.554054"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":47,"string":"47"},"avg_line_length":{"kind":"number","value":33.659574468085104,"string":"33.659574"},"max_line_length":{"kind":"number","value":117,"string":"117"}}},{"rowIdx":571,"cells":{"repo_name":{"kind":"string","value":"renjieliu/leetcode"},"__id__":{"kind":"number","value":11476152656146,"string":"11,476,152,656,146"},"blob_id":{"kind":"string","value":"50751a40383da59f291201b98ccb9246202cb209"},"directory_id":{"kind":"string","value":"8f48d12b88048e424ebb0d72ca6dfab5cf12ae0f"},"path":{"kind":"string","value":"/1001_1499/1401.py"},"content_id":{"kind":"string","value":"f711e0a92e454794764c80652551afcfedbcdf41"},"detected_licenses":{"kind":"list like","value":[],"string":"[]"},"license_type":{"kind":"string","value":"no_license"},"repo_url":{"kind":"string","value":"https://github.com/renjieliu/leetcode"},"snapshot_id":{"kind":"string","value":"e1caf13c18a8107ed9252588b339fb76bcb1b246"},"revision_id":{"kind":"string","value":"4668b64fcb9320b6c316d8608fc61911ce43b6c7"},"branch_name":{"kind":"string","value":"refs/heads/master"},"visit_date":{"kind":"timestamp","value":"2023-03-18T18:16:06.187741","string":"2023-03-18T18:16:06.187741"},"revision_date":{"kind":"timestamp","value":"2023-03-14T20:31:59","string":"2023-03-14T20:31:59"},"committer_date":{"kind":"timestamp","value":"2023-03-14T20:31:59","string":"2023-03-14T20:31:59"},"github_id":{"kind":"number","value":128823819,"string":"128,823,819"},"star_events_count":{"kind":"number","value":7,"string":"7"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"null"},"gha_event_created_at":{"kind":"null"},"gha_created_at":{"kind":"null"},"gha_updated_at":{"kind":"null"},"gha_pushed_at":{"kind":"null"},"gha_size":{"kind":"null"},"gha_stargazers_count":{"kind":"null"},"gha_forks_count":{"kind":"null"},"gha_open_issues_count":{"kind":"null"},"gha_language":{"kind":"null"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"class Solution:\n def checkOverlap(self, radius: int, x_center: int, y_center: int, x1: int, y1: int, x2: int, y2: int) -> bool:\n def distance(A, B):\n return ((A[0] - B[0]) ** 2 + (A[1] - B[1]) ** 2) ** 0.5\n\n circle_up = [x_center, y_center + radius]\n circle_down = [x_center, y_center - radius]\n circle_left = [x_center - radius, y_center]\n circle_right = [x_center + radius, y_center]\n circle_center = [x_center, y_center]\n square_upperLeft = [x1, y2]\n square_bottomLeft = [x1, y1]\n square_upperRight = [x2, y2]\n square_bottomRight = [x2, y1]\n # print(circle_up, x1, x2, y1,y2)\n # print(circle_down, x1, x2, y1,y2)\n # print(circle_left, x1, x2, y1,y2)\n # print(circle_right, x1, x2, y1,y2)\n\n if (distance(square_upperLeft, circle_center) ** 2 <= radius ** 2 # square point within circle\n or distance(square_bottomLeft, circle_center) ** 2 <= radius ** 2\n or distance(square_upperRight, circle_center) ** 2 <= radius ** 2\n or distance(square_bottomRight, circle_center) ** 2 <= radius ** 2\n or (y1 <= circle_down[1] <= y2 and x1 <= circle_down[0] <= x2) # circle has part in the square\n or (y1 <= circle_up[1] <= y2 and x1 <= circle_up[0] <= x2)\n or (y1 <= circle_right[1] <= y2 and x1 <= circle_right[0] <= x2)\n or (y1 <= circle_left[1] <= y2 and x1 <= circle_left[0] <= x2)\n # square across the circle, both egdes are within the circle, but 4 points are not\n or (circle_left[0] <= x1 <= circle_right[0] and circle_left[0] <= x2 <= circle_right[0] and y2 >=\n circle_up[1] and y1 <= circle_down[1])\n or (circle_down[1] <= y1 <= circle_up[1] and circle_down[1] <= y2 <= circle_up[1] and x2 >=\n circle_right[0] and x1 <= circle_left[0])\n ):\n return True\n return False"},"src_encoding":{"kind":"string","value":"UTF-8"},"language":{"kind":"string","value":"Python"},"is_vendor":{"kind":"bool","value":false,"string":"false"},"is_generated":{"kind":"bool","value":false,"string":"false"},"length_bytes":{"kind":"number","value":1999,"string":"1,999"},"extension":{"kind":"string","value":"py"},"num_repo_files":{"kind":"number","value":1627,"string":"1,627"},"filename":{"kind":"string","value":"1401.py"},"num_lang_files":{"kind":"number","value":1620,"string":"1,620"},"alphanum_fraction":{"kind":"number","value":0.5267633816908455,"string":"0.526763"},"alpha_fraction":{"kind":"number","value":0.4822411205602801,"string":"0.482241"},"hex_fraction":{"kind":"number","value":0,"string":"0"},"num_lines":{"kind":"number","value":35,"string":"35"},"avg_line_length":{"kind":"number","value":56.142857142857146,"string":"56.142857"},"max_line_length":{"kind":"number","value":114,"string":"114"}}},{"rowIdx":572,"cells":{"repo_name":{"kind":"string","value":"ncareol/ncharts"},"__id__":{"kind":"number","value":1374389547787,"string":"1,374,389,547,787"},"blob_id":{"kind":"string","value":"d8d36ef21f54c330ed953f1b8d6fa67651d3b7ad"},"directory_id":{"kind":"string","value":"d91c5b489a8d6b6a27455e743050b8b5cca42a3f"},"path":{"kind":"string","value":"/datavis/settings/production.py"},"content_id":{"kind":"string","value":"2515c380165ace85d92da332af8a565bc1922aa0"},"detected_licenses":{"kind":"list like","value":["BSD-2-Clause"],"string":"[\n \"BSD-2-Clause\"\n]"},"license_type":{"kind":"string","value":"permissive"},"repo_url":{"kind":"string","value":"https://github.com/ncareol/ncharts"},"snapshot_id":{"kind":"string","value":"3cdf1f8ea6c509810f9ac51ac1a9d8e37de006e8"},"revision_id":{"kind":"string","value":"07c97b6ae234ff74f89d0c6d1902764e2773a268"},"branch_name":{"kind":"string","value":"refs/heads/develop"},"visit_date":{"kind":"timestamp","value":"2023-08-03T04:39:20.786171","string":"2023-08-03T04:39:20.786171"},"revision_date":{"kind":"timestamp","value":"2023-06-12T22:38:46","string":"2023-06-12T22:38:46"},"committer_date":{"kind":"timestamp","value":"2023-06-12T22:38:46","string":"2023-06-12T22:38:46"},"github_id":{"kind":"number","value":56725944,"string":"56,725,944"},"star_events_count":{"kind":"number","value":1,"string":"1"},"fork_events_count":{"kind":"number","value":0,"string":"0"},"gha_license_id":{"kind":"null"},"gha_fork":{"kind":"bool","value":false,"string":"false"},"gha_event_created_at":{"kind":"timestamp","value":"2016-10-19T21:39:05","string":"2016-10-19T21:39:05"},"gha_created_at":{"kind":"timestamp","value":"2016-04-20T22:48:54","string":"2016-04-20T22:48:54"},"gha_updated_at":{"kind":"timestamp","value":"2016-10-04T18:12:32","string":"2016-10-04T18:12:32"},"gha_pushed_at":{"kind":"timestamp","value":"2016-10-19T21:38:34","string":"2016-10-19T21:38:34"},"gha_size":{"kind":"number","value":15042,"string":"15,042"},"gha_stargazers_count":{"kind":"number","value":0,"string":"0"},"gha_forks_count":{"kind":"number","value":0,"string":"0"},"gha_open_issues_count":{"kind":"number","value":15,"string":"15"},"gha_language":{"kind":"string","value":"C++"},"gha_archived":{"kind":"null"},"gha_disabled":{"kind":"null"},"content":{"kind":"string","value":"#\n# datavis.settings.production\n# Django production settings\n\nfrom .default import *\n\nDEBUG = False\n\nos.environ.setdefault(\"VAR_DIR\", \"/var\")\nVAR_DIR = os.environ.get('VAR_DIR')\n\nDEFAULT_LOG_DIR = LOG_DIR\n\nLOG_DIR = os.path.join(VAR_DIR, 'log/django')\nPROD_LOG_LEVEL = 'WARNING'\n\nVAR_RUN_DIR = os.path.join(VAR_DIR, 'run/django')\nVAR_LIB_DIR = os.path.join(VAR_DIR, 'lib/django')\n\n# Update path to database if sqlite is used\nif 'sqlite' in DATABASES['default']['ENGINE']:\n DATABASES['default']['NAME'] = os.path.join(VAR_LIB_DIR, 'db.sqlite3')\n\nSECRET_KEY = os.environ.get('EOL_DATAVIS_SECRET_KEY')\n\nif SECRET_KEY is None:\n raise ValueError('EOL_DATAVIS_SECRET_KEY environment variable must be set when running with datavis.settings.production')\n\n#\n# django may generate log messages such as:\n# Invalid HTTP_HOST header: 'www.baidu.com'.\n# You may need to add 'www.baidu.com' to ALLOWED_HOSTS.\n#\n# However, don't follow that advice to add those external host\n# names to ALLOWED_HOSTS!\n# Hacked sites may have a link to this site, but as I understand it,\n# the redirect may contain an HTTP packet with an altered HTTP_HOST\n# and SERVER_NAME, hoping that a dumb server, thinking HTTP_HOST\n# is itself, will use it in its own redirects and