Dataset Viewer
Auto-converted to Parquet Duplicate
added
stringdate
2024-11-18 17:59:49
2024-11-19 03:44:43
created
int64
0
2,086B
id
stringlengths
40
40
int_score
int64
2
5
metadata
dict
score
float64
2.31
5.5
source
stringclasses
1 value
text
stringlengths
258
23.4k
num_lines
int64
16
649
avg_line_length
float64
15
61
max_line_length
int64
31
179
ast_depth
int64
8
40
length
int64
101
3.8k
lang
stringclasses
1 value
sast_codeql_findings
stringlengths
2
265k
sast_codeql_findings_count
int64
0
45
sast_codeql_success
bool
1 class
sast_codeql_error
stringclasses
1 value
2024-11-19T01:43:02.947935+00:00
1,585,925,324,000
d8bab637be37aa09043e8d04a21240453c0add23
2
{ "blob_id": "d8bab637be37aa09043e8d04a21240453c0add23", "branch_name": "refs/heads/master", "committer_date": 1585925324000, "content_id": "13d5f02133f1641fc741816173e0004c713e3443", "detected_licenses": [ "MIT" ], "directory_id": "fe230e6ea75a1bb4be0e351c7f3e189c14327821", "extension": "py", "filename": "chicago_workloads.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 3560, "license": "MIT", "license_type": "permissive", "path": "/code/Data_Generation/chicago_workloads.py", "provenance": "stack-edu-0057.json.gz:284812", "repo_name": "HuangWenJ/modelbasedaqp", "revision_date": 1585925324000, "revision_id": "1dbba997c16493e0344aaa95901f3de5e670c352", "snapshot_id": "1a8462b2662240a907afb69d693b4e5b63307b8f", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/HuangWenJ/modelbasedaqp/1dbba997c16493e0344aaa95901f3de5e670c352/code/Data_Generation/chicago_workloads.py", "visit_date": "2023-03-25T05:44:38.642159" }
2.4375
stackv2
import pandas as pd import numpy as np import os import sys os.chdir("../../../dynamic-reproducibility") sys.path.append('utils') from terminal_outputs import printProgressBar from confs import Config QUERIES = Config.chicago_queries CLUSTERS = Config.chicago_clusters if not os.path.exists('input/Crimes_Workload'): print('creating directory' ,'Crimes_Workload') os.makedirs('input/Crimes_Workload') existing = set(os.listdir('input/Crimes_Workload')) if 'train_workload_gauss-{}-users-{}.csv'.format(CLUSTERS,QUERIES) in existing or 'test_workload_gauss-{}-users-{}.csv'.format(CLUSTERS,QUERIES) in existing: print("Files already exist; exiting ") sys.exit(0) def load_data(): print("Loading Data...") global df df = pd.read_csv('input/Crimes_-_2001_to_present.csv', header=0) sample = df.sample(10000) global x_mean x_mean = float(sample[['X Coordinate']].mean()) global y_mean y_mean = float(sample[['Y Coordinate']].mean()) global x_std x_std = float(sample[['X Coordinate']].std()) global y_std y_std = float(sample[['Y Coordinate']].std()) del sample def set_number_and_locations_of_clusters(): print("Constructing central points for queries") clusters = np.random.multivariate_normal([x_mean, y_mean], [[x_std**2, 0],[0, y_std**2]], CLUSTERS) #Create queries around those central points #Fraction of variance for how widespread the queries would be queries = map(lambda x : np.random.multivariate_normal(x, [[0.01*(x_std),0],[0,0.01*(y_std)]], int(QUERIES/CLUSTERS)), clusters) global col_queries col_queries = np.array(list(queries)).reshape(-1,2) def __get_query(q): multiplier_x = np.random.rand()#varying range at queries x_range = (x_std/2.0)*multiplier_x predicate1_0 = df['X Coordinate']>=q[0]-x_range predicate1_1 = df['X Coordinate']<=q[0]+x_range multiplier_y = np.random.rand() y_range = (y_std/2.0)*multiplier_y predicate2_0 = df['Y Coordinate']>=q[1]-y_range predicate2_1 = df['Y Coordinate']<=q[1]+y_range return (x_range, y_range, ((predicate1_0) & (predicate1_1) & (predicate2_0) & (predicate2_1))) def construct_queries(): complete_queries = [] i=0 for q in col_queries: call = __get_query(q) x_range = call[0] y_range = call[1] res = df[call[2]] count = int(res.count()[0]) sum_ = float(res['Arrest'].sum()) avg = float(res['Beat'].mean()) complete_queries.append([q[0], q[1],x_range, y_range, count, sum_, avg]) i+=1 printProgressBar(i, QUERIES,prefix = 'Progress:', suffix = 'Complete', length = 50) finished = pd.DataFrame(np.array(complete_queries), columns=['x','y','x_range', 'y_range', 'count', 'sum_','avg']) test = finished.sample(frac=.2) train = finished.drop(test.index) print("Saving Output Files") test['count'] = test['count'].replace([np.inf, -np.inf], np.nan).dropna() test['sum_'] = test['sum_'].replace([np.inf, -np.inf], np.nan).dropna() train['count'] = train['count'].replace([np.inf, -np.inf], np.nan).dropna() train['sum_'] = train['sum_'].replace([np.inf, -np.inf], np.nan).dropna() test.dropna().to_csv('input/Crimes_Workload/test_workload_gauss-{}-users-{}.csv'.format(CLUSTERS,QUERIES)) train.dropna().to_csv('input/Crimes_Workload/train_workload_gauss-{}-users-{}.csv'.format(CLUSTERS,QUERIES)) if __name__=='__main__': np.random.seed(15) load_data() set_number_and_locations_of_clusters() construct_queries()
85
40.88
157
15
1,025
python
[]
0
true
2024-11-19T01:43:03.162685+00:00
1,568,097,772,000
18c2226f9be707528e39e21b920eaf22f08a20e9
2
{ "blob_id": "18c2226f9be707528e39e21b920eaf22f08a20e9", "branch_name": "refs/heads/master", "committer_date": 1568097772000, "content_id": "285d8e66eb74f34f99fdcbcbf9e739155f2184b3", "detected_licenses": [ "MIT" ], "directory_id": "83ad51c9f7ea71eefcf38882ac9b20d514332a0b", "extension": "py", "filename": "views.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 206723588, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1078, "license": "MIT", "license_type": "permissive", "path": "/app/main/views.py", "provenance": "stack-edu-0057.json.gz:284813", "repo_name": "Hillarydalie/newsrecap", "revision_date": 1568097772000, "revision_id": "28a6cfab5b8a4b69a82ffc497b8a8127e9bb1726", "snapshot_id": "2fe7148575bc82798ec43c991f7666b362f6b869", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Hillarydalie/newsrecap/28a6cfab5b8a4b69a82ffc497b8a8127e9bb1726/app/main/views.py", "visit_date": "2022-12-10T02:49:27.979311" }
2.328125
stackv2
from . import main from flask import render_template,redirect,request,url_for from app.requests import getNews,getSearchItem,getArticles # Insert home page view @main.route('/') def home(): """ homepage route """ title = "Welcome to Newsrecapp" news = getNews() return render_template('index.html',sources = news, title = title) @main.route('/source/<id>') def source(id): headlines = getArticles(id) source = id return render_template('articles.html',headlines = headlines , source = source) @main.route('/news/highlight') def highlight(): technology = getSearchItem('technology') title = 'News Highlight' search_article = request.args.get('searchword') if search_article: return redirect(url_for('.searchArticle',new_article = search_article)) else: return render_template('newsHighlight.html',title = title,technology = technology) @main.route('/search/<new_article>') def searchArticle(new_article): title = f'{new_article}' search = getSearchItem(new_article) return render_template('search.html',title = title,search = search)
35
29.83
86
13
248
python
[]
0
true
2024-11-19T01:43:03.275467+00:00
1,618,831,291,000
414ab79a4ade5f6580615cc63d0e6bfcd076b5b9
3
{ "blob_id": "414ab79a4ade5f6580615cc63d0e6bfcd076b5b9", "branch_name": "refs/heads/master", "committer_date": 1618831291000, "content_id": "c944f4115e3bd5ffc61d5c6c092aa702c7668c3e", "detected_licenses": [ "MIT" ], "directory_id": "4372b3f8aff592d3d447e76bef21fbc1d11b8d21", "extension": "py", "filename": "schema.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 315666789, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 922, "license": "MIT", "license_type": "permissive", "path": "/csv_generator/models/schema.py", "provenance": "stack-edu-0057.json.gz:284814", "repo_name": "Vitamal/schemas", "revision_date": 1618831291000, "revision_id": "0cfc1acb9031a2348bef2207e492d47d1c86e5c1", "snapshot_id": "d236f48233e05af9822a0eba2bc12f078d4cb907", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Vitamal/schemas/0cfc1acb9031a2348bef2207e492d47d1c86e5c1/csv_generator/models/schema.py", "visit_date": "2023-05-07T15:38:15.865366" }
2.578125
stackv2
from django.db import models from . import BaseModel class Schema(BaseModel): COMMA = ',' SEMICOLON = ';' COLON = ':' COLUMN_SEPARATOR = [ (COMMA, 'Comma (,)'), (SEMICOLON, 'Semicolon(;)'), (COLON, 'Colon(:)'), ] QUOTE = "'" DOUBLE_QUOTE = '"' STRING_CHARACTER = [ (QUOTE, "Quote(')"), (DOUBLE_QUOTE, 'Double quote(")'), ] name = models.CharField( max_length=100, verbose_name='name' ) column_separator = models.CharField( max_length=1, choices=COLUMN_SEPARATOR, default=COMMA, verbose_name='column separator' ) string_character = models.CharField( max_length=1, choices=STRING_CHARACTER, verbose_name='string character' ) schema_column = models.JSONField(null=False, blank=True, default=dict) def __str__(self): return self.name
39
22.64
74
10
227
python
[]
0
true
2024-11-19T01:43:05.796585+00:00
1,521,557,028,000
fccab3cd4221e2a0a8d8bcf21150f419adc13bb6
3
{ "blob_id": "fccab3cd4221e2a0a8d8bcf21150f419adc13bb6", "branch_name": "refs/heads/master", "committer_date": 1521557028000, "content_id": "d9c3cf6547e42e5bab12e1fb8504fb7d30ee4dc1", "detected_licenses": [ "Apache-2.0" ], "directory_id": "e18e5d6e4977280952ef3c920ede6aae71f897b1", "extension": "py", "filename": "animals.py", "fork_events_count": 1, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 125653072, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1675, "license": "Apache-2.0", "license_type": "permissive", "path": "/plugins/animals.py", "provenance": "stack-edu-0057.json.gz:284816", "repo_name": "AdamDeCosta/Argus", "revision_date": 1521557028000, "revision_id": "e2298c2be8e048b256f68669255b0bd25efc8290", "snapshot_id": "3523bcbc958be2c7afa685fd8efd78eb981b866e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/AdamDeCosta/Argus/e2298c2be8e048b256f68669255b0bd25efc8290/plugins/animals.py", "visit_date": "2021-04-09T13:40:17.114654" }
2.984375
stackv2
import discord from discord.ext import commands import aiohttp import json class Animals: def __init__(self, client): self.client = client self.session = aiohttp.ClientSession() @commands.command(name='rd', pass_context=True) async def random_dog(self, ctx, *args): """ gets a random dog image from dog.ceo :param args: breed of dog """ mention = ctx.message.author.mention args = args or {} if len(args) == 1: url = "https://dog.ceo/api/breed/{0}/images/random".format(args[0]) elif len(args) == 2: url = "https://dog.ceo/api/breed/{0}/{1}/images/random".format( args[1], args[0]) else: url = "https://dog.ceo/api/breeds/image/random" r = await self.session.get(url) resp = await r.text() if resp == "Not found": await self.client.say("{0} Error: No image found!".format(mention)) return else: resp = json.loads(resp) if resp['status'] != "success": await self.client.say("{0} Error: {1}" .format(mention, resp['message'])) else: try: img = resp['message'] except Exception as e: await self.client.say("{0} Error: Something went wrong!" .format(mention)) print(e) else: embed = discord.Embed() embed.set_image(url=img) await self.client.say(embed=embed) def setup(client): client.add_cog(Animals(client))
59
27.39
79
20
368
python
[]
0
true
2024-11-19T01:43:08.399074+00:00
1,630,733,693,000
685da1b346980640b79c50776c6e3acefc8741b1
2
{ "blob_id": "685da1b346980640b79c50776c6e3acefc8741b1", "branch_name": "refs/heads/main", "committer_date": 1630733693000, "content_id": "91286910848fc0e97634bab98921f00b13735c40", "detected_licenses": [ "Unlicense" ], "directory_id": "43cfb676f6703d0a6132f0f1f96b5927a6dfac53", "extension": "py", "filename": "card.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 398992502, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 784, "license": "Unlicense", "license_type": "permissive", "path": "/_lark/card/card.py", "provenance": "stack-edu-0057.json.gz:284818", "repo_name": "ouranoshong/errbot-backend-lark", "revision_date": 1630733693000, "revision_id": "73748a9e814f01df325b89a98a84be8a0a79162a", "snapshot_id": "621128743396c605dd00a1a86c45653fbfda0aca", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/ouranoshong/errbot-backend-lark/73748a9e814f01df325b89a98a84be8a0a79162a/_lark/card/card.py", "visit_date": "2023-07-17T03:37:41.910631" }
2.421875
stackv2
#!/usr/bin/env python # -*- coding: utf-8 -*- from _lark.card.modules import Module from typing import List, Optional class CardConfig: def __init__(self, wide_screen_mode: bool = True, enable_forward: bool = True): self.wide_screen_mode = wide_screen_mode self.enable_forward = enable_forward class CardHeader: def __init__(self, title: str, template: Optional[str] = None): self.title = title self.template = template class CardMessage: def __init__(self, elements: List[Module], config: Optional[CardConfig] = None, header: Optional[CardHeader] = None): self.elements = elements self.config = config self.header = header
29
26.03
67
11
170
python
[]
0
true
2024-11-19T01:43:08.633983+00:00
1,652,296,409,000
02ffc5f086fccff5593203df5eb5d8caceb48b95
3
{ "blob_id": "02ffc5f086fccff5593203df5eb5d8caceb48b95", "branch_name": "refs/heads/master", "committer_date": 1652296409000, "content_id": "d6e085ffcf2be8a6c46aa78af075a6cfbc006edc", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "3c3af05dbce543e90abaf30866f02c8093bf63bd", "extension": "py", "filename": "utils.py", "fork_events_count": 2, "gha_created_at": 1545325980000, "gha_event_created_at": 1652296409000, "gha_language": "Python", "gha_license_id": "BSD-3-Clause", "github_id": 162609367, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1923, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/foliage/utils.py", "provenance": "stack-edu-0057.json.gz:284821", "repo_name": "harrislapiroff/wagtail-foliage", "revision_date": 1652296409000, "revision_id": "2e695d1bf10b0a2bd69c13366a0c7380fb78c621", "snapshot_id": "387508094e7abc924165386529eb266fdebeb909", "src_encoding": "UTF-8", "star_events_count": 18, "url": "https://raw.githubusercontent.com/harrislapiroff/wagtail-foliage/2e695d1bf10b0a2bd69c13366a0c7380fb78c621/foliage/utils.py", "visit_date": "2022-06-08T11:28:01.664626" }
3.015625
stackv2
from typing import Iterable, Tuple, List from wagtail import VERSION if VERSION < (2, 0): from wagtail.wagtailcore.models import Page, Site else: from wagtail.core.models import Page, Site def build_page_tree( # Would that mypy supported recursive types tree: Iterable[Tuple[Page, Iterable]], root: Page = None ) -> List[Page]: """ Construct a page tree in the database. Accepts a tree in the form: [ (Page, [ (Page, [...]), (Page, [...]), Page, ]), ] where ``[...]`` is a nested iterable of (Page, children) tuples or bare page instances. """ created = [] for node in tree: if isinstance(node, Page): # If `node` is a bare page, it has no children page = node children = [] else: # Otherwise assume it is a (Page, children) tuple page, children = node if root: root.add_child(instance=page) else: type(page).add_root(instance=page) created += [page] created += build_page_tree(children, root=page) return created def get_site() -> Site: try: return Site.objects.get() except Site.MultipleObjectsReturned: # Reraise MultipleObjectsReturned, but with our own message raise Site.MultipleObjectsReturned( 'Foliage can\'t auto-determine the Wagtail Site. ' 'More than one Site exists in the database!' ) def get_root_page() -> Page: try: return Page.objects.get(depth=1) except Page.MultipleObjectsReturned: # Reraise MultipleObjectsReturned, but with our own message raise Site.MultipleObjectsReturned( 'Foliage can\'t auto-determine the root page. ' 'More than one Page exists with depth 1 in the database!' )
72
25.71
75
14
435
python
[]
0
true
2024-11-19T01:43:08.693143+00:00
1,431,018,320,000
d35479999d4286b7d7b69941287942e6b909a46c
2
{ "blob_id": "d35479999d4286b7d7b69941287942e6b909a46c", "branch_name": "refs/heads/master", "committer_date": 1431018320000, "content_id": "c4d811f17244649985618c94d02bd0f12acb117c", "detected_licenses": [ "MIT" ], "directory_id": "aef93329edd6df903eb104d069451b1d02a51bb8", "extension": "py", "filename": "github.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 34352478, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1567, "license": "MIT", "license_type": "permissive", "path": "/github_art/github.py", "provenance": "stack-edu-0057.json.gz:284822", "repo_name": "ufocoder/py-GithubArt", "revision_date": 1431018320000, "revision_id": "3e14b1d39738135760263182d06cbf82b723b435", "snapshot_id": "0b88e51f6858e7c581f951397710d11bbba1a033", "src_encoding": "UTF-8", "star_events_count": 10, "url": "https://raw.githubusercontent.com/ufocoder/py-GithubArt/3e14b1d39738135760263182d06cbf82b723b435/github_art/github.py", "visit_date": "2021-01-15T19:27:59.277561" }
2.484375
stackv2
import subprocess import os from datepoints import GithubDatePoints from pixelsets import LettersPixelSet class Github(object): def __init__(self, string, cwd, dictionary): self.__string = string self.__dictionary = dictionary self.__cwd = os.path.abspath(cwd) self.commands = [] def __git_init(self): self.commands.append(['git', 'init']) self.commands.append(['git', 'show-ref']) def __git_commit(self, datetime_point): # Date formats, URL: http://git-scm.com/docs/git-commit file = datetime_point.strftime("%Y-%m-%d_%H-%M-%S") date = datetime_point.strftime("%Y-%m-%d %H:%M:%S %z") self.commands.append(['touch', file]) self.commands.append(['git', 'add', file]) self.commands.append(['git', 'commit', '--message="' + file + '"', '--date="' + date + '"']) def initialite(self): pixel_set = LettersPixelSet(self.__string, self.__dictionary).get_pixel_set() date_points = GithubDatePoints(pixel_set).get_date_points() self.__git_init() for date_point in date_points: self.__git_commit(date_point) def set_account(self, username, proejct): github_url = 'https://' + username + '@github.com/' + username + '/' + proejct + '.git' self.commands.append(['git', 'remote', 'add', 'origin', github_url]) self.commands.append(['git', 'push', '-u', 'origin', 'master']) def run(self): for command in self.commands: subprocess.call(command, cwd=self.__cwd)
45
33.82
100
15
370
python
[]
0
true
2024-11-19T01:43:18.110227+00:00
1,528,230,873,000
873860326d879bf948cfa0852c05fcac26989243
3
{ "blob_id": "873860326d879bf948cfa0852c05fcac26989243", "branch_name": "refs/heads/master", "committer_date": 1528230873000, "content_id": "e7e0d7ac8a1325a77d7b5bc0dc4392bfd896de79", "detected_licenses": [ "Apache-2.0" ], "directory_id": "94bde0b0e1c42b3e604ca3c9249ede2a5a05d12a", "extension": "py", "filename": "link_bs4.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1465, "license": "Apache-2.0", "license_type": "permissive", "path": "/html_link_extractor/link_bs4.py", "provenance": "stack-edu-0057.json.gz:284824", "repo_name": "Yrral-Nerraw/Information_Gathering_Python_Web_Scraping_Scripts", "revision_date": 1528230873000, "revision_id": "b49911d5bb86ba10fe9b0b0bf0994998085ee3a7", "snapshot_id": "1d82418c8e54abae7997bae0bcb6a65c5cbb037e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Yrral-Nerraw/Information_Gathering_Python_Web_Scraping_Scripts/b49911d5bb86ba10fe9b0b0bf0994998085ee3a7/html_link_extractor/link_bs4.py", "visit_date": "2020-05-18T15:57:09.566888" }
2.96875
stackv2
#!/usr/bin/python # ---------------- READ ME --------------------------------------------- # This Script is Created Only For Practise And Educational Purpose Only # This Script Is Created For https://bitforestinfo.blogspot.in # This Script is Written By # # ################################################## ######## Please Don't Remove Author Name ######### ############### Thanks ########################### ################################################## # # __author__=''' ###################################################### By S.S.B Group ###################################################### Suraj Singh Admin S.S.B Group surajsinghbisht054@gmail.com https://bitforestinfo.blogspot.in/ Note: We Feel Proud To Be Indian ###################################################### ''' # Imprt Module import bs4 import urllib2, sys if len(sys.argv)==1: print "[*] Please Provide Domain Name:\n Usages: python link_bs4.py www.examplesite.com\n" sys.exit(0) def parse_url(url): try: html=urllib2.urlopen(url).read() # Reading Html Codes except Exception as e: print "[Error] ",e sys.exit(0) parse=bs4.BeautifulSoup(html) # Feed Data To bs4 for i in parse.findAll('a'): # Searching For link Tag if 'href' in i.attrs.keys(): # Searching For Href key link=i.attrs['href'] print link return parse_url(sys.argv[1])
50
28.32
94
12
306
python
[]
0
true
2024-11-19T01:43:18.153600+00:00
1,627,908,985,000
d98fc8a37f9074c4325a295c475c6745b0b79e45
4
{ "blob_id": "d98fc8a37f9074c4325a295c475c6745b0b79e45", "branch_name": "refs/heads/main", "committer_date": 1627908985000, "content_id": "7bffcd57105a122bfa0222afccf80458a13c2196", "detected_licenses": [ "MIT" ], "directory_id": "326f67ddb17d2126ada58285b105517db085a650", "extension": "py", "filename": "stockApp.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 391948831, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 616, "license": "MIT", "license_type": "permissive", "path": "/stockApp.py", "provenance": "stack-edu-0057.json.gz:284825", "repo_name": "AmirLyall/streamlitApps", "revision_date": 1627908985000, "revision_id": "1e8157aff4e12e85304732f983f5f186f80f086d", "snapshot_id": "bf13cf7e1589df48919c12ff3af93b3e3f42a831", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/AmirLyall/streamlitApps/1e8157aff4e12e85304732f983f5f186f80f086d/stockApp.py", "visit_date": "2023-06-25T23:33:12.386799" }
3.703125
stackv2
import yfinance as yf import streamlit as st import pandas as pd st.write(""" # Simple Stock Price App Shown are the stock closing price and volume of Google! """) # https://towardsdatascience.com/how-to-get-stock-data-using-python-c0de1df17e75 #define the ticker symbol tickerSymbol = 'GOOGL' #get data on this ticker tickerData = yf.Ticker(tickerSymbol) #get the historical prices for this ticker tickerDf = tickerData.history(period='1d', start='2010-5-31', end='2020-5-31') # Open High Low Close Volume Dividends Stock Splits st.line_chart(tickerDf.Close) st.line_chart(tickerDf.Volume)
22
26.09
80
8
176
python
[]
0
true
2024-11-19T01:43:18.274032+00:00
1,621,602,436,000
9a9f3399d7f823e4f16abea7d511fa212e633efd
3
{ "blob_id": "9a9f3399d7f823e4f16abea7d511fa212e633efd", "branch_name": "refs/heads/master", "committer_date": 1621602436000, "content_id": "4b72890d330848bab0b4bd610d1c265f0f76731c", "detected_licenses": [ "MIT" ], "directory_id": "605dbe3f437e011eacd6e9614514dc9eba5c35b1", "extension": "py", "filename": "mailer.py", "fork_events_count": 1, "gha_created_at": 1608061735000, "gha_event_created_at": 1621550376000, "gha_language": "Python", "gha_license_id": "MIT", "github_id": 321773113, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 4227, "license": "MIT", "license_type": "permissive", "path": "/easy_notifyer/clients/mailer.py", "provenance": "stack-edu-0057.json.gz:284827", "repo_name": "strpc/easy_notifyer", "revision_date": 1621602436000, "revision_id": "6d6eaf7edae9a709d34dda27d7384494fee0e772", "snapshot_id": "f7cd724c26a1cef48b454e5315084e7cc9c9a6e7", "src_encoding": "UTF-8", "star_events_count": 6, "url": "https://raw.githubusercontent.com/strpc/easy_notifyer/6d6eaf7edae9a709d34dda27d7384494fee0e772/easy_notifyer/clients/mailer.py", "visit_date": "2023-05-13T06:54:16.027671" }
2.921875
stackv2
import uuid from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from smtplib import SMTP, SMTP_SSL from typing import BinaryIO, List, Optional, Union class Mailer: """Object for send mail""" def __init__( self, *, host: str, port: int, login: str, password: str, ssl: bool = False, ): """ Args: host (str, optional): = post of smtp server. port (int, optional): = port of smtp server. login (str, optional): = login for auth in smtp server. password (str, optional): password for auth in smtp server. ssl (bool, optional): use SSL connection for smtp. """ self._host = host self._port = port self._login = login self._password = password self._ssl = ssl self._connection: Optional[SMTP_SSL, SMTP] = None def __enter__(self): self.connect() return self def __exit__(self, exc_type, exc_val, exc_tb): self.disconnect() def connect(self): """Connect to smtp-server and create session""" if self._connection is None: type_conn = SMTP_SSL if self._ssl is True else SMTP self._connection = type_conn(host=self._host, port=self._port) self.login() def login(self): """Create session with login/password""" if self._connection is not None and self._login is not None and self._password is not None: self._connection.login(user=self._login, password=self._password) def disconnect(self): """Terminate session""" if self._connection is not None: self._connection.quit() @staticmethod def _format_message( *, from_addr: str, to_addrs: List[str], text: str, subject: str, attach: Union[bytes, str, BinaryIO], filename: str, ) -> MIMEMultipart: """Formatting message for send. Args: from_addr (str): the address sending this mail. to_addrs (list(str)): addresses to send this mail to. subject (str, optional): subject of the mail. attach (bytes, str, tuple, optional): file to send. filename (str, optional): filename for attached file. Returns: MIMEMultipart: multipart of message with body, from, to, attach and subject. """ message = MIMEMultipart() message["From"] = from_addr message["To"] = ", ".join(to_addrs) message["Subject"] = subject message.attach(MIMEText(text)) if attach is not None: filename = filename or uuid.uuid4().hex if hasattr(attach, "read") and isinstance(attach.read(0), bytes): attach = attach.read() elif hasattr(attach, "encode"): attach = attach.encode() message.attach(MIMEApplication(attach, name=filename)) return message def send_message( self, *, message: Optional[str] = None, from_addr: str, to_addrs: Union[str, List[str]], subject: Optional[str] = None, attach: Optional[Union[bytes, str, BinaryIO]] = None, filename: Optional[str] = None, ): """Send email. Args: message (str, optional): Text body of message. from_addr (str, optional): the address sending this mail. to_addrs (str, list(str), optional): addresses to send this mail to. subject (str, optional): subject of the mail. attach (bytes, str, tuple, optional): file to send. filename (str, optional): filename for attached file. """ to_addrs = [mail.strip() for mail in to_addrs.split(",")] msg = self._format_message( from_addr=from_addr, to_addrs=to_addrs, text=message, subject=subject, attach=attach, filename=filename, ) self._connection.sendmail(from_addr=from_addr, to_addrs=to_addrs, msg=msg.as_string())
127
32.28
99
16
933
python
[]
0
true
2024-11-19T01:54:46.600743+00:00
1,632,729,639,000
9e22bcdb6e264059006904444a04ce6a6300a411
2
{ "blob_id": "9e22bcdb6e264059006904444a04ce6a6300a411", "branch_name": "refs/heads/master", "committer_date": 1632729639000, "content_id": "1c304fd07c92b9666cc4f024f111acb314da5bd6", "detected_licenses": [ "BSD-2-Clause" ], "directory_id": "07148f74e6f9929356aa68e8889c7d71525b6978", "extension": "py", "filename": "python_rpyc_server.py", "fork_events_count": 0, "gha_created_at": 1629451716000, "gha_event_created_at": 1632729639000, "gha_language": "C++", "gha_license_id": "NOASSERTION", "github_id": 398223953, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2529, "license": "BSD-2-Clause", "license_type": "permissive", "path": "/frontends/swig_python/python_rpyc_server.py", "provenance": "stack-edu-0057.json.gz:284828", "repo_name": "Marcelloloco/thrill_core_research", "revision_date": 1632729639000, "revision_id": "0a85279d90b66461073d514c9fb74b3f2167aa27", "snapshot_id": "230f58055008c750dbef35412e9b73f68362d503", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Marcelloloco/thrill_core_research/0a85279d90b66461073d514c9fb74b3f2167aa27/frontends/swig_python/python_rpyc_server.py", "visit_date": "2023-08-05T11:23:16.215656" }
2.375
stackv2
#!/usr/bin/env python ########################################################################## # frontends/swig_python/python_rpyc_server.py # # Part of Project Thrill - http://project-thrill.org # # Copyright (C) 2015 Timo Bingmann <tb@panthema.net> # # All rights reserved. Published under the BSD-2 license in the LICENSE file. ########################################################################## import sys import marshal import types import rpyc import thrill class RpcDIA(): def __init__(self, dia): self._dia = dia def AllGather(self): return self._dia.AllGather() def Size(self): return self._dia.Size() def Map(self, map_function): code1 = marshal.loads(map_function) func1 = types.FunctionType(code1, globals()) return RpcDIA(self._dia.Map(func1)) def ReduceBy(self, key_extractor, reduce_function): code1 = marshal.loads(key_extractor) func1 = types.FunctionType(code1, globals()) code2 = marshal.loads(reduce_function) func2 = types.FunctionType(code2, globals()) return RpcDIA(self._dia.ReduceBy(func1, func2)) class RpcContext(): def __init__(self, host_ctx, my_host_rank): self._ctx = thrill.PyContext(host_ctx, my_host_rank) def Generate(self, generator_function, size): code1 = marshal.loads(generator_function) function1 = types.FunctionType(code1, globals()) return RpcDIA(self._ctx.Generate(function1, size)) def Distribute(self, array): return RpcDIA(self._ctx.Distribute(array)) class MyService(rpyc.Service): def on_connect(self): # code that runs when a connection is created # (to init the serivce, if needed) print("hello client") pass def on_disconnect(self): # code that runs when the connection has already closed # (to finalize the service, if needed) print("client disconnected") pass def exposed_Create(self, my_host_rank, endpoints): print("Creating thrill context for rank", my_host_rank, "endpoints", endpoints) host_ctx = thrill.HostContext(my_host_rank, endpoints, 1) return RpcContext(host_ctx, 0) if __name__ == "__main__": from rpyc.utils.server import ThreadedServer t = ThreadedServer(MyService, port=int(sys.argv[1]), protocol_config={"allow_public_attrs": True}) t.start() ##########################################################################
83
29.47
77
13
553
python
[]
0
true
2024-11-19T01:54:46.665061+00:00
1,578,379,747,000
f3420aa110cc13fcb03d1c722cbfbd76ee0c27b9
2
{ "blob_id": "f3420aa110cc13fcb03d1c722cbfbd76ee0c27b9", "branch_name": "refs/heads/master", "committer_date": 1578379747000, "content_id": "edc11574bca5c115d8096bbbde5bb5cc93217729", "detected_licenses": [ "Apache-2.0" ], "directory_id": "640e0cd0549c0047b467cc19f6b538b61d51aee3", "extension": "py", "filename": "prune_with_input.py", "fork_events_count": 0, "gha_created_at": 1578364079000, "gha_event_created_at": 1578364080000, "gha_language": null, "gha_license_id": null, "github_id": 232226023, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1691, "license": "Apache-2.0", "license_type": "permissive", "path": "/api_examples/paddle/fluid/prune_with_input.py", "provenance": "stack-edu-0057.json.gz:284829", "repo_name": "qjing666/examples", "revision_date": 1578379747000, "revision_id": "bdb47e0fd284627a4b79db36db8714fd942b9d68", "snapshot_id": "128c273b9a894aee53d2bb3abbf4da38819eea49", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/qjing666/examples/bdb47e0fd284627a4b79db36db8714fd942b9d68/api_examples/paddle/fluid/prune_with_input.py", "visit_date": "2020-12-05T19:35:05.769069" }
2.390625
stackv2
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # api: paddle.fluid.framework.Program._prune_with_input() # env: local # device: cpu # text:prune-with-input import paddle.fluid as fluid import paddle.fluid.optimizer as optimizer import numpy as np def sample_data(): res = [] for i in range(2): data = np.random.normal(size=(2,)) label = np.random.randint(2, size=(1,)) res.append((data, label)) return res x = fluid.layers.data(name='x', shape=[2], dtype='float32') label = fluid.layers.data(name="label", shape=[1], dtype="int64") # define net here y = fluid.layers.fc(input=[x], size=2, act="softmax") loss = fluid.layers.cross_entropy(input=y, label=label) loss = fluid.layers.mean(x=loss) sgd = fluid.optimizer.SGD(learning_rate=0.01) sgd.minimize(loss) with open("original_program", "w") as f: f.write(str(fluid.default_main_program())) pruned_program = fluid.default_main_program()._prune_with_input( feeded_var_names=[y.name, label.name], targets = [loss]) with open("pruned_program", "w") as f: f.write(str(pruned_program))
51
32.12
74
12
421
python
[]
0
true
2024-11-19T01:54:46.775280+00:00
1,631,544,871,000
6e19753f05da35fe6ceacc343c4b55de96b0220d
4
{ "blob_id": "6e19753f05da35fe6ceacc343c4b55de96b0220d", "branch_name": "refs/heads/main", "committer_date": 1631544871000, "content_id": "57cff9baa90a6adcc10a427025e4ad8d10dfb777", "detected_licenses": [ "MIT" ], "directory_id": "6c7cba2f1e80b023238a2657b7fe1f10272ff7a0", "extension": "py", "filename": "N. Клумбы.py", "fork_events_count": 0, "gha_created_at": 1650345788000, "gha_event_created_at": 1650345789000, "gha_language": null, "gha_license_id": "MIT", "github_id": 483106809, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 608, "license": "MIT", "license_type": "permissive", "path": "/Задания 14-го спринта/Простые задачи/N. Клумбы.py", "provenance": "stack-edu-0057.json.gz:284830", "repo_name": "vaclav0411/algorithms", "revision_date": 1631544871000, "revision_id": "7b6417cbe61963dd4bfadc44f685ae1c81a0b06a", "snapshot_id": "01286fe2a85418d926c7e6b03099280d4706ec59", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/vaclav0411/algorithms/7b6417cbe61963dd4bfadc44f685ae1c81a0b06a/Задания 14-го спринта/Простые задачи/N. Клумбы.py", "visit_date": "2023-08-14T10:50:18.875193" }
3.75
stackv2
def flower_beds(beds: list): right_bed = beds[0][1] left_bed = beds[0][0] for i in range(1, len(beds)): if right_bed >= beds[i][0] and right_bed < beds[i][1]: right_bed = beds[i][1] elif beds[i][0] > right_bed: print(f'{left_bed} {right_bed}') left_bed = beds[i][0] right_bed = beds[i][1] print(f'{left_bed} {right_bed}') if __name__ == '__main__': gardeners = int(input()) array = [list(map(int, input().split())) for i in range(gardeners)] sort = sorted(array, key=lambda x: [x[0], -x[1]]) flower_beds(sort)
18
32.78
71
15
182
python
[]
0
true
2024-11-19T01:54:46.944693+00:00
1,691,682,979,000
3cf4d35d8fcd8899cdfcdee1d2eae8d9e0055ae6
3
{ "blob_id": "3cf4d35d8fcd8899cdfcdee1d2eae8d9e0055ae6", "branch_name": "refs/heads/maint", "committer_date": 1691682979000, "content_id": "d54b91643c8e2d5004ffda7fd2a6dc1aabb62c59", "detected_licenses": [ "BSD-3-Clause", "MIT" ], "directory_id": "76f23cc69dc10c44bc7cf00b78e37db04c7a9c45", "extension": "py", "filename": "nda_aws_token_generator.py", "fork_events_count": 134, "gha_created_at": 1383334808000, "gha_event_created_at": 1694718618000, "gha_language": "Python", "gha_license_id": "NOASSERTION", "github_id": 14052034, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 3818, "license": "BSD-3-Clause,MIT", "license_type": "permissive", "path": "/datalad/support/third/nda_aws_token_generator.py", "provenance": "stack-edu-0057.json.gz:284832", "repo_name": "datalad/datalad", "revision_date": 1691682979000, "revision_id": "40332b5ad25bf8744f7399f6c3575f7d28f71384", "snapshot_id": "2d9c247344d340325ba84e7ab674ac320e57f30c", "src_encoding": "UTF-8", "star_events_count": 453, "url": "https://raw.githubusercontent.com/datalad/datalad/40332b5ad25bf8744f7399f6c3575f7d28f71384/datalad/support/third/nda_aws_token_generator.py", "visit_date": "2023-09-04T11:03:02.264714" }
2.625
stackv2
## NDA AWS Token Generator ## Author: NIMH Data Archives ## http://ndar.nih.gov ## License: MIT ## https://opensource.org/licenses/MIT import binascii import hashlib import logging import xml.etree.ElementTree as etree import sys if sys.version_info[0] == 2: import urllib2 as urllib_request else: from urllib import request as urllib_request class NDATokenGenerator(object): __schemas = { 'soap': 'http://schemas.xmlsoap.org/soap/envelope/', 'data': 'http://gov/nih/ndar/ws/datamanager/server/bean/jaxb' } def __init__(self, url): assert url is not None self.url = url logging.debug('constructed with url %s', url) def generate_token(self, username, password): logging.info('request to generate AWS token') encoded_password = self.__encode_password(password) request_xml = self.__construct_request_xml(username, encoded_password) return self.__make_request(request_xml) def __encode_password(self, password): logging.debug('encoding password') hasher = hashlib.sha1() hasher.update(password.encode('utf-8')) digest_bytes = hasher.digest() byte_string = binascii.hexlify(digest_bytes) output = byte_string.decode('utf-8') logging.debug('encoded password hash: %s', output) return output def __construct_request_xml(self, username, encoded_password): logging.debug('constructing request with %s - %s', username, encoded_password) soap_schema = self.__schemas['soap'] datamanager_schema = self.__schemas['data'] element = etree.Element('{%s}Envelope' % soap_schema) body = etree.SubElement(element, '{%s}Body' % soap_schema) userelement = etree.SubElement(body, '{%s}UserElement' % datamanager_schema) user = etree.SubElement(userelement, "user") uid = etree.SubElement(user, "id") uid.text = '0' uid = etree.SubElement(user, "name") uid.text = username uid = etree.SubElement(user, "password") uid.text = encoded_password uid = etree.SubElement(user, "threshold") uid.text = '0' logging.debug(etree.tostring(element)) return etree.tostring(element) def __make_request(self, request_message): logging.debug('making post request to %s', self.url) headers = { 'SOAPAction': '"generateToken"', 'Content-Type': 'text/xml; charset=utf-8' } request = urllib_request.Request(self.url, data=request_message, headers=headers) logging.debug(request) response = urllib_request.urlopen(request) return self.__parse_response(response.read()) def __parse_response(self, response): logging.debug('parsing response') tree = etree.fromstring(response) error = tree.find('.//errorMessage') if error is not None: error_msg = error.text logging.error('response had error message: %s', error_msg) raise Exception(error_msg) generated_token = tree[0][0] token_elements = [e.text for e in generated_token[0:4]] token = Token(*token_elements) return token class Token: def __init__(self, access_key, secret_key, session, expiration): logging.debug('constructing token') self._access_key = access_key self._secret_key = secret_key self._session = session self._expiration = expiration @property def access_key(self): return self._access_key @property def secret_key(self): return self._secret_key @property def session(self): return self._session @property def expiration(self): return self._expiration
121
30.55
89
12
838
python
[{"finding_id": "codeql_py/weak-sensitive-data-hashing_631a910934060c31_a55e6d18", "tool_name": "codeql", "rule_id": "py/weak-sensitive-data-hashing", "finding_type": "path-problem", "severity": "medium", "confidence": "high", "message": "[Sensitive data (password)](1) is used in a hashing algorithm (SHA1) that is insecure for password hashing, since it is not a computationally expensive hash function.\n[Sensitive data (password)](2) is used in a hashing algorithm (SHA1) that is insecure for password hashing, since it is not a computationally expensive hash function.", "remediation": "", "location": {"file_path": "unknown", "line_start": 39, "line_end": null, "column_start": 23, "column_end": 47, "code_snippet": ""}, "cwe_id": "CWE-327", "cwe_name": null, "cvss_score": null, "cvss_vector": null, "owasp_category": null, "references": [], "fingerprint": null, "tags": ["security", "external/cwe/cwe-327", "external/cwe/cwe-328", "external/cwe/cwe-916"], "raw_output": {"ruleId": "py/weak-sensitive-data-hashing", "ruleIndex": 29, "rule": {"id": "py/weak-sensitive-data-hashing", "index": 29}, "message": {"text": "[Sensitive data (password)](1) is used in a hashing algorithm (SHA1) that is insecure for password hashing, since it is not a computationally expensive hash function.\n[Sensitive data (password)](2) is used in a hashing algorithm (SHA1) that is insecure for password hashing, since it is not a computationally expensive hash function."}, "locations": [{"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 39, "startColumn": 23, "endColumn": 47}}}], "partialFingerprints": {"primaryLocationLineHash": "627b2ac495cdfac9:1", "primaryLocationStartColumnFingerprint": "14"}, "codeFlows": [{"threadFlows": [{"locations": [{"location": {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 30, "startColumn": 40, "endColumn": 48}}, "message": {"text": "ControlFlowNode for password"}}}, {"location": {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 32, "startColumn": 51, "endColumn": 59}}, "message": {"text": "ControlFlowNode for password"}}}, {"location": {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 36, "startColumn": 33, "endColumn": 41}}, "message": {"text": "ControlFlowNode for password"}}}, {"location": {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 39, "startColumn": 23, "endColumn": 47}}, "message": {"text": "ControlFlowNode for Attribute()"}}}]}]}, {"threadFlows": [{"locations": [{"location": {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 36, "startColumn": 33, "endColumn": 41}}, "message": {"text": "ControlFlowNode for password"}}}, {"location": {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 39, "startColumn": 23, "endColumn": 47}}, "message": {"text": "ControlFlowNode for Attribute()"}}}]}]}], "relatedLocations": [{"id": 1, "physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 30, "startColumn": 40, "endColumn": 48}}, "message": {"text": "Sensitive data (password)"}}, {"id": 2, "physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 36, "startColumn": 33, "endColumn": 41}}, "message": {"text": "Sensitive data (password)"}}, {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 30, "startColumn": 40, "endColumn": 48}}}, {"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 36, "startColumn": 33, "endColumn": 41}}}]}}]
1
true
2024-11-19T01:54:47.286246+00:00
1,606,712,310,000
b301a1d49fc643a0deeac75cc2b188a030b34b43
2
{ "blob_id": "b301a1d49fc643a0deeac75cc2b188a030b34b43", "branch_name": "refs/heads/master", "committer_date": 1606712310000, "content_id": "4742e7504cb9c77ecb3fadf2b31e1e51a9e3a8dc", "detected_licenses": [ "MIT" ], "directory_id": "c795ec7f77219892183a1222fb51b8be2e754944", "extension": "py", "filename": "AnimationEffects.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 969, "license": "MIT", "license_type": "permissive", "path": "/Media/common/Scripts/AnimationEffects.py", "provenance": "stack-edu-0057.json.gz:284836", "repo_name": "radtek/MultiverseClientServer", "revision_date": 1606712310000, "revision_id": "b64d7d754a0b2b1a3e5acabd4d6ebb80ab1d9379", "snapshot_id": "89d9a6656953417170e1066ff3bd06782305f071", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/radtek/MultiverseClientServer/b64d7d754a0b2b1a3e5acabd4d6ebb80ab1d9379/Media/common/Scripts/AnimationEffects.py", "visit_date": "2023-01-19T04:54:26.163862" }
2.421875
stackv2
import ClientAPI class PlayAnimation: def __init__(self, oid): self.OID = oid def CancelEffect(self): pass def UpdateEffect(self): pass def ExecuteEffect(self, sourceOID, animName): caster = ClientAPI.World.GetObjectByOID(sourceOID) casterLoc = caster.Position # attach and play the sound if not animName in caster.Model.AnimationNames: return # play animation caster.SetProperty('client.animationoverride', True) caster.QueueAnimation(animName) # wait for the duration of the animation to turn off the animation override yield int(caster.Model.AnimationLength(animName) * 1000) caster.SetProperty('client.animationoverride', False) # clean up sounds #target.ClearSounds() # register the effect ClientAPI.World.RegisterEffect("PlayAnimation", PlayAnimation)
38
24.5
91
14
197
python
[]
0
true
2024-11-19T01:54:47.900457+00:00
1,464,164,760,000
e8537f10204f46b318402b7cdec8228abd477c94
3
{ "blob_id": "e8537f10204f46b318402b7cdec8228abd477c94", "branch_name": "refs/heads/master", "committer_date": 1464164760000, "content_id": "1d28f85c2b53590bb27fb9f261095ec477d30e8b", "detected_licenses": [ "MIT" ], "directory_id": "87f0a79711e71f9ae71071514d9de603b29d2e14", "extension": "py", "filename": "utils.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 59393801, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 645, "license": "MIT", "license_type": "permissive", "path": "/utils.py", "provenance": "stack-edu-0057.json.gz:284838", "repo_name": "kiterub/tiny_demon", "revision_date": 1464164760000, "revision_id": "9a02032ae93ea9f2a2ef61bc20606175feae362e", "snapshot_id": "9d4b632261dd59c78adac2ad8684b646df08df12", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/kiterub/tiny_demon/9a02032ae93ea9f2a2ef61bc20606175feae362e/utils.py", "visit_date": "2021-06-01T07:13:23.744045" }
2.796875
stackv2
from config import redis_conn def has_fileid(file_id): return redis_conn.sismember("fileids", file_id) def add_fileid(file_id): redis_conn.sadd("fileids", file_id) def get_filename_by_id(file_id): return redis_conn.get("{0}:filename".format(file_id)) def set_filename_with_id(file_id, filename): return redis_conn.set("{0}:filename".format(file_id), filename) def is_children(file_id, serial): return redis_conn.sismember("{0}:children".format(file_id), serial) def add_children(file_id, serial): redis_conn.sadd("{0}:children".format(file_id), serial) def get_fileids(): return redis_conn.smembers("fileids")
22
28.32
71
10
159
python
[]
0
true
2024-11-19T01:54:47.963141+00:00
1,689,412,509,000
650aaf2560f65614a91a7d5854f2d20d1b6c8760
2
{ "blob_id": "650aaf2560f65614a91a7d5854f2d20d1b6c8760", "branch_name": "refs/heads/master", "committer_date": 1689412509000, "content_id": "45fb1809780cf40d8867cf679f1e67ba2c23ec29", "detected_licenses": [ "MIT" ], "directory_id": "b836a2aa3301da2f74d978b40f68165765821830", "extension": "py", "filename": "cryptoIDClient.py", "fork_events_count": 30, "gha_created_at": 1525582792000, "gha_event_created_at": 1689412510000, "gha_language": "Python", "gha_license_id": "MIT", "github_id": 132308123, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2365, "license": "MIT", "license_type": "permissive", "path": "/src/cryptoIDClient.py", "provenance": "stack-edu-0057.json.gz:284839", "repo_name": "PIVX-Project/PIVX-SPMT", "revision_date": 1689412509000, "revision_id": "9736c7afe26655c2f237edd9a971b148a3c34695", "snapshot_id": "885ffdd39558d681214fab5147f95895b72bbbcb", "src_encoding": "UTF-8", "star_events_count": 24, "url": "https://raw.githubusercontent.com/PIVX-Project/PIVX-SPMT/9736c7afe26655c2f237edd9a971b148a3c34695/src/cryptoIDClient.py", "visit_date": "2023-08-03T08:49:26.640762" }
2.484375
stackv2
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2017-2019 Random.Zebra (https://github.com/random-zebra/) # Distributed under the MIT software license, see the accompanying # file LICENSE.txt or http://www.opensource.org/licenses/mit-license.php. from random import choice import requests from misc import getCallerName, getFunctionName, printException api_keys = ["b62b40b5091e", "f1d66708a077", "ed85c85c0126", "ccc60d06f737"] def process_cryptoID_exceptions(func): def process_cryptoID_exceptions_int(*args, **kwargs): try: return func(*args, **kwargs) except Exception as e: message = "CryptoID Client exception" printException(getCallerName(True), getFunctionName(True), message, str(e)) return None return process_cryptoID_exceptions_int def UTXOS_cryptoID_to_trezor(utxos): # convert JSON labels new_utxos = [] for u in utxos: new_u = {} new_u["txid"] = u["tx_hash"] new_u["vout"] = u["tx_ouput_n"] new_u["satoshis"] = u["value"] new_u["confirmations"] = u["confirmations"] new_u["script"] = u["script"] new_utxos.append(new_u) return new_utxos class CryptoIDClient: def __init__(self, isTestnet=False): if isTestnet: raise Exception("\nNo CryptoID Testnet server\n") self.isTestnet = False self.url = "http://chainz.cryptoid.info/pivx/api.dws" self.parameters = {} def checkResponse(self, parameters): key = choice(api_keys) parameters['key'] = key resp = requests.get(self.url, params=parameters) if resp.status_code == 200: data = resp.json() return data return None @process_cryptoID_exceptions def getAddressUtxos(self, address): self.parameters = {} self.parameters['q'] = 'unspent' self.parameters['active'] = address res = self.checkResponse(self.parameters) if res is None: return None else: return UTXOS_cryptoID_to_trezor(res['unspent_outputs']) @process_cryptoID_exceptions def getBalance(self, address): self.parameters = {} self.parameters['q'] = 'getbalance' self.parameters['a'] = address return self.checkResponse(self.parameters)
76
30.12
87
15
607
python
[]
0
true
2024-11-19T01:54:48.032181+00:00
1,608,835,665,000
19ad736c4c499492aeb075940f9ae83d749fe123
3
{ "blob_id": "19ad736c4c499492aeb075940f9ae83d749fe123", "branch_name": "refs/heads/main", "committer_date": 1608835665000, "content_id": "a5e7220b909e5a25de84aafade8a40b8ba46762a", "detected_licenses": [ "MIT" ], "directory_id": "92197d3da9ceb3a91d2ce98fb9a3bea91e1723dc", "extension": "py", "filename": "training_resnet.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 312244454, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1662, "license": "MIT", "license_type": "permissive", "path": "/models_v1/training_resnet.py", "provenance": "stack-edu-0057.json.gz:284840", "repo_name": "Frostday/Emotion-Detection", "revision_date": 1608835665000, "revision_id": "a213b3abaa3b5bcbea1d00af48b0030e8d68b80d", "snapshot_id": "cb508ff8deaf5e9b49fa8e40c0e33624802a909e", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/Frostday/Emotion-Detection/a213b3abaa3b5bcbea1d00af48b0030e8d68b80d/models_v1/training_resnet.py", "visit_date": "2023-02-06T17:52:39.585867" }
2.65625
stackv2
import tensorflow as tf from tensorflow.keras.layers import Input, Lambda, Dense, Flatten from tensorflow.keras.models import Model from tensorflow.keras.applications.resnet50 import ResNet50 from tensorflow.keras.applications.resnet50 import preprocess_input from tensorflow.keras.preprocessing import image from tensorflow.keras.preprocessing.image import ImageDataGenerator import numpy as np import matplotlib.pyplot as plt from glob import glob IMAGE_SIZE = [100, 100] epochs = 50 batch_size = 5 PATH = './data/' # useful for getting number of files image_files = glob(PATH + '/*/*.jp*g') # useful for getting number of classes folders = glob(PATH + '/*') print("Number of images:", len(image_files)) print("Number of classes: ", len(folders)) resnet = ResNet50(input_shape=IMAGE_SIZE + [3], weights='imagenet', include_top=False) for layer in resnet.layers: layer.trainable = False x = Flatten()(resnet.output) prediction = Dense(len(folders), activation='softmax')(x) model = Model(inputs=resnet.input, outputs=prediction) # model.summary() model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy']) gen = ImageDataGenerator( width_shift_range=0.1, height_shift_range=0.1, shear_range=0.1, zoom_range=0.2, horizontal_flip=True, vertical_flip=True, preprocessing_function=preprocess_input ) train_generator = gen.flow_from_directory( PATH, target_size=IMAGE_SIZE, shuffle=True, batch_size=batch_size, ) r = model.fit( train_generator, epochs=epochs, steps_per_epoch=len(image_files) // batch_size, ) model.save("models/saved_models_resnet/model100x100.hdf5") print("Saved Resnet model")
59
27.19
89
10
410
python
[]
0
true
2024-11-19T01:54:48.150153+00:00
1,621,271,197,000
527f2d3f75840be8caa1d686cd967a8c9d97ff38
3
{ "blob_id": "527f2d3f75840be8caa1d686cd967a8c9d97ff38", "branch_name": "refs/heads/master", "committer_date": 1621271197000, "content_id": "328689f5f8eaeda0dab46cb6d13bbf114ccb9f7d", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "15fbe75198cc2646f843de9a795c1b3cb1b9bf21", "extension": "py", "filename": "object_converter.py", "fork_events_count": 0, "gha_created_at": 1621270993000, "gha_event_created_at": 1626711401000, "gha_language": "PowerBuilder", "gha_license_id": "BSD-3-Clause", "github_id": 368262087, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 8424, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/tools/optimization/candidate_converter/object_converter.py", "provenance": "stack-edu-0057.json.gz:284842", "repo_name": "jlcox119/HOPP", "revision_date": 1621271197000, "revision_id": "e8faa5012cab8335c75f8d1e84270e3127ff64bb", "snapshot_id": "8750b4a82bf97e8fc1d1794418f7c40650b22baf", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/jlcox119/HOPP/e8faa5012cab8335c75f8d1e84270e3127ff64bb/tools/optimization/candidate_converter/object_converter.py", "visit_date": "2023-06-18T15:09:55.119235" }
2.96875
stackv2
import functools from enum import IntEnum from typing import ( Callable, Generator, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union, ) from ..data_logging.data_recorder import DataRecorder from .candidate_converter import CandidateConverter class Type(IntEnum): Value = 0, # None Tuple = 1, # [(element_type, element_mapping)] ValueTuple = 2, # length List = 3, # [(element_type, element_mapping)] ValueList = 4, # length Dict = 5, # [(key, element_type, element_mapping)] Object = 6, # (factory, [(key, element_type, element_mapping)]) From = TypeVar('From') ValueMapping = None IterableMapping = List[Tuple[Type, 'Mapping']] ValueIterableMapping = int DictMapping = List[Tuple[any, Type, any]] ObjectMapping = Tuple[Callable[[], object], DictMapping] Mapping = Union[ValueMapping, IterableMapping, ValueIterableMapping, DictMapping, ObjectMapping] ValueGenerator = Generator[any, None, None] class ObjectConverter(CandidateConverter[From, List]): """ Converts between POD objects and list of attribute's values. """ def __init__(self, prototype: Optional[object] = None): self.element_type: Type = Type.Value self.mapping: Mapping = [] self.length: int = 0 if prototype is not None: self.setup(prototype) def setup(self, prototype: object, recorder: DataRecorder) -> None: """ Creates a mapping of the prototype's attributes to their element types (list, tuple, dict, value) :param prototype: the object whose attributes are to be mapped :param recorder: a data recorder """ self.element_type, self.mapping = build_mapping(prototype, True) # https://stackoverflow.com/questions/393053/length-of-generator-output self.length = len(list(convert_from_element(self.mapping, prototype, self.element_type))) def convert_from(self, candidate: From) -> List: """ :param candidate: instance of the prototype's element_type :return: values converted from attributes of the candidate """ return [value for value in convert_from_element(self.mapping, candidate, self.element_type)] def convert_to(self, candidate: Iterable) -> From: """ :param candidate: list, tuple or ndarray of values of the candidate :return: instance of element_type with provided values """ return convert_to_element(self.mapping, iter(candidate), self.element_type) def build_iterable_map(prototype: Iterable) -> IterableMapping: return [build_mapping(element) for element in prototype] def build_dict_map(prototype: dict) -> DictMapping: # print(sorted(prototype.keys())) return build_kvp_map(sorted(prototype.items())) def build_object_map(prototype: object) -> ObjectMapping: """ Entry point for building a map of the prototype object's attributes to their types :param prototype: :return: """ sorted_attributes = sorted([(attr, getattr(prototype, attr)) for attr in dir(prototype) if not callable(getattr(prototype, attr)) and not attr.startswith("__")]) print([e[0] for e in sorted_attributes]) return (lambda: type(prototype)(), build_kvp_map(sorted_attributes)) def build_kvp_map(items: Iterable[Tuple[any, any]]) -> DictMapping: return [(key,) + build_mapping(value) for key, value in items] def is_mapping_all_values(mapping) -> bool: return functools.reduce(lambda acc, e: acc and e[0] == Type.Value, mapping, True) def build_mapping(prototype: any, on_root=False) -> ('Type', Mapping): if isinstance(prototype, tuple): mapping = build_iterable_map(prototype) if is_mapping_all_values(mapping): return Type.ValueTuple, len(mapping) return Type.Tuple, mapping if isinstance(prototype, list): mapping = build_iterable_map(prototype) if is_mapping_all_values(mapping): return Type.ValueList, len(mapping) return Type.List, mapping if isinstance(prototype, dict): return Type.Dict, build_dict_map(prototype) # if this is the root, then use an object mapping if on_root: return Type.Object, build_object_map(prototype) return Type.Value, None def convert_from_value(_: None, source: any) -> ValueGenerator: yield source def convert_from_iterable(mapping: IterableMapping, source: Iterable) -> ValueGenerator: for i, value in enumerate(source): element_type, element_mapping = mapping[i] yield from convert_from_element(element_mapping, value, element_type) def convert_from_value_iterable(_: ValueIterableMapping, source: Iterable) -> ValueGenerator: yield from source def convert_from_dict(mapping: DictMapping, source: {}) -> ValueGenerator: for key, element_type, element_mapping in mapping: yield from convert_from_element(element_mapping, source[key], element_type) def convert_from_object(mapping: ObjectMapping, source: object) -> ValueGenerator: for key, element_type, element_mapping in mapping[1]: yield from convert_from_element(element_mapping, getattr(source, key), element_type) convert_from_jump_table = { Type.Value: convert_from_value, Type.Tuple: convert_from_iterable, Type.ValueTuple: convert_from_value_iterable, Type.List: convert_from_iterable, Type.ValueList: convert_from_value_iterable, Type.Dict: convert_from_dict, Type.Object: convert_from_object, } def convert_from_element(mapping: Mapping, source, element_type: Type) -> ValueGenerator: """ Entry point for converting a source object's attributes to their values using the given mapping :param mapping: map of the source's attributes to their types :param source: object from which to convert :param element_type: type of source :return: a generator of the object's values """ yield from convert_from_jump_table[element_type](mapping, source) def convert_to_value(_: None, source: Iterator) -> any: return next(source) def convert_to_list(mapping: IterableMapping, source: Iterator) -> []: return list(convert_to_generator(mapping, source)) def convert_to_value_list(mapping: ValueIterableMapping, source: Iterator) -> []: return list(convert_to_value_generator(mapping, source)) def convert_to_tuple(mapping: IterableMapping, source: Iterator) -> (): return tuple(convert_to_generator(mapping, source)) def convert_to_value_tuple(mapping: ValueIterableMapping, source: Iterator) -> []: return tuple(convert_to_value_generator(mapping, source)) def convert_to_generator(mapping: IterableMapping, source: Iterator) -> ValueGenerator: return (convert_to_element(element_mapping, source, element_type) for element_type, element_mapping in mapping) def convert_to_value_generator(mapping: ValueIterableMapping, source: Iterator) -> ValueGenerator: return (next(source) for i in range(mapping)) def convert_to_dict(mapping: DictMapping, source: Iterator) -> {}: return {key: convert_to_element(element_mapping, source, element_type) for key, element_type, element_mapping in mapping} def convert_to_object(mapping: ObjectMapping, source: Iterator) -> object: target = mapping[0]() for key, element_type, element_mapping in mapping[1]: setattr(target, key, convert_to_element(element_mapping, source, element_type)) return target convert_to_jump_table = { Type.Value: convert_to_value, Type.Tuple: convert_to_tuple, Type.ValueTuple: convert_to_value_tuple, Type.List: convert_to_list, Type.ValueList: convert_to_value_list, Type.Dict: convert_to_dict, Type.Object: convert_to_object, } def convert_to_element(mapping, source, element_type) -> any: """ Entry point for converting values into the source object's attributes using the given mapping :param mapping: map of the source's attributes to their types :param source: object from which to convert :param element_type: type of source :return: object of type element_type """ return convert_to_jump_table[element_type](mapping, source)
238
34.39
105
16
1,820
python
[]
0
true
2024-11-19T01:54:48.208282+00:00
1,608,588,137,000
233663103a8c8491a9e4a2ad7cc962dc963bf48f
3
{ "blob_id": "233663103a8c8491a9e4a2ad7cc962dc963bf48f", "branch_name": "refs/heads/master", "committer_date": 1608588137000, "content_id": "6ca74d0c8ddadd9814e8ed4b983e5dcf223f946a", "detected_licenses": [ "Apache-2.0" ], "directory_id": "18f59fdb3f780416bd525f1b9df01f36ada30dbb", "extension": "py", "filename": "viz_graph.py", "fork_events_count": 2, "gha_created_at": 1567607025000, "gha_event_created_at": 1684795276000, "gha_language": "Python", "gha_license_id": "Apache-2.0", "github_id": 206337751, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 587, "license": "Apache-2.0", "license_type": "permissive", "path": "/examples/viz_graph.py", "provenance": "stack-edu-0057.json.gz:284843", "repo_name": "SymJAX/SymJAX", "revision_date": 1608588137000, "revision_id": "d8778c2eb3254b478cef4f45d934bf921e695619", "snapshot_id": "83094fb91a696039ad499d973598cca32d391f49", "src_encoding": "UTF-8", "star_events_count": 52, "url": "https://raw.githubusercontent.com/SymJAX/SymJAX/d8778c2eb3254b478cef4f45d934bf921e695619/examples/viz_graph.py", "visit_date": "2023-05-26T02:45:14.791291" }
2.71875
stackv2
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Randall Balestriero" import symjax.tensor as T import matplotlib.pyplot as plt from symjax.viz import compute_graph x = T.random.randn((10,), name="x") y = T.random.randn((10,), name="y") z = T.random.randn((10,), name="z") w = T.Variable(T.ones(1), name="w") out = (x + y).sum() * w + z.sum() graph = compute_graph(out) graph.draw("file.png", prog="dot") import matplotlib.image as mpimg img = mpimg.imread("file.png") plt.figure(figsize=(15, 5)) imgplot = plt.imshow(img) plt.xticks() plt.yticks() plt.tight_layout()
28
19.96
36
10
174
python
[]
0
true
2024-11-19T01:54:49.189246+00:00
1,624,802,116,000
a19aabbe91a7fb4c57869518e563fcc9fa376ad3
3
{ "blob_id": "a19aabbe91a7fb4c57869518e563fcc9fa376ad3", "branch_name": "refs/heads/master", "committer_date": 1624802116000, "content_id": "9ba033c4eaa1d62322973ca162807777cc3bf8b7", "detected_licenses": [ "MIT", "Apache-2.0" ], "directory_id": "75cbfb15ae671ac6564186cdbbf5aad74a317c66", "extension": "py", "filename": "asset_attachment.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 733, "license": "MIT,Apache-2.0", "license_type": "permissive", "path": "/labelbox/schema/asset_attachment.py", "provenance": "stack-edu-0057.json.gz:284847", "repo_name": "Manjiri1101/labelbox-python", "revision_date": 1624802116000, "revision_id": "0a9e8fec7a76270011c65250963ae1031232f4ad", "snapshot_id": "46df82b30f010239aa2a963edd1bc11a6dc151da", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Manjiri1101/labelbox-python/0a9e8fec7a76270011c65250963ae1031232f4ad/labelbox/schema/asset_attachment.py", "visit_date": "2023-06-20T05:51:44.948604" }
2.625
stackv2
from enum import Enum from labelbox.orm.db_object import DbObject from labelbox.orm.model import Field class AssetAttachment(DbObject): """ Asset attachment provides extra context about an asset while labeling. Attributes: attachment_type (str): IMAGE, VIDEO, TEXT, or IMAGE_OVERLAY attachment_value (str): URL to an external file or a string of text """ class AttachmentType(Enum): VIDEO = "VIDEO" IMAGE = "IMAGE" TEXT = "TEXT" IMAGE_OVERLAY = "IMAGE_OVERLAY" for topic in AttachmentType: vars()[topic.name] = topic.value attachment_type = Field.String("attachment_type", "type") attachment_value = Field.String("attachment_value", "value")
25
28.32
78
11
158
python
[]
0
true
2024-11-19T01:54:49.425883+00:00
1,573,896,666,000
cecca567dc686ee3f24f95fab22d9d379bbaea55
3
{ "blob_id": "cecca567dc686ee3f24f95fab22d9d379bbaea55", "branch_name": "refs/heads/master", "committer_date": 1573896666000, "content_id": "53ac9fd6c1a33300b48501dbf7e3fe9e475c2bbf", "detected_licenses": [ "MIT" ], "directory_id": "174bb065ecb814cf4533cedfedeb16046b029de4", "extension": "py", "filename": "FootballModel.py", "fork_events_count": 0, "gha_created_at": 1573896090000, "gha_event_created_at": 1573896090000, "gha_language": null, "gha_license_id": "MIT", "github_id": 222075245, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 569, "license": "MIT", "license_type": "permissive", "path": "/app/model/FootballModel.py", "provenance": "stack-edu-0057.json.gz:284851", "repo_name": "Louis-Saglio/football-python-flask-app", "revision_date": 1573896666000, "revision_id": "fb07c7acfde9b81aa8d1d32f674432a233849070", "snapshot_id": "4e09b4ad353fe2a74141baa59c6184f605bcb0e9", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Louis-Saglio/football-python-flask-app/fb07c7acfde9b81aa8d1d32f674432a233849070/app/model/FootballModel.py", "visit_date": "2020-09-11T13:12:54.863814" }
3.1875
stackv2
import pickle import pandas as pd import numpy as np from scipy.stats import poisson class FootballModel: """ Model that predict a game result between 2 internationals football teams """ def __init__(self, path: str): self.model = self.load_model(path) @staticmethod def load_model(path: str): """ """ with open(path, 'rb') as file: model = pickle.load(file) return model def predict_avg_score(self, game): """ """ return self.model.predict(game).values[0]
27
20.11
49
14
128
python
[]
0
true
2024-11-19T01:54:49.719480+00:00
1,614,181,199,000
f86ccf95bfc05ff737449c5761bcce2b56701220
4
{ "blob_id": "f86ccf95bfc05ff737449c5761bcce2b56701220", "branch_name": "refs/heads/master", "committer_date": 1614181199000, "content_id": "f8cee38fc5522b6c4b4299451792d03cd5cef9bc", "detected_licenses": [ "MIT" ], "directory_id": "50008b3b7fb7e14f793e92f5b27bf302112a3cb4", "extension": "py", "filename": "recipe-576951.py", "fork_events_count": 0, "gha_created_at": 1614166275000, "gha_event_created_at": 1614181200000, "gha_language": "Python", "gha_license_id": "MIT", "github_id": 341878663, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1488, "license": "MIT", "license_type": "permissive", "path": "/recipes/Python/576951_Simple_if_naive_class_factory_recipe/recipe-576951.py", "provenance": "stack-edu-0057.json.gz:284854", "repo_name": "betty29/code-1", "revision_date": 1614181199000, "revision_id": "d097ca0ad6a6aee2180d32dce6a3322621f655fd", "snapshot_id": "db56807e19ac9cfe711b41d475a322c168cfdca6", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/betty29/code-1/d097ca0ad6a6aee2180d32dce6a3322621f655fd/recipes/Python/576951_Simple_if_naive_class_factory_recipe/recipe-576951.py", "visit_date": "2023-03-14T08:15:47.492844" }
4.09375
stackv2
# create blank class print "creating empty class object" print class A(object): pass # create hypothetical constructor print "defining class constructor" print "will set instance attribute \"a\"" print def init(cls, a): print "initializing the instance" print cls.__setattr__("a",a) # create new method print """\ defining method \"show\" that takes one argument, \ a class. It then prints class variable \"a\" and \ instance variable \"b\" \ """ print def show(cls): print "received class", cls, "as first argument" print "class attribute \"b\"", cls.b print "instnace attribute \"a\":", cls.a print # add attribute to class print "adding class attribute b=10" print A.b = 10 # add constructor to class print "adding class constructor" print "will set instance attribute \"a\"" print A.__init__ = init # add method to class print "adding \"show\" method to class" print A.show = show # create instance print "creating instance \"q\" and passing \"5\" to constructor" print q = A(5) # check class attribute print "checking class attribute \"b\"" print "should equal 10" print q.b print # check instance attribute print "checking instance attribute \"a\"" print "should equal 5" print q.a print # test instance method print "testing method \"show\"" print q.show() # change class attribute print "now chaning class attribute \"b\" to 30" print A.b = 30 # check reference to class attribute print "checking that the class attribute changed" print q.show()
87
16.1
64
8
382
python
[]
0
true
2024-11-19T01:54:49.910657+00:00
1,583,978,741,000
02262ebb47b577f6de1c9845338653e100136fb9
2
{ "blob_id": "02262ebb47b577f6de1c9845338653e100136fb9", "branch_name": "refs/heads/master", "committer_date": 1583978741000, "content_id": "ea43cead01cd86d2d73ecced4e4fc6719c556254", "detected_licenses": [ "MIT" ], "directory_id": "750065657aeb6d4d1f6a2445a5fe460e1769edcb", "extension": "py", "filename": "file.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 246685341, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2582, "license": "MIT", "license_type": "permissive", "path": "/pymon/check/file.py", "provenance": "stack-edu-0057.json.gz:284857", "repo_name": "crest42/PyMon", "revision_date": 1583978741000, "revision_id": "96494cc37f906e6a07388af29b04c559ec72f116", "snapshot_id": "62d760199e4a150dea4696ea1e8ad60712deb5cc", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/crest42/PyMon/96494cc37f906e6a07388af29b04c559ec72f116/pymon/check/file.py", "visit_date": "2021-03-13T13:30:08.566186" }
2.46875
stackv2
from .check import RemoteCheck from .exceptions import MissingExpectedValueError REPR = 'CheckFile' class CheckFile(RemoteCheck): MANDATORY = ['filename'] STAT_FLAGS = {'access_rights': r'%a', 'blocks_num': r'%b', 'byte_per_block': r'%B', 'dev_num': r'%d', 'type': r'%F', 'gid': r'%g', 'group': r'%G', 'link_refcount': r'%h', 'inode': r'%i', 'mount': r'%m', 'name': r'%n', 'size': r'%s', 'uid': r'%u', 'owner': r'%U', 'create_time': r'%W', 'access_time': r'%X', 'mod_time': r'%Y', } def __init__(self, check): self.filename = None self.seperator = ',' super().__init__(check, self.MANDATORY) def __repr__(self): return f"Check File filename: {self.filename}" def __parse_stat_output(self, output): return dict(item.split("=") for item in output.split(self.seperator)) if output is not None else None def execute(self, remote): check_result = super().execute(remote) if check_result.return_code == 0: if check_result.stdout is not None: try: check_result.add_result(self.__parse_stat_output(check_result.stdout)) check_result.set(0,check_result.result) if self.expect is not None: for k in self.expect: if k not in check_result.result: check_result.set(-1,f"Missing expected value in result: {MissingExpectedValueError(k)}") if check_result.result[k] != self.expect[k]: check_result.set(1, f'{k}: {check_result.result[k]} != {self.expect[k]}') except Exception as e: check_result.set(-1,f'stat command returned 0 but no output available: {e}') else: check_result.set(2,f'Error stat command returned {check_result.stderr}') return check_result def get_command(self): format_string = '-c' for k in CheckFile.STAT_FLAGS: format_string += f'{k}={CheckFile.STAT_FLAGS[k]}{self.seperator}' return f'stat {self.filename} {format_string[:-1]}'
64
39.34
120
25
551
python
[]
0
true
2024-11-19T01:54:50.032500+00:00
1,540,848,435,000
8c2e5383f7676b97a33abd2f4db46db0cb9554c0
2
{ "blob_id": "8c2e5383f7676b97a33abd2f4db46db0cb9554c0", "branch_name": "refs/heads/master", "committer_date": 1540848435000, "content_id": "943ba91613bc6fd3fb6f6fdfea1e25266d584a55", "detected_licenses": [ "MIT" ], "directory_id": "ae5e669a085cda1fa6cd9378d754c88202975e3a", "extension": "py", "filename": "coreclient.py", "fork_events_count": 1, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 69143441, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 3029, "license": "MIT", "license_type": "permissive", "path": "/discorrecd/coreclient.py", "provenance": "stack-edu-0057.json.gz:284859", "repo_name": "appul/Discorrecd", "revision_date": 1540848435000, "revision_id": "4c181d0ca8e94b2e781518e427e54fa9d77beaf9", "snapshot_id": "31541b08c3862172ee34ef286cd5dc10f893c74e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/appul/Discorrecd/4c181d0ca8e94b2e781518e427e54fa9d77beaf9/discorrecd/coreclient.py", "visit_date": "2020-05-29T08:47:15.567279" }
2.4375
stackv2
import logging import discord from discorrecd.events import EventManager log = logging.getLogger(__name__) _EVENT_METHODS = [ ('on_ready', 'ready'), ('on_resumed', 'resumed'), ('on_message', 'message'), ('on_message_delete', 'message_delete'), ('on_message_edit', 'message_edit'), ('on_typing', 'typing'), ('on_channel_create', 'channel_create'), ('on_channel_delete', 'channel_delete'), ('on_channel_update', 'channel_update'), ('on_member_create', 'member_create'), ('on_member_delete', 'member_delete'), ('on_member_update', 'member_update'), ('on_member_ban', 'member_ban'), ('on_member_unban', 'member_unban'), ('on_group_join', 'group_join'), ('on_group_remove', 'group_remove'), ('on_server_join', 'server_join'), ('on_server_remove', 'server_remove'), ('on_server_update', 'server_update'), ('on_server_available', 'server_available'), ('on_server_unavailable', 'server_unavailable'), ('on_server_role_create', 'server_role_create'), ('on_server_role_delete', 'server_role_delete'), ('on_server_role_update', 'server_role_update'), ('on_server_emojis_update', 'server_emojis_update'), ('on_voice_state_update', 'voice_state_update'), ('on_socket_raw_receive', 'socket_raw_receive'), ('on_socket_raw_send', 'socket_raw_send') ] class CoreClient(discord.Client): """A wrapper client for the Discorrecd Core""" def __init__(self, event_manager: EventManager, **options): """ :param event_manager: The event manager to events should be registered :param options: The options which will passed onto the parent (:class:`discord.Client`) constructor """ super().__init__(**options) self._event_manager = event_manager # type: EventManager self._hook_events() def _hook_events(self): """Populate the event manager by hooking the :class:`discord.Client` event methods.""" self._hook_error_method() for method_name, event in _EVENT_METHODS: self._hook_method(method_name, event) def _hook_method(self, method_name: str, event: str): """Hook a :class:`discord.Client` event method. :param method_name: The name of the method to be hooked :param event: The name of the event """ async def method(*args, **kwargs): await self._event_manager.emit(event, *args, **kwargs) method.__name__ = method_name if event not in self._event_manager: self._event_manager.add(event) self.event(method) def _hook_error_method(self): """Hook the `on_error` method""" async def on_error(*args, **kwargs): log.error(*args, **kwargs) await self._event_manager.emit('client_error', *args, **kwargs) await super().on_error(*args, **kwargs) if 'client_error' not in self._event_manager: self._event_manager.add('client_error') self.event(on_error)
85
34.64
107
14
700
python
[]
0
true
2024-11-19T01:54:50.102401+00:00
1,563,498,010,000
3721d7aab5e1c4609f4a59c0bdb3e2dc09b6ce85
3
{ "blob_id": "3721d7aab5e1c4609f4a59c0bdb3e2dc09b6ce85", "branch_name": "refs/heads/master", "committer_date": 1563498010000, "content_id": "d4aefc57becb47d5a1c14d64de48f503c7490b3c", "detected_licenses": [ "MIT" ], "directory_id": "b1caa1bcbf436372876894f09b0e180c9b7a6bd0", "extension": "py", "filename": "storage.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 183778203, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 418, "license": "MIT", "license_type": "permissive", "path": "/ytcc/storage.py", "provenance": "stack-edu-0057.json.gz:284860", "repo_name": "alexkohler/ytgrep", "revision_date": 1563498010000, "revision_id": "d23c23b0f9a2ab300a1df22c91e08e771831d235", "snapshot_id": "c3974409b9f5b4eb6dea20ecccbff5fa2e8678fd", "src_encoding": "UTF-8", "star_events_count": 31, "url": "https://raw.githubusercontent.com/alexkohler/ytgrep/d23c23b0f9a2ab300a1df22c91e08e771831d235/ytcc/storage.py", "visit_date": "2020-05-17T14:55:58.287383" }
2.78125
stackv2
# -*- coding: UTF-8 -*- import re import os import hashlib class Storage(): def __init__(self, video_url: str) -> None: self.video_url = video_url def get_file_path(self) -> str: return 'subtitle_{0}.en.vtt'.format(re.sub( r'[^\w-]', '', hashlib.md5(str(self.video_url).encode('utf-8')).hexdigest())) def remove_file(self) -> None: os.remove(self.get_file_path())
18
22.22
89
20
109
python
[]
0
true
2024-11-19T01:54:50.215430+00:00
1,628,267,542,000
86895078069d1a1ba256620df6b6a6e6e245ea16
2
{ "blob_id": "86895078069d1a1ba256620df6b6a6e6e245ea16", "branch_name": "refs/heads/main", "committer_date": 1628267542000, "content_id": "0043841796c262fba0e966b788ff4fa33977e474", "detected_licenses": [ "MIT" ], "directory_id": "77892a5ab82e2c5285b5562fb1dee1015132101d", "extension": "py", "filename": "제리.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 378318612, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 4689, "license": "MIT", "license_type": "permissive", "path": "/cogs/제리.py", "provenance": "stack-edu-0057.json.gz:284862", "repo_name": "dhfhfk/unused-discord-bot", "revision_date": 1628267542000, "revision_id": "17bdd13b3da17ddd3445c559c00988ca311dfa73", "snapshot_id": "7d1589037d7670851ee7a40ac2285ffd85d3a977", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/dhfhfk/unused-discord-bot/17bdd13b3da17ddd3445c559c00988ca311dfa73/cogs/제리.py", "visit_date": "2023-07-01T16:16:01.802364" }
2.328125
stackv2
from discord_slash.utils.manage_commands import create_option, create_choice import discord from discord.ext.commands import Bot from discord.ext import commands from discord_slash import cog_ext, SlashContext, SlashCommand from discord import DMChannel import re import asyncio import os guild_ids = [int(os.environ['guild_id'])] embed_color = 0x4ac8c7 class 제리(commands.Cog): def __init__(self, client): self.client = client @cog_ext.cog_slash(name="제리", description="📁 제리 디시콘", guild_ids=guild_ids, options=[ create_option( name="내용", description="무슨 내용인가요?", option_type=3, required=True, choices=[ create_choice( name="메롱", value="제리메롱" ), create_choice( name="처먹", value="제리처먹" ), create_choice( name="띠용", value="제리띠용" ), create_choice( name="화들짝", value="제리화들짝" ), create_choice( name="경악", value="제리경악" ), create_choice( name="쯧쯧", value="제리쯧쯧" ), create_choice( name="끄덕", value="제리끄덕" ), create_choice( name="인사", value="제리인사" ), create_choice( name="폭소", value="제리폭소" ) ] ) ]) async def _제리(self, ctx, 내용: str): if 내용 == "제리메롱": embed=discord.Embed(description="제리메롱", color=embed_color) embed.set_image(url="https://i.ibb.co/2ymkqL0/wpflapfhd.gif") await ctx.send(embed=embed) elif 내용 == "제리처먹": embed=discord.Embed(description="제리처먹", color=embed_color) embed.set_image(url="https://i.ibb.co/wsD8mfj/wpflcjajr.gif") await ctx.send(embed=embed) elif 내용 == "제리띠용": embed=discord.Embed(description="제리띠용", color=embed_color) embed.set_image(url="https://i.ibb.co/whdv6J4/wpflEldyd.gif") await ctx.send(embed=embed) elif 내용 == "제리화들짝": embed=discord.Embed(description="제리화들짝", color=embed_color) embed.set_image(url="https://i.ibb.co/qDn4516/wpflghkemfWkr.gif") await ctx.send(embed=embed) elif 내용 == "제리경악": embed=discord.Embed(description="제리경악", color=embed_color) embed.set_image(url="https://i.ibb.co/ngM8DtF/wpflruddkr.gif") await ctx.send(embed=embed) elif 내용 == "제리쯧쯧": embed=discord.Embed(description="제리쯧쯧", color=embed_color) embed.set_image(url="https://i.ibb.co/1rNnyPY/wpflWmtWmt.gif") await ctx.send(embed=embed) elif 내용 == "제리끄덕": embed=discord.Embed(description="제리끄덕", color=embed_color) embed.set_image(url="https://i.ibb.co/dL00Xk6/wpfl-Rmejr.gif") await ctx.send(embed=embed) elif 내용 == "제리인사": embed=discord.Embed(description="제리인사", color=embed_color) embed.set_image(url="https://i.ibb.co/Gs7sNxZ/wpfldlstk2.gif") await ctx.send(embed=embed) elif 내용 == "제리폭소": embed=discord.Embed(description="제리폭소", color=embed_color) embed.set_image(url="https://i.ibb.co/JKxvDfN/wpflvhrth.gif") await ctx.send(embed=embed) def setup(client): client.add_cog(제리(client))
106
39.97
77
18
939
python
[]
0
true
2024-11-19T01:54:50.668504+00:00
1,691,336,559,000
e70df4243dbed2d7da0947d1a01fa8b46aa02434
3
{ "blob_id": "e70df4243dbed2d7da0947d1a01fa8b46aa02434", "branch_name": "refs/heads/master", "committer_date": 1691336559000, "content_id": "47db7e2dadb9af9771b23021ab1ba3d21301e15e", "detected_licenses": [ "MIT" ], "directory_id": "ff6fd44d205ff9ee6e54b660f454d90f240ecf1b", "extension": "py", "filename": "lambda_async_resp_process.py", "fork_events_count": 283, "gha_created_at": 1530113776000, "gha_event_created_at": 1691336560000, "gha_language": "Python", "gha_license_id": "MIT", "github_id": 138901184, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1829, "license": "MIT", "license_type": "permissive", "path": "/textract/async-detect-doc-text/lambda_async_resp_process.py", "provenance": "stack-edu-0057.json.gz:284866", "repo_name": "srcecde/aws-tutorial-code", "revision_date": 1691336559000, "revision_id": "f8536903904b3f55819f26ed0b63cbf80a8b3573", "snapshot_id": "c20abf9c19212a6b4a57f62270a5798896517c2a", "src_encoding": "UTF-8", "star_events_count": 195, "url": "https://raw.githubusercontent.com/srcecde/aws-tutorial-code/f8536903904b3f55819f26ed0b63cbf80a8b3573/textract/async-detect-doc-text/lambda_async_resp_process.py", "visit_date": "2023-08-20T03:42:48.606441" }
2.75
stackv2
""" -*- coding: utf-8 -*- ======================== AWS Lambda ======================== Contributor: Chirag Rathod (Srce Cde) ======================== """ import os import json import boto3 import pandas as pd def lambda_handler(event, context): BUCKET_NAME = os.environ["BUCKET_NAME"] PREFIX = os.environ["PREFIX"] job_id = json.loads(event["Records"][0]["Sns"]["Message"])["JobId"] page_lines = process_response(job_id) csv_key_name = f"{job_id}.csv" df = pd.DataFrame(page_lines.items()) df.columns = ["PageNo", "Text"] df.to_csv(f"/tmp/{csv_key_name}", index=False) upload_to_s3(f"/tmp/{csv_key_name}", BUCKET_NAME, f"{PREFIX}/{csv_key_name}") print(df) return {"statusCode": 200, "body": json.dumps("File uploaded successfully!")} def upload_to_s3(filename, bucket, key): s3 = boto3.client("s3") s3.upload_file(Filename=filename, Bucket=bucket, Key=key) def process_response(job_id): textract = boto3.client("textract") response = {} pages = [] response = textract.get_document_text_detection(JobId=job_id) pages.append(response) nextToken = None if "NextToken" in response: nextToken = response["NextToken"] while nextToken: response = textract.get_document_text_detection( JobId=job_id, NextToken=nextToken ) pages.append(response) nextToken = None if "NextToken" in response: nextToken = response["NextToken"] page_lines = {} for page in pages: for item in page["Blocks"]: if item["BlockType"] == "LINE": if item["Page"] in page_lines.keys(): page_lines[item["Page"]].append(item["Text"]) else: page_lines[item["Page"]] = [] return page_lines
72
24.4
81
18
439
python
[]
0
true
2024-11-19T01:54:50.752644+00:00
1,321,892,102,000
44583d0404757d68c24727379cf73cafccfb75c8
3
{ "blob_id": "44583d0404757d68c24727379cf73cafccfb75c8", "branch_name": "refs/heads/master", "committer_date": 1321892102000, "content_id": "a609766528ef658efcac053a15f975fb1d152821", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "ea004ba957ca1d44345a66aa13dd43aa99459e1e", "extension": "py", "filename": "collector.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 1721524, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 4880, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/src/mootiro_form/models/collector.py", "provenance": "stack-edu-0057.json.gz:284867", "repo_name": "it3s/mootiro_form", "revision_date": 1321892102000, "revision_id": "59d06a25d629d8acca38deb3a35f6543322b1b83", "snapshot_id": "529475df08e594dd7f4b6fb596474af24d174798", "src_encoding": "UTF-8", "star_events_count": 8, "url": "https://raw.githubusercontent.com/it3s/mootiro_form/59d06a25d629d8acca38deb3a35f6543322b1b83/src/mootiro_form/models/collector.py", "visit_date": "2021-01-10T19:27:31.696666" }
2.53125
stackv2
# -*- coding: utf-8 -*- from __future__ import unicode_literals # unicode by default from datetime import datetime from sqlalchemy import Column, UnicodeText, Boolean, Integer, ForeignKey, \ DateTime, Unicode from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.hybrid import hybrid_property from mootiro_form import _ from mootiro_form.models import Base, id_column, sas from mootiro_form.models.form import Form from mootiro_form.utils.text import random_word class Collector(Base): '''Represents a collector to collect form entries.''' __tablename__ = "collector" id = id_column(__tablename__) # Inheritance configuration typ = Column('type', UnicodeText(50)) __mapper_args__ = {'polymorphic_on': typ} name = Column(UnicodeText(255), nullable=False) # When an entry is received, we can either display a thanks message, # or redirect to some URL. 3 columns are needed for this: thanks_message = Column(UnicodeText) thanks_url = Column(UnicodeText(2000)) # We define on_completion as a property to validate its possible values: ON_COMPLETION_VALUES = ('msg', 'url') _on_completion = Column('on_completion', Unicode(3)) @hybrid_property def on_completion(self): return self._on_completion @on_completion.setter def on_completion(self, val): if val not in self.ON_COMPLETION_VALUES: raise ValueError \ ('Invalid value for on_completion: "{0}"'.format(val)) self._on_completion = val email_each_entry = Column(Boolean, default=False) limit_by_date = Column(Boolean, default=False) start_date = Column(DateTime) end_date = Column(DateTime) message_after_end = Column(UnicodeText) message_before_start = Column(UnicodeText) # When an instance is persisted, it automatically gets a slug, slug = Column(UnicodeText(10), nullable=False, # a part of the URL. index=True, default=lambda: random_word(10)) form_id = Column(Integer, ForeignKey('form.id'), index=True) form = relationship(Form, backref=backref('collectors', order_by=id, cascade='all')) def __unicode__(self): return self.name def __repr__(self): return 'Collector(id={0}, name="{1}")'.format(self.id, self.name) def to_dict(self, translator=None): d = {k: getattr(self, k) for k in ('id', 'name', 'thanks_message', 'thanks_url', 'on_completion', 'message_before_start', 'message_after_end', 'email_each_entry', 'limit_by_date', 'slug', 'status')} d['start_date'] = unicode(self.start_date)[:16] \ if self.start_date else '' d['end_date'] = unicode(self.end_date)[:16] if self.end_date else '' d['type'] = self.typ d['display_type'] = self.typ.replace("_", " ").capitalize() d['translated_status'] = \ translator(d['status']) if translator else d['status'] return d STATUS_BEFORE = _('pending') # before start date STATUS_DURING = _('published') # entries may be created STATUS_AFTER = _('closed') # after end date @property def status(self): '''Returns a status code.''' if (self.start_date and datetime.utcnow() < self.start_date and self.limit_by_date): return self.STATUS_BEFORE if (self.end_date and datetime.utcnow() > self.end_date and self.limit_by_date): return self.STATUS_AFTER return self.STATUS_DURING class PublicLinkCollector(Collector): '''A collector that provides a slug based public link for collecting entries. We expect to add columns here in the future. ''' __tablename__ = 'public_link_collector' __mapper_args__ = {'polymorphic_identity': 'public_link'} id = Column(Integer, ForeignKey('collector.id'), primary_key=True) class WebsiteCodeCollector(Collector): '''A collector that provides slug based html codes for collecting entries inside external websites. We expect to add columns here in the future, also. ''' __tablename__ = 'website_code_collector' __mapper_args__ = {'polymorphic_identity': 'website_code'} id = Column(Integer, ForeignKey('collector.id'), primary_key=True) invitation_message = Column(UnicodeText) invitation_popup_width = Column(Integer) invitation_popup_height = Column(Integer) embed_frame_height = Column(Integer) def to_dict(self, translator=None): d = super(WebsiteCodeCollector, self).to_dict(translator=translator) d['invitation_message'] = self.invitation_message d['invitation_popup_width'] = self.invitation_popup_width d['invitation_popup_height'] = self.invitation_popup_height d['embed_frame_height'] = self.embed_frame_height return d
127
37.43
77
15
1,100
python
[]
0
true
2024-11-19T01:54:50.857276+00:00
1,530,754,184,000
d6c5ee0527e04127a0f8fca3c349493295a3dddb
3
{ "blob_id": "d6c5ee0527e04127a0f8fca3c349493295a3dddb", "branch_name": "refs/heads/master", "committer_date": 1530754184000, "content_id": "6f27e4ca52b27c15c6e1588f53a8264a2dea1256", "detected_licenses": [ "MIT" ], "directory_id": "939885781d727a0ec6a2839faeb7277ac925a42c", "extension": "py", "filename": "embedding.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1750, "license": "MIT", "license_type": "permissive", "path": "/01_preprocessing/embedding.py", "provenance": "stack-edu-0057.json.gz:284869", "repo_name": "delwende/multiLSTM", "revision_date": 1530754184000, "revision_id": "659eab6dcb506cf331c94d124fe9654bf57d13a3", "snapshot_id": "a921c8f57c649ad6262bc89ce6a9aaaad5dff0ab", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/delwende/multiLSTM/659eab6dcb506cf331c94d124fe9654bf57d13a3/01_preprocessing/embedding.py", "visit_date": "2020-03-23T10:16:40.381107" }
2.671875
stackv2
import codecs import json import numpy as np from gensim.models import Word2Vec from keras.layers import Embedding # tokenizing function def tokenize(sentence): result = sentence.replace('\n', '').split(' ') return(result) # create embeddings with gensim def create_embeddings(file_name, embeddings_path='temp_embeddings/embeddings.gensimmodel', vocab_path='temp_embeddings/mapping.json', **params): class SentenceGenerator(object): def __init__(self, filename): self.filename = filename def __iter__(self): for line in codecs.open(self.filename, 'rU', encoding='utf-8'): yield tokenize(line) sentences = SentenceGenerator(file_name) model = Word2Vec(sentences, **params) model.save(embeddings_path) # weights = model.syn0 # np.save(open(embeddings_path, 'wb'), weights) # http://stackoverflow.com/questions/35596031/gensim-word2vec-find-number-of-words-in-vocabulary vocab = dict([(k, v.index) for k, v in model.wv.vocab.items()]) with open(vocab_path, 'w') as f: f.write(json.dumps(vocab)) return vocab, model # load vocabulary index from json file def load_vocab(vocab_path='temp_embeddings/mapping.json'): with open(vocab_path, 'r') as f: data = json.loads(f.read()) word2idx = data idx2word = dict([(v, k) for k, v in data.items()]) return word2idx, idx2word # embedding layer function def word2vec_embedding_layer(embeddings_path='temp_embeddings/embeddings.npz'): weights = np.load(open(embeddings_path, 'rb')) layer = Embedding(input_dim=weights.shape[0], output_dim=weights.shape[1], weights=[weights]) return layer
54
31.43
100
14
413
python
[]
0
true
2024-11-19T01:54:50.910383+00:00
1,544,324,372,000
b6a64f02808665cd79e0e38cec4182ae31b1aeb6
4
{ "blob_id": "b6a64f02808665cd79e0e38cec4182ae31b1aeb6", "branch_name": "refs/heads/master", "committer_date": 1544324372000, "content_id": "526f622485245e4248f25290fa3545036c7c97bd", "detected_licenses": [ "Unlicense" ], "directory_id": "db46eece6bdc7c72eb648fd84d3e0c879883ecb6", "extension": "py", "filename": "0009.py", "fork_events_count": 0, "gha_created_at": 1509246184000, "gha_event_created_at": 1541893636000, "gha_language": "Python", "gha_license_id": "Unlicense", "github_id": 108700779, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1377, "license": "Unlicense", "license_type": "permissive", "path": "/Solutions/0009.py", "provenance": "stack-edu-0057.json.gz:284870", "repo_name": "zejacobi/ProjectEuler", "revision_date": 1544324372000, "revision_id": "3e5731597784ee9433e9f2249b7ea92dc93527ee", "snapshot_id": "3ac7e10ca6f578f35b30f596a02b090fc65f4e0f", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/zejacobi/ProjectEuler/3e5731597784ee9433e9f2249b7ea92dc93527ee/Solutions/0009.py", "visit_date": "2018-12-19T22:33:35.064970" }
4
stackv2
""" # PROBLEM 9 A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ from math import ceil # Okay, so obviously a, b, and c must be constrained to be below 997. # And a and b both need to be below 332 and 499 respectively. Which implies the lowest # possible value for c is 334. But there has to be an upper bound to c as well that is actually # lower than 997. Because 1 ^ 2 + 2 ^ 2 != 997 ^ 2. # There's the ~ n ^ 2 complexity solution, which requires us to iterate a and b between # The bounds we've established. Is there are smart way to work from both ends and iteratively # Squeeze the values towards a solution, maybe in linear time? # I can't think of what this might be, so I may as well just settle for a mildly smart # brute-ish force solution for a in range(1, 333): for b in range(a + 1, int(500 - ceil(a/2) + 1)): c = 1000 - b - a # Note that when a is even, we need to remove the case where b == c if c > b and (a ** 2 + b ** 2) == c ** 2: print(a, b, c, a * b * c) exit(0) # we've been assured there's only one possible number, so exit with no error here exit(1) # something obviously has gone wrong.
37
36.22
95
14
437
python
[]
0
true
2024-11-19T01:54:50.967513+00:00
1,430,214,365,000
a95617a9165a5ac94f00b63b5dfc1a30b3eb0a70
3
{ "blob_id": "a95617a9165a5ac94f00b63b5dfc1a30b3eb0a70", "branch_name": "refs/heads/master", "committer_date": 1430214365000, "content_id": "9cb8ac12e6736046d0db84cb096952383d8d0a98", "detected_licenses": [ "MIT" ], "directory_id": "16fd1d27db50e1dcbcdd2ece09eb426aa7f38030", "extension": "py", "filename": "simple.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 781, "license": "MIT", "license_type": "permissive", "path": "/semaeval/engine/simple/simple.py", "provenance": "stack-edu-0057.json.gz:284871", "repo_name": "asmaier/semaeval", "revision_date": 1430214365000, "revision_id": "d57814e9f0719ea4a3ae13db1ef7c84d37b6ef4e", "snapshot_id": "9df2d04cffbe3ed68af3bd8c57d8408ca850bce3", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/asmaier/semaeval/d57814e9f0719ea4a3ae13db1ef7c84d37b6ef4e/semaeval/engine/simple/simple.py", "visit_date": "2021-05-28T18:42:02.791051" }
2.59375
stackv2
# -*- coding: utf-8 -*- import nltk from ... import config if "simple" in config.engines: labels = config.engines["simple"]["labels"] def convert_label(label): if label in labels: return labels[label] else: print "simple:",label return label # see http://timmcnamara.co.nz/post/2650550090/extracting-names-with-6-lines-of-python-code def extract_entities(text, lang): entities={} for sent in nltk.sent_tokenize(text): for chunk in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sent))): # see http://stackoverflow.com/questions/26352041/nltk-entity-extraction-difference-from-nltk-2-0-4-to-nltk-3-0 if hasattr(chunk, "label"): key=' '.join(c[0] for c in chunk.leaves()) value=convert_label(chunk.label()) entities[key]=value return entities
28
26.93
114
17
218
python
[]
0
true
2024-11-19T01:54:51.083782+00:00
1,623,746,468,000
b2ea62a67517d480d144f947682cbc45f91a54fd
3
{ "blob_id": "b2ea62a67517d480d144f947682cbc45f91a54fd", "branch_name": "refs/heads/master", "committer_date": 1623746468000, "content_id": "9d5808ee3b2d77bdbd26d5d303a3e111fb50189a", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "ee0b9cd2424e634a212a6d9734af1eaedd40dfe0", "extension": "py", "filename": "fitting_widgets.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 7529, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/jhub37_mantid_baseline/sasview-5.0.3/src/sas/sasgui/perspectives/fitting/fitting_widgets.py", "provenance": "stack-edu-0057.json.gz:284872", "repo_name": "moving-northwards/Docker", "revision_date": 1623746468000, "revision_id": "8ef18fd8c6abb0608ce9b53187e53d00d3e4e9ae", "snapshot_id": "775755b4618c1a7946f540505b0178e119d294d1", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/moving-northwards/Docker/8ef18fd8c6abb0608ce9b53187e53d00d3e4e9ae/jhub37_mantid_baseline/sasview-5.0.3/src/sas/sasgui/perspectives/fitting/fitting_widgets.py", "visit_date": "2023-05-26T08:42:58.634525" }
2.515625
stackv2
################################################################################ #This software was developed by the University of Tennessee as part of the #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) #project funded by the US National Science Foundation. # #See the license text in license.txt # #copyright 2009, University of Tennessee ################################################################################ import wx from wx.lib.scrolledpanel import ScrolledPanel MAX_NBR_DATA = 4 WIDTH = 430 HEIGHT = 350 class DialogPanel(ScrolledPanel): def __init__(self, *args, **kwds): ScrolledPanel.__init__(self, *args, **kwds) self.SetupScrolling() class BatchDataDialog(wx.Dialog): """ The current design of Batch fit allows only of type of data in the data set. This allows the user to make a quick selection of the type of data to use in fit tab. """ def __init__(self, parent=None, *args, **kwds): wx.Dialog.__init__(self, parent, *args, **kwds) self.SetSize((WIDTH, HEIGHT)) self.data_1d_selected = None self.data_2d_selected = None self._do_layout() def _do_layout(self): """ Draw the content of the current dialog window """ vbox = wx.BoxSizer(wx.VERTICAL) box_description = wx.StaticBox(self, wx.ID_ANY, str("Hint")) hint_sizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) selection_sizer = wx.GridBagSizer(5, 5) button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.data_1d_selected = wx.RadioButton(self, wx.ID_ANY, 'Data1D', style=wx.RB_GROUP) self.data_2d_selected = wx.RadioButton(self, wx.ID_ANY, 'Data2D') self.data_1d_selected.SetValue(True) self.data_2d_selected.SetValue(False) button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") button_OK = wx.Button(self, wx.ID_OK, "Ok") button_OK.SetFocus() hint = "Selected Data set contains both 1D and 2D Data.\n" hint += "Please select on type of analysis before proceeding.\n" hint_sizer.Add(wx.StaticText(self, wx.ID_ANY, hint)) #draw area containing radio buttons ix = 0 iy = 0 selection_sizer.Add(self.data_1d_selected, (iy, ix), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) iy += 1 selection_sizer.Add(self.data_2d_selected, (iy, ix), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) #contruction the sizer contaning button button_sizer.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) button_sizer.Add(button_cancel, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) button_sizer.Add(button_OK, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) vbox.Add(hint_sizer, 0, wx.EXPAND | wx.ALL, 10) vbox.Add(selection_sizer, 0, wx.TOP | wx.BOTTOM, 10) vbox.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.EXPAND, 0) vbox.Add(button_sizer, 0, wx.TOP | wx.BOTTOM, 10) self.SetSizer(vbox) self.Layout() def get_data(self): """ return 1 if user requested Data1D , 2 if user requested Data2D """ if self.data_1d_selected.GetValue(): return 1 else: return 2 class DataDialog(wx.Dialog): """ Allow file selection at loading time """ def __init__(self, data_list, parent=None, text='', nb_data=MAX_NBR_DATA, *args, **kwds): wx.Dialog.__init__(self, parent, *args, **kwds) self.SetTitle("Data Selection") self._max_data = nb_data self._nb_selected_data = nb_data self.SetSize((WIDTH, HEIGHT)) self.list_of_ctrl = [] if not data_list: return select_data_text = " %s Data selected.\n" % str(self._nb_selected_data) self._data_text_ctrl = wx.StaticText(self, wx.ID_ANY, str(select_data_text)) self._data_text_ctrl.SetForegroundColour('blue') self._sizer_main = wx.BoxSizer(wx.VERTICAL) self._sizer_txt = wx.BoxSizer(wx.VERTICAL) self._sizer_button = wx.BoxSizer(wx.HORIZONTAL) self._choice_sizer = wx.GridBagSizer(5, 5) self._panel = DialogPanel(self, style=wx.RAISED_BORDER, size=(WIDTH - 20, HEIGHT / 3)) self.__do_layout(data_list, text=text) def __do_layout(self, data_list, text=''): """ layout the dialog """ if not data_list or len(data_list) <= 1: return #add text if text.strip() == "": text = "Fitting: We recommend that you selected" text += " no more than '%s' data\n" % str(self._max_data) text += "for adequate plot display size. \n" text += "unchecked data won't be send to fitting . \n" text_ctrl = wx.StaticText(self, wx.ID_ANY, str(text)) self._sizer_txt.Add(text_ctrl) iy = 0 ix = 0 data_count = 0 for i in range(len(data_list)): data_count += 1 cb = wx.CheckBox(self._panel, wx.ID_ANY, str(data_list[i].name), (10, 10)) wx.EVT_CHECKBOX(self, cb.GetId(), self._count_selected_data) if data_count <= MAX_NBR_DATA: cb.SetValue(True) else: cb.SetValue(False) self.list_of_ctrl.append((cb, data_list[i])) self._choice_sizer.Add(cb, (iy, ix), (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) iy += 1 self._panel.SetSizer(self._choice_sizer) #add sizer self._sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") self._sizer_button.Add(button_cancel, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) button_OK = wx.Button(self, wx.ID_OK, "Ok") button_OK.SetFocus() self._sizer_button.Add(button_OK, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) static_line = wx.StaticLine(self, wx.ID_ANY) self._sizer_txt.Add(self._panel, 0, wx.EXPAND | wx.ALL, 10) self._sizer_main.Add(self._sizer_txt, 0, wx.EXPAND | wx.ALL, 10) self._sizer_main.Add(self._data_text_ctrl, 0, wx.EXPAND | wx.ALL, 10) self._sizer_main.Add(static_line, 0, wx.EXPAND, 0) self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND | wx.ALL, 10) self.SetSizer(self._sizer_main) self.Layout() def get_data(self): """ return the selected data """ temp = [] for item in self.list_of_ctrl: cb, data = item if cb.GetValue(): temp.append(data) return temp def _count_selected_data(self, event): """ count selected data """ if event.GetEventObject().GetValue(): self._nb_selected_data += 1 else: self._nb_selected_data -= 1 select_data_text = " %s Data selected.\n" % str(self._nb_selected_data) self._data_text_ctrl.SetLabel(select_data_text) if self._nb_selected_data <= self._max_data: self._data_text_ctrl.SetForegroundColour('blue') else: self._data_text_ctrl.SetForegroundColour('red')
188
39.05
86
16
1,916
python
[]
0
true
2024-11-19T01:54:51.625559+00:00
1,508,937,942,000
c201d744e3816e90aa560fd224356d49f8bf8023
2
{ "blob_id": "c201d744e3816e90aa560fd224356d49f8bf8023", "branch_name": "refs/heads/master", "committer_date": 1508937942000, "content_id": "312ce35825b2deb828293910b1de5cac4670a95e", "detected_licenses": [ "MIT" ], "directory_id": "6bc9b01dd7afc1c0f0bf6228910d206b7f0d8720", "extension": "py", "filename": "utils.py", "fork_events_count": 1, "gha_created_at": 1481805054000, "gha_event_created_at": 1483693345000, "gha_language": "Python", "gha_license_id": null, "github_id": 76557981, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2370, "license": "MIT", "license_type": "permissive", "path": "/scarface/utils.py", "provenance": "stack-edu-0057.json.gz:284876", "repo_name": "founders4schools/django-scarface", "revision_date": 1508937942000, "revision_id": "7dea54065664d9673f4554a1f439e3c7186090a4", "snapshot_id": "de148e3e8749dfcb7365de0fb166a0e6fa7ae214", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/founders4schools/django-scarface/7dea54065664d9673f4554a1f439e3c7186090a4/scarface/utils.py", "visit_date": "2021-01-11T12:07:03.255969" }
2.390625
stackv2
# -*- coding: utf-8 -*- import inspect from functools import partial import boto3 from django.conf import settings __author__ = 'dreipol GmbH' class Decorator(object): def __init__(self, function, *args, **kwargs): self.function = function @property def original_function(self): function = self.function while isinstance(function, Decorator): function = function.function return function class DefaultConnection(Decorator): def __get__(self, obj, objtype=None): if obj is None: return self.function return partial(self, obj) def __call__(self, *args, **kwargs): connection_keyword = 'connection' if len(args) + len(kwargs) == 0: call_kwargs = dict() else: call_kwargs = inspect.getcallargs( self.original_function, *args, **kwargs ) if not call_kwargs.get(connection_keyword, None): call_kwargs[connection_keyword] = get_sns_connection() return self.function(**call_kwargs) class PushLogger(Decorator): def __get__(self, obj, objtype=None): if obj is None: return self.function self.obj = obj return partial(self, obj) def __call__(self, *args, **kwargs): call_kwargs = inspect.getcallargs(self.original_function, *args, **kwargs) push_message = call_kwargs.get('push_message') self.obj.sign(push_message) if logging_enabled(): push_message.save() return self.function(*args, **kwargs) def get_sns_connection(): """ Creates a new AWS connection based upon the credentials defined in the django configuration :param region: the region of the DynamoDB, defaults to Ireland :return: a new dynamodb2 connection """ region = settings.SCARFACE_REGION_NAME if hasattr(settings, "SCARFACE_REGION_NAME") else 'eu-west-1' return boto3.client('sns', region, aws_access_key_id=settings.AWS_ACCESS_KEY, aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY ) def logging_enabled(): return settings.SCARFACE_LOGGING_ENABLED if hasattr( settings, 'SCARFACE_LOGGING_ENABLED' ) else True
81
28.26
104
14
491
python
[]
0
true
2024-11-19T01:54:52.540790+00:00
1,620,772,291,000
8d6fd962bec5fe715518ec83e07c0ac80c4f890f
3
{ "blob_id": "8d6fd962bec5fe715518ec83e07c0ac80c4f890f", "branch_name": "refs/heads/master", "committer_date": 1620772291000, "content_id": "4bde9100c8478180617b3ac586610b363a97cb5f", "detected_licenses": [ "MIT" ], "directory_id": "8c87bc3dca66de62c2e6aa8c9f5221d8ed4a1ece", "extension": "py", "filename": "movie.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2059, "license": "MIT", "license_type": "permissive", "path": "/uclahedp/plot/movie.py", "provenance": "stack-edu-0057.json.gz:284884", "repo_name": "robinzhang24/uclahedp", "revision_date": 1620772291000, "revision_id": "122ecb180cc58c3aadb47de016427a46094cc8fa", "snapshot_id": "d34dd53c46549ffa10d02f8d2c106fc572e3c6be", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/robinzhang24/uclahedp/122ecb180cc58c3aadb47de016427a46094cc8fa/uclahedp/plot/movie.py", "visit_date": "2023-04-27T15:53:58.585273" }
2.78125
stackv2
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 28 15:13:31 2019 @author: peter *** This program requires ffmpeg be installed in anaconda To install, run the following command in your anaconda terminal conda install -c conda-forge ffmpeg *** """ import h5py import numpy as np import matplotlib #matplotlib.use("Agg") import matplotlib.pyplot as plt from matplotlib.animation import FFMpegWriter def pickTimeInds(pick_time, timearr): output = np.zeros(pick_time.shape, dtype=np.int32) for i, t in enumerate(pick_time): ti = np.argmin(np.abs(timearr - t)) output[i] = ti return output def simpleMovie(inds, x, y, arr, savefile, contour=False, cmap=None): dpi =600 if cmap is None: cmap = 'jet' nframes = len(inds) extent = [x[0], x[-1], y[0], y[-1]] data = arr[inds, :, :] vmin = np.min(data) vmax = np.max(data) metadata = dict(title='Movie test', artist="uclahedp", comment='comment') writer = FFMpegWriter(fps=15, metadata=metadata) fig = plt.figure(figsize=(6,6)) x = np.squeeze(arr[inds[0],:,:]) cplot = plt.imshow(x, cmap=cmap, aspect='auto', vmin=vmin, vmax=vmax, origin='lower', extent=extent) with writer.saving(fig, savefile, dpi): for i in range(nframes): print("Frame: " + str(i)) x = np.squeeze(arr[inds[i],:,:]) cplot.set_data(x) writer.grab_frame() if __name__ == '__main__': f = '/Volumes/PVH_DATA/LAPD_Jan2019/FULL/run18_LAPD_C6_full.hdf5' savefile = '/Volumes/PVH_DATA/LAPD_Jan2019/FULL/simpleMovie.mp4' with h5py.File(f, 'r') as f: x = f['xaxis'][:] y = f['yaxis'] timearr = f['time'][:] arr = f['data'][:,:,:,0,0,2] times = np.linspace(0, 2, num=60) tinds = pickTimeInds(times, timearr*1e6) simpleMovie(tinds, x, y, arr, savefile)
85
23.24
77
14
603
python
[]
0
true
2024-11-19T01:54:53.936835+00:00
1,527,014,119,000
16cc3c069856c264ed44ee11ea8fa6c01be2e152
3
{ "blob_id": "16cc3c069856c264ed44ee11ea8fa6c01be2e152", "branch_name": "refs/heads/master", "committer_date": 1527014119000, "content_id": "45616523f66873e9367de8bf90661f8a257a9785", "detected_licenses": [ "MIT" ], "directory_id": "9d5a833cc18cf290f018e74dc6c0c51895103401", "extension": "py", "filename": "hat.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 134459337, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1880, "license": "MIT", "license_type": "permissive", "path": "/hat.py", "provenance": "stack-edu-0057.json.gz:284887", "repo_name": "Josh-Andrews/DataLogger", "revision_date": 1527014119000, "revision_id": "fc9a3308dd5e45b02b135bc094a41d468545115f", "snapshot_id": "8310c902100d3bf9af35c0f1ccb985b6df418307", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Josh-Andrews/DataLogger/fc9a3308dd5e45b02b135bc094a41d468545115f/hat.py", "visit_date": "2020-03-18T07:32:43.503780" }
3.109375
stackv2
#!/usr/bin/python # hat.py # # Script to grab one set of serial data and log it to a sql database # Requires a database and table to be set up already for the data # # Sources: # pyserial.readthedoc.io/en/latest/pyserial_api.html # pyserial.readthedoc.io/en/latest/shortintro.html # https://docs.python.org/3/library/sqlite3.html # # Written by Josh Andrews 4/27/18 import serial import time import datetime import sqlite3 as sq # list to hold all data going to sql database sqldat = [] # Get date and time in YYYY-MM-DD HH:MM:SS timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") sqldat.append(timestamp) # connect to the expansion hat and write to it # (any write returns all sensor values). ser = serial.Serial('/dev/ttyAMA0', 9600, timeout=0.5) ser.write(b'1') # while we have data to read, read it and store in list as a float. # currently uses the timeout to breakout of loop if no errors. # need to look more at documentation on EOL with readline() while True: try: ser_bytes = ser.readline() info = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8")) sqldat.append(info) except: break # use tuple form to insert data into sql sqldat = tuple(sqldat,) #open/create sql database, use full path to make crontab happy. conn = sq.connect('/var/www/html/sensor_data.db') c = conn.cursor() # insert our sensor information to database c.execute('''INSERT INTO sens_data VALUES (?,(?*1.8)+32,?,?,?,?,((?/100)*1.8)+32,?/10000,?/1000)''',sqldat) # delete data over 24 hours old. Wouldn't want to actually do this in a # real project, just have the php file serve up whats needed so we keep a # record of historical sensor information. c.execute('''DELETE FROM sens_data WHERE timestamp <= datetime('now','-24 hours','localtime')''') # commit the changes and close the database conn.commit() conn.close()
61
29.82
107
17
519
python
[]
0
true
2024-11-19T01:54:54.003706+00:00
1,587,302,273,000
38bd5f417206f5c2cfa635acc84acde20c1f3543
3
{ "blob_id": "38bd5f417206f5c2cfa635acc84acde20c1f3543", "branch_name": "refs/heads/master", "committer_date": 1587302273000, "content_id": "c07fd7ddc108ee13af65bae4dea7c9c73b617856", "detected_licenses": [ "CC0-1.0" ], "directory_id": "28229c94427e42ecd6e504eeb92fcdbeae1091ba", "extension": "py", "filename": "categorydata.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 244598835, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1940, "license": "CC0-1.0", "license_type": "permissive", "path": "/exercise002/vgrocery/controller/categorydata.py", "provenance": "stack-edu-0057.json.gz:284888", "repo_name": "ViniciusMadureira/ifsp-oop2-exercise001", "revision_date": 1587302273000, "revision_id": "c66727bfde82ee96b10b81a84f6b52bbcb62f68b", "snapshot_id": "d29697a736be5dc2f2eed4a8c43e54530eb7022c", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/ViniciusMadureira/ifsp-oop2-exercise001/c66727bfde82ee96b10b81a84f6b52bbcb62f68b/exercise002/vgrocery/controller/categorydata.py", "visit_date": "2021-02-12T14:24:28.344682" }
2.859375
stackv2
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "Vinícius Madureira" __copyright__ = "Copyright 2020, Vinícius Madureira" __license__ = "Creative Commons Zero 1.0 Universal" __version__ = "0.01a" __maintainer__ = "Vinícius Madureira" __email__ = "viniciusmadureira@outlook.com" __status__ = "Testing" from collections import OrderedDict from model.category import Category from controller.sqlite import SQLite from sqlite3 import Error """ CategoryData class: Controller to add, delete and update Product type objects in static product's dictionary (OrderedDict). """ class CategoryData: categories = OrderedDict() @staticmethod def add(category: Category): if not CategoryData.exists(category.name) and category.isValid(): CategoryData.categories[category.name] = category return True return False @staticmethod def delete(categoryName: str): if CategoryData.exists(categoryName): CategoryData.categories.pop(categoryName) return True return False @staticmethod def update(category: Category, category_name: str): if CategoryData.exists(categoryName): CategoryData.products[category.name] = CategoryData.categories.pop(categoryName) return True return False @staticmethod def exists(categoryName: str): return categoryName in CategoryData.categories.keys() @staticmethod def loadCategories(): sqlite = SQLite(SQLite.PATH) CategoryData.categories = OrderedDict() try: result = sqlite.select("SELECT categories.id, categories.name, categories.description FROM categories ORDER BY categories.name;") if result: CategoryData.categories = result except Error as e: print("SQLite Error. Message: {}.".format(str(e))) return CategoryData.categories
60
31.28
141
17
403
python
[]
0
true
2024-11-19T01:54:54.125749+00:00
1,552,719,922,000
1fe4a523e8be6fd6b34630afb3237a9889bd6654
3
{ "blob_id": "1fe4a523e8be6fd6b34630afb3237a9889bd6654", "branch_name": "refs/heads/master", "committer_date": 1552719922000, "content_id": "9001d917e1b8e347542b4f7dd3a13df05d87bdac", "detected_licenses": [ "MIT" ], "directory_id": "ffe57560bea0e45be6eb6a1422cbc20fd8468737", "extension": "py", "filename": "k_means_clustering.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 156575762, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 5215, "license": "MIT", "license_type": "permissive", "path": "/k_means_clustering.py", "provenance": "stack-edu-0057.json.gz:284889", "repo_name": "cjbayron/ml-models", "revision_date": 1552719922000, "revision_id": "b3171c9a82fe5ecdcdc5abcdc20af7c18f9f8ec4", "snapshot_id": "a76f13dfbb0c17146a8b8faa56ca97cd66e44b42", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/cjbayron/ml-models/b3171c9a82fe5ecdcdc5abcdc20af7c18f9f8ec4/k_means_clustering.py", "visit_date": "2020-04-05T04:59:02.426159" }
3
stackv2
''' K-means Clustering (from scratch) with elbow method selection ''' import numpy as np import matplotlib.pyplot as plt from scipy.spatial.distance import euclidean import common.utils as ut # get data from: # https://www.kaggle.com/c/otto-group-product-classification-challenge TRN_DATA_PATH = 'datasets/otto-group-product-classification/train.csv' NUM_SAMPLES = 2000 COLOR_POOL = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'brown', 'gold', 'black', 'pink', 'tan', 'lime', 'magenta', 'teal', 'lavender', 'khaki', 'aqua', 'fuchsia', 'ivory'] def visualize_data(feats, labels, ca): '''Display labeled data and clustered data ''' print("Visualizing data...") red_feats = ut.reduce_to_2D_by_tsne(feats) label2col_map = ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'brown', 'gray', 'pink'] label_list = np.unique(labels) cluster_list = np.unique(ca) fig, ax = plt.subplots(ncols=2, figsize=(10, 5)) for label in label_list: # get samples with label == label idxs = np.where(labels == label) # get components pc1, pc2 = red_feats['pc1'].values[idxs], red_feats['pc2'].values[idxs] # scatter plot w/ color based on labels ax[0].scatter(x=pc1, y=pc2, color=label2col_map[label-1], alpha=0.5, label=label) ax[0].set_xlabel('PC1') ax[0].set_ylabel('PC2') ax[0].set_title('Labeled Products') for i, cluster in enumerate(cluster_list): # get samples assigned to cluster idxs = np.where(ca == cluster) # get components pc1, pc2 = red_feats['pc1'].values[idxs], red_feats['pc2'].values[idxs] # scatter plot w/ color based on cluster ax[1].scatter(x=pc1, y=pc2, color=COLOR_POOL[i], alpha=0.5, label=cluster) ax[1].set_xlabel('PC1') ax[1].set_ylabel('PC2') ax[1].set_title('Grouped Products') for graph in ax: graph.legend() # show legend graph.grid(True) # show gridlines plt.show() def calculate_cost(X, u): ''' Calculate k-means distortion/cost X- samples assigned to cluster u - cluster mean ''' cost = 0 cost += np.sum([(euclidean(x, u)**2) for x in X]) return cost def k_means(k, X, max_iter=100, print_every_iter=5): ''' K-means from scratch k - no. of clusters X - samples ''' if k > len(X): raise Exception("No. of clusters > no. of samples!") # randomly initialize means U = X[np.random.choice(range(len(X)), size=k, replace=True)] # initialize cluster array c = np.array([-1] * len(X)) for j in range(max_iter): U_prev = np.array(U) # cluster assignment for i, x in enumerate(X): u_dists = [euclidean(x, u) for u in U] c[i] = np.argmin(u_dists) # update means cost = 0 for k_idx in range(k): c_xs = X[np.where(c == k_idx)] if len(c_xs) == 0: # re-initialize mean/cluster U[k_idx] = X[np.random.choice(range(len(X)))] else: U[k_idx] = np.mean(c_xs) # get cost cost += calculate_cost(c_xs, U[k_idx]) cost /= len(X) if (j+1) % print_every_iter == 0: print("k = %d. Iter %d. Cost: %.6f" % (k, j+1, cost)) # if no update, then minima is already found if np.array_equal(U, U_prev): break return c, cost def show_elbow(K, costs): '''Graph "elbow" for selection of k ''' plt.subplots(figsize=(8, 5)) plt.plot(K, costs, 'o-') plt.xticks(K) plt.grid(True) plt.xlabel('K', fontsize=15) plt.ylabel('Cost', fontsize=15) plt.title('Elbow method') plt.show() def main(): '''Main ''' feats, labels = ut.get_data_from_csv(TRN_DATA_PATH) if NUM_SAMPLES < len(feats): feats, labels = ut.sample(feats, labels, NUM_SAMPLES) tries = 5 min_k = 3 max_k = 12 K = list(range(min_k, max_k + 1)) K_ca = [] K_costs = [] for k in K: best_cost = 0.0 best_ca = None for t in range(tries): print("-- Trial %d --" % (t+1)) # get cluster assignment and cost ca, cost = k_means(k=k, X=feats.values) if t == 0: best_cost = cost best_ca = ca else: if cost < best_cost: best_cost = cost best_ca = ca K_costs.append(best_cost) K_ca.append(best_ca) # elbow method to select k show_elbow(K, K_costs) # get input try: selected_k = int(input('Choose k (range: %d - %d): ' % (min_k, max_k))) if k < min_k or k > max_k: raise ValueError except ValueError: print('Invalid k given!') return 1 idx = K.index(selected_k) ca = K_ca[idx] print("Selected k: %d. Final Cost: %.6f" % (selected_k, K_costs[idx])) # visualize results visualize_data(feats, labels, ca) return 0 if __name__ == "__main__": main()
186
27.04
79
19
1,446
python
[]
0
true
2024-11-19T01:54:54.232492+00:00
1,485,783,244,000
5adbe92b88cfa34c3d5d5bef206e82f6500e50b2
3
{ "blob_id": "5adbe92b88cfa34c3d5d5bef206e82f6500e50b2", "branch_name": "refs/heads/master", "committer_date": 1485783244000, "content_id": "7c9c792bcd298a501f1be25fd690b9ea0e989edc", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "60e006eb75b4d6786a4e679cde318f141c367b0b", "extension": "py", "filename": "value_parsers.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 723, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/flask_app/search/value_parsers.py", "provenance": "stack-edu-0057.json.gz:284891", "repo_name": "alonho/backslash", "revision_date": 1485783244000, "revision_id": "ca58aefa46d00bed48383b4f2823314553e6afb1", "snapshot_id": "537d21836b525be2c586055c6ea67c1b6ed8940d", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/alonho/backslash/ca58aefa46d00bed48383b4f2823314553e6afb1/flask_app/search/value_parsers.py", "visit_date": "2021-01-17T08:43:59.567550" }
2.9375
stackv2
import re import datetime import dateparser from .exceptions import SearchSyntaxError units = { 'd': datetime.timedelta(days=1), 'h': datetime.timedelta(hours=1), } def parse_date(value): match = re.match(r"^([\-\+])(\d+)([{}])".format(''.join(units)), value) if not match: returned = dateparser.parse(value) if returned is None: raise SearchSyntaxError('Invalid date provided: {!r}'.format(value)) return returned.timestamp() returned = datetime.datetime.now() sign, num, unit = match.groups() num = int(num) diff = num * units[unit] if sign == '-': returned -= diff else: returned += diff return returned.timestamp()
32
21.59
80
14
169
python
[]
0
true
2024-11-19T01:54:54.369335+00:00
1,611,366,906,000
f7d49c73121475b443ca46a5c55c357751fe071b
3
{ "blob_id": "f7d49c73121475b443ca46a5c55c357751fe071b", "branch_name": "refs/heads/main", "committer_date": 1611366906000, "content_id": "9ca5c9d0c714eff9d5cb0e4ca5986f802da331be", "detected_licenses": [ "Apache-2.0" ], "directory_id": "a42fb6a9947211d7ebae45f2073c61e7d4c4ad9b", "extension": "py", "filename": "dcu_pareto.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1057, "license": "Apache-2.0", "license_type": "permissive", "path": "/dcache_poc/dcu_pareto.py", "provenance": "stack-edu-0057.json.gz:284893", "repo_name": "clayne/speculative_interference", "revision_date": 1611366906000, "revision_id": "4bbf3a7fdd593ff781f87777ba34c0efdddde1d5", "snapshot_id": "8cc5677010c0cb45a839bcc66d14c7241219f978", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/clayne/speculative_interference/4bbf3a7fdd593ff781f87777ba34c0efdddde1d5/dcache_poc/dcu_pareto.py", "visit_date": "2023-02-18T08:08:36.773593" }
2.8125
stackv2
import matplotlib.pyplot as plt import numpy as np import csv import scipy.special as sc def binary_entropy(x): return -(sc.xlogy(x, x) + sc.xlog1py(1 - x, -x))/np.log(2) plt.rcParams.update({'font.size': 20}) with open('dcache', newline='\n') as csvfile: ic = list(csv.reader(csvfile)) icx = [float(x[0]) for x in ic] icy = [float(x[1]) for x in ic] icap = [] for i in range(len(icx)): cap = icx[i] * (1 - binary_entropy(icy[i])) icap.append(cap) #fig, ax2 = plt.subplots(1,1,figsize=(15,5)) file = 'bitrate.pdf' #fig.suptitle('Error rate - Throughput') #fig.text(0.99, 0.5, 'Capacity (bps)', va='center', rotation='vertical', fontsize=30) plt.plot(icx, icy, 'o', color='black') plt.plot(np.unique(icx), np.poly1d(np.polyfit(icx, icy, 6))(np.unique(icx)), color='black') plt.title('(b) D-Cache', fontsize=30) plt.xlabel('bit rate (bps)') plt.ylabel('Bit Error Probability') #plt.ylim(0,0.4) #plt.yaxis.grid() #plt.yaxis.set_major_locator(plt.MaxNLocator(2)) plt.tight_layout() plt.show() #plt.savefig(file, bbox_inches='tight')
34
30.09
91
12
340
python
[]
0
true
2024-11-19T01:54:54.553094+00:00
1,558,459,977,000
9f1f3be57cbfdbe8ac22d1c6ce2b950af3089122
3
{ "blob_id": "9f1f3be57cbfdbe8ac22d1c6ce2b950af3089122", "branch_name": "refs/heads/master", "committer_date": 1558459977000, "content_id": "2a3d9007c94883c398c0883fd7f00e749cfa2106", "detected_licenses": [ "MIT" ], "directory_id": "11f75121b7861795876cad114566f0c1ef1e3ef1", "extension": "py", "filename": "changeHandler.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 140028571, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 4541, "license": "MIT", "license_type": "permissive", "path": "/static/py/changeHandler.py", "provenance": "stack-edu-0057.json.gz:284894", "repo_name": "robbie-a-freeman/Single-Crystal-Mineral-Database", "revision_date": 1558459977000, "revision_id": "dc900ac59319385a1bde2617c4573754f6a6025d", "snapshot_id": "aa181098d1c191b3fef567024960df96f224192b", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/robbie-a-freeman/Single-Crystal-Mineral-Database/dc900ac59319385a1bde2617c4573754f6a6025d/static/py/changeHandler.py", "visit_date": "2020-03-22T12:15:36.471557" }
2.8125
stackv2
"""Script that checks for changes uploaded to the database by Tom through FileZilla and updates the master sheet to be the new sheet. Then, it alters the changelog.html file to reflect the changes. Uses pandas for the table changes and Beautiful Soup 4 for the html changes. Returns False if no changes are made and True if changes are made. """ import pandas as pd import os import bs4 import sys import xlrd import tableManager __author__ = "Robbie Freeman" __credits__ = ["Thomas Duffy"] __maintainer__ = "Robbie Freeman" __email__ = "robbie.a.freeman@gmail.com" __status__ = "Development" def getSheetNames(): xl = pd.ExcelFile("static/downloads/single-crystal_db_complete.xlsx") xlNames = [] for s in xl.sheet_names: if not "Refs" in s and not "Key" in s: xlNames.append(s) return xlNames def main(): ''' Commented out for bug testing, and this is an unimplemented feature # Take in a new excel sheet. Read in the data using Pandas. Make it the new # master sheet if not os.path.isfile("../static/downloads/newSheet.xlsx") : return False newData = tableManager.getInitialTables("static/downloads/newSheet.xlsx") currentData = tableManager.getInitialTables() # Check for validity. Return the error if invalid. TODO expand checks assert(len(newData) == len(currentData)) # Compare the new data with the data already in the master sheet to determine # the nature of the changes TODO implement changes = [] if len(newData.index) == len(currentData.index): changes.append("Updated current minerals") elif len(newData.index) > len(currentData.index): changes.append("Added minerals") elif len(newData.index) < len(currentData.index): changes.append("Removed minerals") ''' tables = tableManager.getInitialTables(asOne=False) # Create the CSV file from the original, master excel sheet '''if os.path.isfile('static/downloads/single-crystal_db_complete.csv') : os.remove("static/downloads/single-crystal_db_complete.csv") tables.to_csv('static/downloads/single-crystal_db_complete.csv', index=False) #TODO fix ''' # Find the mineral group and structure categories and log them in mineralCats.txt # for generating search.html # Scan through each row looking for unique mineral classes and unique structures # within each lastLabel = '' categories = [] # list of lists of tuples of the form (class, structure) classdf = pd.DataFrame(columns=tables[0].columns) sheetNames = getSheetNames() for i in range(len(tables)): print(sheetNames[i]) category = [] for index, row in tables[i].iterrows(): # for each of the rows rowdf = row.to_frame() # Dataframe of row, which is normally a Series lastLabel = lastLabel.replace(" ","&#160;") # account for spaces in classes (NOT structures) if isinstance(row['Structure/SG'], str): structure = row['Structure/SG'].split(',')[0] # if it's a row with a mineral class label if not (pd.isnull(row['Name'])) and pd.isnull(row['Composition']) and lastLabel != row['Name']: lastLabel = row['Name'] # if it's a row following a label but not a label itself elif lastLabel != '' and (lastLabel, structure) not in category: print((lastLabel, structure)) category.append((lastLabel, structure)) categories.append(category) if os.path.isfile("static/text/categories.txt") : os.remove("static/text/categories.txt") orig_stdout = sys.stdout file = open('static/text/categories.txt', 'w') sys.stdout = file for i in range(len(tables)): print(sheetNames[i], end='') print(categories[i], end='') sys.stdout = orig_stdout file.close() '''# Delete the master and use the new sheet as the current master os.remove("static/downloads/single-crystal_db.xlsx") os.remove("static/downloads/single-crystal_db.csv") os.rename("static/downloads/newSheet.xlsx", "static/downloads/single-crystal_db.xlsx") newData.to_csv("static/downloads/single-crystal_db.csv") os.remove("static/downloads/newSheet.xlsx") # Log the changes changelog(changes) ''' # Update the entries.html page (or at least the string that holds its data) sys.path.insert(0, 'static/py') import allEntries allEntries.main() # return True, as changes were successfully made return True
111
39.91
107
17
1,024
python
[]
0
true
2024-11-19T01:54:54.615993+00:00
1,576,174,750,000
954aaf68abfc9029b48bd2e2490bcdc5be4e48f7
2
{ "blob_id": "954aaf68abfc9029b48bd2e2490bcdc5be4e48f7", "branch_name": "refs/heads/master", "committer_date": 1576201396000, "content_id": "d56c2fa082bc5b77fab112801d27844b276322c9", "detected_licenses": [ "MIT" ], "directory_id": "3faf1ff6b32134964f0e577f052575083cb235d1", "extension": "py", "filename": "train.py", "fork_events_count": 0, "gha_created_at": 1573911431000, "gha_event_created_at": 1573911431000, "gha_language": null, "gha_license_id": "MIT", "github_id": 222104420, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2937, "license": "MIT", "license_type": "permissive", "path": "/train.py", "provenance": "stack-edu-0057.json.gz:284895", "repo_name": "xmba15/CarND-Behavioral-Cloning-P3", "revision_date": 1576174750000, "revision_id": "6bfae29243bc4fe2050d2b91958181eb67bb59e5", "snapshot_id": "d4964423d4a1b3a5b54d8b450f1db9c6496d4da6", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/xmba15/CarND-Behavioral-Cloning-P3/6bfae29243bc4fe2050d2b91958181eb67bb59e5/train.py", "visit_date": "2020-09-11T14:59:39.964332" }
2.4375
stackv2
#!/usr/bin/env python # -*- coding: utf-8 -*- from matplotlib import pyplot as plt from sklearn.model_selection import train_test_split from sklearn.utils import shuffle from config import Config from data_loader import BehavioralDataset from models import BehavioralModel from tensorflow.keras.callbacks import ModelCheckpoint, ReduceLROnPlateau, EarlyStopping def load_data(dataset): triple_x_train, y_train = dataset.load_data() triple_x_train, triple_x_val, y_train, y_val = train_test_split( triple_x_train, y_train, test_size=0.2, random_state=42 ) return triple_x_train, triple_x_val, y_train, y_val def plot_history(history): train_loss = history.history["loss"] val_loss = history.history["val_loss"] if "acc" in history.history: train_acc = history.history["acc"] val_acc = history.history["val_acc"] epoch_nums = len(train_loss) if "acc" in history.history: fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(10, 10)) loss_ax = ax[0] else: fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 10)) loss_ax = ax loss_ax.set_xlabel("epochs") loss_ax.set_ylabel("loss") loss_ax.set_title("loss") loss_ax.plot(range(0, epoch_nums), train_loss, label="train loss") loss_ax.plot(range(0, epoch_nums), val_loss, label="val loss") loss_ax.legend() if "acc" in history.history: ax[1].set_xlabel("epochs") ax[1].set_ylabel("val") ax[1].set_title("accuracy") ax[1].plot(range(0, epoch_nums), train_acc, label="train acc") ax[1].plot(range(0, epoch_nums), val_acc, label="val acc") ax[1].legend() plt.suptitle("train-val logs") # plt.show() plt.savefig("train_val_logs.png") def main(): dt_config = Config() dataset = BehavioralDataset(path_to_data=dt_config.DATA_PATH) triple_x_train, triple_x_val, y_train, y_val = load_data(dataset) model = BehavioralModel(input_shape=(160, 320, 3)) callbacks = [ ModelCheckpoint( os.path.join(dt_config.SAVED_MODELS_PATH, "model-{epoch:03d}.h5"), monitor="val_loss", verbose=1, save_best_only=True, mode="auto", period=1, ), ReduceLROnPlateau(monitor="val_loss", factor=0.1, patience=7, verbose=0, mode="auto", min_lr=0.00001), EarlyStopping(monitor="val_loss", min_delta=0, patience=15, verbose=0, mode="auto"), ] history = model.fit_generator( batch_generator(triple_x_train, y_train, dt_config.BATCH_SIZE), epochs=dt_config.EPOCHS, steps_per_epoch=len(triple_x_train) * 6 // dt_config.BATCH_SIZE + 1, validation_data=batch_generator(triple_x_val, y_val, dt_config.BATCH_SIZE, False), validation_steps=(len(triple_x_val) - 1) // dt_config.BATCH_SIZE + 1, callbacks=callbacks, ) if __name__ == "__main__": main()
85
33.55
110
15
775
python
[]
0
true
2024-11-19T01:54:55.225221+00:00
1,691,580,764,000
92381d32a201fa564eeadff1a5b8ac9baa262728
3
{ "blob_id": "92381d32a201fa564eeadff1a5b8ac9baa262728", "branch_name": "refs/heads/main", "committer_date": 1691580764000, "content_id": "ecfdc60f15d0333853ffc1d3284d088797582953", "detected_licenses": [ "MIT" ], "directory_id": "6d9be7a09300d84c5394e927a31d0e4c82aa3943", "extension": "py", "filename": "_ar6.py", "fork_events_count": 8, "gha_created_at": 1469004333000, "gha_event_created_at": 1694710624000, "gha_language": "Python", "gha_license_id": "MIT", "github_id": 63765507, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2029, "license": "MIT", "license_type": "permissive", "path": "/regionmask/defined_regions/_ar6.py", "provenance": "stack-edu-0057.json.gz:284900", "repo_name": "regionmask/regionmask", "revision_date": 1691580764000, "revision_id": "d8fd75d04f6bb9e8b070e104fd77e48bac9c4b30", "snapshot_id": "6a94c9f8b1964beac2da1af5c0c0639189fec752", "src_encoding": "UTF-8", "star_events_count": 111, "url": "https://raw.githubusercontent.com/regionmask/regionmask/d8fd75d04f6bb9e8b070e104fd77e48bac9c4b30/regionmask/defined_regions/_ar6.py", "visit_date": "2023-08-18T04:05:55.107416" }
2.53125
stackv2
from ..core._geopandas import from_geopandas from ._ressources import read_remote_shapefile REPR = """ AR6 reference regions - Iturbide et al., 2020 Attributes ---------- all : Regions All regions (land + ocean). land : Regions Land regions only ocean : Regions Ocean regions only """ class ar6_cls: """docstring for ar6""" def __init__(self): self._df = None self._all = None self._land = None self._ocean = None self._name = "AR6 reference regions" self._source = "Iturbide et al., 2020 (Earth Syst. Sci. Data)" @property def df(self): if self._df is None: self._df = read_remote_shapefile("IPCC-WGI-reference-regions-v4.zip") return self._df @property def all(self): if self._all is None: self._all = from_geopandas( self.df, names="Name", abbrevs="Acronym", name=self._name, source=self._source, overlap=False, ) return self._all @property def land(self): if self._land is None: land = self.df.Type.str.contains("Land") self._land = from_geopandas( self.df.loc[land], names="Name", abbrevs="Acronym", name=self._name + " (land only)", source=self._source, overlap=False, ) return self._land @property def ocean(self): if self._ocean is None: ocean = self.df.Type.str.contains("Ocean") self._ocean = from_geopandas( self.df.loc[ocean], names="Name", abbrevs="Acronym", name=self._name + " (ocean only)", source=self._source, overlap=False, ) return self._ocean def __repr__(self): # pragma: no cover return REPR ar6 = ar6_cls()
93
20.82
81
16
478
python
[]
0
true
2024-11-19T01:54:55.969849+00:00
1,592,278,450,000
9616b410afd69602a47d94b73cbe3fe30943e12a
3
{ "blob_id": "9616b410afd69602a47d94b73cbe3fe30943e12a", "branch_name": "refs/heads/master", "committer_date": 1592278450000, "content_id": "81be946de277cc03bcd1d9600756698a40645ee3", "detected_licenses": [ "Apache-2.0" ], "directory_id": "239560e26d08bc398e3c1e6d53e7fb0b65f74d61", "extension": "py", "filename": "multi_scale_anchor_generator.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 5593, "license": "Apache-2.0", "license_type": "permissive", "path": "/kerascv/layers/anchor_generators/multi_scale_anchor_generator.py", "provenance": "stack-edu-0057.json.gz:284903", "repo_name": "GAIMJKP/keras-cv", "revision_date": 1592278450000, "revision_id": "bf00322ef8e9c5d0b5d8e797ff7b24ac5adeb5f4", "snapshot_id": "72b40e8772d25acd2ad60600074f4355eca3b0d5", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/GAIMJKP/keras-cv/bf00322ef8e9c5d0b5d8e797ff7b24ac5adeb5f4/kerascv/layers/anchor_generators/multi_scale_anchor_generator.py", "visit_date": "2022-10-16T23:33:18.045620" }
2.71875
stackv2
# Copyright 2020 The Keras CV Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import tensorflow as tf from .anchor_generator import AnchorGenerator class MultiScaleAnchorGenerator(tf.keras.layers.Layer): """Defines a MultiScaleAnchorGenerator that generates anchor boxes for multiple feature maps. # Attributes: image_size: A list/tuple of 2 ints, the 1st represents the image height, the 2nd image width. scales: A list/tuple of list/tuple of positive floats (usually less than 1.) as a fraction to shorter side of `image_size`. It represents the base anchor size (when aspect ratio is 1.). For example, if `image_size=(300, 200)`, and `scales=[[.1]]`, then the base anchor size is 20. If `image_size=(300, 200)` and `scales=[[.1], [.2]]`, then the base anchor sizes are 20 and 40. aspect_ratios: a list/tuple of list/tuple of positive floats representing the ratio of anchor width to anchor height. **Must** have the same length as `scales`. For example, if `image_size=(300, 200)`, `scales=[[.1]]`, and `aspect_ratios=[[.64]]`, the base anchor size is 20, then anchor height is 25 and anchor width is 16. If `image_size=(300, 200)`, `scales=[[.1], [.2]]`, and `aspect_ratios=[[.64], [.1]]`, the base anchor size is 20 and 40, then the anchor heights are 25 and 40, the anchor widths are 16 and 40. The anchor aspect ratio is independent to the original aspect ratio of image size. strides: A list/tuple of list/tuple of 2 ints or floats representing the distance between anchor points. For example, `stride=[(30, 40)]` means each anchor is separated by 30 pixels in height, and 40 pixels in width. Defaults to `None`, where anchor stride would be calculated as `min(image_height, image_width) / feature_map_height` and `min(image_height, image_width) / feature_map_width` for each feature map. offsets: A list/tuple of list/tuple of 2 floats between [0., 1.] representing the center of anchor points relative to the upper-left border of each feature map cell. Defaults to `None`, which is the center of each feature map cell when `strides=None`, or center of each anchor stride otherwise. clip_boxes: Boolean to represents whether the anchor coordinates should be clipped to the image size. Defaults to `True`. normalize_coordinates: Boolean to represents whether the anchor coordinates should be normalized to [0., 1.] with respect to the image size. Defaults to `True`. """ def __init__( self, image_size, scales, aspect_ratios, strides=None, offsets=None, clip_boxes=True, normalize_coordinates=True, name=None, **kwargs ): self.image_size = image_size self.image_height = image_size[0] self.image_width = image_size[1] self.scales = scales self.aspect_ratios = aspect_ratios if strides is None: strides = [None] * len(scales) if offsets is None: offsets = [None] * len(scales) self.strides = strides self.offsets = offsets self.clip_boxes = clip_boxes self.normalize_coordinates = normalize_coordinates self.anchor_generators = [] for (i, (scale_list, aspect_ratio_list, stride, offset)) in enumerate( zip(scales, aspect_ratios, strides, offsets) ): self.anchor_generators.append( AnchorGenerator( image_size, scales=scale_list, aspect_ratios=aspect_ratio_list, stride=stride, offset=offset, clip_boxes=clip_boxes, normalize_coordinates=normalize_coordinates, name="anchor_generator_" + str(i), ) ) super(MultiScaleAnchorGenerator, self).__init__(name=name, **kwargs) def call(self, feature_map_sizes): result = [] for feature_map_size, anchor_generator in zip( feature_map_sizes, self.anchor_generators ): anchors = anchor_generator(feature_map_size) anchors = tf.reshape(anchors, (-1, 4)) result.append(anchors) return tf.concat(result, axis=0) def get_config(self): config = { "image_size": self.image_size, "scales": self.scales, "aspect_ratios": self.aspect_ratios, "strides": self.strides, "offsets": self.offsets, "clip_boxes": self.clip_boxes, "normalize_coordinates": self.normalize_coordinates, } base_config = super(MultiScaleAnchorGenerator, self).get_config() return dict(list(base_config.items()) + list(config.items()))
114
48.06
120
17
1,246
python
[]
0
true
2024-11-19T01:54:56.087798+00:00
1,512,605,069,000
707802397e3b21f51ded1bfdb9b98e93fbdae8d6
3
{ "blob_id": "707802397e3b21f51ded1bfdb9b98e93fbdae8d6", "branch_name": "refs/heads/master", "committer_date": 1512605069000, "content_id": "3b3a2d8fcdf797a16dbb509a86717002ab267668", "detected_licenses": [ "MIT" ], "directory_id": "b2ca3bc0eaaf3dd430a2f5c118c01632d0a01143", "extension": "py", "filename": "DBAPI.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2182, "license": "MIT", "license_type": "permissive", "path": "/Final Project/DBAPI.py", "provenance": "stack-edu-0057.json.gz:284904", "repo_name": "SFMason-USF/web-apps", "revision_date": 1512605069000, "revision_id": "9d5b1e7d7ac2a709da863171d6380072af012d8d", "snapshot_id": "6a6e2728eda2fde778929ca1a6bf56d3e6d84873", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/SFMason-USF/web-apps/9d5b1e7d7ac2a709da863171d6380072af012d8d/Final Project/DBAPI.py", "visit_date": "2021-08-23T22:54:48.621587" }
2.609375
stackv2
import sqlite3 def connect(func): def func_wrapper(*args, **kwargs): conn = sqlite3.connect("myDB.db") return func(*args, **kwargs) conn.close() return func_wrapper #TODO check and edit function @connect def createUsers(conn): try: conn.execute('''CREATE TABLE USERS (username text, hashresult text, salt text, role text)''') conn.commit() except(sqlite3.OperationalError): print('') @connect def createSites(conn): try: conn.execute('''CREATE TABLE SITES (siteid text, siteurl text)''') conn.commit() except(sqlite3.OperationalError): print('') @connect def createVoteReport(conn): try: conn.execute('''CREATE TABLE VOTEREPORT (username text, first text, second text, third text)''') conn.commit() except(sqlite3.OperationalError): print('') #TODO check and edit function @connect def addUser(conn, username, hashresult, salt, role): c = conn.cursor() t = (username,) c.execute('SELECT * FROM USERS WHERE username=?', t) data = c.fetchone() if (data is None): params = (username, hashresult, salt, role) c.execute("INSERT INTO USERS VALUES (?, ?, ?, ?)", params) conn.commit() return True else: return False @connect def addSite(conn, siteid, siteurl): c = conn.cursor() t = (siteid,) c.execute('SELECT * FROM SITES WHERE siteid=?', t) data = c.fetchone() if (data is None): params = (siteid, siteurl) c.execute("INSERT INTO SITES VALUES (?, ?)", params) conn.commit() return True else: return False @connect def addVote(conn, username, first, second, third): c = conn.cursor() t = (username,) c.execute('SELECT * FROM VOTEREPORT WHERE username=?', t) data = c.fetchone() if (data is None): params = (username, first, second, third) c.execute("INSERT INTO VOTEREPORT VALUES (?, ?, ?, ?)", params) conn.commit() return True else: return False
79
25.62
71
12
518
python
[]
0
true
2024-11-19T01:54:56.152867+00:00
1,691,566,580,000
da9f86b3f19f4b8db14bc92c69aff0bf65193052
3
{ "blob_id": "da9f86b3f19f4b8db14bc92c69aff0bf65193052", "branch_name": "refs/heads/master", "committer_date": 1691566580000, "content_id": "0b359a50b1ac0200430fe8605d30abb4d93450e9", "detected_licenses": [ "MIT" ], "directory_id": "691b82da7c38a6c109088d8426ffa26175f4ff31", "extension": "py", "filename": "actions.py", "fork_events_count": 460, "gha_created_at": 1514122783000, "gha_event_created_at": 1687678030000, "gha_language": "Python", "gha_license_id": "MIT", "github_id": 115265222, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 9502, "license": "MIT", "license_type": "permissive", "path": "/apps/easytask/actions.py", "provenance": "stack-edu-0057.json.gz:284905", "repo_name": "Hopetree/izone", "revision_date": 1691566580000, "revision_id": "46f90dbaa3968cb3261d60a74765fa462415f000", "snapshot_id": "4072957eb12c7703a235c6df87ab49c7a7fdd84e", "src_encoding": "UTF-8", "star_events_count": 1167, "url": "https://raw.githubusercontent.com/Hopetree/izone/46f90dbaa3968cb3261d60a74765fa462415f000/apps/easytask/actions.py", "visit_date": "2023-08-19T00:21:48.632159" }
2.75
stackv2
# -*- coding: utf-8 -*- """ 定义一些任务的执行操作,将具体的操作从tasks.py里面抽离出来 每个任务需要饮用的模块放到函数里面引用,方便单独调试函数 """ import requests def get_link_status(url): """ 请求地址,返回请求状态和内容 @param url: @return: """ try: resp = requests.get(url, timeout=5, verify=False) except Exception: return 500, '请求超时' return resp.status_code, resp.text def white_list_check(lis, string): """ 校验一个字符串是否包含一个列表中任意一个元素 @param lis: @param string: @return: bool """ for each in lis: if each in string: return True return False def action_update_article_cache(): """ 更新所有文章的缓存,缓存格式跟文章视图保持一致 @return: """ from markdown import Markdown from markdown.extensions.toc import TocExtension # 锚点的拓展 from markdown.extensions.codehilite import CodeHiliteExtension from django.core.cache import cache from django.utils.text import slugify from blog.utils import CustomHtmlFormatter from blog.models import Article total_num, done_num = 0, 0 # 查询到所有缓存的key keys = cache.keys('article:markdown:*') for obj in Article.objects.all(): total_num += 1 ud = obj.update_date.strftime("%Y%m%d%H%M%S") md_key = f'article:markdown:{obj.id}:{ud}' # 设置不存在的缓存 if md_key not in keys: md = Markdown(extensions=[ 'markdown.extensions.extra', 'markdown_checklist.extension', CodeHiliteExtension(pygments_formatter=CustomHtmlFormatter), TocExtension(slugify=slugify), ]) # 设置过期时间的时候分散时间,不要设置成同一时间 cache.set(md_key, (md.convert(obj.body), md.toc), 3600 * 24 + 10 * done_num) done_num += 1 data = {'total': total_num, 'done': done_num} return data def action_check_friend_links(site_link=None, white_list=None): """ 检查友链: 1、检查当前显示的友链,请求友链,将非200的友链标记为不显示,并记录禁用原因 2、检查当前不显示的友链,请求友链,将200返回的标记为显示,并删除禁用原因 3、新增补充校验:可以添加参数site_link,则不仅仅校验网页是否打开200,还会校验网站中是否有site_link外链 @return: """ import re from blog.models import FriendLink white_list = white_list or [] # 设置白名单,不校验 active_num = 0 to_not_show = 0 to_show = 0 active_friend_list = FriendLink.objects.filter(is_active=True) for active_friend in active_friend_list: active_num += 1 if active_friend.name in white_list: continue if active_friend.is_show is True: code, text = get_link_status(active_friend.link) if code != 200: active_friend.is_show = False active_friend.not_show_reason = f'网页请求返回{code}' active_friend.save(update_fields=['is_show', 'not_show_reason']) to_not_show += 1 else: # 设置了网站参数则校验友链中是否包含本站外链 if site_link: site_check_result = re.findall(site_link, text) if not site_check_result: active_friend.is_show = False active_friend.not_show_reason = f'网站未设置本站外链' active_friend.save(update_fields=['is_show', 'not_show_reason']) to_not_show += 1 else: code, text = get_link_status(active_friend.link) if code == 200: if not site_link: active_friend.is_show = True active_friend.not_show_reason = '' active_friend.save(update_fields=['is_show', 'not_show_reason']) to_show += 1 else: site_check_result = re.findall(site_link, text) if site_check_result: active_friend.is_show = True active_friend.not_show_reason = '' active_friend.save(update_fields=['is_show', 'not_show_reason']) to_show += 1 data = {'active_num': active_num, 'to_not_show': to_not_show, 'to_show': to_show} return data def action_clear_notification(day=200, is_read=True): """ 清理消息推送 @param is_read: False表示清理所有,True表示只清理已读,默认清理已读 @param day: 清理day天前的信息 @return: """ from datetime import datetime, timedelta from django.db.models import Q from comment.models import Notification, SystemNotification current_date = datetime.now() delta = timedelta(days=day) past_date = current_date - delta if is_read is True: query = Q(create_date__lte=past_date, is_read=True) else: query = Q(create_date__lte=past_date) comment_notification_objects = Notification.objects.filter(query) system_notification_objects = SystemNotification.objects.filter(query) comment_num = comment_notification_objects.count() system_num = system_notification_objects.count() comment_notification_objects.delete() system_notification_objects.delete() return {'comment_num': comment_num, 'system_num': system_num} def action_cleanup_task_result(day=3): """ 清理任务结果 清理day天前成功或结束的,其他状态的一概不清理 @return: """ from datetime import datetime, timedelta from django.db.models import Q from django_celery_results.models import TaskResult current_date = datetime.now() delta = timedelta(days=day) past_date = current_date - delta query = Q(date_done__lte=past_date) task_result_objects = TaskResult.objects.filter(query) task_result_count = task_result_objects.count() task_result_objects.delete() return {'task_result_count': task_result_count} def action_baidu_push(baidu_url, months): """ 主动推送文章地址到百度,指定推送最近months月的文章链接 @param baidu_url: 百度接口调用地址,包含token @param months: 几个月内的文章 @return: """ import requests from datetime import datetime from dateutil.relativedelta import relativedelta from blog.models import Article from blog.utils import site_full_url def baidu_push(urls): headers = { 'User-Agent': 'curl/7.12.1', 'Host': 'data.zz.baidu.com', 'Content-Type': 'text/plain', 'Content-Length': '83' } try: response = requests.post(baidu_url, headers=headers, data=urls, timeout=5) return True, response.json() except Exception as e: return False, e current_date = datetime.now() previous_date = current_date - relativedelta(months=months) article_list = Article.objects.filter(create_date__gte=previous_date, is_publish=True) article_count = article_list.count() if not article_count: return {'article_count': article_count, 'status': True, 'result': 'ignore'} url_list = [f'{site_full_url()}{each.get_absolute_url()}' for each in article_list] status, result = baidu_push('\n'.join(url_list)) return {'article_count': article_count, 'status': status, 'result': result} def action_check_site_links(white_domain_list=None): """ 校验导航网站有效性,只校验状态为True或者False的,为空的不校验,所以特殊地址可以设置成空跳过校验 @param white_domain_list: 域名白名单 @return: """ from webstack.models import NavigationSite white_domain_list = white_domain_list or [] active_num = 0 to_not_show = 0 to_show = 0 active_site_list = NavigationSite.objects.filter(is_show__isnull=False) for site in active_site_list: active_num += 1 # 当站点包含白名单域名则直接跳过校验 if white_list_check(white_domain_list, site.link): continue if site.is_show is True: code, text = get_link_status(site.link) if code < 200 or code >= 400: site.is_show = False site.not_show_reason = f'网页请求返回{code}' site.save(update_fields=['is_show', 'not_show_reason']) to_not_show += 1 else: code, text = get_link_status(site.link) if 200 <= code < 400: site.is_show = True site.not_show_reason = '' site.save(update_fields=['is_show', 'not_show_reason']) to_show += 1 data = {'active_num': active_num, 'to_not_show': to_not_show, 'to_show': to_show} return data if __name__ == '__main__': import os import django os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'izone.settings') django.setup() # print(action_clear_notification(100)) # print(action_cleanup_task_result(7)) print(action_check_site_links())
255
32.4
90
22
2,159
python
[{"finding_id": "codeql_py/request-without-cert-validation_1fcc7e933dc682b3_f0267f36", "tool_name": "codeql", "rule_id": "py/request-without-cert-validation", "finding_type": "problem", "severity": "medium", "confidence": "medium", "message": "This request may run without certificate validation because [it is disabled](1).", "remediation": "", "location": {"file_path": "unknown", "line_start": 16, "line_end": null, "column_start": 16, "column_end": 58, "code_snippet": ""}, "cwe_id": "CWE-295", "cwe_name": null, "cvss_score": null, "cvss_vector": null, "owasp_category": null, "references": [], "fingerprint": null, "tags": ["security", "external/cwe/cwe-295"], "raw_output": {"ruleId": "py/request-without-cert-validation", "ruleIndex": 42, "rule": {"id": "py/request-without-cert-validation", "index": 42}, "message": {"text": "This request may run without certificate validation because [it is disabled](1)."}, "locations": [{"physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 16, "startColumn": 16, "endColumn": 58}}}], "partialFingerprints": {"primaryLocationLineHash": "5be342ad35708513:1", "primaryLocationStartColumnFingerprint": "7"}, "relatedLocations": [{"id": 1, "physicalLocation": {"artifactLocation": {"uri": "code.py", "uriBaseId": "%SRCROOT%", "index": 0}, "region": {"startLine": 16, "startColumn": 52, "endColumn": 57}}, "message": {"text": "it is disabled"}}]}}]
1
true
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
15