hexsha string | size int64 | ext string | lang string | max_stars_repo_path string | max_stars_repo_name string | max_stars_repo_head_hexsha string | max_stars_repo_licenses list | max_stars_count int64 | max_stars_repo_stars_event_min_datetime string | max_stars_repo_stars_event_max_datetime string | max_issues_repo_path string | max_issues_repo_name string | max_issues_repo_head_hexsha string | max_issues_repo_licenses list | max_issues_count int64 | max_issues_repo_issues_event_min_datetime string | max_issues_repo_issues_event_max_datetime string | max_forks_repo_path string | max_forks_repo_name string | max_forks_repo_head_hexsha string | max_forks_repo_licenses list | max_forks_count int64 | max_forks_repo_forks_event_min_datetime string | max_forks_repo_forks_event_max_datetime string | content string | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 | qsc_code_num_words_quality_signal int64 | qsc_code_num_chars_quality_signal float64 | qsc_code_mean_word_length_quality_signal float64 | qsc_code_frac_words_unique_quality_signal float64 | qsc_code_frac_chars_top_2grams_quality_signal float64 | qsc_code_frac_chars_top_3grams_quality_signal float64 | qsc_code_frac_chars_top_4grams_quality_signal float64 | qsc_code_frac_chars_dupe_5grams_quality_signal float64 | qsc_code_frac_chars_dupe_6grams_quality_signal float64 | qsc_code_frac_chars_dupe_7grams_quality_signal float64 | qsc_code_frac_chars_dupe_8grams_quality_signal float64 | qsc_code_frac_chars_dupe_9grams_quality_signal float64 | qsc_code_frac_chars_dupe_10grams_quality_signal float64 | qsc_code_frac_chars_replacement_symbols_quality_signal float64 | qsc_code_frac_chars_digital_quality_signal float64 | qsc_code_frac_chars_whitespace_quality_signal float64 | qsc_code_size_file_byte_quality_signal float64 | qsc_code_num_lines_quality_signal float64 | qsc_code_num_chars_line_max_quality_signal float64 | qsc_code_num_chars_line_mean_quality_signal float64 | qsc_code_frac_chars_alphabet_quality_signal float64 | qsc_code_frac_chars_comments_quality_signal float64 | qsc_code_cate_xml_start_quality_signal float64 | qsc_code_frac_lines_dupe_lines_quality_signal float64 | qsc_code_cate_autogen_quality_signal float64 | qsc_code_frac_lines_long_string_quality_signal float64 | qsc_code_frac_chars_string_length_quality_signal float64 | qsc_code_frac_chars_long_word_length_quality_signal float64 | qsc_code_frac_lines_string_concat_quality_signal float64 | qsc_code_cate_encoded_data_quality_signal float64 | qsc_code_frac_chars_hex_words_quality_signal float64 | qsc_code_frac_lines_prompt_comments_quality_signal float64 | qsc_code_frac_lines_assert_quality_signal float64 | qsc_codepython_cate_ast_quality_signal float64 | qsc_codepython_frac_lines_func_ratio_quality_signal float64 | qsc_codepython_cate_var_zero_quality_signal bool | qsc_codepython_frac_lines_pass_quality_signal float64 | qsc_codepython_frac_lines_import_quality_signal float64 | qsc_codepython_frac_lines_simplefunc_quality_signal float64 | qsc_codepython_score_lines_no_logic_quality_signal float64 | qsc_codepython_frac_lines_print_quality_signal float64 | qsc_code_num_words int64 | qsc_code_num_chars int64 | qsc_code_mean_word_length int64 | qsc_code_frac_words_unique null | qsc_code_frac_chars_top_2grams int64 | qsc_code_frac_chars_top_3grams int64 | qsc_code_frac_chars_top_4grams int64 | qsc_code_frac_chars_dupe_5grams int64 | qsc_code_frac_chars_dupe_6grams int64 | qsc_code_frac_chars_dupe_7grams int64 | qsc_code_frac_chars_dupe_8grams int64 | qsc_code_frac_chars_dupe_9grams int64 | qsc_code_frac_chars_dupe_10grams int64 | qsc_code_frac_chars_replacement_symbols int64 | qsc_code_frac_chars_digital int64 | qsc_code_frac_chars_whitespace int64 | qsc_code_size_file_byte int64 | qsc_code_num_lines int64 | qsc_code_num_chars_line_max int64 | qsc_code_num_chars_line_mean int64 | qsc_code_frac_chars_alphabet int64 | qsc_code_frac_chars_comments int64 | qsc_code_cate_xml_start int64 | qsc_code_frac_lines_dupe_lines int64 | qsc_code_cate_autogen int64 | qsc_code_frac_lines_long_string int64 | qsc_code_frac_chars_string_length int64 | qsc_code_frac_chars_long_word_length int64 | qsc_code_frac_lines_string_concat null | qsc_code_cate_encoded_data int64 | qsc_code_frac_chars_hex_words int64 | qsc_code_frac_lines_prompt_comments int64 | qsc_code_frac_lines_assert int64 | qsc_codepython_cate_ast int64 | qsc_codepython_frac_lines_func_ratio int64 | qsc_codepython_cate_var_zero int64 | qsc_codepython_frac_lines_pass int64 | qsc_codepython_frac_lines_import int64 | qsc_codepython_frac_lines_simplefunc int64 | qsc_codepython_score_lines_no_logic int64 | qsc_codepython_frac_lines_print int64 | effective string | hits int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1b3fc56f89b286cd3e7f74268441f669d3653b53 | 1,028 | py | Python | T1/code/linearRegCostFunction.py | andersonmanhaes/ml_mestrado | d737d80e07d9392895e4455e49a33b8700080cf1 | [
"MIT"
] | null | null | null | T1/code/linearRegCostFunction.py | andersonmanhaes/ml_mestrado | d737d80e07d9392895e4455e49a33b8700080cf1 | [
"MIT"
] | null | null | null | T1/code/linearRegCostFunction.py | andersonmanhaes/ml_mestrado | d737d80e07d9392895e4455e49a33b8700080cf1 | [
"MIT"
] | null | null | null | def calculateCost_linearReg(theta, X, y, lambda_):
y_pred = X.dot(theta.T)
m = len(y)
# Cálculo do custo
cost = (1/(2*m))*np.sum(np.square(y_pred-y))
regularization_component = (lambda_/(2*m)) * np.sum(np.square(theta[1:]))
J = cost + regularization_component
return J
def linearRegCostFunction(theta, X, y, lambda_):
"""
Método que implementa o cálculo do custo da regressão linear regularizada e do gradiente descendente
"""
# definição das variáveis
theta = np.array(theta, ndmin=2)
m = len(y)
y = np.array(y, ndmin=2).T
theta_size = 2
grad = np.zeros(theta_size)
# Cálculo do custo
J = calculateCost_linearReg(theta, X, y, lambda_)
print("J= {}".format(str(J)))
# atualização de theta
for j in range(theta_size):
value = 0
for i in range(m):
value += (X[i].dot(theta.T) - y[i]) * X[i][j]
if j > 0:
value += (lambda_/m) * theta[:,j]
grad[j] = (value*(1/m))
return grad
| 24.47619 | 104 | 0.585603 | 152 | 1,028 | 3.868421 | 0.375 | 0.030612 | 0.035714 | 0.066327 | 0.170068 | 0.170068 | 0 | 0 | 0 | 0 | 0 | 0.013298 | 0.268482 | 1,028 | 41 | 105 | 25.073171 | 0.768617 | 0.075875 | 0 | 0.083333 | 0 | 0 | 0.006017 | 0 | 0 | 0 | 0 | 0.02439 | 0 | 0 | null | null | 0 | 0 | null | null | 0.041667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1b4145ca16b8a751b4a5845d04dc9bbf5cd57a2a | 474 | py | Python | fineants/admin.py | n2o/FineAnts | 2272a9db38c42a650bd51fea369fe2d106dbfddc | [
"MIT"
] | null | null | null | fineants/admin.py | n2o/FineAnts | 2272a9db38c42a650bd51fea369fe2d106dbfddc | [
"MIT"
] | null | null | null | fineants/admin.py | n2o/FineAnts | 2272a9db38c42a650bd51fea369fe2d106dbfddc | [
"MIT"
] | null | null | null | from django.contrib import admin
from .models import Transaction
class TransactionAdmin(admin.ModelAdmin):
list_display = ('title', 'creditor', 'amount', 'created')
search_fields = ['title', 'creditor', 'amount', 'created']
fieldsets = [
('General', {'fields': ['title', 'creditor', 'debitors', 'amount', 'description']}),
('Meta', {'fields': ['created'], 'classes': ['collapse']}),
]
admin.site.register(Transaction, TransactionAdmin) | 33.857143 | 92 | 0.64135 | 43 | 474 | 7.023256 | 0.627907 | 0.129139 | 0.125828 | 0.172185 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.164557 | 474 | 14 | 93 | 33.857143 | 0.762626 | 0 | 0 | 0 | 0 | 0 | 0.284211 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
1b517be94e019b3e5e2eade3f88b2b7ef1162829 | 1,056 | py | Python | diofant/domains/__init__.py | project-kotinos/diofant___diofant | 882549ac3a4dac238695aa620c02fce6ca33f9d3 | [
"BSD-3-Clause"
] | 1 | 2021-08-22T09:34:15.000Z | 2021-08-22T09:34:15.000Z | diofant/domains/__init__.py | project-kotinos/diofant___diofant | 882549ac3a4dac238695aa620c02fce6ca33f9d3 | [
"BSD-3-Clause"
] | null | null | null | diofant/domains/__init__.py | project-kotinos/diofant___diofant | 882549ac3a4dac238695aa620c02fce6ca33f9d3 | [
"BSD-3-Clause"
] | null | null | null | """Implementation of mathematical domains. """
from ..core.compatibility import GROUND_TYPES
from . import (algebraicfield, complexfield, domain, expressiondomain,
finitefield, integerring, rationalfield, realfield)
from .algebraicfield import (AlgebraicField, ComplexAlgebraicField,
RealAlgebraicField)
from .complexfield import CC, ComplexField
from .domain import Domain
from .expressiondomain import EX, ExpressionDomain
from .finitefield import FiniteField
from .finitefield import GMPYFiniteField as FF_gmpy
from .finitefield import PythonFiniteField as FF_python
from .groundtypes import PythonRational
from .integerring import IntegerRing, ZZ_gmpy, ZZ_python
from .rationalfield import QQ_gmpy, QQ_python, RationalField
from .realfield import RR, RealField
_GROUND_TYPES_MAP = {'gmpy': (FF_gmpy, ZZ_gmpy, QQ_gmpy),
'python': (FF_python, ZZ_python, QQ_python)}
FF, ZZ, QQ = _GROUND_TYPES_MAP[GROUND_TYPES]
GF = FF
# Remove clash with functions of polys module:
del ring
del field
| 37.714286 | 70 | 0.768939 | 121 | 1,056 | 6.545455 | 0.363636 | 0.055556 | 0.079545 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | 1,056 | 27 | 71 | 39.111111 | 0.9 | 0.081439 | 0 | 0 | 0 | 0 | 0.010373 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.619048 | 0 | 0.619048 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
1b5651c01570f182f6cf1b307750f9acd4bba20e | 3,053 | py | Python | helpdesk/decorators.py | eazaika/django-helpdesk | 2e1d950fbe3dac07e06003313264e5eeb4d39e3d | [
"CC-BY-3.0",
"BSD-3-Clause"
] | 1 | 2019-12-30T11:46:07.000Z | 2019-12-30T11:46:07.000Z | helpdesk/decorators.py | eazaika/django-helpdesk | 2e1d950fbe3dac07e06003313264e5eeb4d39e3d | [
"CC-BY-3.0",
"BSD-3-Clause"
] | null | null | null | helpdesk/decorators.py | eazaika/django-helpdesk | 2e1d950fbe3dac07e06003313264e5eeb4d39e3d | [
"CC-BY-3.0",
"BSD-3-Clause"
] | null | null | null | from functools import wraps
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.shortcuts import redirect
from django.utils.decorators import available_attrs
from django.shortcuts import get_object_or_404
from helpdesk import settings as helpdesk_settings
from helpdesk.models import Ticket
def protect_view(view_func):
"""
Decorator for protecting the views checking user, redirecting
to the log-in page if necessary or returning 404 status code
"""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if not request.user.is_authenticated and helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT:
return redirect('helpdesk:login')
elif not request.user.is_authenticated and helpdesk_settings.HELPDESK_ANON_ACCESS_RAISES_404:
raise Http404
return view_func(request, *args, **kwargs)
return _wrapped_view
def staff_member_or_submitter_required(view_func):
"""
Decorator for staff member the views checking user, redirecting
to the log-in page if necessary or returning 403
"""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
try:
ticket = get_object_or_404(Ticket, id=kwargs['ticket_id'])
user_is_submitter = (request.user.email == ticket.submitter_email)
except:
user_is_submitter = False
if not request.user.is_authenticated and not request.user.is_active:
return redirect('helpdesk:login')
if not helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE and not request.user.is_staff and not user_is_submitter:
raise PermissionDenied()
return view_func(request, *args, **kwargs)
return _wrapped_view
def staff_member_required(view_func):
"""
Decorator for staff member the views checking user, redirecting
to the log-in page if necessary or returning 403
"""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if not request.user.is_authenticated and not request.user.is_active:
return redirect('helpdesk:login')
if not helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE and not request.user.is_staff:
raise PermissionDenied()
return view_func(request, *args, **kwargs)
return _wrapped_view
def superuser_required(view_func):
"""
Decorator for superuser member the views checking user, redirecting
to the log-in page if necessary or returning 403
"""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if not request.user.is_authenticated and not request.user.is_active:
return redirect('helpdesk:login')
if not request.user.is_superuser:
raise PermissionDenied()
return view_func(request, *args, **kwargs)
return _wrapped_view
| 37.231707 | 128 | 0.725188 | 397 | 3,053 | 5.34005 | 0.198992 | 0.060377 | 0.072642 | 0.083019 | 0.711321 | 0.691981 | 0.691981 | 0.691981 | 0.691981 | 0.654245 | 0 | 0.011093 | 0.202751 | 3,053 | 81 | 129 | 37.691358 | 0.859901 | 0.152309 | 0 | 0.530612 | 0 | 0 | 0.025886 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.163265 | false | 0 | 0.163265 | 0 | 0.571429 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
1b57f847831d7fdfa915e384a7a0ba3fedd78661 | 709 | py | Python | src/models/knnRegressor.py | python-like-r/python-like-r | 6f787ad3c2688b44569361976f11da7bab1c8a68 | [
"Apache-2.0"
] | null | null | null | src/models/knnRegressor.py | python-like-r/python-like-r | 6f787ad3c2688b44569361976f11da7bab1c8a68 | [
"Apache-2.0"
] | null | null | null | src/models/knnRegressor.py | python-like-r/python-like-r | 6f787ad3c2688b44569361976f11da7bab1c8a68 | [
"Apache-2.0"
] | null | null | null | from sklearn.neighbors import KNeighborsRegressor
from src.models.BaseRegressor import BaseRegressor
class knnRegressor(BaseRegressor):
"""KNN regressor wrapper for sklearn class KNeighborsRegressor.
:formula: a string with the formula for y in terms of x_is
:k: number of neighbors"""
def __init__(self, formula, data=None, k = 3):
# Initializing parent class
super(knnRegressor, self).__init__(formula+"+0", data)
self.sklearnModel = KNeighborsRegressor(n_neighbors = k)
self.k = k
def fit(self):
self.sklearnModel.fit(self.X, self.y)
def predict(self, newdata):
X = self.getX(newdata)
return self.sklearnModel.predict(X)
| 32.227273 | 67 | 0.692525 | 88 | 709 | 5.465909 | 0.5 | 0.099792 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003591 | 0.214386 | 709 | 21 | 68 | 33.761905 | 0.859964 | 0.239774 | 0 | 0 | 0 | 0 | 0.00381 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.166667 | 0 | 0.583333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
1b5bccf0e23f373262b56b7f9bbd1320c5e84258 | 1,892 | py | Python | codewars/range-extraction.py | austinmccalley/challenge-sites | a0bb8d36894e7b298ffe8a2f0d3bd1a34ff3224f | [
"MIT"
] | null | null | null | codewars/range-extraction.py | austinmccalley/challenge-sites | a0bb8d36894e7b298ffe8a2f0d3bd1a34ff3224f | [
"MIT"
] | null | null | null | codewars/range-extraction.py | austinmccalley/challenge-sites | a0bb8d36894e7b298ffe8a2f0d3bd1a34ff3224f | [
"MIT"
] | null | null | null | def check_next_num(inp, j):
for i in range(j, len(inp)):
elm = inp[i]
if len(inp) > i+1:
if inp[i+1] == (elm+1):
check_next_num(inp, i+1)
else:
if j == 0:
return i
return i
else:
return len(inp)-1
def solution(inp):
"""
1. Sort inp
2. Check to see if next in inp slist is the next value
"""
inp.sort()
ranges = []
res = []
for i in range(len(inp)):
l = check_next_num(inp, i)
ranges.append([i, l])
print([i, l])
seen = []
for r in ranges:
si = r[0]
ei = r[1]
sv = inp[si]
ev = inp[ei]
if ei not in seen:
if ev == sv:
res.append(str(ev))
seen.append(ei)
if (ev - sv) >= 2:
s = str(sv)+'-'+str(ev)
res.append(s)
seen.append(ei)
elif (ev-sv) == 1:
res.append(str(sv))
return (",".join(res))
print(ranges)
#Indexs 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
solution([-6,-3,-2,-1,0,1,3,4,5,7,8, 9, 10,11,14,15,17,18,19,20])
"""
[0,0], [1,5], [6,13], [14,15], [17, 19]
[[0, 0], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 8], [7, 8], [8, 8], [9, 13], [10, 13], [11, 13], [12, 13], [13, 13], [14, 15], [15, 15], [16, 19]
-6,-3-1,3-5,7-11,14,15,17-20
-6,-3-1,3-5,7-11,14,15,17-20
-6,-3-1,3-5,7-11,14,15,17-20
"""
#Indexes 0 1 2 3 4 5 6 7 8 9
# solution([-3,-2,-1,2,10,15,16,18,19,20])
"""
[0, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 9]
[[0, 2], [3, 3], [4, 4], [5, 6], [6, 6], [7, 9]]
[[0, 0], [1, 2], [2, 2], [3, 3], [4, 4], [5, 6], [6, 6], [7, 9], [8, 9], [9, 9]]
-3--1,2,10,15,16,18-20
-3--1,2,10,15,16,18-20
-3,-2,-1,2,10,15,16,18-20
""" | 22 | 150 | 0.391121 | 358 | 1,892 | 2.050279 | 0.173184 | 0.019074 | 0.040872 | 0.043597 | 0.269755 | 0.20436 | 0.20436 | 0.190736 | 0.159401 | 0.122616 | 0 | 0.245585 | 0.371564 | 1,892 | 86 | 151 | 22 | 0.371741 | 0.109408 | 0 | 0.153846 | 0 | 0 | 0.001799 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.051282 | false | 0 | 0 | 0 | 0.153846 | 0.051282 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1b6c108a89deea1582291919e5917a54458ec433 | 6,670 | py | Python | src/assay/assay2table.py | lmsac/GproDIA | 3fc1cdee535c9743806b7be423aba29daca24406 | [
"BSD-3-Clause"
] | 2 | 2021-11-13T21:37:42.000Z | 2021-11-16T07:40:06.000Z | src/assay/assay2table.py | lmsac/GproDIA | 3fc1cdee535c9743806b7be423aba29daca24406 | [
"BSD-3-Clause"
] | null | null | null | src/assay/assay2table.py | lmsac/GproDIA | 3fc1cdee535c9743806b7be423aba29daca24406 | [
"BSD-3-Clause"
] | null | null | null | from .modseq import stringify_modification
import pandas as pd
from collections import OrderedDict
class AssayToDataFrameConverter:
def __init__(self, columns=None):
if columns is None:
columns = default_columns()
self.columns = columns
def assay_to_dataframe(self, assay, **kwargs):
def convert_column(column, assay):
value = None
path = column.get('path', None)
if isinstance(path, str):
if path in assay:
value = assay[path]
elif isinstance(path, list):
result = assay
for i, field in enumerate(path):
if i == len(path) - 1 and field in result:
value = result[field]
break
result = result.get(field, None)
if result is None:
break
if value is not None:
convert = column.get('convert', None)
if callable(convert):
value = convert(value)
return value
func = column.get('function', None)
if callable(func):
return func(assay, **kwargs)
default = column.get('default', None)
return default
d = OrderedDict((
(column['name'], convert_column(column, assay))
for column in self.columns
))
if not any((
isinstance(x, list) or isinstance(x, tuple)
for x in d.values()
)):
return pd.DataFrame(d, index=[0])
else:
return pd.DataFrame.from_dict(d)
def assays_to_dataframe(self, assays, **kwargs):
return pd.concat((
self.assay_to_dataframe(x, index=i, **kwargs)
for i, x in enumerate(assays)
), ignore_index=True)
def default_columns():
info = [
{
'name': 'peptideSequence',
'path': 'peptideSequence'
},
{
'name': 'modification',
'path': 'modification',
'convert': stringify_modification,
},
{
'name': 'precursorCharge',
'path': 'precursorCharge',
}
]
precursor = [
{
'name': 'precursorMz',
'path': 'precursorMZ'
},
{
'name': 'retentionTime',
'path': 'rt'
},
]
fragment = [
{
'name': 'fragmentMz',
'path': ['fragments', 'fragmentMZ']
},
{
'name': 'fragmentIntensity',
'path': ['fragments', 'fragmentIntensity']
},
{
'name': 'fragmentType',
'path': ['fragments', 'fragmentType']
},
{
'name': 'fragmentNumber',
'path': ['fragments', 'fragmentNumber']
},
{
'name': 'fragmentCharge',
'path': ['fragments', 'fragmentCharge']
},
{
'name': 'fragmentAnnotation',
'path': ['fragments', 'fragmentAnnotation']
}
]
metadata = [
{
'name': 'protein',
'path': ['metadata', 'protein']
},
{
'name': 'decoy',
'path': ['metadata', 'decoy'],
'default': False
}
]
return info + precursor + fragment + metadata
if __name__ == '__main__':
converter = AssayToDataFrameConverter()
assay0 = {
'modification': None,
'precursorCharge': 2,
'precursorMZ': 1184.6093373850001,
'peptideSequence': 'AAAAAAAAAPAAAATAPTTAATTAATAAQ',
'fragments': {
'fragmentMZ': [201.08698363000033, 214.118618035, 285.155732035, 356.192846035, 427.229960035, 498.26707403499995, 569.3041880349999, 640.3413020349999, 737.3940660349999, 808.4311800349999, 879.4682940349999, 950.5054080349998, 1021.5425220349998, 1122.5902010349996, 1193.6273150349996, 218.11353273500032, 289.1506467350005, 390.19832573500054, 461.2354397350005, 532.2725537350005, 633.3202327350006, 734.3679117350006, 805.4050257350005, 876.4421397350005, 977.4898187350005, 1078.5374977350004, 1175.5902617350005, 1246.6273757350004, 1728.8762747350002, 1799.9133887350004, 1104.5796363349996, 1175.6167503349996, 1060.5269330350004, 1157.5796970350004, 1228.6168110350004, 1710.8657100350001, 696.3675170349999, 868.4523100349999, 954.4947065349999, 816.4153933850001, 807.4101110350001],
'fragmentNumber': [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 20, 21, 15, 16, 12, 13, 14, 20, 18, 22, 24, 19, 19],
'fragmentLossType': ['NH3', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'noloss', 'H2O', 'H2O', 'H2O', 'H2O', 'H2O', 'H2O', 'noloss', 'noloss', 'noloss', 'noloss', 'H2O'],
'fragmentType': ['y', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'b', 'b', 'y', 'y', 'y', 'y', 'b', 'b', 'b', 'y', 'y'],
'fragmentAnnotation': ['y2-NH3^+1', 'b3^+1', 'b4^+1', 'b5^+1', 'b6^+1', 'b7^+1', 'b8^+1', 'b9^+1', 'b10^+1', 'b11^+1', 'b12^+1', 'b13^+1', 'b14^+1', 'b15^+1', 'b16^+1', 'y2^+1', 'y3^+1', 'y4^+1', 'y5^+1', 'y6^+1', 'y7^+1', 'y8^+1', 'y9^+1', 'y10^+1', 'y11^+1', 'y12^+1', 'y13^+1', 'y14^+1', 'y20^+1', 'y21^+1', 'b15-H2O^+1', 'b16-H2O^+1', 'y12-H2O^+1', 'y13-H2O^+1', 'y14-H2O^+1', 'y20-H2O^+1', 'b18^+2', 'b22^+2', 'b24^+2', 'y19^+2', 'y19-H2O^+2'],
'fragmentIntensity': [22774.28, 157563.6, 444095.9, 993978.3, 1666265, 2408575, 3411004, 2116178, 258959.3, 298698, 278765, 255920.5, 139878.8, 119512, 82443.61, 430567.5, 52544.59, 183384.2, 105601.1, 72300.24, 56770.18, 70014.88, 18832.65, 17846.54, 113519.6, 118261.5, 488446.9, 97438.05, 273214.5, 16548.61, 117036.2, 488446.9, 25312.04, 134764.2, 24459.05, 77885.37, 107844.3, 19617.25, 18051.07, 18561.47, 18938.11],
'fragmentCharge': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
}
}
print(converter.assay_to_dataframe(assay0)) | 43.594771 | 809 | 0.507046 | 717 | 6,670 | 4.677824 | 0.393305 | 0.020871 | 0.030411 | 0.039356 | 0.098688 | 0.084377 | 0.081992 | 0.081992 | 0.081992 | 0.081992 | 0 | 0.261384 | 0.315142 | 6,670 | 153 | 810 | 43.594771 | 0.472855 | 0 | 0 | 0.015152 | 0 | 0 | 0.188577 | 0.004347 | 0 | 0 | 0 | 0 | 0 | 1 | 0.037879 | false | 0 | 0.022727 | 0.007576 | 0.121212 | 0.007576 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1b7978c6313f4e37e912e7c9a269114e035758e2 | 1,193 | py | Python | tests/test_sieve.py | calina-c/flask-sieve | 564edbed530ba631ceb44672f3f4606941a18d11 | [
"BSD-2-Clause"
] | 39 | 2019-04-07T18:50:25.000Z | 2021-08-05T02:49:52.000Z | tests/test_sieve.py | calina-c/flask-sieve | 564edbed530ba631ceb44672f3f4606941a18d11 | [
"BSD-2-Clause"
] | 18 | 2020-03-29T05:25:19.000Z | 2022-03-11T23:45:11.000Z | tests/test_sieve.py | calina-c/flask-sieve | 564edbed530ba631ceb44672f3f4606941a18d11 | [
"BSD-2-Clause"
] | 8 | 2019-04-12T20:18:07.000Z | 2021-06-23T09:24:39.000Z | import unittest
from flask import Flask
from flask_sieve import Sieve
from flask_sieve.exceptions import ValidationException
class TestSieve(unittest.TestCase):
def test_registers_error_handler(self):
app = Flask(__name__)
Sieve(app)
self.assertIn(ValidationException, app.error_handler_spec[None][None])
errors = {'field': 'Test error'}
with app.app_context():
response, status = app.error_handler_spec[None][None][ValidationException](
ValidationException(errors)
)
self.assertEqual(400, status)
self.assertIn('Test error', str(response.get_json()))
def test_deferring_registration_of_error_handler(self):
app = Flask(__name__)
s = Sieve()
s.init_app(app)
self.assertIn(ValidationException, app.error_handler_spec[None][None])
errors = {'field': 'Test error'}
with app.app_context():
response, status = app.error_handler_spec[None][None][ValidationException](
ValidationException(errors)
)
self.assertEqual(400, status)
self.assertIn('Test error', str(response.get_json()))
| 31.394737 | 87 | 0.65549 | 129 | 1,193 | 5.821705 | 0.286822 | 0.095872 | 0.079893 | 0.101198 | 0.729694 | 0.729694 | 0.655127 | 0.655127 | 0.655127 | 0.655127 | 0 | 0.00663 | 0.241408 | 1,193 | 37 | 88 | 32.243243 | 0.823204 | 0 | 0 | 0.571429 | 0 | 0 | 0.041911 | 0 | 0 | 0 | 0 | 0 | 0.214286 | 1 | 0.071429 | false | 0 | 0.142857 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1b7aa443f68b0dbd0041968bb702196223c9c46d | 2,654 | py | Python | logpuzzle/logpuzzle.py | alexeiva/google-python-exercises | f924b07a8f57e5c9384fca8e69aff74171ec37f6 | [
"Apache-2.0"
] | null | null | null | logpuzzle/logpuzzle.py | alexeiva/google-python-exercises | f924b07a8f57e5c9384fca8e69aff74171ec37f6 | [
"Apache-2.0"
] | null | null | null | logpuzzle/logpuzzle.py | alexeiva/google-python-exercises | f924b07a8f57e5c9384fca8e69aff74171ec37f6 | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/python
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
import os
import re
import sys
import urllib
"""Logpuzzle exercise
Given an apache logfile, find the puzzle urls and download the images.
Here's what a puzzle url looks like:
10.254.254.28 - - [06/Aug/2007:00:13:48 -0700] "GET /~foo/puzzle-bar-aaab.jpg HTTP/1.0" 302 528 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"
"""
def read_urls(filename):
"""Returns a list of the puzzle urls from the given log file,
extracting the hostname from the filename itself.
Screens out duplicate urls and returns the urls sorted into
increasing order."""
# +++your code here+++
url_list = []
matches = []
pattern = r'\S+puzzle\S+'
hostname = r'http://code.google.com'
with open(filename, 'r') as f:
matches = re.findall(pattern, f.read())
for m in matches:
if m not in url_list:
url_list.append(hostname + m)
url_list = sorted(set(url_list))
return url_list
def smartsort(url_list):
places_back = []
for i in url_list:
r = re.sub(r'(\w\w\w\w)-(\w\w\w\w).jpg', r'\2-\1.jpg', i)
places_back.append(r)
places_back = sorted(places_back)
places_front = []
for i in places_back:
r = re.sub(r'(\w\w\w\w)-(\w\w\w\w).jpg', r'\2-\1.jpg', i)
places_front.append(r)
return places_front
def download_images(img_urls, dest_dir):
"""Given the urls already in the correct order, downloads
each image into the given directory.
Gives the images local filenames img0, img1, and so on.
Creates an index.html in the directory
with an img tag to show each local image file.
Creates the directory if necessary.
"""
# +++your code here+++
if not os.path.isdir(dest_dir):
os.mkdir(dest_dir)
html = '''
<verbatim>
<html>
<body>
'''
for i,v in enumerate(img_urls):
mydir = dest_dir + "/img%i.jpg" % i
print "Retrieving img %i of %i..." % (i, len(img_urls) - 1)
urllib.urlretrieve(v, mydir)
html += "<img src='%s'/>" % (mydir)
html += '''
</body>
</html>
'''
with open('index.html', 'a') as f:
f.write(html)
def main():
args = sys.argv[1:]
if not args:
print 'usage: [--todir dir] logfile '
sys.exit(1)
todir = ''
if args[0] == '--todir':
todir = args[1]
del args[0:2]
img_urls = smartsort(read_urls(args[0]))
if todir:
download_images(img_urls, todir)
else:
print '\n'.join(img_urls)
if __name__ == '__main__':
main()
| 24.803738 | 192 | 0.644687 | 441 | 2,654 | 3.793651 | 0.38322 | 0.016736 | 0.021518 | 0.023909 | 0.037059 | 0.037059 | 0.037059 | 0.037059 | 0.037059 | 0.037059 | 0 | 0.035832 | 0.200829 | 2,654 | 106 | 193 | 25.037736 | 0.752947 | 0.096081 | 0 | 0.064516 | 0 | 0 | 0.164766 | 0.031686 | 0 | 0 | 0 | 0.018868 | 0 | 0 | null | null | 0 | 0.064516 | null | null | 0.048387 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1b86bc0456bb918d52a048819d68b56506c2ba5b | 149 | py | Python | bin/2048.py | gab50000/2048 | bc114f6ec76e83a1bbcd7a9c91392eaba559c83d | [
"MIT"
] | null | null | null | bin/2048.py | gab50000/2048 | bc114f6ec76e83a1bbcd7a9c91392eaba559c83d | [
"MIT"
] | null | null | null | bin/2048.py | gab50000/2048 | bc114f6ec76e83a1bbcd7a9c91392eaba559c83d | [
"MIT"
] | null | null | null | #!/usr/bin/python
import sys
sys.path.append("..")
import game
import main
g = game.Spielfeld()
mw = main.MainWindow(g)
with mw:
mw.application() | 12.416667 | 23 | 0.697987 | 23 | 149 | 4.521739 | 0.652174 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.134228 | 149 | 12 | 24 | 12.416667 | 0.806202 | 0.107383 | 0 | 0 | 0 | 0 | 0.015038 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.375 | 0 | 0.375 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
1b900a5b075c856e752ab150a3c246e81d244fb0 | 2,656 | py | Python | src/hardware_indep/actions.c.py | GEANT-DataPlaneProgramming/t4p4s | 334dec8e941ed7526d320fc1697ad7a30c3709fb | [
"Apache-2.0"
] | 85 | 2017-06-17T04:13:52.000Z | 2022-03-25T08:28:23.000Z | src/hardware_indep/actions.c.py | GEANT-DataPlaneProgramming/t4p4s | 334dec8e941ed7526d320fc1697ad7a30c3709fb | [
"Apache-2.0"
] | 31 | 2017-05-29T17:51:20.000Z | 2022-03-16T19:36:12.000Z | src/hardware_indep/actions.c.py | GEANT-DataPlaneProgramming/t4p4s | 334dec8e941ed7526d320fc1697ad7a30c3709fb | [
"Apache-2.0"
] | 42 | 2017-03-07T12:17:25.000Z | 2021-12-13T09:20:15.000Z | # SPDX-License-Identifier: Apache-2.0
# Copyright 2016 Eotvos Lorand University, Budapest, Hungary
from compiler_log_warnings_errors import addError, addWarning
from utils.codegen import format_declaration, format_statement, format_expr, format_type, get_method_call_env
from compiler_common import types, unique_everseen
#[ #include <unistd.h>
#[ #include "dpdk_lib.h"
#[ #include "actions.h"
#[ #include "util_debug.h"
#[ #include "util_packet.h"
#[ extern ctrl_plane_backend bg;
################################################################################
#[ #define STD_DIGEST_RECEIVER_ID 1024
# TODO make it unique by digest name
for mcall in hlir.all_nodes.by_type('MethodCallStatement').map('methodCall').filter(lambda n: 'path' in n.method and n.method.path.name=='digest'):
digest = mcall.typeArguments[0]
funname = f'{mcall.method.path.name}__{digest.path.name}'
#{ ${format_type(mcall.urtype)} $funname(uint32_t /* ignored */ receiver, ctrl_plane_digest cpd, SHORT_STDPARAMS) {
#[ debug(" " T4LIT(<<<<,outgoing) " " T4LIT(Sending digest,outgoing) " to port " T4LIT(%d,port) " using extern " T4LIT(extern_Digest_pack,extern) " for " T4LIT(cpd,extern) "\n", STD_DIGEST_RECEIVER_ID);
#[ /* ctrl_plane_digest cpd = create_digest(bg, "digest");
for fld in digest.urtype.fields:
if fld.urtype.size > 32:
#[ dbg_bytes(digest.${fld.name}, (${fld.urtype.size}+7)/8, " : $[field]{fld.name}/" T4LIT(${fld.urtype.size}) " = ");
#[ add_digest_field(cpd, digest.${fld.name}, ${fld.urtype.size});
else:
#[ debug(" : " T4LIT(ingress_port,field) "/" T4LIT(${fld.urtype.size}) " = " T4LIT(%x) "\n", digest.${fld.name});
#[ add_digest_field(cpd, &(digest.${fld.name}), ${fld.urtype.size});
#[ */
#{ #ifdef T4P4S_P4RT
#[ // dev_mgr_send_digest(dev_mgr_ptr, (struct p4_digest*)(((Digest_t*)cpd)->ctrl_plane_digest), STD_DIGEST_RECEIVER_ID);
#} #endif
#[ send_digest(bg, cpd, STD_DIGEST_RECEIVER_ID);
#[ sleep_millis(DIGEST_SLEEP_MILLIS);
#} }
#[
#{ const char* action_names[] = {
for table in hlir.tables:
for action in unique_everseen(table.actions):
#[ "${action.action_object.name}",
#} };
#[
#{ const char* action_canonical_names[] = {
for table in hlir.tables:
for action in unique_everseen(table.actions):
#[ "${action.action_object.canonical_name}",
#} };
#[
#{ const char* action_short_names[] = {
for table in hlir.tables:
for action in unique_everseen(table.actions):
#[ "${action.action_object.short_name}",
#} };
#[
| 37.942857 | 210 | 0.634036 | 333 | 2,656 | 4.828829 | 0.384384 | 0.033582 | 0.048507 | 0.047264 | 0.218905 | 0.218905 | 0.202736 | 0.202736 | 0.202736 | 0.202736 | 0 | 0.013736 | 0.177711 | 2,656 | 69 | 211 | 38.492754 | 0.722527 | 0.594503 | 0 | 0.4 | 0 | 0 | 0.087368 | 0.046316 | 0 | 0 | 0 | 0.014493 | 0 | 0 | null | null | 0 | 0.2 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1b98bc661cf1c221325c6c691a4a95019a2deabd | 800 | py | Python | locfilm/locations/migrations/0003_auto_20201012_0249.py | locfilm/locfilm-api | 85942f83f790e96dda043437ab227d38939f1f69 | [
"MIT"
] | null | null | null | locfilm/locations/migrations/0003_auto_20201012_0249.py | locfilm/locfilm-api | 85942f83f790e96dda043437ab227d38939f1f69 | [
"MIT"
] | 6 | 2020-09-27T21:44:11.000Z | 2021-06-10T20:12:26.000Z | locfilm/locations/migrations/0003_auto_20201012_0249.py | locfilm/locfilm-api | 85942f83f790e96dda043437ab227d38939f1f69 | [
"MIT"
] | 2 | 2020-09-22T02:06:03.000Z | 2020-09-22T02:12:51.000Z | # Generated by Django 3.1.1 on 2020-10-12 02:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('locations', '0002_auto_20201005_2106'),
]
operations = [
migrations.AlterField(
model_name='location',
name='address',
field=models.CharField(max_length=150, verbose_name='local address'),
),
migrations.AlterField(
model_name='location',
name='contact_email',
field=models.EmailField(max_length=254, verbose_name='contact email'),
),
migrations.AlterField(
model_name='location',
name='name',
field=models.CharField(max_length=100, verbose_name='location name'),
),
]
| 27.586207 | 82 | 0.59625 | 81 | 800 | 5.728395 | 0.518519 | 0.103448 | 0.137931 | 0.1875 | 0.390086 | 0.265086 | 0 | 0 | 0 | 0 | 0 | 0.070299 | 0.28875 | 800 | 28 | 83 | 28.571429 | 0.745167 | 0.05625 | 0 | 0.409091 | 1 | 0 | 0.158035 | 0.030544 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.045455 | 0 | 0.181818 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1b9a6c96b41d0ee3d680f4c3b984e3df8632c84a | 9,305 | py | Python | heliocats/stats.py | cmoestl/heliocats | 5e2b054990319e14859669561a361cc0c7ca4295 | [
"MIT"
] | 4 | 2020-10-03T07:39:56.000Z | 2022-03-28T12:39:54.000Z | heliocats/stats.py | cmoestl/heliocats | 5e2b054990319e14859669561a361cc0c7ca4295 | [
"MIT"
] | 2 | 2021-01-08T13:21:54.000Z | 2022-03-12T00:11:50.000Z | heliocats/stats.py | cmoestl/heliocats | 5e2b054990319e14859669561a361cc0c7ca4295 | [
"MIT"
] | 4 | 2020-04-09T13:49:50.000Z | 2020-06-18T04:36:07.000Z | #stats.py
#statistics stuff for heliocats
#https://github.com/cmoestl/heliocats
import numpy as np
import pandas as pd
import scipy.io
import urllib
import os
from config import data_path
from sunpy.time import parse_time
'''
import copy
import matplotlib.dates as mdates
import matplotlib
import seaborn as sns
import datetime
import json
import pdb
import scipy.io
import pickle
import sys
import cdflib
import matplotlib.pyplot as plt
import heliosat
from numba import njit
from astropy.time import Time
import astropy
import heliopy.data.spice as spicedata
import heliopy.spice as spice
'''
#######################################
def is_float(value):
try:
float(value)
return True
except:
return False
def running_mean(x, N):
return np.convolve(x, np.ones((N,))/N)[(N-1):]
def expon(x, a, k, b):
return a*np.exp(k*x) + b
def powerlaw(x, a, b):
return a*x**b
def gaussian_nox0(x, a,sigma):
return a*np.exp(-(x)**2/(2*sigma**2))
def gaussian(x, a, x0, sigma):
return a*np.exp(-(x-x0)**2/(2*sigma**2))
def hathaway_fit(x,x0, a, b, c):
#for numerical fitting of hathaway function
#x1 is input in days, convert to months
x1=(x-x0)/30.42
#print(x1[0])
hatfunc=a*(((x1)/b)**3) * 1/(np.exp((((x1)/b)**2))-c)
return hatfunc
def hathaway(x,x0, a, b, c):
#Hathaway 2015 equation 6 page 40
#average cycle sunspot number
#A=100 #amplitude ##195 for sunspot
#b=100*12 #56*12 for months to days
#c=0.8
#4 free parameters A, b, c, t0
#b=b*12 #months to days
x1=(parse_time(x).plot_date-parse_time(x0).plot_date)/30.42 #days
#print(len(x1),len(x))
hatfunc=a*(((x1)/b)**3) * 1/(np.exp((((x1)/b)**2))-c)
return hatfunc
def dynamic_pressure(density, speed):
'''
make dynamic pressure from density and speed
assume pdyn is only due to protons
'''
protonmass=1.6726219*1e-27 #kg
pdyn=np.multiply(np.square(speed*1e3),density)*1e6*protonmass*1e9 #in nanoPascal
return pdyn
def load_url_current_directory(filename,url):
'''
loads a file from any url to the current directory
I use owncloud for the direct url links,
also works for dropbox when changing the last 0 to 1 in the url-> gives a direct link to files
'''
if not os.path.exists(filename):
print('download file ', filename, ' from')
print(url)
try:
urllib.request.urlretrieve(url, filename)
print('done')
except urllib.error.URLError as e:
print(' ', data_url,' ',e.reason)
def getcat(filename):
cat = scipy.io.readsav(filename, verbose=False)
return cat
def decode_array(bytearrin):
'''
for decoding the strings from the IDL .sav file to a list of python strings, not bytes
make list of python lists with arbitrary length
'''
bytearrout = ['' for x in range(len(bytearrin))]
for i in range(0, len(bytearrin)):
bytearrout[i] = bytearrin[i].decode()
# has to be np array so to be used with numpy "where"
bytearrout = np.array(bytearrout)
return bytearrout
'''
def hathaway(x, a, b, c, x0):
return a*(((x-x0)/b)**3) * 1/(np.exp((((x-x0)/b)**2))-c)
paramh = scipy.optimize.curve_fit(hathaway, wt,wd)
#gaussian fits for daily new cases
newcases=np.gradient(cases)
paramg = scipy.optimize.curve_fit(gaussian, dates1, newcases )
ygfit=gaussian(dates_fut1,paramg[0][0],paramg[0][1],paramg[0][2])
#plt.plot_date(dates,newcases)
#plt.plot_date(dates_fut,ygfit,'-k')
print('Gaussian fit parameters:',paramg[0])
tests for gaussians and Hathaway's function for solar cycle, not used
Wind
tfit=mdates.date2num(sunpy.time.parse_time('2009-04-01'))+np.arange(0,365*10)
t0=mdates.date2num(sunpy.time.parse_time('2009-01-01'))
Gaussian
sigma=1000
bfitmax=30
mu=mdates.date2num(sunpy.time.parse_time('2013-01-01'))
ygauss=1/(sigma*np.sqrt(2*np.pi))*np.exp(-((xfit-mu)**2)/(2*sigma**2) )
normalize with 1/max(ygauss)
plt.plot_date(xfit, ygauss*1/max(ygauss)*bfitmax,'o',color='mediumseagreen',linestyle='-',markersize=0, label='Earth fit')
Hathaway 2015 equation 6 page 40
average cycle sunspot number
A=100 amplitude 195 for sunspot
b=100*12 56*12 for months to days
c=0.8
4 free parameters A, b, c, t0
Fwind=A*(((tfit-t0)/b)**3) * 1/(np.exp((((tfit-t0)/b)**2))-c)
plt.plot_date(tfit, Fwind,'o',color='mediumseagreen',linestyle='-',markersize=0, label='Earth fit')
xaxis: 10 years, daily data point
xfit2=mdates.date2num(sunpy.time.parse_time('2007-01-01'))+np.arange(0,365*10)
MESSENGER
sigma=1000
bfitmax=10
mu=mdates.date2num(sunpy.time.parse_time('2013-01-01'))
ygauss=1/(sigma*np.sqrt(2*np.pi))*np.exp(-((xfit2-mu)**2)/(2*sigma**2) )
normalize with 1/max(ygauss)
plt.plot_date(xfit, ygauss*1/max(ygauss)*bfitmax,'o',color='darkgrey',linestyle='-',markersize=0, label='Mercury fit')
VEX
inital guess
sigma=1000
bfitmax=20
mu=mdates.date2num(sunpy.time.parse_time('2013-01-01'))
ygauss=1/(sigma*np.sqrt(2*np.pi))*np.exp(-((xfit2-mu)**2)/(2*sigma**2) )
normalize with 1/max(ygauss)
plt.plot_date(xfit2, ygauss*1/max(ygauss)*bfitmax,'o',color='orange',linestyle='-',markersize=0, label='Venus fit')
for Mars: reconstruct likely parameters if sigma is quite similar for all fits, take mean of those sigmas and adjust bfitmax as function of distance with power law)
plot reconstructed function for Mars
bfitmax=40
plt.plot_date(xfit2, Fwind,'o',color='steelblue',linestyle='--',markersize=0, label='Mars reconstr.')
'''
'''
def hathaway(x, a, b, c, x0):
return a*(((x-x0)/b)**3) * 1/(np.exp((((x-x0)/b)**2))-c)
paramh = scipy.optimize.curve_fit(hathaway, wt,wd)
#gaussian fits for daily new cases
newcases=np.gradient(cases)
paramg = scipy.optimize.curve_fit(gaussian, dates1, newcases )
ygfit=gaussian(dates_fut1,paramg[0][0],paramg[0][1],paramg[0][2])
#plt.plot_date(dates,newcases)
#plt.plot_date(dates_fut,ygfit,'-k')
print('Gaussian fit parameters:',paramg[0])
tests for gaussians and Hathaway's function for solar cycle, not used
Wind
tfit=mdates.date2num(sunpy.time.parse_time('2009-04-01'))+np.arange(0,365*10)
t0=mdates.date2num(sunpy.time.parse_time('2009-01-01'))
Gaussian
sigma=1000
bfitmax=30
mu=mdates.date2num(sunpy.time.parse_time('2013-01-01'))
ygauss=1/(sigma*np.sqrt(2*np.pi))*np.exp(-((xfit-mu)**2)/(2*sigma**2) )
normalize with 1/max(ygauss)
plt.plot_date(xfit, ygauss*1/max(ygauss)*bfitmax,'o',color='mediumseagreen',linestyle='-',markersize=0, label='Earth fit')
Hathaway 2015 equation 6 page 40
average cycle sunspot number
A=100 amplitude 195 for sunspot
b=100*12 56*12 for months to days
c=0.8
4 free parameters A, b, c, t0
Fwind=A*(((tfit-t0)/b)**3) * 1/(np.exp((((tfit-t0)/b)**2))-c)
plt.plot_date(tfit, Fwind,'o',color='mediumseagreen',linestyle='-',markersize=0, label='Earth fit')
xaxis: 10 years, daily data point
xfit2=mdates.date2num(sunpy.time.parse_time('2007-01-01'))+np.arange(0,365*10)
MESSENGER
sigma=1000
bfitmax=10
mu=mdates.date2num(sunpy.time.parse_time('2013-01-01'))
ygauss=1/(sigma*np.sqrt(2*np.pi))*np.exp(-((xfit2-mu)**2)/(2*sigma**2) )
normalize with 1/max(ygauss)
plt.plot_date(xfit, ygauss*1/max(ygauss)*bfitmax,'o',color='darkgrey',linestyle='-',markersize=0, label='Mercury fit')
VEX
inital guess
sigma=1000
bfitmax=20
mu=mdates.date2num(sunpy.time.parse_time('2013-01-01'))
ygauss=1/(sigma*np.sqrt(2*np.pi))*np.exp(-((xfit2-mu)**2)/(2*sigma**2) )
normalize with 1/max(ygauss)
plt.plot_date(xfit2, ygauss*1/max(ygauss)*bfitmax,'o',color='orange',linestyle='-',markersize=0, label='Venus fit')
for Mars: reconstruct likely parameters if sigma is quite similar for all fits, take mean of those sigmas and adjust bfitmax as function of distance with power law)
plot reconstructed function for Mars
bfitmax=40
plt.plot_date(xfit2, Fwind,'o',color='steelblue',linestyle='--',markersize=0, label='Mars reconstr.')
#old version of B fits
# print('Fit results for B in Form: y=B0*x^k')
# ####### power law fits for all events
# bmaxfit=np.polyfit(np.log10(ic.mo_sc_heliodistance),np.log10(ic.mo_bmax),1)
# b=10**bmaxfit[1]
# bmaxfitfun=b*(xfit**bmaxfit[0])
# print('bmax: ',round(10**bmaxfit[1],2),' x ^', round(bmaxfit[0],2))
# bmeanfit=np.polyfit(np.log10(ic.mo_sc_heliodistance),np.log10(ic.mo_bmean),1)
# b=10**bmeanfit[1]
# bmeanfitfun=b*(xfit**bmeanfit[0])
# print('bmean: ', round(10**bmeanfit[1],2),' x ^',round(bmeanfit[0],2))
# ##fit with only minimum events
# bmeanfit_min=np.polyfit(np.log10(ic.mo_sc_heliodistance[iall_min]),np.log10(ic.mo_bmean[iall_min]),1)
# bmeanfitfun_min=(10**bmeanfit_min[1])*(xfit**bmeanfit_min[0])
# print('bmean_min: ', round(10**bmeanfit_min[1],2),' x ^', round(bmeanfit_min[0],2))
# ##fit with only rising events
# bmeanfit_rise=np.polyfit(np.log10(ic.mo_sc_heliodistance[iall_rise]),np.log10(ic.mo_bmean[iall_rise]),1)
# bmeanfitfun_rise=(10**bmeanfit_rise[1])*(xfit**bmeanfit_rise[0])
# print('bmean_rise: ', round(10**bmeanfit_rise[1],2),' x ^', round(bmeanfit_rise[0],2))
# ##fit with only maximum events
# bmeanfit_max=np.polyfit(np.log10(ic.mo_sc_heliodistance[iall_max]),np.log10(ic.mo_bmean[iall_max]),1)
# bmeanfitfun_max=(10**bmeanfit_max[1])*(xfit**bmeanfit_max[0])
# print('bmean_max: ', round(10**bmeanfit_max[1],2),' x ^',round(bmeanfit_max[0],2))
''' | 29.633758 | 164 | 0.692638 | 1,564 | 9,305 | 4.06202 | 0.192455 | 0.020148 | 0.024241 | 0.043444 | 0.637652 | 0.6153 | 0.600189 | 0.600189 | 0.600189 | 0.581772 | 0 | 0.061123 | 0.131435 | 9,305 | 314 | 165 | 29.633758 | 0.724944 | 0.090919 | 0 | 0.113208 | 0 | 0 | 0.013669 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.226415 | false | 0 | 0.132075 | 0.09434 | 0.584906 | 0.075472 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
1bbdc348eec0f5b84cb548243a14b8f2a51e8045 | 416 | py | Python | nac/core/tests/test_suite.py | NaleRaphael/nac | 205e81502a6bb963bfca47793e3e2b5bc1d582c8 | [
"MIT"
] | 1 | 2019-10-08T07:50:39.000Z | 2019-10-08T07:50:39.000Z | nac/core/tests/test_suite.py | NaleRaphael/nac | 205e81502a6bb963bfca47793e3e2b5bc1d582c8 | [
"MIT"
] | null | null | null | nac/core/tests/test_suite.py | NaleRaphael/nac | 205e81502a6bb963bfca47793e3e2b5bc1d582c8 | [
"MIT"
] | null | null | null | from __future__ import absolute_import
import unittest
from nac.core import BenchmarkSuite
from ._example import TimeArrayMultiplication
class TestBenchmarkSuite(unittest.TestCase):
def test_create_suite(self):
tests = TimeArrayMultiplication.func_list
suite = BenchmarkSuite(map(TimeArrayMultiplication, tests))
for case in suite:
self.assertTrue(case.func_name in tests)
| 29.714286 | 67 | 0.766827 | 45 | 416 | 6.866667 | 0.6 | 0.058252 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.180288 | 416 | 13 | 68 | 32 | 0.906158 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.1 | 1 | 0.1 | false | 0 | 0.4 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
1bbe8446d740c56d3b8e806c769abc328df5be96 | 6,739 | py | Python | meshlib/stlreader.py | p-hofmann/MeshReader | 9296482d0ad6f0c944b065619df04ffcf5a4cf9e | [
"MIT"
] | 2 | 2018-05-24T01:20:54.000Z | 2020-05-22T16:20:47.000Z | meshlib/stlreader.py | p-hofmann/MeshReader | 9296482d0ad6f0c944b065619df04ffcf5a4cf9e | [
"MIT"
] | null | null | null | meshlib/stlreader.py | p-hofmann/MeshReader | 9296482d0ad6f0c944b065619df04ffcf5a4cf9e | [
"MIT"
] | 2 | 2019-11-07T14:09:06.000Z | 2020-11-07T20:40:36.000Z | import numpy as np
import os
from struct import unpack
from .defaultreader import DefaultReader
class StlReader(DefaultReader):
"""
@type _facets: dict[str, list[tuple[tuple[float]]]]
@type _norms: dict[str, list[tuple[float]]]
"""
def __init__(self):
self._facets = {}
self._norms = {}
@staticmethod
def read_binary(file_path):
"""
Created on Thu Nov 19 06:37:35 2013
@author: Sukhbinder Singh
Reads a Binary file and
Returns Header,Points,Normals,Vertex1,Vertex2,Vertex3
Source: http://sukhbinder.wordpress.com/2013/11/28/binary-stl-file-reader-in-python-powered-by-numpy/
@type file_path: str
@rtype:
"""
fp = open(file_path, 'rb')
header = fp.read(80)
nn = fp.read(4)
number_of_facets = unpack('i', nn)[0]
record_dtype = np.dtype([
('normals', np.float32, (3,)),
('Vertex1', np.float32, (3,)),
('Vertex2', np.float32, (3,)),
('Vertex3', np.float32, (3,)),
('atttr', '<i2', (1,))
])
data = np.fromfile(fp, dtype=record_dtype, count=number_of_facets)
fp.close()
normals = data['normals']
vertex_1 = data['Vertex1']
vertex_2 = data['Vertex2']
vertex_3 = data['Vertex3']
# p = np.append(vertex_1, vertex_2, axis=0)
# p = np.append(p, vertex_3, axis=0) # list(v1)
# points = np.array(list(set(tuple(p1) for p1 in p)))
return header, normals, vertex_1, vertex_2, vertex_3
@staticmethod
def parse_askii_verticle(input_stream):
"""
'vertex 0.0 0.0 0.0'
@param input_stream:
@rtype: (float, float, float)
"""
_, verticle_x, verticle_y, verticle_z = input_stream.readline().strip().split(' ')
return float(verticle_x), float(verticle_y), float(verticle_z),
@staticmethod
def parse_askii_triangle(input_stream):
"""
'vertex 0.0 0.0 0.0' x3
@param input_stream:
@rtype: ((float, float, float), (float, float, float), (float, float, float))
"""
assert input_stream.readline().strip().startswith("outer loop")
triangle = (
StlReader.parse_askii_verticle(input_stream),
StlReader.parse_askii_verticle(input_stream),
StlReader.parse_askii_verticle(input_stream))
assert input_stream.readline().strip().startswith("endloop")
return triangle
@staticmethod
def parse_askii_list_of_facets(input_stream):
"""
'facet normal 0.0 -1.0 0.0'
'outer loop'
'vertex 0.0 0.0 0.0' x3
'endloop'
'endfacet'
@param input_stream:
@rtype: collections.Iterable[((float, float, float), ((float, float, float), (float, float, float), (float, float, float)))]
"""
line = input_stream.readline().strip()
while not line.startswith("endsolid"):
_, _, normal_x, normal_y, normal_z = line.split(' ')
triangle = StlReader.parse_askii_triangle(input_stream)
assert input_stream.readline().strip().startswith("endfacet")
yield (normal_x, normal_y, normal_z), triangle
line = input_stream.readline().strip()
@staticmethod
def parse_askii_solids(input_stream):
"""
'solid cube_corner'
'facet normal 0.0 -1.0 0.0'
'outer loop'
'vertex 0.0 0.0 0.0' x3
'endloop'
'endfacet'
'endsolid'
@param input_stream:
@rtype: collections.Iterable[(str, collections.Iterable[((float, float, float), ((float, float, float), (float, float, float), (float, float, float)))]])]
"""
line = input_stream.readline()
while line:
line = line.strip()
assert line.startswith("solid"), line
_, name = line.split(' ', 1)
# print(line)
yield name, StlReader.parse_askii_list_of_facets(input_stream)
line = input_stream.readline()
input_stream.close()
@staticmethod
def read_askii_stl(file_path):
"""
@type file_path: str
@rtype: collections.Iterable[(str, collections.Iterable[((float, float, float), ((float, float, float), (float, float, float), (float, float, float)))]])]
"""
assert os.path.exists(file_path), "Bad path: {}".format(file_path)
return StlReader.parse_askii_solids(open(file_path, 'r'))
@staticmethod
def _is_ascii_stl(file_path):
"""
@type file_path: str
@rtype: bool
"""
with open(file_path, 'rb') as input_data:
line = input_data.readline()
if line.startswith(b'solid'):
return True
else:
return False
def read(self, file_path):
"""
@type file_path: str
@rtype: None
"""
del self._facets
del self._norms
self._facets = {}
self._norms = {}
if StlReader._is_ascii_stl(file_path):
for name, facets in StlReader.read_askii_stl(file_path):
assert name not in self._facets, "Objects in file are not unique"
self._facets[name] = []
self._norms[name] = []
for normal, (v1, v2, v3) in facets:
self._facets[name].append((v1, v2, v3))
self._norms[name].append(normal)
else:
head, n, v1, v2, v3 = StlReader.read_binary(file_path)
self._facets["obj"] = []
self._norms["obj"] = []
for norm, vertex_1, vertex_2, vertex_3 in zip(n, v1, v2, v3):
# yield (tuple(i), tuple(j), tuple(k))
self._facets["obj"].append((vertex_1, vertex_2, vertex_3))
self._norms["obj"].append(norm)
def get_names(self):
"""
@rtype: collections.Iterable[str]
"""
return self._facets.keys()
def get_facets(self, name=None):
"""
@rtype: collections.Iterable[((float, float, float), (float, float, float), (float, float, float))]
"""
if name:
assert name in self._facets, "Unknown object: {}".format(name)
for facet in self._facets[name]:
yield facet
else:
assert name is None, "Unknown object: {}".format(name)
for name in self._facets:
for facet in self._facets[name]:
yield facet
def has_triangular_facets(self):
"""
@rtype: bool
"""
# todo: is this always the case?
return True
| 32.399038 | 162 | 0.556462 | 786 | 6,739 | 4.587786 | 0.21374 | 0.141431 | 0.187188 | 0.216306 | 0.419856 | 0.354409 | 0.306988 | 0.265114 | 0.204659 | 0.191902 | 0 | 0.025636 | 0.311174 | 6,739 | 207 | 163 | 32.555556 | 0.751185 | 0.253302 | 0 | 0.245283 | 0 | 0 | 0.045455 | 0 | 0 | 0 | 0 | 0.004831 | 0.075472 | 1 | 0.113208 | false | 0 | 0.037736 | 0 | 0.235849 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1bc1e1c2b1a1f1414b5bd9f17dbf5fab11ebb57f | 423 | py | Python | UserChose/App/models.py | DILIREBALI/usershose | 15856364452ca075014d7c9ac193afabf7f9be9c | [
"Apache-2.0"
] | null | null | null | UserChose/App/models.py | DILIREBALI/usershose | 15856364452ca075014d7c9ac193afabf7f9be9c | [
"Apache-2.0"
] | 6 | 2021-03-18T22:51:48.000Z | 2022-03-11T23:42:41.000Z | UserChose/App/models.py | DILIREBALI/usershose | 15856364452ca075014d7c9ac193afabf7f9be9c | [
"Apache-2.0"
] | null | null | null | from django.db import models
# Create your models here.
class User(models.Model):
username = models.CharField(max_length=32, verbose_name='用户姓名')
userphone = models.CharField(max_length=16, unique=True, verbose_name='手机号')
class Chose(models.Model):
color = models.CharField(max_length=12, verbose_name='鞋子颜色')
size = models.CharField(max_length=8, verbose_name='鞋子大小')
user = models.ForeignKey(User)
| 35.25 | 80 | 0.744681 | 59 | 423 | 5.20339 | 0.542373 | 0.19544 | 0.234528 | 0.312704 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019022 | 0.130024 | 423 | 11 | 81 | 38.454545 | 0.815217 | 0.056738 | 0 | 0 | 0 | 0 | 0.037783 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
1bc437ed1080a0bf7f04c2395591faa3eccaf075 | 1,936 | py | Python | .leetcode/643.maximum-average-subarray-i.py | KuiyuanFu/PythonLeetCode | 8962df2fa838eb7ae48fa59de272ba55a89756d8 | [
"MIT"
] | null | null | null | .leetcode/643.maximum-average-subarray-i.py | KuiyuanFu/PythonLeetCode | 8962df2fa838eb7ae48fa59de272ba55a89756d8 | [
"MIT"
] | null | null | null | .leetcode/643.maximum-average-subarray-i.py | KuiyuanFu/PythonLeetCode | 8962df2fa838eb7ae48fa59de272ba55a89756d8 | [
"MIT"
] | null | null | null | # @lc app=leetcode id=643 lang=python3
#
# [643] Maximum Average Subarray I
#
# https://leetcode.com/problems/maximum-average-subarray-i/description/
#
# algorithms
# Easy (42.62%)
# Likes: 1226
# Dislikes: 146
# Total Accepted: 116.1K
# Total Submissions: 271.6K
# Testcase Example: '[1,12,-5,-6,50,3]\n4'
#
# You are given an integer array nums consisting of n elements, and an integer
# k.
#
# Find a contiguous subarray whose length is equal to k that has the maximum
# average value and return this value. Any answer with a calculation error less
# than 10^-5 will be accepted.
#
#
# Example 1:
#
#
# Input: nums = [1,12,-5,-6,50,3], k = 4
# Output: 12.75000
# Explanation: Maximum average is (12 - 5 - 6 + 50) / 4 = 51 / 4 = 12.75
#
#
# Example 2:
#
#
# Input: nums = [5], k = 1
# Output: 5.00000
#
#
#
# Constraints:
#
#
# n == nums.length
# 1 <= k <= n <= 10^5
# -10^4 <= nums[i] <= 10^4
#
#
#
# @lc tags=array
# @lc imports=start
from imports import *
# @lc imports=end
# @lc idea=start
#
# 找指定长度的连续子数组的平均值最大。
# 滑动窗口。
#
# @lc idea=end
# @lc group=
# @lc rank=
# @lc code=start
class Solution:
def findMaxAverage(self, nums: List[int], k: int) -> float:
s = sum(nums[:k - 1])
res = -10000
for i in range(k - 1, len(nums)):
s += nums[i]
res = max(res, s / k)
s -= nums[i - (k - 1)]
return res
pass
# @lc code=end
# @lc main=start
if __name__ == '__main__':
print('Example 1:')
print('Input : ')
print('nums = [1,12,-5,-6,50,3], k = 4')
print('Exception :')
print('12.75000')
print('Output :')
print(str(Solution().findMaxAverage([1, 12, -5, -6, 50, 3], 4)))
print()
print('Example 2:')
print('Input : ')
print('nums = [5], k = 1')
print('Exception :')
print('5.00000')
print('Output :')
print(str(Solution().findMaxAverage([5], 1)))
print()
pass
# @lc main=end | 18.438095 | 79 | 0.571798 | 287 | 1,936 | 3.829268 | 0.425087 | 0.013649 | 0.018198 | 0.027298 | 0.11465 | 0.11465 | 0.025478 | 0.025478 | 0.025478 | 0 | 0 | 0.091346 | 0.247934 | 1,936 | 105 | 80 | 18.438095 | 0.663462 | 0.512913 | 0 | 0.344828 | 0 | 0 | 0.164586 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.034483 | false | 0.068966 | 0.034483 | 0 | 0.137931 | 0.551724 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 2 |
59f641ab12c118dc51d57c3a1146f2177928fe06 | 209 | py | Python | application/constant/response.py | Jasbeauty/mine_blog | 22899be4db20a92ad40cf35f84a3123dd0ebeee6 | [
"Apache-2.0"
] | null | null | null | application/constant/response.py | Jasbeauty/mine_blog | 22899be4db20a92ad40cf35f84a3123dd0ebeee6 | [
"Apache-2.0"
] | null | null | null | application/constant/response.py | Jasbeauty/mine_blog | 22899be4db20a92ad40cf35f84a3123dd0ebeee6 | [
"Apache-2.0"
] | 2 | 2018-07-26T05:40:23.000Z | 2018-07-30T06:59:48.000Z | # -*- coding: utf8 -*-
# @author: yinan
# @time: 18-7-4 下午5:52
# @filename: response.py
def return_message(data, msg, code):
return {
"code": code,
"data": data,
"msg": msg
}
| 16.076923 | 36 | 0.516746 | 26 | 209 | 4.115385 | 0.730769 | 0.130841 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.054422 | 0.296651 | 209 | 12 | 37 | 17.416667 | 0.673469 | 0.37799 | 0 | 0 | 0 | 0 | 0.088 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0.166667 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
941705035ab57ab3d49709e84272aadb0b5f4f24 | 1,952 | py | Python | Python_Bots_Excercices/Rule_based/rule_based_chatbot_sql_full_text.py | WojciechK2/Skryptowe | cce6a64c1325b8ba578f8b784445cb71cbf16e11 | [
"CC0-1.0"
] | null | null | null | Python_Bots_Excercices/Rule_based/rule_based_chatbot_sql_full_text.py | WojciechK2/Skryptowe | cce6a64c1325b8ba578f8b784445cb71cbf16e11 | [
"CC0-1.0"
] | null | null | null | Python_Bots_Excercices/Rule_based/rule_based_chatbot_sql_full_text.py | WojciechK2/Skryptowe | cce6a64c1325b8ba578f8b784445cb71cbf16e11 | [
"CC0-1.0"
] | null | null | null | import sqlite3
welcome = "Hi! I'm Arthur, the customer support chatbot. How can I help you?"
#Creating and inserting values into db
conn = sqlite3.connect('fulltext_chatbot.sqlite')
conn.enable_load_extension(True)
conn.load_extension('fts5')
conn.execute("CREATE VIRTUAL TABLE responses USING fts5(question,answer)")
db_cursor = conn.cursor()
db_cursor.execute('INSERT INTO responses(question,answer) VALUES(\"The app if freezing after I click run button\",\"You need to clean up the cache. Please go to ...\");')
db_cursor.execute('INSERT INTO responses(question,answer) VALUES(\"I don t know how to proceed with the invoice\",\"Please go to Setting, next Subscriptions and there is the Billing section\");')
db_cursor.execute('INSERT INTO responses(question,answer) VALUES(\"I get an error when I try to install the app\",\"Could you plese send the log files placed in ... to ...\");')
db_cursor.execute('INSERT INTO responses(question,answer) VALUES(\"It crash after I have updated it\",\"Please restart your PC\");')
db_cursor.execute('INSERT INTO responses(question,answer) VALUES(\"I cannot login in to the app\",\"Use the forgot password button to setup a new password\");')
db_cursor.execute('INSERT INTO responses(question,answer) VALUES(\"I m not able to download it\",\"Probably you have an ad blocker plugin installed and it blocks the popup with the download link\");')
conn.commit()
def db_search(question):
db_cursor = conn.cursor()
db_cursor.execute("SELECT answer, bm25(responses) FROM responses WHERE responses MATCH 'question: \"+str(question)+\"' ORDER BY bm25(responses) LIMIT 0,1;")
return_string = db_cursor.fetchall()
return return_string
def get_highest_similarity(question):
return db_search(question)
def run_chatbot():
print(welcome)
question = ""
while question != "thank you":
question = input()
answer = get_highest_similarity(question)
print(answer)
run_chatbot()
| 47.609756 | 200 | 0.74334 | 289 | 1,952 | 4.937716 | 0.446367 | 0.056062 | 0.073581 | 0.088297 | 0.268395 | 0.268395 | 0.268395 | 0.232656 | 0.232656 | 0.194814 | 0 | 0.005942 | 0.137807 | 1,952 | 40 | 201 | 48.8 | 0.841949 | 0.018955 | 0 | 0.068966 | 0 | 0.206897 | 0.619247 | 0.104603 | 0 | 0 | 0 | 0 | 0 | 1 | 0.103448 | false | 0.034483 | 0.034483 | 0.034483 | 0.206897 | 0.068966 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
9418f29f36a0f494dbc17a6f36e38b4179ed7f22 | 220 | py | Python | CommonTools/RecoAlgos/python/LargestEtCaloJetSelector_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | CommonTools/RecoAlgos/python/LargestEtCaloJetSelector_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | CommonTools/RecoAlgos/python/LargestEtCaloJetSelector_cfi.py | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 3,240 | 2015-01-02T05:53:18.000Z | 2022-03-31T17:24:21.000Z | import FWCore.ParameterSet.Config as cms
hltSelector4Jets = cms.EDFilter( "LargestEtCaloJetSelector",
src = cms.InputTag( "hltMCJetCorJetIcone5" ),
filter = cms.bool( False ),
maxNumber = cms.uint32( 4 )
)
| 24.444444 | 60 | 0.713636 | 22 | 220 | 7.136364 | 0.818182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027473 | 0.172727 | 220 | 8 | 61 | 27.5 | 0.835165 | 0 | 0 | 0 | 0 | 0 | 0.200913 | 0.109589 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
94259e2b10c489147782cd6428da1d62350e4319 | 257 | py | Python | mhdata/merge/binary/metadata/location_meta.py | nikibobi/MHWorldData | 78b5a4dc10ef532d5bad7359ef0b098f99104782 | [
"MIT"
] | null | null | null | mhdata/merge/binary/metadata/location_meta.py | nikibobi/MHWorldData | 78b5a4dc10ef532d5bad7359ef0b098f99104782 | [
"MIT"
] | null | null | null | mhdata/merge/binary/metadata/location_meta.py | nikibobi/MHWorldData | 78b5a4dc10ef532d5bad7359ef0b098f99104782 | [
"MIT"
] | null | null | null | from os.path import dirname, abspath
from mhdata.io.csv import read_csv
def load_area_map():
this_dir = dirname(abspath(__file__))
area_map = {int(r['id']):r['name'] for r in read_csv(this_dir + '/metadata_files/area_map.csv')}
return area_map
| 32.125 | 100 | 0.719844 | 44 | 257 | 3.886364 | 0.590909 | 0.163743 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.14786 | 257 | 7 | 101 | 36.714286 | 0.780822 | 0 | 0 | 0 | 0 | 0 | 0.132296 | 0.108949 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
9438102ab6520c896753fe2b9c39e216021da939 | 3,482 | py | Python | apps/odoo/lib/odoo-10.0.post20170615-py2.7.egg/odoo/addons/l10n_de_skr03/__manifest__.py | gtfarng/Odoo_migrade | 9cc28fae4c379e407645248a29d22139925eafe7 | [
"Apache-2.0"
] | 1 | 2019-12-19T01:53:13.000Z | 2019-12-19T01:53:13.000Z | apps/odoo/lib/odoo-10.0.post20170615-py2.7.egg/odoo/addons/l10n_de_skr03/__manifest__.py | gtfarng/Odoo_migrade | 9cc28fae4c379e407645248a29d22139925eafe7 | [
"Apache-2.0"
] | null | null | null | apps/odoo/lib/odoo-10.0.post20170615-py2.7.egg/odoo/addons/l10n_de_skr03/__manifest__.py | gtfarng/Odoo_migrade | 9cc28fae4c379e407645248a29d22139925eafe7 | [
"Apache-2.0"
] | null | null | null | # -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# SKR03
# =====
# Dieses Modul bietet Ihnen einen deutschen Kontenplan basierend auf dem SKR03.
# Gemäss der aktuellen Einstellungen ist die Firma nicht Umsatzsteuerpflichtig.
# Diese Grundeinstellung ist sehr einfach zu ändern und bedarf in der Regel
# grundsätzlich eine initiale Zuweisung von Steuerkonten zu Produkten und / oder
# Sachkonten oder zu Partnern.
# Die Umsatzsteuern (voller Steuersatz, reduzierte Steuer und steuerfrei)
# sollten bei den Produktstammdaten hinterlegt werden (in Abhängigkeit der
# Steuervorschriften). Die Zuordnung erfolgt auf dem Aktenreiter Finanzbuchhaltung
# (Kategorie: Umsatzsteuer).
# Die Vorsteuern (voller Steuersatz, reduzierte Steuer und steuerfrei)
# sollten ebenso bei den Produktstammdaten hinterlegt werden (in Abhängigkeit
# der Steuervorschriften). Die Zuordnung erfolgt auf dem Aktenreiter
# Finanzbuchhaltung (Kategorie: Vorsteuer).
# Die Zuordnung der Steuern für Ein- und Ausfuhren aus EU Ländern, sowie auch
# für den Ein- und Verkauf aus und in Drittländer sollten beim Partner
# (Lieferant/Kunde)hinterlegt werden (in Anhängigkeit vom Herkunftsland
# des Lieferanten/Kunden). Die Zuordnung beim Kunden ist 'höherwertig' als
# die Zuordnung bei Produkten und überschreibt diese im Einzelfall.
#
# Zur Vereinfachung der Steuerausweise und Buchung bei Auslandsgeschäften
# erlaubt Odoo ein generelles Mapping von Steuerausweis und Steuerkonten
# (z.B. Zuordnung 'Umsatzsteuer 19%' zu 'steuerfreie Einfuhren aus der EU')
# zwecks Zuordnung dieses Mappings zum ausländischen Partner (Kunde/Lieferant).
# Die Rechnungsbuchung beim Einkauf bewirkt folgendes:
# Die Steuerbemessungsgrundlage (exklusive Steuer) wird ausgewiesen bei den
# jeweiligen Kategorien für den Vorsteuer Steuermessbetrag (z.B. Vorsteuer
# Steuermessbetrag Voller Steuersatz 19%).
# Der Steuerbetrag erscheint unter der Kategorie 'Vorsteuern' (z.B. Vorsteuer
# 19%). Durch multidimensionale Hierachien können verschiedene Positionen
# zusammengefasst werden und dann in Form eines Reports ausgegeben werden.
#
# Die Rechnungsbuchung beim Verkauf bewirkt folgendes:
# Die Steuerbemessungsgrundlage (exklusive Steuer) wird ausgewiesen bei den
# jeweiligen Kategorien für den Umsatzsteuer Steuermessbetrag
# (z.B. Umsatzsteuer Steuermessbetrag Voller Steuersatz 19%).
# Der Steuerbetrag erscheint unter der Kategorie 'Umsatzsteuer'
# (z.B. Umsatzsteuer 19%). Durch multidimensionale Hierachien können
# verschiedene Positionen zusammengefasst werden.
# Die zugewiesenen Steuerausweise können auf Ebene der einzelnen
# Rechnung (Eingangs- und Ausgangsrechnung) nachvollzogen werden,
# und dort gegebenenfalls angepasst werden.
# Rechnungsgutschriften führen zu einer Korrektur (Gegenposition)
# der Steuerbuchung, in Form einer spiegelbildlichen Buchung.
{
'name': 'Deutschland SKR03 - Accounting',
'version': '2.0',
'author': 'openbig.org',
'website': 'http://www.openbig.org',
'category': 'Localization',
'description': """
Dieses Modul beinhaltet einen deutschen Kontenrahmen basierend auf dem SKR03.
==============================================================================
German accounting chart and localization.
""",
'depends': ['l10n_de'],
'data': [
'data/l10n_de_skr03_chart_data.xml',
'data/account_tax_fiscal_position_data.xml',
'data/account_chart_template_data.yml',
],
}
| 47.69863 | 82 | 0.767662 | 395 | 3,482 | 6.736709 | 0.493671 | 0.022548 | 0.020293 | 0.015032 | 0.339722 | 0.339722 | 0.339722 | 0.300639 | 0.300639 | 0.238256 | 0 | 0.009033 | 0.141585 | 3,482 | 72 | 83 | 48.361111 | 0.881231 | 0.798105 | 0 | 0 | 0 | 0 | 0.694656 | 0.287023 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
945a7e0f61aeeebd77301a1afe6dbf946af840d3 | 998 | py | Python | setup.py | pyutil/cnb | 9471fac447b6463a4cfe2a135c71af8fd8672323 | [
"MIT"
] | 1 | 2015-12-22T12:29:07.000Z | 2015-12-22T12:29:07.000Z | setup.py | zvolsky/cnb | 9471fac447b6463a4cfe2a135c71af8fd8672323 | [
"MIT"
] | null | null | null | setup.py | zvolsky/cnb | 9471fac447b6463a4cfe2a135c71af8fd8672323 | [
"MIT"
] | 3 | 2018-02-14T22:02:26.000Z | 2018-02-16T09:07:56.000Z | from distutils.core import setup
setup(
name = 'cnb',
py_modules = ['cnb'],
version = '0.9.3',
description = 'Access current exchange rate and (short time) historical daily rates from the Czech National Bank.',
install_requires = ['six', 'pytz'],
author = 'Mirek Zvolsky',
author_email = 'zvolsky@seznam.cz',
url = 'https://github.com/zvolsky/cnb',
download_url = 'https://github.com/zvolsky/cnb/tarball/0.9.3',
keywords = ['currencies', 'rates', 'exchange', 'financial', 'money', 'cnb'],
classifiers=[
'Development Status :: 4 - Beta',
'Topic :: Office/Business :: Financial :: Accounting',
'Intended Audience :: Developers',
'Intended Audience :: Financial and Insurance Industry',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
],
)
| 38.384615 | 117 | 0.644289 | 109 | 998 | 5.862385 | 0.688073 | 0.089202 | 0.117371 | 0.053208 | 0.084507 | 0.084507 | 0 | 0 | 0 | 0 | 0 | 0.011264 | 0.199399 | 998 | 25 | 118 | 39.92 | 0.788486 | 0 | 0 | 0 | 0 | 0 | 0.627255 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.04 | 0 | 0.04 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
945cb74529f009b80ae24139027b27625a40ded9 | 2,396 | py | Python | test/unit/command/test_create.py | retr0h/hyver | e17a95d97e43afa2e99dce5a7b2619a1ce330654 | [
"MIT"
] | null | null | null | test/unit/command/test_create.py | retr0h/hyver | e17a95d97e43afa2e99dce5a7b2619a1ce330654 | [
"MIT"
] | null | null | null | test/unit/command/test_create.py | retr0h/hyver | e17a95d97e43afa2e99dce5a7b2619a1ce330654 | [
"MIT"
] | null | null | null | # vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2017 John Dewey
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import pytest
import sh
from hyver import config
from hyver.command import create
@pytest.fixture
def create_instance(config_instance, mocker):
m = mocker.patch(
'hyver.config.Config.uuid', new_callable=mocker.PropertyMock)
m.return_value = 'patched-uuid'
return create.Create(config_instance)
def test_config_member(create_instance):
assert isinstance(create_instance._config, config.Config)
def test_cmd_member(create_instance):
assert create_instance._cmd is None
def test_env_member(create_instance):
assert isinstance(create_instance._env, dict)
def test_bake(create_instance):
x = [
str(sh.xhyve),
'-m mem-override',
'-c cpus-override',
'-s 0:0,hostbridge -s 31,lpc',
'-l com1,stdio',
'-s 2:0,virtio-net',
'-s 3,ahci-cd,vms/centos7/CentOS-7-x86_64-Minimal-1611.iso',
'-s 4,virtio-blk,vms/centos7/hdd.img',
'-f kexec,vms/centos7/vmlinuz,vms/centos7/initrd.img,"earlyprintk=serial console=ttyS0"', # noqa
]
create_instance.bake()
assert ' '.join(x) == str(create_instance._cmd)
def test_execute(config_instance):
pass
def test_get_cmd(config_instance):
# NOTE(retr0h): Tested indirectly through bake()
pass
| 31.946667 | 105 | 0.732053 | 348 | 2,396 | 4.951149 | 0.514368 | 0.081254 | 0.034823 | 0.04527 | 0.058038 | 0.058038 | 0.058038 | 0 | 0 | 0 | 0 | 0.015776 | 0.179883 | 2,396 | 74 | 106 | 32.378378 | 0.861069 | 0.477462 | 0 | 0.058824 | 0 | 0.058824 | 0.246542 | 0.144833 | 0 | 0 | 0 | 0 | 0.117647 | 1 | 0.205882 | false | 0.058824 | 0.117647 | 0 | 0.352941 | 0.029412 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
9465df6c518c59c9c4eace7fbd0a48a17a90003e | 357 | bzl | Python | platform/dnsmasq/deps.bzl | AngelAlvie/homeworld | 84406acd0ea03ddd4c807868b204a04898e639e3 | [
"MIT"
] | 18 | 2017-06-24T08:27:52.000Z | 2022-01-04T08:41:11.000Z | platform/dnsmasq/deps.bzl | AngelAlvie/homeworld | 84406acd0ea03ddd4c807868b204a04898e639e3 | [
"MIT"
] | 453 | 2017-07-01T14:24:39.000Z | 2020-07-02T05:32:25.000Z | platform/dnsmasq/deps.bzl | AngelAlvie/homeworld | 84406acd0ea03ddd4c807868b204a04898e639e3 | [
"MIT"
] | 19 | 2017-07-02T19:59:03.000Z | 2020-02-23T00:24:54.000Z | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def dnsmasq_dependencies():
http_archive(
name = "dnsmasq",
urls = ["http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.78.tar.xz"],
sha256 = "89949f438c74b0c7543f06689c319484bd126cc4b1f8c745c742ab397681252b",
build_file = "//dnsmasq:BUILD.import",
)
| 35.7 | 84 | 0.686275 | 37 | 357 | 6.459459 | 0.702703 | 0.09205 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.177852 | 0.165266 | 357 | 9 | 85 | 39.666667 | 0.624161 | 0 | 0 | 0 | 0 | 0.125 | 0.57423 | 0.364146 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | true | 0 | 0.125 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
9467d77980dbb6f4eaf0e78517e72059b3d8b76b | 346 | py | Python | synth/sawtooth.py | dunlapc4/playdio | 8af96c4a746ba42ef1e683c7a259de9d808176c9 | [
"MIT"
] | null | null | null | synth/sawtooth.py | dunlapc4/playdio | 8af96c4a746ba42ef1e683c7a259de9d808176c9 | [
"MIT"
] | null | null | null | synth/sawtooth.py | dunlapc4/playdio | 8af96c4a746ba42ef1e683c7a259de9d808176c9 | [
"MIT"
] | 1 | 2020-06-07T22:02:52.000Z | 2020-06-07T22:02:52.000Z | # This is a synthesizer filter for adding sawtooth wave patterns
# of a given duration and sample rate
from scipy import signal
import fileIO
import math
import numpy as np
def sawWav(fileName, fs, freq):
t = np.linspace(0, 1, int(fs))
dat = signal.sawtooth(2 * math.pi * freq * t)
fileIO.file_output(fileName, fs, dat.tobytes())
| 23.066667 | 64 | 0.713873 | 56 | 346 | 4.392857 | 0.732143 | 0.081301 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010791 | 0.196532 | 346 | 14 | 65 | 24.714286 | 0.874101 | 0.283237 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.5 | 0 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
849b1aeba279eaa010572d0cfeca4b73ac21bb65 | 702 | py | Python | luhn/luhn.py | rdlu/exercism-python | 61e89f4969af5bcad028e843aaae6a8869b0187d | [
"MIT"
] | null | null | null | luhn/luhn.py | rdlu/exercism-python | 61e89f4969af5bcad028e843aaae6a8869b0187d | [
"MIT"
] | null | null | null | luhn/luhn.py | rdlu/exercism-python | 61e89f4969af5bcad028e843aaae6a8869b0187d | [
"MIT"
] | null | null | null | class Luhn:
def __init__(self, card_num: str):
self._reversed_card_num = card_num.replace(' ', '')[::-1]
self._even_digits = self._reversed_card_num[1::2]
self._odd_digits = self._reversed_card_num[::2]
def valid(self) -> bool:
if str.isnumeric(self._reversed_card_num) and len(self._reversed_card_num) > 1:
return self._sum_card() % 10 == 0
else:
return False
def _sum_card(self) -> int:
even_digits_sum = 0
for digit in self._even_digits:
x = int(digit) * 2
even_digits_sum += x if x <= 9 else x - 9
return even_digits_sum + sum([int(x) for x in self._odd_digits])
| 36.947368 | 87 | 0.591168 | 102 | 702 | 3.686275 | 0.323529 | 0.130319 | 0.212766 | 0.25266 | 0.18883 | 0 | 0 | 0 | 0 | 0 | 0 | 0.024194 | 0.293447 | 702 | 18 | 88 | 39 | 0.733871 | 0 | 0 | 0 | 0 | 0 | 0.001425 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1875 | false | 0 | 0 | 0 | 0.4375 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
84cdc1bc01a195958046c53dcf46f7701a9ce876 | 1,952 | py | Python | app/admin.py | WarmongeR1/django-admin-article | 6c5d7b0fd83f214da6fc0ee74937e7487372d35d | [
"MIT"
] | null | null | null | app/admin.py | WarmongeR1/django-admin-article | 6c5d7b0fd83f214da6fc0ee74937e7487372d35d | [
"MIT"
] | null | null | null | app/admin.py | WarmongeR1/django-admin-article | 6c5d7b0fd83f214da6fc0ee74937e7487372d35d | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from app.admin_opt import OptAdmin
from app.models import ModelA, ModelB, ModelC, ModelD, ModelE
@admin.register(ModelA)
class ModelAAdmin(admin.ModelAdmin):
list_per_page = 10
list_display = [
'value',
]
show_full_result_count = False
search_fields = ['value']
def get_queryset(self, request):
if len(request.GET) == 0:
return ModelA.objects.none()
else:
return super().get_queryset(request)
@admin.register(ModelB)
class ModelBAdmin(OptAdmin):
list_per_page = 25
list_display = [
'name',
'data',
]
raw_id_fields = ['data', ] # practice 1
ordering = []
# list_select_related = ['data', ] # practice 2
#
# def get_queryset(self, request): # practice 2
# qs = super(ModelBAdmin, self).get_queryset(request)
# return qs.prefetch_related('data')
@admin.register(ModelC)
class ModelCAdmin(OptAdmin):
pass
@admin.register(ModelD)
class ModelDAdmin(OptAdmin):
pass
@admin.register(ModelE)
class ModelEAdmin(OptAdmin):
pass
def get_user_by_email(email):
try:
return get_user_model().objects.get(email__iexact=email)
except User.DoestNotExist:
return None
class UserEmailSearchAdmin(admin.ModelAdmin):
def get_search_results(self, request, queryset, search_term):
user = get_user_by_email(search_term.strip())
if user is not None:
queryset = queryset.filter(user_id=user.id)
use_distinct = True
else:
queryset, use_distinct = super().get_search_results(request,
queryset,
search_term)
return queryset, use_distinct
| 24.098765 | 76 | 0.620902 | 220 | 1,952 | 5.313636 | 0.381818 | 0.055603 | 0.043627 | 0.035928 | 0.042772 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006433 | 0.283299 | 1,952 | 80 | 77 | 24.4 | 0.829164 | 0.112193 | 0 | 0.134615 | 0 | 0 | 0.012768 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.057692 | false | 0.057692 | 0.096154 | 0 | 0.519231 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
84d34c74229a33683b915925b046b4fdff54a29d | 2,686 | py | Python | data_feeder.py | matissapinis/shuffle-exchange | aa607b8fb648fe08287f5917963a005151821831 | [
"MIT"
] | 9 | 2019-07-20T23:09:25.000Z | 2021-01-30T08:18:06.000Z | data_feeder.py | matissapinis/shuffle-exchange | aa607b8fb648fe08287f5917963a005151821831 | [
"MIT"
] | null | null | null | data_feeder.py | matissapinis/shuffle-exchange | aa607b8fb648fe08287f5917963a005151821831 | [
"MIT"
] | 2 | 2019-10-27T20:35:29.000Z | 2021-11-25T06:14:59.000Z | # The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import random
import config as cnf
import data_utils as data_gen
class DataSupplier:
def supply_training_data(self, length, batch_size) -> tuple:
pass
def supply_validation_data(self, length, batch_size) -> tuple:
pass
def supply_test_data(self, length, batch_size) -> tuple:
pass
class DefaultSupplier(DataSupplier):
def supply_training_data(self, length, batch_size) -> tuple:
return self.__gen_training_data(True)
def supply_validation_data(self, length, batch_size) -> tuple:
return self.__gen_training_data(False)
@staticmethod
def __gen_training_data(for_training):
x = []
y = []
for index, seq_len in enumerate(cnf.bins):
data, labels = data_gen.get_batch(seq_len, cnf.batch_size, for_training, cnf.task)
x += [data]
y += [labels]
return x, y
def supply_test_data(self, length, batch_size):
data, labels = data_gen.get_batch(length, batch_size, False, cnf.task)
return [data], [labels]
def create_batch(generator, batch_size, length, for_training=False):
qna = []
while len(qna) < batch_size:
question, answer = next(generator)
if max(len(question), len(answer)) > length:
continue
question_and_answer = data_gen.add_padding(question, answer, length, for_training)
qna.append(question_and_answer)
random.shuffle(qna)
questions, answers = tuple(zip(*qna))
return [questions], [answers]
def create_data_supplier() -> DataSupplier:
return DefaultSupplier()
| 33.575 | 94 | 0.71035 | 369 | 2,686 | 5.02168 | 0.395664 | 0.04857 | 0.056665 | 0.061522 | 0.214247 | 0.214247 | 0.187264 | 0.182407 | 0.148408 | 0.103616 | 0 | 0 | 0.211095 | 2,686 | 79 | 95 | 34 | 0.874469 | 0.387937 | 0 | 0.175 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.225 | false | 0.075 | 0.075 | 0.075 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
84e05d83561867ee55bf98dea81d51dae83b7ddc | 5,328 | py | Python | build/lib/danbotstatus/dbhs.py | Zaeem20/danbot-status-py | 59f6b06f72a73d817736f5009bf74153365d5804 | [
"MIT"
] | 1 | 2021-01-09T06:41:06.000Z | 2021-01-09T06:41:06.000Z | build/lib/danbotstatus/dbhs.py | Zaeem20/danbot-status-py | 59f6b06f72a73d817736f5009bf74153365d5804 | [
"MIT"
] | 1 | 2022-02-27T14:06:05.000Z | 2022-03-05T18:22:36.000Z | build/lib/danbotstatus/dbhs.py | Zaeem20/danbot-status-py | 59f6b06f72a73d817736f5009bf74153365d5804 | [
"MIT"
] | 1 | 2021-06-25T11:39:31.000Z | 2021-06-25T11:39:31.000Z | import requests
base = "https://danbot.host/nodeStatus"
sysinfo = 'https://danbot.host/sysinfo'
leaderboard = "https://api.danbot.host/leaderboard"
######################################
##### GETTING ALL STATUS #####
######################################
def getallstats():
r = requests.get(base)
if r.status_code == 200:
return r.json() ## RETURNS ALL STATUS IN DICTIONARY
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error
######################################
#### GETTING ONLY NODE STATUS ####
######################################
def getallnodestats():
r = requests.get(base)
if r.status_code == 200:
nodestats = r.json()['nodestatus']
return nodestats # RETURNS ONLY NODES STATUS IN FORM OF DICTIONARY
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error
###############################################
###### GETTING A PARTICULAR NODE STATUS #####
###############################################
def getnodestatus(val = None):
if val is None:
error = "Node number can't be of NoneType"
return error
else:
r = requests.get(base)
if r.status_code == 200:
jsonify = r.json()['nodestatus']
if int(val) == 0:
error = "Node 0 wasn't found!"
return error
elif int(val) < 0:
error = "Node number can't be a negative value!"
return error
elif int(val) > 0 and int(val) <= len(jsonify):
result = jsonify[f"Node{val}"]
return result # Returns Particular Node Status In Dictionary
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error
##########################################
##### GETTING MISC STATUS ##########
##########################################
def getmiscstatus():
r = requests.get(base)
if r.status_code == 200:
jsonify = r.json()['misc']
return(jsonify)
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error # Returns Misc Status in form of Dictionary
##########################################
##### GETTING LAVA STATUS ##########
##########################################
def getlavastatus(val = None):
if val is None:
error = "Node number can't be of NoneType"
return error
else:
r = requests.get(base)
if r.status_code == 200:
jsonify = r.json()['misc']
if int(val) == 0:
error = "Lava0 wasn't found!"
return error
elif int(val) < 0:
error = "Lava number can't be a negative value!"
return error
elif int(val) > 0 and int(val) <= len(jsonify):
try:
result = jsonify[f'Lava{val}']
except KeyError as e:
rerror = f"{e} was not found! "
return rerror
else:
return result # Returns True, if its online
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error
#############################################
#### GETTING ALL SYSTEM INFORMATION ####
#############################################
def getallsysinfo():
r = requests.get(sysinfo)
if r.status_code == 200:
sysstats = r.json()
return sysstats # RETURNS SYSTEM(NODE) INFORMATION STATUS IN FORM OF DICTIONARY
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error
##############################################
######### GETTING PARTICULAR SYS INFO #######
##############################################
def getsysinfo(val = None):
if val is None:
error = "Node number can't be of NoneType"
return error
else:
r = requests.get(sysinfo)
if r.status_code == 200:
jsonify = r.json()
if int(val) == 0:
error = "Node 0 wasn't found!"
return error
elif int(val) < 0:
error = "Node number can't be a negative value!"
return error
elif int(val) > 0 and int(val) <= len(jsonify):
result = jsonify[f"Node{val}"]
return result # Returns Particular Node Status In Dictionary
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error
#############################################
##### GETTING LEADERBOARD ################
#############################################
def getleaderboard():
r = requests.get(leaderboard)
if r.status_code == 200:
result = r.json()
return result # Returns Leaderboard in list, where each list values are dictionary type
else:
error = f"Error when fetching, please try again! Status Code : {r.status_code}"
return error
| 34.597403 | 96 | 0.468468 | 548 | 5,328 | 4.525547 | 0.166058 | 0.096774 | 0.070968 | 0.041935 | 0.695968 | 0.674194 | 0.674194 | 0.674194 | 0.669355 | 0.620161 | 0 | 0.009785 | 0.309497 | 5,328 | 153 | 97 | 34.823529 | 0.664311 | 0.114489 | 0 | 0.731481 | 0 | 0 | 0.250192 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.074074 | false | 0 | 0.009259 | 0 | 0.314815 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
84e5ce19951619256a651e5e62bac3cf7e2210b9 | 623 | py | Python | dataset_specifications/const_noise.py | joeloskarsson/CGAN-regression | 1cbcced10d28c11df8500373fc625e5df493f21d | [
"MIT"
] | 12 | 2020-05-22T08:02:27.000Z | 2022-03-28T06:14:23.000Z | dataset_specifications/const_noise.py | joeloskarsson/CGAN-regression | 1cbcced10d28c11df8500373fc625e5df493f21d | [
"MIT"
] | 3 | 2021-06-08T21:33:24.000Z | 2022-03-11T07:11:06.000Z | dataset_specifications/const_noise.py | joeloskarsson/CGAN-regression | 1cbcced10d28c11df8500373fc625e5df493f21d | [
"MIT"
] | null | null | null | import numpy as np
import utils
from dataset_specifications.dataset import Dataset
class ConstNoiseSet(Dataset):
def __init__(self):
super().__init__()
self.name = "const_noise"
self.std_dev = np.sqrt(0.25)
def get_support(self, x):
return (x-2*self.std_dev, x+2*self.std_dev)
def sample(self, n):
xs = np.random.uniform(low=-1., high=1., size=n)
noise = np.random.normal(loc=0., scale=self.std_dev, size=n)
ys = xs + noise
return np.stack((xs, ys), axis=1)
def get_pdf(self, x):
return utils.get_gaussian_pdf(x, self.std_dev)
| 23.961538 | 68 | 0.624398 | 97 | 623 | 3.814433 | 0.453608 | 0.094595 | 0.135135 | 0.048649 | 0.064865 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019068 | 0.242376 | 623 | 25 | 69 | 24.92 | 0.764831 | 0 | 0 | 0 | 0 | 0 | 0.017685 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.235294 | false | 0 | 0.176471 | 0.117647 | 0.647059 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
84eeefdee87344e091c09d134dd210f652eb2a83 | 827 | py | Python | replayer.py | alec-deason/tidal_recorder | 5d1e476f39f676ec107d34756729bf9bb3a81f77 | [
"BSD-2-Clause"
] | 2 | 2020-04-20T04:41:04.000Z | 2022-02-13T12:35:36.000Z | replayer.py | alec-deason/tidal_recorder | 5d1e476f39f676ec107d34756729bf9bb3a81f77 | [
"BSD-2-Clause"
] | null | null | null | replayer.py | alec-deason/tidal_recorder | 5d1e476f39f676ec107d34756729bf9bb3a81f77 | [
"BSD-2-Clause"
] | null | null | null | import sys
import json
import time
import pexpect
import pexpect.replwrap
import subprocess
with open(sys.argv[1], 'r') as f:
log = json.load(f)
tidal_startup = subprocess.check_output('bash -c "ghc-pkg field -f ~/.cabal/store/ghc-$(ghc --numeric-version)/package.db tidal data-dir --simple-output"', shell=True).strip().decode("utf8") + "/BootTidal.hs"
tidal = subprocess.Popen(["ghci", "-ghci-script", tidal_startup])
tidal = pexpect.replwrap.REPLWrapper(f"ghci -ghci-script {tidal_startup}", "tidal>", None, continuation_prompt="tidal|")
current_time = log[0][0]
for (next_time, data) in log:
#TODO: sleep has no guarentees about how long it will actually last...
time.sleep(next_time - current_time)
current_time = next_time
tidal.run_command(data)
time.sleep(3.0)
tidal.child.kill(0)
print("done")
| 33.08 | 208 | 0.723096 | 126 | 827 | 4.650794 | 0.571429 | 0.061433 | 0.047782 | 0.064846 | 0.105802 | 0.105802 | 0 | 0 | 0 | 0 | 0 | 0.009655 | 0.123337 | 827 | 24 | 209 | 34.458333 | 0.798621 | 0.083434 | 0 | 0 | 0 | 0.052632 | 0.257596 | 0.070013 | 0 | 0 | 0 | 0.041667 | 0 | 1 | 0 | false | 0 | 0.315789 | 0 | 0.315789 | 0.052632 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
84f9bb6cf2c5a77a0a4e681cea4d4c713636907b | 2,318 | py | Python | ooobuild/lo/document/extended_type_detection.py | Amourspirit/ooo_uno_tmpl | 64e0c86fd68f24794acc22d63d8d32ae05dd12b8 | [
"Apache-2.0"
] | null | null | null | ooobuild/lo/document/extended_type_detection.py | Amourspirit/ooo_uno_tmpl | 64e0c86fd68f24794acc22d63d8d32ae05dd12b8 | [
"Apache-2.0"
] | null | null | null | ooobuild/lo/document/extended_type_detection.py | Amourspirit/ooo_uno_tmpl | 64e0c86fd68f24794acc22d63d8d32ae05dd12b8 | [
"Apache-2.0"
] | null | null | null | # coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# 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.
#
# Service Class
# this is a auto generated file generated by Cheetah
# Libre Office Version: 7.3
# Namespace: com.sun.star.document
from .x_extended_filter_detection import XExtendedFilterDetection as XExtendedFilterDetection_9ff211f5
class ExtendedTypeDetection(XExtendedFilterDetection_9ff211f5):
"""
Service Class
describes a class of service which will be used for deep TypeDetection in a generic way
Due to the registered types, flat TypeDetection is already possible, i.e. the assignment of types (e.g. to a URL) only on the basis of configuration data. If, however, you imagine special cases (e.g. modifying the file extension of a Writer file from .sdw to .doc), it quickly becomes clear that you cannot always get a correct result with flat detection. To be certain to get correct results, you need deep detection, i.e. the file itself has to be examined. And that is exactly the function of DetectServices. They get all the information collected so far on a document and then decide which type to assign it to. In the new modular model, such a detector is meant as UNO service which registers itself in the office and is requested by the generic type detection if necessary.
Therefore you need two pieces of information:
See service TypeDetection and his configuration for further information.
See Also:
`API ExtendedTypeDetection <https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1document_1_1ExtendedTypeDetection.html>`_
"""
__ooo_ns__: str = 'com.sun.star.document'
__ooo_full_ns__: str = 'com.sun.star.document.ExtendedTypeDetection'
__ooo_type_name__: str = 'service'
__all__ = ['ExtendedTypeDetection']
| 51.511111 | 783 | 0.771355 | 348 | 2,318 | 5.037356 | 0.537356 | 0.034227 | 0.017114 | 0.030804 | 0.026241 | 0.026241 | 0 | 0 | 0 | 0 | 0 | 0.015088 | 0.170837 | 2,318 | 44 | 784 | 52.681818 | 0.896982 | 0.802416 | 0 | 0 | 0 | 0 | 0.235897 | 0.217949 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ca1c8a30a6421f30155c54d9e070066e825adb0c | 789 | py | Python | recursion_backtracking/gray_code.py | rjsnh1522/geeks-4-geeks-python | 9bea0ce4f3fae9b5f9e5952fb5b4b3a8c6186cf4 | [
"MIT"
] | null | null | null | recursion_backtracking/gray_code.py | rjsnh1522/geeks-4-geeks-python | 9bea0ce4f3fae9b5f9e5952fb5b4b3a8c6186cf4 | [
"MIT"
] | 5 | 2021-03-10T11:49:39.000Z | 2022-02-27T01:35:59.000Z | recursion_backtracking/gray_code.py | rjsnh1522/geeks-4-geeks-python | 9bea0ce4f3fae9b5f9e5952fb5b4b3a8c6186cf4 | [
"MIT"
] | null | null | null | class Solution:
def binary_to_decimal(self, n):
return int(n, 2)
def grayCode(self, A):
num_till_now = [0, 1]
if A == 1:
return num_till_now
results = []
for i in range(1, A):
rev = num_till_now.copy()
rev.reverse()
num_till_now = num_till_now + rev
lent = len(num_till_now)
for j in range(len(num_till_now)):
if j >= lent//2:
num_till_now[j] = "1" + str(num_till_now[j])
else:
num_till_now[j] = "0" + str(num_till_now[j])
for i in num_till_now:
results.append(self.binary_to_decimal(i))
return results
number = 16
s = Solution()
ss = s.grayCode(number)
print(ss)
| 25.451613 | 64 | 0.508238 | 112 | 789 | 3.330357 | 0.339286 | 0.225201 | 0.321716 | 0.117962 | 0.075067 | 0 | 0 | 0 | 0 | 0 | 0 | 0.020534 | 0.382763 | 789 | 30 | 65 | 26.3 | 0.74538 | 0 | 0 | 0 | 0 | 0 | 0.002535 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.08 | false | 0 | 0 | 0.04 | 0.24 | 0.04 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ca2cd04632891908fd4591761cd96be2711726c5 | 3,060 | py | Python | B2G/gecko/media/mtransport/runnable_utils.py | wilebeast/FireFox-OS | 43067f28711d78c429a1d6d58c77130f6899135f | [
"Apache-2.0"
] | 3 | 2015-08-31T15:24:31.000Z | 2020-04-24T20:31:29.000Z | B2G/gecko/media/mtransport/runnable_utils.py | wilebeast/FireFox-OS | 43067f28711d78c429a1d6d58c77130f6899135f | [
"Apache-2.0"
] | null | null | null | B2G/gecko/media/mtransport/runnable_utils.py | wilebeast/FireFox-OS | 43067f28711d78c429a1d6d58c77130f6899135f | [
"Apache-2.0"
] | 3 | 2015-07-29T07:17:15.000Z | 2020-11-04T06:55:37.000Z | MAX_ARGS = 10
def gen_args_type(args):
ret = ["C o", "M m"]
for arg in range(0, args):
ret.append("A%d a%d"%(arg, arg))
return ", ".join(ret)
def gen_args(args):
ret = ["o", "m"]
for arg in range(0, args):
ret.append("a%d"%(arg))
return ", ".join(ret)
def gen_args_(args):
ret = []
for arg in range(0, args):
ret.append("a%d_"%(arg))
return ", ".join(ret)
def gen_init(args, r = False):
ret = ["o_(o)", "m_(m)"]
if r:
ret.append("r_(r)")
for arg in range(0, args):
ret.append("a%d_(a%d)"%(arg, arg))
return ", ".join(ret)
def gen_typenames(args):
ret = ["typename C", "typename M"]
for arg in range(0, args):
ret.append("typename A%d"%(arg))
return ", ".join(ret)
def gen_types(args):
ret = ["C", "M"]
for arg in range(0, args):
ret.append("A%d"%(arg))
return ", ".join(ret)
def generate_class_template(args, ret = False):
print "// %d arguments --"%args
if not ret:
print "template<"+ gen_typenames(args) + "> class runnable_args%d : public runnable_args_base {"%args
else:
print "template<"+ gen_typenames(args) + ", typename R> class runnable_args%d_ret : public runnable_args_base {"%args
print " public:"
if not ret:
print " runnable_args%d("%args + gen_args_type(args) + ") :"
print " " + gen_init(args) + " {}"
else:
print " runnable_args%d_ret("%args + gen_args_type(args) + ", R *r) :"
print " " + gen_init(args, True) + " {}"
print
print " NS_IMETHOD Run() {"
if not ret:
print " ((*o_).*m_)(" + gen_args_(args) + ");"
else:
print " *r_ = ((*o_).*m_)(" + gen_args_(args) + ");"
print " return NS_OK;"
print " }"
print
print " private:"
print " C o_;"
print " M m_;"
if ret:
print " R* r_;"
for arg in range(0, args):
print " A%d a%d_;"%(arg, arg)
print "};"
print
print
print
def generate_function_template(args):
print "// %d arguments --"%args
print "template<" + gen_typenames(args) + ">"
print "runnable_args%d<"%args + gen_types(args) + ">* WrapRunnable(" + gen_args_type(args) + ") {"
print " return new runnable_args%d<"%args + gen_types(args) + ">"
print " (" + gen_args(args) + ");"
print "}"
print
def generate_function_template_ret(args):
print "// %d arguments --"%args
print "template<" + gen_typenames(args) + ", typename R>"
print "runnable_args%d_ret<"%args + gen_types(args) + ", R>* WrapRunnableRet(" + gen_args_type(args) + ", R* r) {"
print " return new runnable_args%d_ret<"%args + gen_types(args) + ", R>"
print " (" + gen_args(args) + ", r);"
print "}"
print
for num_args in range (0, MAX_ARGS):
generate_class_template(num_args)
generate_class_template(num_args, True)
print
print
print
for num_args in range(0, MAX_ARGS):
generate_function_template(num_args)
generate_function_template_ret(num_args)
| 27.321429 | 125 | 0.566013 | 426 | 3,060 | 3.856808 | 0.112676 | 0.051126 | 0.043822 | 0.055386 | 0.68168 | 0.597079 | 0.48448 | 0.375533 | 0.347535 | 0.276932 | 0 | 0.004848 | 0.258497 | 3,060 | 111 | 126 | 27.567568 | 0.71926 | 0 | 0 | 0.406593 | 0 | 0 | 0.227421 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.450549 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
ca5557e64025637277ef387593b2b597c561f07e | 94 | py | Python | src/Codechef/Beginner/FLOW007.py | phungj/MSOE_Comp_Prog_Py | 95e7521b28d3dbcb6279e7baf03067ca27acbe37 | [
"MIT"
] | null | null | null | src/Codechef/Beginner/FLOW007.py | phungj/MSOE_Comp_Prog_Py | 95e7521b28d3dbcb6279e7baf03067ca27acbe37 | [
"MIT"
] | null | null | null | src/Codechef/Beginner/FLOW007.py | phungj/MSOE_Comp_Prog_Py | 95e7521b28d3dbcb6279e7baf03067ca27acbe37 | [
"MIT"
] | null | null | null | t = int(input())
for i in range(t):
n = input()
rev_n = int(n[::-1])
print(rev_n) | 15.666667 | 24 | 0.5 | 18 | 94 | 2.5 | 0.611111 | 0.177778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.014706 | 0.276596 | 94 | 6 | 25 | 15.666667 | 0.647059 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.2 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ca5c8ba97fa5559bc69d9b52a9b701d7e246d9ae | 2,243 | py | Python | musicalsave.py | sadcode-org/MusicalSave | 8e521479094cf427e0c030772dbfb9fd2a1d472e | [
"MIT"
] | 1 | 2020-01-31T15:47:11.000Z | 2020-01-31T15:47:11.000Z | musicalsave.py | sadcode-org/MusicalSave | 8e521479094cf427e0c030772dbfb9fd2a1d472e | [
"MIT"
] | null | null | null | musicalsave.py | sadcode-org/MusicalSave | 8e521479094cf427e0c030772dbfb9fd2a1d472e | [
"MIT"
] | null | null | null | import urllib.request
import re
import argparse
import sys
import os
from time import sleep
__version__ = "1.0"
banner = """
\033[1m\033[91m .d888888b.
d88888888b
8888 8888
8888 8888
8888 8888 .d888888b.
8888 8888 d88888888b
8888 8888 8888 8888
8888 8888 8888 8888
8888 8888 8888 8888
d88P 8888 8888 8888
888888888888888b. 8888 8888 "88888888888888
8888888888888P" 8888 8888 Y8888888888888
8888 8888
"888 888"
Y888888Y
\033[93mMusical.ly Downloader (\033[91mMusicalSave\033[93m)
\033[94mMade with <3 by: \033[93mSadCode Official (\033[91mSadCode\033[93m)
\033[94mVersion: \033[93m{}
\033[0m
"""
def download(url):
print("\033[1;92m [+] Visiting -->\033[93m", url)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print("\033[1;92m [+] Extracting Video")
file_url = re.search('http(.*)mp4', html)
file_url = file_url[0]
file_name = file_url.split("/")[-1]
path = file_name
print("\033[1;92m [+] Downloading -->\033[93m", path)
urllib.request.urlretrieve(file_url, path)
print("\033[1;33m [!] Successfully Downloaded To -->\033[93m",
os.getcwd()+"/"+str(file_name),
"\033[0m")
def main():
parser = argparse.ArgumentParser(description = "Musical.ly Downloader")
parser.add_argument("-u", "--url",
help = "URL to the Musical.ly video.")
parser.add_argument("-v", "--version",
action='store_true',
help = "Get the current version.")
args = parser.parse_args()
if args.version:
print(__version__)
elif args.url:
print(banner.format(__version__))
download(args.url)
elif len(sys.argv) == 1:
parser.print_help()
main()
| 28.75641 | 90 | 0.501115 | 231 | 2,243 | 4.757576 | 0.406926 | 0.160146 | 0.163785 | 0.174704 | 0.083712 | 0.083712 | 0.083712 | 0.043676 | 0.043676 | 0.043676 | 0 | 0.233842 | 0.38609 | 2,243 | 77 | 91 | 29.12987 | 0.56427 | 0 | 0 | 0.103448 | 0 | 0.017241 | 0.592798 | 0.024931 | 0 | 0 | 0 | 0 | 0 | 1 | 0.034483 | false | 0 | 0.103448 | 0 | 0.137931 | 0.12069 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ca778b4d6545d7967dcda6857d7c4d9279905ee7 | 529 | py | Python | rl_groundup/functions/linear_value_function.py | TristanBester/rl_groundup | 2e981667e21330a35a6ab2a642e278aaaf4dca84 | [
"MIT"
] | 1 | 2021-04-20T00:43:43.000Z | 2021-04-20T00:43:43.000Z | rl_groundup/functions/linear_value_function.py | TristanBester/rl_groundup | 2e981667e21330a35a6ab2a642e278aaaf4dca84 | [
"MIT"
] | null | null | null | rl_groundup/functions/linear_value_function.py | TristanBester/rl_groundup | 2e981667e21330a35a6ab2a642e278aaaf4dca84 | [
"MIT"
] | null | null | null | # Created by Tristan Bester.
import numpy as np
class LinearValueFunction(object):
'''A parametric function used to approximate the state-value function
under a specific policy. The approximate value for a given state
is equal to the dot product of the states feature vector and the
parameter vector of the function.
'''
def __init__(self, n_weights):
self.weights = np.zeros(n_weights)
def evaluate(self, feature_vector):
return np.dot(self.weights, feature_vector)
| 33.0625 | 74 | 0.705104 | 73 | 529 | 5 | 0.589041 | 0.106849 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.234405 | 529 | 15 | 75 | 35.266667 | 0.901235 | 0.487713 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.166667 | 0.166667 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
ca79ab655ae737f8bf3baec1d15ae2e0aa37e480 | 352 | py | Python | template/src/exception.py | zhkzyth/storm_maker | 01e90742fb6aacc139cd94f6ea01fa7795ef5204 | [
"MIT"
] | null | null | null | template/src/exception.py | zhkzyth/storm_maker | 01e90742fb6aacc139cd94f6ea01fa7795ef5204 | [
"MIT"
] | null | null | null | template/src/exception.py | zhkzyth/storm_maker | 01e90742fb6aacc139cd94f6ea01fa7795ef5204 | [
"MIT"
] | null | null | null | #! /usr/bin/env python
# encoding: utf-8
class TimeOutError(Exception):
pass
class MaxRetryError(Exception):
pass
class GodError(Exception):
"""
custom exception msg class
"""
def __init__(self, msg="Intern Error", code=500):
self.msg = msg
self.code = code
def __str__(self):
return self.msg
| 15.304348 | 53 | 0.619318 | 42 | 352 | 5 | 0.571429 | 0.1 | 0.171429 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015504 | 0.267045 | 352 | 22 | 54 | 16 | 0.79845 | 0.181818 | 0 | 0.2 | 0 | 0 | 0.04428 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.2 | 0 | 0.1 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
ca7b79dfdd8c7b6c57c03fb02e5cb974340d698b | 298 | py | Python | Exercises/gravity-between-two.py | shoriwe-upb/TallerEjercicios | ba37eb6cd673a8d38a1dfac87c5efac3f728da21 | [
"MIT"
] | null | null | null | Exercises/gravity-between-two.py | shoriwe-upb/TallerEjercicios | ba37eb6cd673a8d38a1dfac87c5efac3f728da21 | [
"MIT"
] | null | null | null | Exercises/gravity-between-two.py | shoriwe-upb/TallerEjercicios | ba37eb6cd673a8d38a1dfac87c5efac3f728da21 | [
"MIT"
] | null | null | null | def main():
object_a_mass = float(input("Object A mass: "))
object_b_mass = float(input("Object B mass: "))
distance = float(input("Distance between both: "))
G = 6.67408 * (10**11)
print(G*(object_a_mass*object_b_mass)/ (distance ** 2))
if __name__ == '__main__':
main()
| 27.090909 | 59 | 0.624161 | 43 | 298 | 3.953488 | 0.465116 | 0.123529 | 0.194118 | 0.235294 | 0.258824 | 0.258824 | 0 | 0 | 0 | 0 | 0 | 0.046218 | 0.201342 | 298 | 10 | 60 | 29.8 | 0.668067 | 0 | 0 | 0 | 0 | 0 | 0.204698 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0 | 0 | 0.125 | 0.125 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ca8d3c3797b6977c56edd3a5e98c5dcd7805603f | 537 | py | Python | tests/flytekit/unit/contrib/sensors/test_task.py | flytehub/flytekit | f8f53567594069b29fcd3f99abd1da71a5ef0e22 | [
"Apache-2.0"
] | null | null | null | tests/flytekit/unit/contrib/sensors/test_task.py | flytehub/flytekit | f8f53567594069b29fcd3f99abd1da71a5ef0e22 | [
"Apache-2.0"
] | null | null | null | tests/flytekit/unit/contrib/sensors/test_task.py | flytehub/flytekit | f8f53567594069b29fcd3f99abd1da71a5ef0e22 | [
"Apache-2.0"
] | null | null | null | from flytekit.contrib.sensors.base_sensor import Sensor as _Sensor
from flytekit.contrib.sensors.task import sensor_task
class MyMockSensor(_Sensor):
def __init__(self, **kwargs):
super(MyMockSensor, self).__init__(**kwargs)
def _do_poll(self):
"""
:rtype: (bool, Optional[datetime.timedelta])
"""
return True, None
def test_sensor_works():
@sensor_task
def my_test_task(wf_params):
return MyMockSensor()
out = my_test_task.unit_test()
assert len(out) == 0
| 21.48 | 66 | 0.666667 | 66 | 537 | 5.075758 | 0.545455 | 0.071642 | 0.113433 | 0.155224 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002404 | 0.225326 | 537 | 24 | 67 | 22.375 | 0.802885 | 0.081937 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.076923 | 1 | 0.307692 | false | 0 | 0.153846 | 0.076923 | 0.692308 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
ca94ba5628876db2b50859d8cfd0be5ce4121a83 | 116 | py | Python | curso-python-usp-01/exercicio_semana8a.py | veraueda/Python | 5115ff1f2a46e71c722eb1744c03439c84a2622f | [
"MIT"
] | null | null | null | curso-python-usp-01/exercicio_semana8a.py | veraueda/Python | 5115ff1f2a46e71c722eb1744c03439c84a2622f | [
"MIT"
] | null | null | null | curso-python-usp-01/exercicio_semana8a.py | veraueda/Python | 5115ff1f2a46e71c722eb1744c03439c84a2622f | [
"MIT"
] | null | null | null | carnes1 = ["picanha", "alcatra"]
carnes2 = ["filé mignon", "cupim", "ponta de alcatra"]
carnes3 = carnes2 + carnes1
| 29 | 54 | 0.672414 | 13 | 116 | 6 | 0.769231 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050505 | 0.146552 | 116 | 3 | 55 | 38.666667 | 0.737374 | 0 | 0 | 0 | 0 | 0 | 0.396552 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ca95b0ea88c159d7a113685b37bb5104223866db | 208 | py | Python | nrange.py | jiayoustone/high_performance_python | 63abb5e02bdbf086229b682b1768ed3afc63d8bb | [
"RSA-MD"
] | null | null | null | nrange.py | jiayoustone/high_performance_python | 63abb5e02bdbf086229b682b1768ed3afc63d8bb | [
"RSA-MD"
] | null | null | null | nrange.py | jiayoustone/high_performance_python | 63abb5e02bdbf086229b682b1768ed3afc63d8bb | [
"RSA-MD"
] | null | null | null | def nrange(start, stop, step=1):
while start < stop:
yield start
start += step
@profile
def ncall():
for i in nrange(1,1000000):
pass
if __name__ == "__main__":
ncall()
| 16 | 32 | 0.567308 | 27 | 208 | 4.074074 | 0.666667 | 0.163636 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.062937 | 0.3125 | 208 | 12 | 33 | 17.333333 | 0.706294 | 0 | 0 | 0 | 0 | 0 | 0.038462 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0.1 | 0 | 0 | 0.2 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
04658c970df82f5ce84bcb9c92f7f487d01793ab | 515 | py | Python | askhome/utils.py | mathead/pyask-smart-home | 3e93b287f96792715f5c3b48d6c79383aafba422 | [
"MIT"
] | null | null | null | askhome/utils.py | mathead/pyask-smart-home | 3e93b287f96792715f5c3b48d6c79383aafba422 | [
"MIT"
] | null | null | null | askhome/utils.py | mathead/pyask-smart-home | 3e93b287f96792715f5c3b48d6c79383aafba422 | [
"MIT"
] | null | null | null | import inflection
def get_action_string(func_name):
"""Transform function name to Alexa action"""
return rstrip_word(inflection.camelize(func_name, False), 'Request')
def get_request_string(func_name):
"""Transform function name to Alexa request name"""
return rstrip_word(inflection.camelize(func_name), 'Request') + 'Request'
def rstrip_word(text, suffix):
"""Strip suffix from end of text"""
if not text.endswith(suffix):
return text
return text[:len(text)-len(suffix)]
| 27.105263 | 77 | 0.716505 | 69 | 515 | 5.188406 | 0.405797 | 0.089385 | 0.078212 | 0.128492 | 0.469274 | 0.469274 | 0.469274 | 0.234637 | 0 | 0 | 0 | 0 | 0.16699 | 515 | 18 | 78 | 28.611111 | 0.834499 | 0.223301 | 0 | 0 | 0 | 0 | 0.054688 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.111111 | 0 | 0.888889 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
0481d27b19d427270fcb18731b7ea02afd3a7274 | 871 | py | Python | SoundPlayer.py | solidfake/TekkenBot | 5f7b144144206d56d8300d997d3a66654def509d | [
"MIT"
] | 15 | 2018-12-12T21:16:09.000Z | 2021-05-03T17:55:07.000Z | SoundPlayer.py | solidfake/TekkenBot | 5f7b144144206d56d8300d997d3a66654def509d | [
"MIT"
] | 3 | 2018-12-06T03:08:34.000Z | 2020-01-08T19:25:50.000Z | SoundPlayer.py | solidfake/TekkenBot | 5f7b144144206d56d8300d997d3a66654def509d | [
"MIT"
] | 7 | 2018-03-24T01:50:55.000Z | 2021-10-04T20:42:01.000Z | import winsound
import os
class SoundPlayer:
NOTES = 'A Bb B C Db D Eb E F Gb G Ab'.split()
launch_wav_exists = os.path.exists('"TekkenData/Sound/LAUNCH_PUNISH.wav"')
jab_wave_exists = os.path.exists('"TekkenData/Sound/LAUNCH_PUNISH.wav"')
def noteFreq(name, oct):
return int((27.5 * 2 ** oct) * 2.0 ** (SoundPlayer.NOTES.index(name) // 12.))
def play_no_launch_punish():
#if SoundPlayer.launch_wav_exists:
winsound.PlaySound("TekkenData/Sound/LAUNCH_PUNISH.wav", winsound.SND_ASYNC)
#else:
#winsound.Beep(SoundPlayer.noteFreq('Ab', 3), 750)
def play_no_jab_punish():
#if SoundPlayer.jab_wave_exists:
winsound.PlaySound("TekkenData/Sound/JAB_PUNISH.wav", winsound.SND_ASYNC)
#else:
#winsound.Beep(SoundPlayer.noteFreq('A', 3), 250) | 37.869565 | 89 | 0.639495 | 115 | 871 | 4.669565 | 0.443478 | 0.111732 | 0.117318 | 0.150838 | 0.554935 | 0.402235 | 0.402235 | 0.402235 | 0.402235 | 0.223464 | 0 | 0.023845 | 0.229621 | 871 | 23 | 90 | 37.869565 | 0.776453 | 0.197474 | 0 | 0 | 0 | 0 | 0.245536 | 0.203869 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.166667 | 0.083333 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
0486d55273cbf57ff05a0c4f76201f62c977d746 | 256 | py | Python | Set 8/PR1.py | rcsiit1/python-practicals | 76558dcbff2a6ae81ef4a5cb1d14c43a11c98faf | [
"Apache-2.0"
] | 1 | 2018-11-17T08:01:16.000Z | 2018-11-17T08:01:16.000Z | Set 8/PR1.py | rcsiit1/python-practicals | 76558dcbff2a6ae81ef4a5cb1d14c43a11c98faf | [
"Apache-2.0"
] | null | null | null | Set 8/PR1.py | rcsiit1/python-practicals | 76558dcbff2a6ae81ef4a5cb1d14c43a11c98faf | [
"Apache-2.0"
] | 1 | 2018-10-14T19:31:42.000Z | 2018-10-14T19:31:42.000Z | import turtle
p=turtle.Turtle()
def rec():
p.forward(100)
p.right(30)
p.forward(100)
p.right(150)
p.forward(100)
p.right(30)
p.forward(100)
p.right(150)
for i in range(36):
rec()
p.right(10)
turtle.exitOnClick()
| 12.8 | 20 | 0.585938 | 42 | 256 | 3.571429 | 0.404762 | 0.2 | 0.293333 | 0.32 | 0.52 | 0.52 | 0.52 | 0.52 | 0.52 | 0.52 | 0 | 0.135417 | 0.25 | 256 | 19 | 21 | 13.473684 | 0.645833 | 0 | 0 | 0.533333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.066667 | false | 0 | 0.066667 | 0 | 0.133333 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
0490e45df068823fa036a6870727adf57fe0434d | 1,615 | py | Python | modules/logger.py | Stefanlarsson95/RPI_Audio | 92416985806a4f25696e4d387b5a60cf6e277f2b | [
"MIT"
] | 1 | 2022-01-26T12:05:08.000Z | 2022-01-26T12:05:08.000Z | modules/logger.py | Stefanlarsson95/RPI_Audio | 92416985806a4f25696e4d387b5a60cf6e277f2b | [
"MIT"
] | null | null | null | modules/logger.py | Stefanlarsson95/RPI_Audio | 92416985806a4f25696e4d387b5a60cf6e277f2b | [
"MIT"
] | null | null | null |
'''
Multicollor logger by Stefan Larsson
'''
import datetime
class LOGLEVEL:
def __init__(self):
pass
FATAL = -1
ERROR = 0
WARN = 1
INFO = 2
DEBUG = 3
class Log:
def __init__(self, level=LOGLEVEL.WARN):
self._lvl = level
def fatal(self, text): # Red
print("{}--:\033[91m FATAL\033[0m :--- {}".format(datetime.datetime.now().strftime("t:%S.%f"), text))
def err(self, text, err=''): # Red
if self._lvl >= LOGLEVEL.ERROR:
print("{}--:\033[91m ERROR\033[0m :--- {}: {}".format(datetime.datetime.now().strftime("t:%S.%f"), text, err))
def warn(self, text): # Magenta
if self._lvl >= LOGLEVEL.WARN:
print("{}--:\033[95m Warning\033[0m :--- {}".format(datetime.datetime.now().strftime("t:%S.%f"), text))
def info(self, text): # Green
if self._lvl >= LOGLEVEL.INFO:
print("{}--:\033[92m Info\033[0m :--- {}".format(datetime.datetime.now().strftime("t:%S.%f"), text))
def debug(self, text): # Yellow
if self._lvl >= LOGLEVEL.DEBUG:
print("{}--:\033[93m Debug\033[0m :--- {}".format(datetime.datetime.now().strftime("t:%S.%f"), text))
def blue(self, text): # Blue
if self._lvl >= LOGLEVEL.DEBUG:
print("{}--:\033[94m Debug\033[0m :--- {}".format(datetime.datetime.now().strftime("t:%S.%f"), text))
def set_level(self, level):
if level in range(-1, 3):
self._lvl = level
else:
self.warn("Unable to set Log level: " + str(level))
def get_level(self):
return self._lvl
| 29.363636 | 122 | 0.546749 | 212 | 1,615 | 4.080189 | 0.268868 | 0.06474 | 0.076301 | 0.131792 | 0.410405 | 0.410405 | 0.410405 | 0.34104 | 0.34104 | 0.34104 | 0 | 0.05033 | 0.249536 | 1,615 | 54 | 123 | 29.907407 | 0.663366 | 0.043963 | 0 | 0.111111 | 0 | 0 | 0.18051 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.277778 | false | 0.027778 | 0.027778 | 0.027778 | 0.527778 | 0.166667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
04aec817a0b9a71ad89b396d6bdf644968ba36a3 | 846 | py | Python | brainstorm/games/even.py | znhv/winsio | 4d4e69961285ea3dcebc5ad6358e2d753d6b4f9d | [
"MIT"
] | null | null | null | brainstorm/games/even.py | znhv/winsio | 4d4e69961285ea3dcebc5ad6358e2d753d6b4f9d | [
"MIT"
] | null | null | null | brainstorm/games/even.py | znhv/winsio | 4d4e69961285ea3dcebc5ad6358e2d753d6b4f9d | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""Module with the logic of the game even."""
import random
NAME = "Even"
RULES = 'Answer "yes" if the number is even, otherwise answer "no".'
def is_even(num):
"""Проверяем, является ли число простым или нет.
Args:
num (int): Случайное число от 1 до 10
Returns:
bool: Если число простое, то возвращаем да, иначе нет.
"""
return "yes" if (num % 2) == 0 else "no"
def generate_number():
"""Генерируем случайное число от 1 до 10.
Returns:
int: Возвращаем случайное число.
"""
return random.randint(1, 10)
def generate_round():
"""
Генерируем раунд.
Returns:
question: Вопрос пользователю
result: Правильный ответ на вопрос
"""
question = generate_number()
answer = is_even(question)
return question, answer
| 19.674419 | 68 | 0.619385 | 108 | 846 | 4.805556 | 0.564815 | 0.034682 | 0.061657 | 0.065511 | 0.1079 | 0.1079 | 0.1079 | 0 | 0 | 0 | 0 | 0.019417 | 0.269504 | 846 | 42 | 69 | 20.142857 | 0.820388 | 0.48818 | 0 | 0 | 0 | 0 | 0.188202 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.272727 | false | 0 | 0.090909 | 0 | 0.636364 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
04b3991cd22751e28a53cb60309195fc7ac3b882 | 201 | py | Python | Beginner/hello.py | saurabhpati/python.beginner | a1ed49eb0da7aea80d914ef8b6df162ebf8abae1 | [
"MIT"
] | null | null | null | Beginner/hello.py | saurabhpati/python.beginner | a1ed49eb0da7aea80d914ef8b6df162ebf8abae1 | [
"MIT"
] | null | null | null | Beginner/hello.py | saurabhpati/python.beginner | a1ed49eb0da7aea80d914ef8b6df162ebf8abae1 | [
"MIT"
] | null | null | null | # Displays the use of arguments passed to a program.
# run this program with hello.py <first argument> <second argument> ...
import sys;
x = sys.argv;
print('Number of arguments', len(x));
print(x);
| 22.333333 | 71 | 0.706468 | 32 | 201 | 4.4375 | 0.75 | 0.15493 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.164179 | 201 | 8 | 72 | 25.125 | 0.845238 | 0.597015 | 0 | 0 | 0 | 0 | 0.24359 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0.5 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
04b45203e03add904a52d903b81d24c85a7bc104 | 573 | py | Python | DESAFIO-017.py | Lukones/Evolution-Projetos-Python | d979f3702f0e22ab5256b19fd957dba587c44f85 | [
"MIT"
] | null | null | null | DESAFIO-017.py | Lukones/Evolution-Projetos-Python | d979f3702f0e22ab5256b19fd957dba587c44f85 | [
"MIT"
] | null | null | null | DESAFIO-017.py | Lukones/Evolution-Projetos-Python | d979f3702f0e22ab5256b19fd957dba587c44f85 | [
"MIT"
] | null | null | null | # Um programa que análisa o nome e faz alterações no mesmo #
nome = str(input('Digite seu nome: ')).strip()
print('Analiando seu nome...')
print(f'Seu nome em maiúsculas é {(nome.upper())}')
print(f'Seu nome em minúsculas é {(nome.lower())}')
print(f'Seu nome tem ao todo {(len(nome) - nome.count(" "))} letras')
# Os dois modos abaixos desconsideram o espaço e conta as letras #
print(f'Seu primeiro nome tem {(nome.find(" "))} letras') # modo direto
separa = nome.split() #modo alternativo
print(f'Seu primeiro nome é {separa[0]} e ele tem {len(separa[0])} letras')
| 38.2 | 75 | 0.685864 | 94 | 573 | 4.180851 | 0.510638 | 0.089059 | 0.114504 | 0.099237 | 0.183206 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004115 | 0.151832 | 573 | 14 | 76 | 40.928571 | 0.804527 | 0.26178 | 0 | 0 | 0 | 0 | 0.702899 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.75 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
04db55985f7d3ca283f70d2a7a4d60d8b10b60be | 943 | py | Python | pyopenproject/business/services/command/group/find.py | webu/pyopenproject | 40b2cb9fe0fa3f89bc0fe2a3be323422d9ecf966 | [
"MIT"
] | 5 | 2021-02-25T15:54:28.000Z | 2021-04-22T15:43:36.000Z | pyopenproject/business/services/command/group/find.py | webu/pyopenproject | 40b2cb9fe0fa3f89bc0fe2a3be323422d9ecf966 | [
"MIT"
] | 7 | 2021-03-15T16:26:23.000Z | 2022-03-16T13:45:18.000Z | pyopenproject/business/services/command/group/find.py | webu/pyopenproject | 40b2cb9fe0fa3f89bc0fe2a3be323422d9ecf966 | [
"MIT"
] | 6 | 2021-06-18T18:59:11.000Z | 2022-03-27T04:58:52.000Z | from pyopenproject.api_connection.exceptions.request_exception import RequestError
from pyopenproject.api_connection.requests.get_request import GetRequest
from pyopenproject.business.exception.business_error import BusinessError
from pyopenproject.business.services.command.group.group_command import GroupCommand
from pyopenproject.model.group import Group
class Find(GroupCommand):
def __init__(self, connection, group):
"""Constructor for class Find, from GroupCommand.
:param connection: The connection data
:param group: The group to find
"""
super().__init__(connection)
self.group = group
def execute(self):
try:
json_obj = GetRequest(self.connection, f"{self.CONTEXT}/{self.group.id}").execute()
return Group(json_obj)
except RequestError as re:
raise BusinessError(f"Error finding group by id: {self.group.id}") from re
| 37.72 | 95 | 0.724284 | 110 | 943 | 6.063636 | 0.418182 | 0.127436 | 0.05997 | 0.089955 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.194062 | 943 | 24 | 96 | 39.291667 | 0.877632 | 0.125133 | 0 | 0 | 0 | 0 | 0.09068 | 0.037783 | 0 | 0 | 0 | 0 | 0 | 1 | 0.133333 | false | 0 | 0.333333 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
04de3431ff5c359b045f338c5363ab8b486a6f81 | 627 | py | Python | rf2settings/app/__init__.py | tappi287/rf2_video_settings | 6ae73c63f48e6d515a9efb653f236dea0494d9f1 | [
"MIT"
] | 8 | 2020-12-09T17:34:40.000Z | 2022-02-21T10:15:09.000Z | rf2settings/app/__init__.py | tappi287/rf2_video_settings | 6ae73c63f48e6d515a9efb653f236dea0494d9f1 | [
"MIT"
] | 11 | 2021-02-27T00:21:47.000Z | 2022-02-25T14:41:56.000Z | rf2settings/app/__init__.py | tappi287/rf2_video_settings | 6ae73c63f48e6d515a9efb653f236dea0494d9f1 | [
"MIT"
] | 2 | 2021-06-28T21:11:53.000Z | 2022-02-06T17:20:18.000Z | from . import app_content, app_controller, app_main, app_presets, app_rfconnect, app_multiplayer, \
app_dashboard, app_graphics, app_headlights, app_benchmark
def expose_app_methods():
app_content.expose_content_methods()
app_controller.expose_controller_methods()
app_main.expose_main_methods()
app_presets.expose_preset_methods()
app_rfconnect.expose_rfconnect_methods()
app_multiplayer.expose_multiplayer_methods()
app_dashboard.expose_dashboard_methods()
app_graphics.expose_graphics_methods()
app_headlights.expose_headlights_methods()
app_benchmark.expose_benchmark_methods() | 41.8 | 99 | 0.816587 | 76 | 627 | 6.184211 | 0.223684 | 0.212766 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.113238 | 627 | 15 | 100 | 41.8 | 0.845324 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.076923 | true | 0 | 0.076923 | 0 | 0.153846 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
04f3d46831827f3143e08040c1b0e0ec28c794c5 | 326 | py | Python | blog/views.py | pradyumnakr/portfolio-project | 972ec9112b88fdcddf12904d5a5745569b6e7bf5 | [
"Apache-2.0"
] | null | null | null | blog/views.py | pradyumnakr/portfolio-project | 972ec9112b88fdcddf12904d5a5745569b6e7bf5 | [
"Apache-2.0"
] | null | null | null | blog/views.py | pradyumnakr/portfolio-project | 972ec9112b88fdcddf12904d5a5745569b6e7bf5 | [
"Apache-2.0"
] | null | null | null | from django.shortcuts import render,get_object_or_404
from .models import Blog
def allblogs(request):
blogs=Blog.objects
return render(request,'blog/allblogs.html',{'blogs':blogs})
def detail(request,blog_id):
detailblog=get_object_or_404(Blog,pk=blog_id)
return render(request,'blog/detail.html',{'blog':detailblog}) | 32.6 | 62 | 0.788344 | 49 | 326 | 5.081633 | 0.44898 | 0.13253 | 0.088353 | 0.11245 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02 | 0.079755 | 326 | 10 | 62 | 32.6 | 0.81 | 0 | 0 | 0 | 0 | 0 | 0.131498 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.25 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
04f5939b88b74e8324bf166ca676a2324ebbde78 | 1,623 | py | Python | assets/views.py | ciscochao/IMU_DevOps | aa9c1d2d97f4b986870ed53b2235bf0e32de13a7 | [
"MIT"
] | null | null | null | assets/views.py | ciscochao/IMU_DevOps | aa9c1d2d97f4b986870ed53b2235bf0e32de13a7 | [
"MIT"
] | null | null | null | assets/views.py | ciscochao/IMU_DevOps | aa9c1d2d97f4b986870ed53b2235bf0e32de13a7 | [
"MIT"
] | null | null | null | from django.shortcuts import render
from django.shortcuts import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import json
from assets import models
from assets import assets_handler
from django.shortcuts import get_object_or_404
# Create your views here.
@csrf_exempt
def report(request):
if request.method == "POST":
assets_data = request.POST.get('assets_data')
print(assets_data)
data = json.loads(assets_data)
# 判断data是否为空
if not data:
return HttpResponse("提交的数据为空!")
if not issubclass(dict, type(data)):
return HttpResponse("提交的数据必须是字典格式!")
# 判断提交的数据是否有唯一键:sn
sn = data.get('sn', None)
if sn:
# 判断是否为线上资产中存在的资产
assets_obj = models.Assets.objects.filter(sn=sn)
if assets_obj:
# 更新线上资产信息
update_assets = assets_handler.UpdateAssets(request, assets_obj[0], data)
return HttpResponse("资产已更新!")
else:
# 进入待审批区域
obj = assets_handler.NewAssets(request, data)
response = obj.add_to_new_assets_zone()
return HttpResponse(response)
else:
return HttpResponse("提交的数据中未包含SN,请校验数据!")
return HttpResponse("怎么就200了!")
def index(request):
assets = models.Assets.objects.all()
return render(request, 'assets/index.html', locals())
def dashboard(request):
pass
return render(request, 'assets/dashborad.html', locals())
def detail(request):
pass
return render(request, 'assets/detail.html', locals())
| 30.055556 | 89 | 0.636476 | 179 | 1,623 | 5.659218 | 0.385475 | 0.106614 | 0.056269 | 0.074038 | 0.071076 | 0.071076 | 0 | 0 | 0 | 0 | 0 | 0.005907 | 0.269871 | 1,623 | 53 | 90 | 30.622642 | 0.848945 | 0.051756 | 0 | 0.102564 | 0 | 0 | 0.082245 | 0.013708 | 0 | 0 | 0 | 0 | 0 | 1 | 0.102564 | false | 0.051282 | 0.179487 | 0 | 0.512821 | 0.025641 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
b6bd80f40c880d0005d1ffcae7c79bc76b9a863b | 524 | py | Python | modules/connector.py | danielmarostica/python-data-flow | 99d13a35ec1dcc10d374af737f0432ff14d68016 | [
"MIT"
] | 1 | 2021-07-07T22:09:32.000Z | 2021-07-07T22:09:32.000Z | modules/connector.py | danielmarostica/python-data-flow | 99d13a35ec1dcc10d374af737f0432ff14d68016 | [
"MIT"
] | null | null | null | modules/connector.py | danielmarostica/python-data-flow | 99d13a35ec1dcc10d374af737f0432ff14d68016 | [
"MIT"
] | null | null | null | import pyodbc as pyodbc
import sys
def connect():
print('Conectando ao prod...')
server = '19.360.30.105\NAME'
database = 'name'
username = 'data'
password = '7JCP'
try:
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = connection.cursor()
except pyodbc.Error as ex:
sqlstate = ex.args[1]
print(sqlstate)
else:
print('Conectado.')
return cursor | 26.2 | 149 | 0.616412 | 62 | 524 | 5.209677 | 0.645161 | 0.074303 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035176 | 0.240458 | 524 | 20 | 150 | 26.2 | 0.776382 | 0 | 0 | 0 | 0 | 0 | 0.241905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0.117647 | 0.117647 | null | null | 0.176471 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
b6e9a6c80ded65367af3be82a6a4bd9e4752846d | 8,162 | py | Python | skactiveml/stream/tests/test_uncertainty_zliobaite.py | LukasLuehrs/scikit-activeml | 04d7107272ef0438070808475599131d8726f547 | [
"BSD-3-Clause"
] | null | null | null | skactiveml/stream/tests/test_uncertainty_zliobaite.py | LukasLuehrs/scikit-activeml | 04d7107272ef0438070808475599131d8726f547 | [
"BSD-3-Clause"
] | null | null | null | skactiveml/stream/tests/test_uncertainty_zliobaite.py | LukasLuehrs/scikit-activeml | 04d7107272ef0438070808475599131d8726f547 | [
"BSD-3-Clause"
] | null | null | null | import unittest
import numpy as np
from sklearn.datasets import make_classification
from skactiveml.classifier import ParzenWindowClassifier
from skactiveml.stream import (
FixedUncertainty,
VariableUncertainty,
Split,
RandomVariableUncertainty,
)
class TemplateTestUncertaintyZliobaite:
def setUp(self):
# initialise valid data to test uncertainty parameters
rand = np.random.RandomState(0)
stream_length = 100
train_init_size = 10
X, y = make_classification(
n_samples=stream_length + train_init_size,
random_state=rand.randint(2**31 - 1),
shuffle=True,
)
self.X = X[:train_init_size, :]
self.candidates = X[train_init_size:, :]
self.y = y[:train_init_size]
self.clf = ParzenWindowClassifier()
self.kwargs = dict(
candidates=self.candidates, clf=self.clf, X=self.X, y=self.y
)
def test_init_param_budget(self):
# budget must be defined as a float greater than 0
query_strategy = self.get_query_strategy()(budget=[])
self.assertRaises(TypeError, query_strategy.query, **(self.kwargs))
query_strategy = self.get_query_strategy()(budget="string")
self.assertRaises(TypeError, query_strategy.query, **(self.kwargs))
query_strategy = self.get_query_strategy()(budget=-1)
self.assertRaises(TypeError, query_strategy.query, **(self.kwargs))
def test_init_param_budget_manager(self):
# budgetmanager must be defined as an object of an budget manager
# class
query_strategy = self.get_query_strategy()(budget_manager=[])
self.assertRaises(TypeError, query_strategy.query, **(self.kwargs))
def test_init_param_random_state(self):
query_strategy = self.get_query_strategy()(
random_state="string",
)
self.assertRaises(ValueError, query_strategy.query, **(self.kwargs))
def test_query_param_candidates(self):
# candidates must be defined as a two dimensinal array
query_strategy = self.get_query_strategy()()
self.assertRaises(
ValueError,
query_strategy.query,
candidates=1,
clf=self.clf,
X=self.X,
y=self.y,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=None,
clf=self.clf,
X=self.X,
y=self.y,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=np.ones(5),
clf=self.clf,
X=self.X,
y=self.y,
)
def test_query_param_clf(self):
# clf must be defined as a classifier
query_strategy = self.get_query_strategy()()
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf="string",
X=self.X,
y=self.y,
)
query_strategy = self.get_query_strategy()()
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=1,
X=self.X,
y=self.y,
)
def test_query_param_X(self):
# X must be defined as a two dimensinal array and must be equal in
# length to y
query_strategy = self.get_query_strategy()()
self.assertRaises(
ValueError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=1,
y=self.y,
fit_clf=True,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=None,
y=self.y,
fit_clf=True,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=np.ones(5),
y=self.y,
fit_clf=True,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X[1:],
y=self.y,
fit_clf=True,
)
def test_query_param_y(self):
# y must be defined as a one Dimensional array and must be equal in
# length to X
query_strategy = self.get_query_strategy()()
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=1,
fit_clf=True,
)
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=None,
fit_clf=True,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y[1:],
fit_clf=True,
)
def test_query_param_sample_weight(self):
# sample weight needs to be a list that can be convertet to float
# equal in size of y
query_strategy = self.get_query_strategy()()
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y[1:],
sample_weight="string",
fit_clf=True,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y[1:],
sample_weight=["string", "numbers", "test"],
fit_clf=True,
)
self.assertRaises(
ValueError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y[1:],
sample_weight=[1],
fit_clf=True,
)
def test_query_param_fit_clf(self):
# fit_clf needs to be a boolean
query_strategy = self.get_query_strategy()()
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y,
fit_clf="string",
)
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y,
fit_clf=1,
)
def test_query_param_return_utilities(self):
# return_utilities needs to be a boolean
query_strategy = self.get_query_strategy()()
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y[1:],
return_utilities="string",
)
self.assertRaises(
TypeError,
query_strategy.query,
candidates=self.candidates,
clf=self.clf,
X=self.X,
y=self.y[1:],
return_utilities=1,
)
class TestSplit(TemplateTestUncertaintyZliobaite, unittest.TestCase):
def get_query_strategy(self):
return Split
class TestFixedUncertainty(TemplateTestUncertaintyZliobaite, unittest.TestCase):
def get_query_strategy(self):
return FixedUncertainty
class TestVariableUncertainty(
TemplateTestUncertaintyZliobaite, unittest.TestCase
):
def get_query_strategy(self):
return VariableUncertainty
class TestRandomVariableUncertainty(
TemplateTestUncertaintyZliobaite, unittest.TestCase
):
def get_query_strategy(self):
return RandomVariableUncertainty
| 29.15 | 80 | 0.557584 | 846 | 8,162 | 5.210402 | 0.122931 | 0.159256 | 0.096416 | 0.12069 | 0.749546 | 0.72323 | 0.70735 | 0.676497 | 0.632486 | 0.562387 | 0 | 0.00532 | 0.355183 | 8,162 | 279 | 81 | 29.25448 | 0.832225 | 0.069468 | 0 | 0.628099 | 0 | 0 | 0.006992 | 0 | 0 | 0 | 0 | 0 | 0.099174 | 1 | 0.061983 | false | 0 | 0.020661 | 0.016529 | 0.119835 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
b6eb4f4b2f21f5874da407746c25ef56756db32f | 3,158 | py | Python | 2nd_100/problem120.py | takekoputa/project-euler | 6f434be429bd26f5d0f84f5ab0f5fa2bd677c790 | [
"MIT"
] | null | null | null | 2nd_100/problem120.py | takekoputa/project-euler | 6f434be429bd26f5d0f84f5ab0f5fa2bd677c790 | [
"MIT"
] | null | null | null | 2nd_100/problem120.py | takekoputa/project-euler | 6f434be429bd26f5d0f84f5ab0f5fa2bd677c790 | [
"MIT"
] | 1 | 2021-11-02T12:08:46.000Z | 2021-11-02T12:08:46.000Z | # Question: https://projecteuler.net/problem=120
# The coefficients of a^(odd) cancel out, so there might be a pattern ...
# n | X_n = (a-1)^n + (a+1)^n | mod a^2
#-----|----------------------------|--------
# 1 | 2a | 2a
# 2 | 2a^2 + 2 | 2
# 3 | 2a^3 + 6a | 6a
# 4 | 2a^4 + 6a^2 + 2 | 2
# 5 | 2a^5 + 20a^3 + 10a | 10a
# 6 | 2a^6 + 30a^4 + 30a^2 + 2 | 2
# 7 | 2a^7 + 42a^5 + 70a^3 + 14a | 14a
# So, if n is even, X^n = 2 (mod a^2)
# if n is odd, X^n = 2na (mod a^2)
# For a given 'a', what is the maximum x such that 2na = x (mod a^2) where n is an abitrary positive integer?
# We know that 2na is even, so if a if odd, the highest possible value of x is a^2 - 1
# if a is even, the highest possible value of x is a^2 - 2
# If a is even, then there exists k such that a = 2k. pick n = k, we have 2na = 2ka = a^2 = 0 (mod a^2)
# n = k - 1, we have 2na = a^2 - 2a (mod a^2)
# n = k - 2, we have 2na = a^2 - 4a (mod a^2)
# ...
# n = k - k, we have 2na = a^2 - 2ka = a^2 - a^2 = 0 (mod a^2)
# so the modulo group is {0, a^2 - 2ka}
# If a is odd, then there exists k such that a = 2k + 1. Pick n = 2k+1, then 2na = 2(2k+1)a = 2a^2 = 0 (mod a^2)
# ...
# n = k+2, then 2na = 2(k+2)a = (2k+1)a + 3a = a^2 + 3a = 3a = a^2 - a^2 + 3a = a^2 - (2k-2)a (mod a^2)
# n = k+1, then 2na = 2(k+1)a = (2k+1)a + a = a^2 + a = a = a^2 - (2k)a (mod a^2)
# start here -> n = k, then 2na = 2ka = (2k+1)a - a = a^2 - a (mod a^2)
# n = k-1, then 2na = 2(k-1)a = (2k+1)a - 3a = a^2 - 3a (mod a^2)
# n = k-2, then 2na = 2(k-2)a = (2k+1)a - 5a = a^2 - 5a (mod a^2)
# ...
# n = k-k, then 2na = 0 (mod a^2)
# so the modulo group is {0, a^2 - ka}
# So, if 'a' is odd, r_max = max(2, a^2 - a). Since a >= 3, r_max = a^2 - a
# if 'a' is even, r_max = max(2, a^2 - 2a). Since a >= 3, r_max = a^2 - 2a
# So, sum_{3,n}(r_max) = [sum_{1,n}(a^2-a)] - [sum_{3<=a<=n, 'a' even} (a)] - {a=1}(a^2-a) - {a=2}(a^2-a)
# = [sum_{1,n}(a^2-a)] - (2*[sum_{1<=i<=floor(n/2)} (i)] - 2) - {a=1}(a^2-a) - {a=2}(a^2-a)
# = 1/6 * n * (n+1) * (2n+1) - 1/2 * n * (n+1) - (2*n/2*(n/2+1) - 2) - 0 - 2
# = 1/3 * (n-1) * n * (n+1) - 1/4*n*(n+2)
N = 1000
result = (N-1)*N*(N+1) // 3 - N * (N+2)//4
print(result)
| 65.791667 | 163 | 0.329639 | 527 | 3,158 | 1.954459 | 0.155598 | 0.091262 | 0.072816 | 0.046602 | 0.436893 | 0.395146 | 0.33301 | 0.287379 | 0.223301 | 0.165049 | 0 | 0.141162 | 0.493034 | 3,158 | 47 | 164 | 67.191489 | 0.502186 | 0.952818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
b6ee0da47a30525b356a99911b7c63ec9d7832dd | 226 | py | Python | algorithm/challenges/stair.py | rishabhiitbhu/hackerrank | acc300851c81a29472177f15fd8b56ebebe853ea | [
"MIT"
] | null | null | null | algorithm/challenges/stair.py | rishabhiitbhu/hackerrank | acc300851c81a29472177f15fd8b56ebebe853ea | [
"MIT"
] | null | null | null | algorithm/challenges/stair.py | rishabhiitbhu/hackerrank | acc300851c81a29472177f15fd8b56ebebe853ea | [
"MIT"
] | 1 | 2020-01-30T06:47:09.000Z | 2020-01-30T06:47:09.000Z | n = int(input().strip())
for i in range(0,n):
for y in range(0,n):
if(y<n-i-1):
print(' ', end='')
elif(y>=n-i-1 and y!=n-1):
print('#',end='')
else:
print('#')
| 20.545455 | 34 | 0.376106 | 36 | 226 | 2.361111 | 0.472222 | 0.070588 | 0.188235 | 0.211765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.035714 | 0.380531 | 226 | 10 | 35 | 22.6 | 0.571429 | 0 | 0 | 0 | 0 | 0 | 0.013333 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.333333 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8e06293f0d749c6d5f00950fb1f2b0ba3afe8475 | 598 | py | Python | test_haystack/test_app_using_appconfig/tests.py | skirsdeda/django-haystack | 5bec313d8271eb11524b9aa7710983605023ec35 | [
"BSD-3-Clause"
] | null | null | null | test_haystack/test_app_using_appconfig/tests.py | skirsdeda/django-haystack | 5bec313d8271eb11524b9aa7710983605023ec35 | [
"BSD-3-Clause"
] | 2 | 2016-03-16T10:45:01.000Z | 2017-03-24T08:18:38.000Z | test_haystack/test_app_using_appconfig/tests.py | chelis/django-haystack | 94558b34c6b3c490e8d5a9bd4be25d67335aa1ad | [
"BSD-3-Clause"
] | 1 | 2016-09-01T14:09:13.000Z | 2016-09-01T14:09:13.000Z | # encoding: utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
import django
from django.test import TestCase
from .models import MicroBlogPost
from ..utils import unittest
@unittest.skipIf(django.VERSION < (1, 7), 'AppConfig tests do not apply to Django versions before 1.7')
class AppConfigTests(TestCase):
def test_index_collection(self):
from haystack import connections
unified_index = connections['default'].get_unified_index()
models = unified_index.get_indexed_models()
self.assertIn(MicroBlogPost, models)
| 26 | 103 | 0.759197 | 74 | 598 | 5.932432 | 0.594595 | 0.082005 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01002 | 0.165552 | 598 | 22 | 104 | 27.181818 | 0.869739 | 0.025084 | 0 | 0 | 0 | 0 | 0.111876 | 0 | 0 | 0 | 0 | 0 | 0.083333 | 1 | 0.083333 | false | 0 | 0.5 | 0 | 0.666667 | 0.083333 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
8e064397fb0ff387ef967e65d16da5895cef6eaa | 8,920 | py | Python | tinkercellrepo/python/wikidust/mapupload_test.py | dhlee4/Tinkercell_new | c4d1848bbb905f0e1f9e011837268ac80aff8711 | [
"BSD-3-Clause"
] | 1 | 2021-01-07T13:12:51.000Z | 2021-01-07T13:12:51.000Z | tinkercellrepo/python/wikidust/mapupload_test.py | dhlee4/Tinkercell_new | c4d1848bbb905f0e1f9e011837268ac80aff8711 | [
"BSD-3-Clause"
] | 7 | 2020-04-12T22:25:46.000Z | 2020-04-13T07:50:40.000Z | tinkercellrepo/python/wikidust/mapupload_test.py | daniel-anavaino/tinkercell | 7896a7f809a0373ab3c848d25e3691d10a648437 | [
"BSD-3-Clause"
] | 2 | 2020-04-12T21:57:01.000Z | 2020-04-12T21:59:29.000Z | #TODO also test handling of bad input
import unittest
import test
import mapupload
import wikibrowser
import os, sys
from getpass import getpass
#LOG_PATH = "mapupload.log"
#log = WikiDustLogger(path=LOG_PATH)
class MapUploadTest(unittest.TestCase):
def __init__(self, url, username, password, error):
unittest.TestCase.__init__(self)
self.url = url
self.username = username
self.password = password
self.error = error
def setUp(self):
def noQuestions(message):
return False
mapupload.askQuestion = noQuestions # don't ask to send error reports
mapupload.DEFAULT_URL = self.url
self.uploader = mapupload.MapUploader()
self.checker = wikibrowser.Browser()
self.uploader.screenshotPath = test.testImages()[0]
self.uploader.mapCode = "[PASTE URL OF IMAGE HERE test image:%s]" % os.path.basename(self.uploader.screenshotPath)
if self.error == type(None): # else it won't be needed
self.checker.loadWiki(self.url, self.username, self.password)
self.uploader.username.set(self.username)
self.uploader.password.set(self.password)
def runTest(self):
try:
name = os.path.basename( self.uploader.screenshotPath )
code = self.uploader.mapCode
url = self.uploader.userSuppliedURL.get()
if self.error == None:
self.assertFalse( self.checker.fileExists(name) )
self.assertFalse( self.checker.codeExists(code, url) )
self.uploader.upload()
self.assertTrue( self.checker.fileExists(name) )
self.assertTrue( self.checker.codeExists(name, url) ) # actual code may change
self.assertEqual( self.error, type(self.uploader.lastSuppressed) )
else:
try:
self.uploader.upload()
self.assertEqual( self.error, type(self.uploader.lastSuppressed) )
except Exception, e:
self.assertEqual( self.error, type(e) )
print "%s is right" % self.error.__name__
except AssertionError:
print "%s should be %s" % (type(self.uploader.lastSuppressed), self.error)
print "details: %s" % self.uploader.lastSuppressed
raise SystemExit
def tearDown(self):
self.uploader.destroy()
self.checker.logout()
TEST_WIKIS = {}
JEFFWIKI = TEST_WIKIS["jeffwiki"] = {}
GOLDENBRICKS = TEST_WIKIS["goldenbricks"] = {}
REGISTRY = TEST_WIKIS["registry"] = {}
WIKIPEDIA = TEST_WIKIS["wikipedia"] = {}
# correct urls, usernames, passwords, and resulting exception types
JEFFWIKI_DEFAULTS = ( "http://wikidust.sbolstandard.org/index.php/Sandbox:Unittesting",
raw_input("JeffWiki username: "),
getpass("JeffWiki password: "), type(None) )
GOLDENBRICKS_DEFAULTS = ( "https://courses.washington.edu/synbio/goldenbricks/index.php?title=Test_3",
raw_input("UW netid username: "),
getpass("UW netid password: "), type(None) )
REGISTRY_DEFAULTS = ( "http://partsregistry.org/wiki/index.php?title=Part:BBa_K314000",
raw_input("Registry username: "),
getpass("Registry password: "), type(None) )
WIKIPEDIA_DEFAULTS = ( "http://en.wikipedia.org/wiki/User:Jeffdjohnson/map_code_sandbox2",
raw_input("Wikipedia username: "),
getpass("Wikipedia password: "), type(None) )
# test cases
JEFFWIKI["correct"] = JEFFWIKI_DEFAULTS
JEFFWIKI["locked"] = ("http://wikidust.sbolstandard.org/index.php/Main_Page", "", "", wikibrowser.PageLockedError)
JEFFWIKI["badurl"] = ("tinkercell.com", JEFFWIKI_DEFAULTS[1], JEFFWIKI_DEFAULTS[2], wikibrowser.BadURLError)
JEFFWIKI["wrongurl"] = ("http://www.tinkercell.com", JEFFWIKI_DEFAULTS[1], JEFFWIKI_DEFAULTS[2], wikibrowser.SiteLayoutError)
JEFFWIKI["nologin"] = (JEFFWIKI_DEFAULTS[0], "", "", JEFFWIKI_DEFAULTS[3])
JEFFWIKI["useronly"] = (JEFFWIKI_DEFAULTS[0], JEFFWIKI_DEFAULTS[1], "", wikibrowser.BadLoginError)
JEFFWIKI["passonly"] = (JEFFWIKI_DEFAULTS[0], "", "stuff", wikibrowser.BadLoginError)
JEFFWIKI["baduser"] = (JEFFWIKI_DEFAULTS[0], "jef", JEFFWIKI_DEFAULTS[2], wikibrowser.BadLoginError)
JEFFWIKI["badpass"] = (JEFFWIKI_DEFAULTS[0], JEFFWIKI_DEFAULTS[1], "stuff", wikibrowser.BadLoginError)
GOLDENBRICKS["correct"] = GOLDENBRICKS_DEFAULTS
GOLDENBRICKS["locked"] = ("https://courses.washington.edu/synbio/goldenbricks/index.php?title=Oscillators",
GOLDENBRICKS_DEFAULTS[1], GOLDENBRICKS_DEFAULTS[2], wikibrowser.PageLockedError)
GOLDENBRICKS["badurl"] = ("tinkercell.com", GOLDENBRICKS_DEFAULTS[1], GOLDENBRICKS_DEFAULTS[2], wikibrowser.BadURLError)
GOLDENBRICKS["wrongurl"] = ("http://www.tinkercell.com", GOLDENBRICKS_DEFAULTS[1], GOLDENBRICKS_DEFAULTS[2], wikibrowser.SiteLayoutError)
GOLDENBRICKS["nologin"] = (GOLDENBRICKS_DEFAULTS[0], "", "", wikibrowser.BadLoginError)
GOLDENBRICKS["useronly"] = (GOLDENBRICKS_DEFAULTS[0], GOLDENBRICKS_DEFAULTS[1], "", wikibrowser.BadLoginError)
GOLDENBRICKS["passonly"] = (GOLDENBRICKS_DEFAULTS[0], "", GOLDENBRICKS_DEFAULTS[2], wikibrowser.BadLoginError)
GOLDENBRICKS["baduser"] = (GOLDENBRICKS_DEFAULTS[0], "jeff2", GOLDENBRICKS_DEFAULTS[2], wikibrowser.BadLoginError)
GOLDENBRICKS["badpass"] = (GOLDENBRICKS_DEFAULTS[0], GOLDENBRICKS_DEFAULTS[1], "stuff!", wikibrowser.BadLoginError)
REGISTRY["correct"] = REGISTRY_DEFAULTS
REGISTRY["locked"] = ("http://partsregistry.org/wiki/index.php?title=MediaWiki:Monobook.css", #BE SURE THIS DOESN't WORK!!
REGISTRY_DEFAULTS[1], REGISTRY_DEFAULTS[2], wikibrowser.PageLockedError)
REGISTRY["badurl"] = ("www.amazon.com", REGISTRY_DEFAULTS[1], REGISTRY_DEFAULTS[2], wikibrowser.BadURLError)
REGISTRY["wrongurl"] = ("http://amazon.com", REGISTRY_DEFAULTS[1], REGISTRY_DEFAULTS[2], wikibrowser.SiteLayoutError)
REGISTRY["nologin"] = (REGISTRY_DEFAULTS[0], "", "", wikibrowser.BadLoginError)
REGISTRY["useronly"] = (REGISTRY_DEFAULTS[0], REGISTRY_DEFAULTS[1], "", wikibrowser.BadLoginError)
REGISTRY["passonly"] = (REGISTRY_DEFAULTS[0], "", REGISTRY_DEFAULTS[2], wikibrowser.BadLoginError)
REGISTRY["baduser"] = (REGISTRY_DEFAULTS[0], "eljefee", REGISTRY_DEFAULTS[2], wikibrowser.BadLoginError)
REGISTRY["badpass"] = (REGISTRY_DEFAULTS[0], REGISTRY_DEFAULTS[1], "wrongpass", wikibrowser.BadLoginError)
WIKIPEDIA["correct"] = WIKIPEDIA_DEFAULTS
WIKIPEDIA["badurl"] = ("http://com", WIKIPEDIA_DEFAULTS[1], WIKIPEDIA_DEFAULTS[2], wikibrowser.BadURLError)
WIKIPEDIA["wrongurl"] = ("http://ebay.com", WIKIPEDIA_DEFAULTS[1], WIKIPEDIA_DEFAULTS[2], wikibrowser.SiteLayoutError)
WIKIPEDIA["nologin"] = (WIKIPEDIA_DEFAULTS[0], "", "", wikibrowser.BadLoginError)
WIKIPEDIA["useronly"] = (WIKIPEDIA_DEFAULTS[0], WIKIPEDIA_DEFAULTS[1], "", wikibrowser.BadLoginError)
WIKIPEDIA["passonly"] = (WIKIPEDIA_DEFAULTS[0], "", WIKIPEDIA_DEFAULTS[2], wikibrowser.BadLoginError)
WIKIPEDIA["baduser"] = (WIKIPEDIA_DEFAULTS[0], "jhasdghasdjhkasf", WIKIPEDIA_DEFAULTS[2], wikibrowser.BadLoginError)
WIKIPEDIA["badpass"] = (WIKIPEDIA_DEFAULTS[0], WIKIPEDIA_DEFAULTS[1], "notright345u6", wikibrowser.BadLoginError)
WIKIPEDIA["locked"] = ("http://en.wikipedia.org/wiki/Main_Page",
WIKIPEDIA_DEFAULTS[1], WIKIPEDIA_DEFAULTS[2], wikibrowser.PageLockedError)
def suite():
suite = unittest.TestSuite()
for wiki in TEST_WIKIS:
if "" in TEST_WIKIS[wiki]["correct"][1:3]: # username or password not entered
continue
else:
if raw_input("test %s? " % wiki) == "yes":
wiki = TEST_WIKIS[wiki]
for login in wiki:
#if login == "correct":
# continue
print " adding test case %s" % login
login = wiki[login]
suite.addTest( MapUploadTest(url=login[0], username=login[1], password=login[2], error=login[3]) )
return suite
def runTests():
suite().debug()
if __name__ == "__main__":
runTests()
| 59.865772 | 137 | 0.619731 | 848 | 8,920 | 6.391509 | 0.220519 | 0.03321 | 0.066421 | 0.04262 | 0.361255 | 0.304613 | 0.165129 | 0.124723 | 0.086347 | 0 | 0 | 0.011735 | 0.254821 | 8,920 | 148 | 138 | 60.27027 | 0.803671 | 0.038901 | 0 | 0.064 | 0 | 0 | 0.148481 | 0 | 0 | 0 | 0 | 0.006757 | 0.064 | 0 | null | null | 0.144 | 0.048 | null | null | 0.032 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
8e105e119e936d7a04b176a73838d47040ee7b70 | 317 | py | Python | get_sdwan_device_list.py | GC-Younger-Team/AWS-Serverless-Architecture-based-Cisco-DNA-Demo-Platform | b11ba573f9c1dc33f0e23afce48b31afab4096d9 | [
"MIT"
] | 4 | 2020-10-26T07:56:15.000Z | 2021-07-07T03:55:28.000Z | get_sdwan_device_list.py | GC-Younger-Team/AWS-Serverless-Architecture-based-Cisco-DNA-Demo-Platform | b11ba573f9c1dc33f0e23afce48b31afab4096d9 | [
"MIT"
] | null | null | null | get_sdwan_device_list.py | GC-Younger-Team/AWS-Serverless-Architecture-based-Cisco-DNA-Demo-Platform | b11ba573f9c1dc33f0e23afce48b31afab4096d9 | [
"MIT"
] | 1 | 2021-07-07T03:55:29.000Z | 2021-07-07T03:55:29.000Z | import socket
import json
from get_device import get_device
def Logstash(event, context):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
get_device_list=get_device(event, context)
s.connect(('10.11.2.7', 6001))
s.send(str(json.dumps(get_device_list)).encode('utf-8'))
s.close()
| 26.416667 | 61 | 0.716088 | 52 | 317 | 4.192308 | 0.596154 | 0.206422 | 0.119266 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.040741 | 0.148265 | 317 | 12 | 62 | 26.416667 | 0.766667 | 0 | 0 | 0 | 0 | 0 | 0.044025 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.333333 | 0 | 0.444444 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
8e19be1c9e380660a020f79b041b56cda0f79b9e | 280 | py | Python | Nodes/Statements/Iterative/While.py | Mohsin-Ul-Islam/YAPL | 163da2dfd879fc6dee9bc0e1b1c94972c75935cd | [
"MIT"
] | null | null | null | Nodes/Statements/Iterative/While.py | Mohsin-Ul-Islam/YAPL | 163da2dfd879fc6dee9bc0e1b1c94972c75935cd | [
"MIT"
] | null | null | null | Nodes/Statements/Iterative/While.py | Mohsin-Ul-Islam/YAPL | 163da2dfd879fc6dee9bc0e1b1c94972c75935cd | [
"MIT"
] | null | null | null | class Node:
def __init__(self, condition, body):
self.condition = condition
self.body = body
def visit(self, context):
rvalue = None
while self.condition.visit(context):
rvalue = self.body.visit(context)
return rvalue
| 23.333333 | 45 | 0.6 | 31 | 280 | 5.290323 | 0.419355 | 0.237805 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.310714 | 280 | 11 | 46 | 25.454545 | 0.849741 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0 | 0 | 0.444444 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8e1b23884210499d861748fa0808dce0baa1a875 | 369 | py | Python | output/models/sun_data/mgroup_def/target_ns/target_ns00101m/target_ns00101m2_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 1 | 2021-08-14T17:59:21.000Z | 2021-08-14T17:59:21.000Z | output/models/sun_data/mgroup_def/target_ns/target_ns00101m/target_ns00101m2_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | 4 | 2020-02-12T21:30:44.000Z | 2020-04-15T20:06:46.000Z | output/models/sun_data/mgroup_def/target_ns/target_ns00101m/target_ns00101m2_xsd/__init__.py | tefra/xsdata-w3c-tests | b6b6a4ac4e0ab610e4b50d868510a8b7105b1a5f | [
"MIT"
] | null | null | null | from output.models.sun_data.mgroup_def.target_ns.target_ns00101m.target_ns00101m2_xsd.target_ns00101m1 import (
A1 as Ns00101M1A1,
A as Ns00101M1A,
)
from output.models.sun_data.mgroup_def.target_ns.target_ns00101m.target_ns00101m2_xsd.target_ns00101m2 import (
A1 as A1,
A as A,
)
__all__ = [
"Ns00101M1A1",
"Ns00101M1A",
"A1",
"A",
]
| 23.0625 | 111 | 0.728997 | 51 | 369 | 4.921569 | 0.392157 | 0.179283 | 0.12749 | 0.151394 | 0.621514 | 0.621514 | 0.621514 | 0.621514 | 0.621514 | 0.621514 | 0 | 0.20915 | 0.170732 | 369 | 15 | 112 | 24.6 | 0.611111 | 0 | 0 | 0 | 0 | 0 | 0.065041 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8e2b2e66f019f29bf60497463403aa4c2f760fb9 | 137 | py | Python | examples/image/cath/util/__init__.py | mariogeiger/se3cnn | afd027c72e87f2c390e0a2e7c6cfc8deea34b0cf | [
"MIT"
] | 170 | 2018-07-03T17:18:35.000Z | 2022-03-30T15:30:40.000Z | examples/image/cath/util/__init__.py | blondegeek/se3cnn | c918bafa7431d822bd5680efee2c60903513ffb5 | [
"MIT"
] | 34 | 2018-10-09T08:56:24.000Z | 2020-01-30T09:46:52.000Z | examples/image/cath/util/__init__.py | SuperXiang/se3cnn | afd027c72e87f2c390e0a2e7c6cfc8deea34b0cf | [
"MIT"
] | 40 | 2018-07-03T13:40:14.000Z | 2022-01-28T16:40:48.000Z | __all__ = [
'arch_blocks',
'get_mask',
'get_param_groups',
'logger',
'losses',
'lr_schedulers',
'optimizers_L1L2',
'tensorflow_logger',
] | 13.7 | 20 | 0.722628 | 16 | 137 | 5.5 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015873 | 0.080292 | 137 | 10 | 21 | 13.7 | 0.68254 | 0 | 0 | 0 | 0 | 0 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8e386ceda93c7d23d18e411133bdb452b31d861c | 1,019 | py | Python | api/swagger_server/test/test_menu_controller.py | dgisolfi/PythonPackaging | d756d23fa37b6467accc88ee8d72c9344da675b9 | [
"WTFPL"
] | null | null | null | api/swagger_server/test/test_menu_controller.py | dgisolfi/PythonPackaging | d756d23fa37b6467accc88ee8d72c9344da675b9 | [
"WTFPL"
] | null | null | null | api/swagger_server/test/test_menu_controller.py | dgisolfi/PythonPackaging | d756d23fa37b6467accc88ee8d72c9344da675b9 | [
"WTFPL"
] | null | null | null | # coding: utf-8
from __future__ import absolute_import
from six import BytesIO
from flask import json
from swagger_server.test import BaseTestCase
from swagger_server.models.item import Item # noqa: E501
from swagger_server.models.menu import Menu # noqa: E501
class TestMenuController(BaseTestCase):
"""MenuController integration test stubs"""
def test_get_menu(self):
"""Test case for get_menu
Returns all possible drinks
"""
response = self.client.open("/menu", method="GET")
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
def test_get_menu_item(self):
"""Test case for get_menu_item
Returns a drink specified by name
"""
response = self.client.open(
"/menu/{name}".format(name="name_example"), method="GET"
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
if __name__ == "__main__":
import unittest
unittest.main()
| 26.128205 | 87 | 0.66634 | 127 | 1,019 | 5.149606 | 0.417323 | 0.042813 | 0.077982 | 0.070336 | 0.348624 | 0.269113 | 0.201835 | 0.201835 | 0.201835 | 0.201835 | 0 | 0.019011 | 0.225711 | 1,019 | 38 | 88 | 26.815789 | 0.809886 | 0.185476 | 0 | 0.111111 | 0 | 0 | 0.116967 | 0 | 0 | 0 | 0 | 0 | 0.111111 | 1 | 0.111111 | false | 0 | 0.388889 | 0 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
8e4d2bf8090ebe5b7a2f57a8cc610dee694c17cf | 130 | py | Python | decrypt.py | tiodh/enkripsi | 3cbce829ef64534a301f557b3aa2197394c91600 | [
"CC0-1.0"
] | null | null | null | decrypt.py | tiodh/enkripsi | 3cbce829ef64534a301f557b3aa2197394c91600 | [
"CC0-1.0"
] | null | null | null | decrypt.py | tiodh/enkripsi | 3cbce829ef64534a301f557b3aa2197394c91600 | [
"CC0-1.0"
] | null | null | null | chipper = input('Input Message: ')
plain = ''
for alphabet in chipper:
temp = ord(alphabet)-1
plain += chr(temp)
print(plain)
| 14.444444 | 34 | 0.669231 | 18 | 130 | 4.833333 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009346 | 0.176923 | 130 | 8 | 35 | 16.25 | 0.803738 | 0 | 0 | 0 | 0 | 0 | 0.115385 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.166667 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
8e4fd57d97f6bb1315c28a6ff1e8dbb84dec1a75 | 2,283 | py | Python | ripper/proxy_manager.py | chancat87/russia_ddos | 4fac86f666b90c76f1a16a9ad457be4304577889 | [
"MIT"
] | null | null | null | ripper/proxy_manager.py | chancat87/russia_ddos | 4fac86f666b90c76f1a16a9ad457be4304577889 | [
"MIT"
] | null | null | null | ripper/proxy_manager.py | chancat87/russia_ddos | 4fac86f666b90c76f1a16a9ad457be4304577889 | [
"MIT"
] | null | null | null | import random
import threading
from ripper.proxy import Sock5Proxy
from ripper.constants import PROXY_MAX_FAILURE_RATIO, PROXY_MIN_VALIDATION_REQUESTS
lock = threading.Lock()
class ProxyManager:
"""Manager for proxy collection."""
proxy_list: list[Sock5Proxy] = []
"""Active proxies."""
proxy_list_initial_len: int = 0
"""Count of proxies during the last application."""
__proxy_extract_counter: int = 0
"""Vacuum operation is called automatically on every PROXY_MIN_VALIDATION_REQUESTS proxy extractions"""
def set_proxy_list(self, proxy_list: list[Sock5Proxy]):
self.proxy_list = proxy_list
self.proxy_list_initial_len = len(proxy_list)
# TODO prioritize faster proxies
def get_random_proxy(self) -> Sock5Proxy:
self.__proxy_extract_counter += 1
if self.__proxy_extract_counter % PROXY_MIN_VALIDATION_REQUESTS == 0:
self.vacuum()
if not self.proxy_list or not len(self.proxy_list):
return None
return random.choice(self.proxy_list)
def find_proxy_index(self, proxy: Sock5Proxy) -> int:
"""returns -1 if not found"""
try:
return self.proxy_list.index(proxy)
# except ValueError:
except:
return -1
def __delete_proxy(self, proxy: Sock5Proxy) -> bool:
index = self.find_proxy_index(proxy)
if index >= 0:
self.proxy_list.pop(index)
return index >= 0
def delete_proxy_sync(self, proxy: Sock5Proxy) -> bool:
lock.acquire()
is_deleted = self.__delete_proxy(proxy)
lock.release()
return is_deleted
def __validate_proxy(self, proxy: Sock5Proxy) -> bool:
total_cnt = proxy.success_cnt + proxy.failure_cnt
if total_cnt < PROXY_MIN_VALIDATION_REQUESTS:
return True
failure_ratio = proxy.failure_cnt / proxy.success_cnt
return failure_ratio < PROXY_MAX_FAILURE_RATIO
def vacuum(self) -> int:
"""Removes proxies which are not valid"""
new_proxy_list = list(filter(lambda proxy: self.__validate_proxy(proxy), self.proxy_list))
cnt = len(self.proxy_list) - len(new_proxy_list)
if cnt > 0:
self.proxy_list = new_proxy_list
return cnt
| 34.074627 | 107 | 0.667981 | 288 | 2,283 | 4.993056 | 0.288194 | 0.118915 | 0.099444 | 0.072323 | 0.069541 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009884 | 0.246605 | 2,283 | 66 | 108 | 34.590909 | 0.826163 | 0.061323 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015152 | 0 | 1 | 0.152174 | false | 0 | 0.086957 | 0 | 0.521739 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
8e50bf8bcb01978a8fa4750ec4ee173dea55986b | 4,207 | py | Python | baselines/agglomerative.py | ekQ/flan | 03eb6207ddbd71649ac103a0fa84676701d737c4 | [
"MIT"
] | 1 | 2018-12-26T11:54:23.000Z | 2018-12-26T11:54:23.000Z | baselines/agglomerative.py | ekQ/flan | 03eb6207ddbd71649ac103a0fa84676701d737c4 | [
"MIT"
] | null | null | null | baselines/agglomerative.py | ekQ/flan | 03eb6207ddbd71649ac103a0fa84676701d737c4 | [
"MIT"
] | 2 | 2017-08-27T17:52:39.000Z | 2019-10-20T10:49:38.000Z | """
NOTE: This method hasn't been used recently and therefor might not work as such.
Agglomerative clustering approach for multiple network alignment.
"""
import utilities as util
def agglomerative(asg, similarities, P, max_iters):
"""
Agglomerative approach for multiple network alignment.
TODO Get rid of similarities and use P instead
"""
# Do some magic...
changed = True
iteration = 0
while changed and iteration < max_iters:
print "Iteration %d." % (iteration+1)
changed = False
clusters = asg.get_cluster_keys()
min_cost = 1e20
min_src_clust = None
min_dst_clust = None
for i, src_clust in enumerate(clusters):
if len(similarities[src_clust]) <= 1:
continue
#print "Src clust:", src_clust, "|candidates|:", len(similarities[src_clust]), len(asg.get_candidates(src_clust))
clusters_set = set(asg.get_cluster_keys())
min_cost = 1e20
min_src_clust = None
min_dst_clust = None
for dst_clust in asg.get_candidates(src_clust):
if dst_clust not in clusters_set:
continue
#test_asg = asg.copy()
#test_asg.merge_clusters(src_clust, dst_clust)
#c = util.cost(test_asg, P)
updated_idxs = asg.update_all_matches(src_clust, dst_clust)
c = util.cost(asg, P)
asg.update_match(updated_idxs, src_clust)
#print "Dst clust: %d, cost: %f" % (dst_clust, c)
if c < min_cost:
min_cost = c
min_dst_clust = dst_clust
min_src_clust = src_clust
if min_src_clust != min_dst_clust:
#print "\tAssigning {} to {}.\tCost: {}".format(min_src_clust, min_dst_clust, min_cost)
asg.merge_clusters(min_src_clust, min_dst_clust)
changed = True
iteration += 1
print "Converged in %d iterations." % iteration
return asg
def agglomerative_fixed(asg, similarities, P, max_entities):
# Do some magic...
changed = True
iteration = 0
n_open = asg.count_opened_entities()
prev_cost = util.cost(asg, P)
while n_open > max_entities:
print "Iteration %d." % (iteration+1)
clusters = asg.get_cluster_keys()
min_cost = 1e20
min_extra_cost = 1e20
min_src_clust = None
min_dst_clust = None
min_n_merged = -1
for i, src_clust in enumerate(clusters):
if len(similarities[src_clust]) <= 1:
continue
#print "Src clust:", src_clust, "|candidates|:", len(similarities[src_clust]), len(asg.get_candidates(src_clust))
clusters_set = set(asg.get_cluster_keys())
for dst_clust in asg.get_candidates(src_clust):
if dst_clust == src_clust or dst_clust not in clusters_set:
continue
updated_idxs = asg.update_all_matches(src_clust, dst_clust)
c = util.cost(asg, P)
if c - prev_cost >= 0:
extra_cost = (c - prev_cost) / float(len(updated_idxs))
else:
extra_cost = c - prev_cost
#if len(updated_idxs) > 1:
# print "\t{}, {}".format(len(updated_idxs), extra_cost)
asg.update_match(updated_idxs, src_clust)
#print "Dst clust: %d, cost: %f" % (dst_clust, c)
if extra_cost < min_extra_cost:
min_cost = c
min_extra_cost = extra_cost
min_dst_clust = dst_clust
min_src_clust = src_clust
min_n_merged = len(updated_idxs)
asg.merge_clusters(min_src_clust, min_dst_clust)
n_open = asg.count_opened_entities()
print "\tAssigned {} ({}) to {}.\tCost: {}\tExtra cost: {}\tn_open: {}".format(min_src_clust, min_n_merged, min_dst_clust, min_cost, min_extra_cost, n_open)
iteration += 1
prev_cost = min_cost
print "Converged in %d iterations." % iteration
return asg
| 41.245098 | 164 | 0.577846 | 524 | 4,207 | 4.343511 | 0.19084 | 0.112478 | 0.04833 | 0.030756 | 0.70826 | 0.597979 | 0.554921 | 0.491213 | 0.45167 | 0.397627 | 0 | 0.008182 | 0.331828 | 4,207 | 101 | 165 | 41.653465 | 0.801494 | 0.145947 | 0 | 0.702703 | 0 | 0 | 0.043294 | 0 | 0 | 0 | 0 | 0.009901 | 0 | 0 | null | null | 0 | 0.013514 | null | null | 0.067568 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f3ce4f00a0a27d771dd9d18776a75e179077d360 | 1,152 | py | Python | authentico/forms.py | Dogruyer/hospital-automation | e5faffce93c0bda475cd0dbd0e7ef0f55b11564d | [
"Apache-2.0"
] | 2 | 2020-12-09T07:42:34.000Z | 2020-12-09T09:35:20.000Z | authentico/forms.py | Dogruyer/hospital-automation | e5faffce93c0bda475cd0dbd0e7ef0f55b11564d | [
"Apache-2.0"
] | 6 | 2020-06-05T19:34:52.000Z | 2022-03-11T23:35:55.000Z | authentico/forms.py | Dogruyer/hospital-automation | e5faffce93c0bda475cd0dbd0e7ef0f55b11564d | [
"Apache-2.0"
] | 2 | 2018-01-30T20:12:20.000Z | 2020-12-09T07:42:38.000Z | from django.forms import ModelForm, forms
from django import forms
from .models import User
from django.contrib.auth.forms import UserCreationForm
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True)
class Meta:
model = User
fields = ("username", "email", "password1", "password2")
def clean_email(self):
email = self.cleaned_data.get('email')
username = self.cleaned_data.get('username')
if email and User.objects.filter(email=email).exclude(username=username).count():
raise forms.ValidationError(u'Email addresses must be unique.')
return email
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.is_active = True
if commit:
user.save()
return user
class LoginForm(forms.Form):
username = forms.CharField(required=True, label="Kullanici Adi veya Email")
password = forms.CharField(widget=forms.PasswordInput, required=True, label="Parola")
def clean_form(self):
return self.cleaned_data | 29.538462 | 89 | 0.679688 | 137 | 1,152 | 5.664234 | 0.430657 | 0.056701 | 0.07732 | 0.051546 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002212 | 0.215278 | 1,152 | 39 | 90 | 29.538462 | 0.856195 | 0 | 0 | 0 | 0 | 0 | 0.095403 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0.074074 | 0.148148 | 0.037037 | 0.592593 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 |
f3d5c9bf64eedba0f6f468357059e46f9c2f136c | 176 | py | Python | demo.py | bitsofinfo/github-actions-demo | 3b0a23c4276fe290c9c2001e16998cf5aeffc9ae | [
"MIT"
] | null | null | null | demo.py | bitsofinfo/github-actions-demo | 3b0a23c4276fe290c9c2001e16998cf5aeffc9ae | [
"MIT"
] | 15 | 2020-12-04T02:33:00.000Z | 2020-12-05T02:23:38.000Z | demo.py | bitsofinfo/github-actions-demo | 3b0a23c4276fe290c9c2001e16998cf5aeffc9ae | [
"MIT"
] | null | null | null | from jinja2 import Template
import sys
def main():
args = sys.argv[1:]
print(Template("arg1={{arg1}}").render({"arg1":args[0]}))
if __name__ == "__main__":
main() | 19.555556 | 61 | 0.625 | 24 | 176 | 4.25 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.041096 | 0.170455 | 176 | 9 | 62 | 19.555556 | 0.657534 | 0 | 0 | 0 | 0 | 0 | 0.141243 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.285714 | 0 | 0.428571 | 0.142857 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f3e99bde9010747f0fba862dafda2bbbc446ce8c | 289 | py | Python | 36 Decorators/main3.py | codewithsandy/Python-Basic-Exp | 4c70ada4a042923a94301453c7bd76e704cd2989 | [
"MIT"
] | 3 | 2021-05-08T13:11:41.000Z | 2021-05-14T02:43:20.000Z | 36 Decorators/main3.py | codewithsandy/Python-Basic-Exp | 4c70ada4a042923a94301453c7bd76e704cd2989 | [
"MIT"
] | null | null | null | 36 Decorators/main3.py | codewithsandy/Python-Basic-Exp | 4c70ada4a042923a94301453c7bd76e704cd2989 | [
"MIT"
] | null | null | null | def dec1(def1):
def exec():
print("Executing now")
def1()
print("Executed")
return exec
@dec1
def who_is_sandy():
print("Sandy is good programmer")
#who_is_sandy = dec1(who_is_sandy) #Decorative function is dec1 another term is @dec1
who_is_sandy()
| 20.642857 | 87 | 0.650519 | 41 | 289 | 4.390244 | 0.439024 | 0.111111 | 0.222222 | 0.155556 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.031818 | 0.238754 | 289 | 13 | 88 | 22.230769 | 0.786364 | 0.294118 | 0 | 0 | 0 | 0 | 0.222772 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.3 | false | 0 | 0 | 0 | 0.4 | 0.3 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f3ed975cd086d68207091965049d101d948c5eeb | 589 | py | Python | aiohwenergy/errors.py | DCSBL/aiohwenergy | 7dbe249f925c75bdccf76ddda470e93a0e1a803f | [
"Apache-2.0"
] | 1 | 2020-12-03T22:53:51.000Z | 2020-12-03T22:53:51.000Z | aiohwenergy/errors.py | Unsigus/aiohwenergy | 940fa7f2ec06e6bce311db21bf684763056254bf | [
"Apache-2.0"
] | 2 | 2022-01-29T12:43:17.000Z | 2022-02-01T05:56:09.000Z | aiohwenergy/errors.py | Unsigus/aiohwenergy | 940fa7f2ec06e6bce311db21bf684763056254bf | [
"Apache-2.0"
] | 1 | 2022-01-28T20:43:38.000Z | 2022-01-28T20:43:38.000Z | """Aiohwenergy errors."""
class AiohwenergyException(Exception):
"""Base error for aiohwenergy."""
class RequestError(AiohwenergyException):
"""Unable to fulfill request.
Raised when host or API cannot be reached.
"""
class InvalidStateError(AiohwenergyException):
"""Raised when the device is not in the correct state."""
class UnsupportedError(AiohwenergyException):
"""Raised when the device is not supported from this library."""
class DisabledError(AiohwenergyException):
"""Raised when device API is disabled. User has to enable API in app."""
| 23.56 | 76 | 0.728353 | 66 | 589 | 6.5 | 0.606061 | 0.09324 | 0.20979 | 0.153846 | 0.205128 | 0.205128 | 0.205128 | 0 | 0 | 0 | 0 | 0 | 0.171477 | 589 | 24 | 77 | 24.541667 | 0.879098 | 0.502547 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
f3ef9e6c1d0b253415ed5070423b997bcfc24b14 | 732 | py | Python | tests/test_ssh_client.py | ubikampus/raspberry-config-cli | ed8332e9e85400f0e2147a340b283d7358eafcff | [
"MIT"
] | null | null | null | tests/test_ssh_client.py | ubikampus/raspberry-config-cli | ed8332e9e85400f0e2147a340b283d7358eafcff | [
"MIT"
] | null | null | null | tests/test_ssh_client.py | ubikampus/raspberry-config-cli | ed8332e9e85400f0e2147a340b283d7358eafcff | [
"MIT"
] | null | null | null | import unittest
from unittest.mock import patch
from btconfig import ssh_client
class FakeClient():
def exec_command(self, value):
return value
class MockSSHClient(ssh_client.SSHClient):
def __init__(self):
self.connections = {}
pass
def connect(self, target=None):
if target:
self.connections[target] = FakeClient()
else:
self.connections = {"m1": FakeClient(), "m2": FakeClient()}
class ClientTest(unittest.TestCase):
def setUp(self):
self.client = MockSSHClient()
def test_runs_all(self):
assert len(self.client.run('stuff')) == 2
def test_run_one_runs_one(self):
assert len(self.client.run('stuff', 'm1')) == 1 | 26.142857 | 71 | 0.639344 | 87 | 732 | 5.229885 | 0.471264 | 0.098901 | 0.057143 | 0.074725 | 0.136264 | 0.136264 | 0.136264 | 0 | 0 | 0 | 0 | 0.009009 | 0.241803 | 732 | 28 | 72 | 26.142857 | 0.810811 | 0 | 0 | 0 | 0 | 0 | 0.021828 | 0 | 0 | 0 | 0 | 0 | 0.090909 | 1 | 0.272727 | false | 0.045455 | 0.136364 | 0.045455 | 0.590909 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
6d03709a693af694278064cb96df3c12122febfe | 781 | py | Python | slow_tests/attackers_chinese.py | e-tornike/OpenAttack | b19c53af2e01f096505f8ebb8f48a54388295003 | [
"MIT"
] | 444 | 2020-07-14T12:13:26.000Z | 2022-03-28T02:46:30.000Z | slow_tests/attackers_chinese.py | e-tornike/OpenAttack | b19c53af2e01f096505f8ebb8f48a54388295003 | [
"MIT"
] | 50 | 2020-07-15T01:34:42.000Z | 2022-01-24T12:19:19.000Z | slow_tests/attackers_chinese.py | e-tornike/OpenAttack | b19c53af2e01f096505f8ebb8f48a54388295003 | [
"MIT"
] | 86 | 2020-08-02T13:16:45.000Z | 2022-03-27T06:22:04.000Z | from OpenAttack import substitute
import sys, os
sys.path.insert(0, os.path.join(
os.path.dirname(os.path.abspath(__file__)),
".."
))
import OpenAttack
def get_attackers_on_chinese(dataset, clsf):
triggers = OpenAttack.attackers.UATAttacker.get_triggers(clsf, dataset, clsf.tokenizer)
attackers = [
OpenAttack.attackers.FDAttacker(token_unk=clsf.token_unk, lang="chinese"),
OpenAttack.attackers.UATAttacker(triggers=triggers, lang="chinese"),
OpenAttack.attackers.TextBuggerAttacker(lang="chinese"),
OpenAttack.attackers.GeneticAttacker(lang="chinese", filter_words=["的", "了", "着"]),
OpenAttack.attackers.PWWSAttacker(lang="chinese"),
OpenAttack.attackers.PSOAttacker(lang="chinese")
]
return attackers | 37.190476 | 91 | 0.71831 | 85 | 781 | 6.470588 | 0.435294 | 0.241818 | 0.152727 | 0.218182 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.001506 | 0.149808 | 781 | 21 | 92 | 37.190476 | 0.826807 | 0 | 0 | 0 | 0 | 0 | 0.060102 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0 | 0.166667 | 0 | 0.277778 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6d50aa6f25d364990d11c67a95e2f6602abccbb0 | 496 | py | Python | openprocurement_client/tests/main.py | openprocurement/ProzorroUKR-openprocurement.client.python | ccd573d2b71fe8ab197773253e170c132c66501b | [
"Apache-2.0"
] | 1 | 2020-05-16T22:05:30.000Z | 2020-05-16T22:05:30.000Z | openprocurement_client/tests/main.py | openprocurement/ProzorroUKR-openprocurement.client.python | ccd573d2b71fe8ab197773253e170c132c66501b | [
"Apache-2.0"
] | null | null | null | openprocurement_client/tests/main.py | openprocurement/ProzorroUKR-openprocurement.client.python | ccd573d2b71fe8ab197773253e170c132c66501b | [
"Apache-2.0"
] | null | null | null | import unittest
from openprocurement_client.tests import (
tests_resources,
tests_sync,
test_registry_client,
tests_dasu,
tests_utils
)
def suite():
suite = unittest.TestSuite()
suite.addTest(tests_sync.suite())
suite.addTest(test_registry_client.suite())
suite.addTest(tests_resources.suite())
suite.addTest(tests_dasu.suite())
suite.addTest(tests_utils.suite())
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')
| 20.666667 | 47 | 0.715726 | 58 | 496 | 5.758621 | 0.362069 | 0.149701 | 0.203593 | 0.197605 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.173387 | 496 | 23 | 48 | 21.565217 | 0.814634 | 0 | 0 | 0 | 0 | 0 | 0.02621 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0 | 0.111111 | 0 | 0.222222 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6d598ec04df6c5961f0988c5fdd2b39836ae7345 | 6,839 | py | Python | pinner/locations/models.py | plusbeauxjours/pinner-backend | a0e95ddef6cb8be6ea107e40330b1f8d2f5c76ac | [
"MIT"
] | null | null | null | pinner/locations/models.py | plusbeauxjours/pinner-backend | a0e95ddef6cb8be6ea107e40330b1f8d2f5c76ac | [
"MIT"
] | 12 | 2019-08-22T17:31:02.000Z | 2022-02-10T09:52:38.000Z | pinner/locations/models.py | plusbeauxjours/pinner-backend | a0e95ddef6cb8be6ea107e40330b1f8d2f5c76ac | [
"MIT"
] | null | null | null | from django.db import models
from django.contrib.humanize.templatetags.humanize import naturaltime
from django.utils.html import escape, format_html
from config import models as config_models
from cached_property import cached_property
from utils import notify_slack
from django.dispatch import receiver
from django.db.models.signals import post_save
class Continent (config_models.TimeStampedModel):
continent_name = models.CharField(max_length=100, null=True, blank=True)
continent_photo = models.URLField(null=True, blank=True)
continent_thumbnail = models.URLField(null=True, blank=True)
continent_code = models.CharField(max_length=20, null=True, blank=True)
@cached_property
def country_count(self):
return self.countries.all().count()
@cached_property
def user_log_count(self):
# return self.moveNotificationContinent.values('actor__id').all().order_by('-actor__id').distinct('actor__id').count()
return self.moveNotificationContinent.values('actor__id').all().order_by('-actor__id').count()
def __str__(self):
return self.continent_name
def image_tag(self):
return format_html(
'<img src="{url}" style="width:50px; height:50px; object-fit: cover;">',
url=self.continent_thumbnail)
image_tag.short_description = 'Image'
image_tag.allow_tags = True
class Country (config_models.TimeStampedModel):
latitude = models.FloatField(blank=True, null=True)
longitude = models.FloatField(blank=True, null=True)
country_code = models.CharField(max_length=10, null=True, blank=True)
country_name = models.CharField(max_length=50, null=True, blank=True)
country_name_native = models.CharField(max_length=50, null=True, blank=True)
country_capital = models.CharField(max_length=50, null=True, blank=True)
country_currency = models.CharField(max_length=20, null=True, blank=True)
country_photo = models.URLField(null=True, blank=True)
country_thumbnail = models.URLField(null=True, blank=True)
country_emoji = models.CharField(max_length=20, null=True, blank=True)
country_phone = models.CharField(max_length=20, null=True, blank=True)
continent = models.ForeignKey(Continent, null=True, blank=True, on_delete=models.CASCADE, related_name='countries')
@cached_property
def city_count(self):
return self.cities.all().count()
@cached_property
def total_like_count(self):
return Like.objects.filter(city__country=self).count()
@cached_property
def user_log_count(self):
# return self.moveNotificationCountry.values('actor__id').all().order_by('-actor__id').distinct('actor__id').count()
return self.moveNotificationCountry.values('actor__id').all().order_by('-actor__id').count()
def __str__(self):
return self.country_name
def image_tag(self):
return format_html(
'<img src="{url}" style="width:50px; height:50px; object-fit: cover;">',
url=self.country_thumbnail)
image_tag.short_description = 'Image'
image_tag.allow_tags = True
class City (config_models.TimeStampedModel):
latitude = models.FloatField(blank=True, null=True)
longitude = models.FloatField(blank=True, null=True)
country = models.ForeignKey(
Country, on_delete=models.CASCADE, related_name='cities')
city_id = models.CharField(max_length=100, null=True, blank=True)
city_name = models.CharField(max_length=100, null=True, blank=True)
city_photo = models.URLField(null=True, blank=True)
city_thumbnail = models.URLField(null=True, blank=True)
population = models.IntegerField(null=True, blank=True)
info = models.TextField(null=True, blank=True)
near_city = models.ManyToManyField(
'self', blank=True, symmetrical=False, related_name='near_cities')
@cached_property
def like_count(self):
return self.likes.all().count()
@cached_property
def user_count(self):
return self.currentCity.values('id').all().count()
@cached_property
def user_log_count(self):
# return self.moveNotificationCity.values('actor__id').all().order_by('-actor__id').distinct('actor__id').count()
return self.moveNotificationCity.values('actor__id').all().order_by('-actor__id').count()
def __str__(self):
return self.city_name
def image_tag(self):
return format_html(
'<img src="{url}" style="width:50px; height:50px; object-fit: cover;">',
url=self.city_thumbnail)
image_tag.short_description = 'Image'
image_tag.allow_tags = True
class Like(config_models.TimeStampedModel):
creator = models.ForeignKey(
'users.User', on_delete=models.CASCADE, null=True, related_name='likes')
city = models.ForeignKey(
City, on_delete=models.CASCADE, null=True, related_name='likes')
@property
def natural_time(self):
return naturaltime(self.created_at)
def __str__(self):
return 'User: {} - City cityname: {}'.format(self.creator.username, self.city.city_name)
@receiver(post_save, sender=City)
def send_slack_notification_city_created(sender, instance, created, **kwargs):
if created:
to_channel = "#location_%s" % (instance.country.continent.continent_code.lower())
attachments = [{
"fallback": "New City on Pinner",
"color": "#569934",
"title": "New city: %s" % (instance.city_name),
"title_link": "https://www.pinner.fun/city/%s" % (instance.city_id),
"text": "Created new city on %s %s. \n Total cities on %s %s: %s." % (
instance.country.country_name, instance.country.country_emoji, instance.country.country_name, instance.country.country_emoji, instance.country.city_count),
"image_url": instance.city_photo,
"footer": "🙌🏻 New City!",
}]
notify_slack(to_channel, attachments=attachments)
@receiver(post_save, sender=Country)
def send_slack_notification_country_created(sender, instance, created, **kwargs):
if created:
to_channel = "#location_%s" % (instance.continent.continent_code.lower())
attachments = [{
"fallback": "New Country on Pinner",
"color": "#569934",
"title": "Created new city on %s %s. \n Total cities on %s %s: %s." % (
instance.country_name, instance.country_emoji, instance.country_name, instance.country_emoji, instance.city_count, ),
"title_link": "https://www.pinner.fun/country/%s" % (instance.country_code),
"text": "Optional text that appears within the attachment",
"image_url": instance.country_photo,
"footer": "🙌🏻 New Country!",
}]
notify_slack(to_channel, attachments=attachments)
| 41.448485 | 171 | 0.692499 | 854 | 6,839 | 5.327869 | 0.17096 | 0.045714 | 0.057143 | 0.074725 | 0.672747 | 0.644835 | 0.587473 | 0.493187 | 0.493187 | 0.454505 | 0 | 0.008759 | 0.182044 | 6,839 | 164 | 172 | 41.70122 | 0.803897 | 0.050154 | 0 | 0.346457 | 0 | 0.03937 | 0.121996 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.141732 | false | 0 | 0.062992 | 0.125984 | 0.582677 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 2 |
6d5e7d4afb6ccec0a6fb35addd70cff5d18de370 | 459 | py | Python | ARMODServers/Apps/Index/migrations/0022_alter_indexheader_header_showcase_descript.py | Phantomxm2021/ARMOD-Dashboard | 383cf0a5e72dc5a2651f43e693f06773d5b88bbd | [
"Apache-2.0"
] | 1 | 2021-11-04T09:03:27.000Z | 2021-11-04T09:03:27.000Z | ARMODServers/Apps/Index/migrations/0022_alter_indexheader_header_showcase_descript.py | Phantomxm2021/ARMOD-Dashboard | 383cf0a5e72dc5a2651f43e693f06773d5b88bbd | [
"Apache-2.0"
] | null | null | null | ARMODServers/Apps/Index/migrations/0022_alter_indexheader_header_showcase_descript.py | Phantomxm2021/ARMOD-Dashboard | 383cf0a5e72dc5a2651f43e693f06773d5b88bbd | [
"Apache-2.0"
] | null | null | null | # Generated by Django 3.2 on 2021-05-09 09:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('Index', '0021_auto_20210509_1729'),
]
operations = [
migrations.AlterField(
model_name='indexheader',
name='header_showcase_descript',
field=models.CharField(default='', max_length=512, verbose_name='Header showcase descript'),
),
]
| 24.157895 | 104 | 0.638344 | 49 | 459 | 5.816327 | 0.77551 | 0.070175 | 0.126316 | 0.182456 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.09593 | 0.250545 | 459 | 18 | 105 | 25.5 | 0.732558 | 0.093682 | 0 | 0 | 1 | 0 | 0.210145 | 0.113527 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.083333 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
6d6065310e650d8d11df4d3988027c603be7c771 | 580 | py | Python | backend/authApp/serializers/accountSerializer.py | JonaCaste/Banco-Django | 0331623f28043394cc06181e3dc3b9a6ecb870aa | [
"MIT"
] | null | null | null | backend/authApp/serializers/accountSerializer.py | JonaCaste/Banco-Django | 0331623f28043394cc06181e3dc3b9a6ecb870aa | [
"MIT"
] | null | null | null | backend/authApp/serializers/accountSerializer.py | JonaCaste/Banco-Django | 0331623f28043394cc06181e3dc3b9a6ecb870aa | [
"MIT"
] | null | null | null | from authApp.models.account import Account
from rest_framework import serializers
class AccountSerializer(serializers.ModelSerializer):
class Meta: #metadata "generalizacion de la clase"
model = Account
fields = ['balance', 'lastChangeDate', 'isActivate']
#datos a serializar
#las llaves foraneas e id`s autogenerados no se suelen añadir,
#por que es info que no "utilizamos"(en peticiones),
#ya que es info sensible | 44.615385 | 91 | 0.574138 | 56 | 580 | 5.928571 | 0.803571 | 0.03012 | 0.054217 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.368966 | 580 | 13 | 92 | 44.615385 | 0.907104 | 0.331034 | 0 | 0 | 0 | 0 | 0.080729 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
6d64618413e91571766a6330d7d50c58d287476e | 1,319 | py | Python | Python/BasicTutorials/conditions.py | ronkitay/Rons-Tutorials | c0459c57cc24b546847ec24afa94d2c1e5373bd4 | [
"MIT"
] | null | null | null | Python/BasicTutorials/conditions.py | ronkitay/Rons-Tutorials | c0459c57cc24b546847ec24afa94d2c1e5373bd4 | [
"MIT"
] | null | null | null | Python/BasicTutorials/conditions.py | ronkitay/Rons-Tutorials | c0459c57cc24b546847ec24afa94d2c1e5373bd4 | [
"MIT"
] | null | null | null | #!/usr/bin/python
# -*- coding: utf-8 -*-
from rons_tutorial_formatting import *
print_block_separator()
some_variable = True
if some_variable:
print "some_variable is {0:b}".format(some_variable)
print "some_variable is {0}".format(some_variable)
another_variable = 7
if another_variable:
print "another_variable is {0:n}".format(another_variable)
last_variable = 0
if not last_variable:
print "last_variable is {0}".format(last_variable)
if last_variable or not some_variable: # Will be false
print "If was true"
elif last_variable < 0 or some_variable: # Will be true
print "Something was true"
else:
print "Done"
end_block()
start_block()
list_1 = [1, 2, 3]
list_2 = [1, 2, 3]
print ("list_1 == list_2 => %r" % (list_1 == list_2))
print ("list_1 is list_2 => %r" % (list_1 is list_2))
print ("id(list_1) == id(list_2) => %r" % (id(list_1) == id(list_2)))
end_block()
start_block()
n1 = 10
n2 = 11
print ("n1 = %d, n2 = %d" % (n1, n2))
print ("n1 == n2 => %r" % (n1 == n2))
print ("n1 is n2 => %r" % (n1 is n2))
n2 -= 1
print ("n1 = %d, n2 = %d" % (n1, n2))
print ("n1 == n2 => %r" % (n1 == n2))
print ("n1 is n2 => %r" % (n1 is n2))
n1 -= 1
print ("n1 = %d, n2 = %d" % (n1, n2))
print ("n1 == n2 => %r" % (n1 == n2))
print ("n1 is n2 => %r" % (n1 is n2))
end_block() | 21.274194 | 69 | 0.608795 | 225 | 1,319 | 3.386667 | 0.217778 | 0.082677 | 0.070866 | 0.086614 | 0.355643 | 0.308399 | 0.271654 | 0.187664 | 0.187664 | 0.187664 | 0 | 0.070409 | 0.203184 | 1,319 | 62 | 70 | 21.274194 | 0.654615 | 0.04928 | 0 | 0.341463 | 0 | 0 | 0.260592 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.02439 | null | null | 0.487805 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
ed9024bebd1909184d858e13300a2e0ecd9ce768 | 3,553 | py | Python | python/test/mapreduce/module_test.py | Batterii/appengine-mapreduce | f4393e2347d0b841d62f34383fcdf849ef922309 | [
"Apache-2.0"
] | 228 | 2015-01-09T20:32:25.000Z | 2021-11-18T13:20:29.000Z | python/test/mapreduce/module_test.py | Batterii/appengine-mapreduce | f4393e2347d0b841d62f34383fcdf849ef922309 | [
"Apache-2.0"
] | 82 | 2015-01-13T15:12:15.000Z | 2020-10-30T15:26:41.000Z | python/test/mapreduce/module_test.py | Batterii/appengine-mapreduce | f4393e2347d0b841d62f34383fcdf849ef922309 | [
"Apache-2.0"
] | 127 | 2015-01-08T19:50:03.000Z | 2021-10-09T16:47:12.000Z | #!/usr/bin/env python
#
# Copyright 2010 Google Inc. All Rights Reserved.
import unittest
from google.appengine.api import module_testutil
from mapreduce import context
from mapreduce import control
from mapreduce import datastore_range_iterators
from mapreduce import errors
from mapreduce import input_readers
from mapreduce import key_ranges
from mapreduce import mapper_pipeline
from mapreduce import mapreduce_pipeline
from mapreduce import model
from mapreduce import namespace_range
from mapreduce import operation as op
from mapreduce import output_writers
from mapreduce import property_range
from mapreduce import records
from mapreduce import shuffler
from mapreduce import util
class NamespaceRangeTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test module interface."""
MODULE = namespace_range
class PropertyRangeTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test module interface."""
MODULE = property_range
class KeyRangesTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test module interface."""
MODULE = key_ranges
class DatastoreRangeIteratorsTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test module interface."""
MODULE = datastore_range_iterators
class ContextTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test context module interface."""
MODULE = context
class ControlTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test control module interface."""
MODULE = control
class CountersTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test counters module interface."""
MODULE = op.counters
class DbTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test db module interface."""
MODULE = op.db
class ErrorsTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test errors module interface."""
MODULE = errors
class InputReadersTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test input_readers module interface."""
MODULE = input_readers
class ModelTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test model module interface."""
MODULE = model
class OutputWritersTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test output_writers module interface."""
MODULE = output_writers
class UtilTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test util module interface."""
MODULE = util
class MapperPipelineTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test mapper_pipeline module interface."""
MODULE = mapper_pipeline
class MapreducePipelineTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test mapreduce_pipeline module interface."""
MODULE = mapreduce_pipeline
class ShufflerTest(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test shuffler module interface."""
MODULE = shuffler
class RecordsTests(module_testutil.ModuleInterfaceTest,
googletest.TestCase):
"""Test records module interface."""
MODULE = records
if __name__ == '__main__':
googletest.main()
| 23.845638 | 70 | 0.719392 | 332 | 3,553 | 7.554217 | 0.210843 | 0.100478 | 0.223684 | 0.291467 | 0.4063 | 0.4063 | 0.121212 | 0.121212 | 0.121212 | 0 | 0 | 0.001421 | 0.207712 | 3,553 | 148 | 71 | 24.006757 | 0.88952 | 0.164931 | 0 | 0.239437 | 0 | 0 | 0.002779 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.253521 | 0 | 0.732394 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
ed94776ea7a825ca6db82d642797e66f590ee190 | 501 | py | Python | nbsafety/__init__.py | runtime-jupyter-safety/runtime-jupyter-safety | f62a24b5b4f44fed5111c31441bc6a105441e34c | [
"BSD-3-Clause"
] | null | null | null | nbsafety/__init__.py | runtime-jupyter-safety/runtime-jupyter-safety | f62a24b5b4f44fed5111c31441bc6a105441e34c | [
"BSD-3-Clause"
] | 20 | 2020-04-17T02:32:50.000Z | 2020-05-07T05:50:32.000Z | nbsafety/__init__.py | runtime-jupyter-safety/runtime-jupyter-safety | f62a24b5b4f44fed5111c31441bc6a105441e34c | [
"BSD-3-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
# Jupyter Extension points
def _jupyter_nbextension_paths():
return [
dict(
section="notebook",
# the path is relative to the `my_fancy_module` directory
src="resources/nbextension",
# directory in the `nbextension/` namespace
dest="nbsafety",
# _also_ in the `nbextension/` namespace
require="nbsafety/index",
)
]
def load_jupyter_server_extension(nbapp):
pass
| 25.05 | 69 | 0.58483 | 49 | 501 | 5.77551 | 0.714286 | 0.035336 | 0.113074 | 0.176678 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.002924 | 0.317365 | 501 | 19 | 70 | 26.368421 | 0.824561 | 0.365269 | 0 | 0 | 0 | 0 | 0.163462 | 0.067308 | 0 | 0 | 0 | 0 | 0 | 1 | 0.181818 | false | 0.090909 | 0 | 0.090909 | 0.272727 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
ed9ab097fc39e6dbca87c77f3b7f2d4ea1620c00 | 657 | py | Python | test_lights.py | kurrik/treelights | 464c95c5aec98624efc790548e2c0819041f66ff | [
"Apache-2.0"
] | null | null | null | test_lights.py | kurrik/treelights | 464c95c5aec98624efc790548e2c0819041f66ff | [
"Apache-2.0"
] | null | null | null | test_lights.py | kurrik/treelights | 464c95c5aec98624efc790548e2c0819041f66ff | [
"Apache-2.0"
] | null | null | null | #!/usr/bin/env python3
import time
import treelights
from treelights.ledstrip import LEDStrip, Colors
from colour import Color
import animations
import itertools
import inspect
def run_animation(strip, animation, cycles=100, delay=0.03):
strip.off()
for d in itertools.islice(animation(strip), cycles):
time.sleep(d or delay)
if __name__ == '__main__':
LED_COUNT = 100
strip = LEDStrip(LED_COUNT)
try:
run_animation(strip, animations.sparkle, cycles=1000)
run_animation(strip, animations.rainbow)
run_animation(strip, animations.zoom_colors, cycles=400)
run_animation(strip, animations.zoom_multi)
finally:
strip.off()
| 26.28 | 60 | 0.757991 | 89 | 657 | 5.404494 | 0.494382 | 0.174636 | 0.176715 | 0.224532 | 0.128898 | 0 | 0 | 0 | 0 | 0 | 0 | 0.030303 | 0.146119 | 657 | 24 | 61 | 27.375 | 0.827094 | 0.031963 | 0 | 0.095238 | 0 | 0 | 0.012598 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.047619 | false | 0 | 0.333333 | 0 | 0.380952 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
ed9ce2362dcb83b2dff7f566421ecf825bfc5c60 | 373 | py | Python | apps/accounts/urls.py | ospreyelm/HarmonyLab | 0934c67ab93a7da21e45f7956cb1b32ed3c9f728 | [
"BSD-3-Clause"
] | 4 | 2018-02-09T01:18:46.000Z | 2020-11-23T10:06:21.000Z | apps/accounts/urls.py | ospreyelm/HarmonyLab | 0934c67ab93a7da21e45f7956cb1b32ed3c9f728 | [
"BSD-3-Clause"
] | 8 | 2020-07-26T22:06:05.000Z | 2021-08-19T04:17:18.000Z | apps/accounts/urls.py | ospreyelm/HarmonyLab | 0934c67ab93a7da21e45f7956cb1b32ed3c9f728 | [
"BSD-3-Clause"
] | 6 | 2018-02-09T19:11:15.000Z | 2020-09-06T22:49:43.000Z | from django.urls import path
from apps.accounts.views import LogoutView, register, login, forgot_password_view
urlpatterns = [
path('register/', register, name='registration'),
path('login/', login, name='custom-login'),
path('logout/', LogoutView.as_view(), name='custom-logout'),
path('forgot-password/', forgot_password_view, name='forgot-password')
]
| 33.909091 | 81 | 0.72118 | 45 | 373 | 5.866667 | 0.444444 | 0.212121 | 0.136364 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.120643 | 373 | 10 | 82 | 37.3 | 0.804878 | 0 | 0 | 0 | 0 | 0 | 0.241287 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0.25 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 |
eda12df0443ecba8170a95ad74edc05ff9fb9a09 | 620 | py | Python | _building/tmpl/__init__.py | drmingdrmer/k3priorityqueue | 004d9000cac45b6ca5678dc9b3aab8c06b9168e9 | [
"MIT"
] | null | null | null | _building/tmpl/__init__.py | drmingdrmer/k3priorityqueue | 004d9000cac45b6ca5678dc9b3aab8c06b9168e9 | [
"MIT"
] | 22 | 2020-08-10T08:26:22.000Z | 2022-03-23T06:18:47.000Z | _building/tmpl/__init__.py | drmingdrmer/k3priorityqueue | 004d9000cac45b6ca5678dc9b3aab8c06b9168e9 | [
"MIT"
] | 1 | 2021-08-10T02:58:13.000Z | 2021-08-10T02:58:13.000Z | """
{{ name }} is utility to .
Execute a shell script::
import {{ name }}
# execute a shell script
returncode, out, err = pk3proc.shell_script('ls / | grep bin')
print returncode
print out
# output:
# > 0
# > bin
# > sbin
Run a command::
# Unlike the above snippet, following statement does not start an sh process.
returncode, out, err = pk3proc.command('ls', 'a*', cwd='/usr/local')
"""
# from .proc import CalledProcessError
# from .proc import ProcError
__version__ = "0.1.0"
__name__ = "{{ name }}"
from .{{ name }} import foo
from .{{ name }} import SomeError
| 18.787879 | 81 | 0.616129 | 78 | 620 | 4.782051 | 0.576923 | 0.088472 | 0.069705 | 0.101877 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012848 | 0.246774 | 620 | 32 | 82 | 19.375 | 0.785867 | 0.103226 | 0 | 0 | 0 | 0 | 0.131579 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.5 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
eda1ef50c1fea11411ed981d058cc044e06abb84 | 847 | py | Python | marbaloo_validators/__init__.py | marbaloo/marbaloo_validators | 16e07a61b55fdb94322c5b3b8bcd9bf481177fed | [
"MIT"
] | null | null | null | marbaloo_validators/__init__.py | marbaloo/marbaloo_validators | 16e07a61b55fdb94322c5b3b8bcd9bf481177fed | [
"MIT"
] | null | null | null | marbaloo_validators/__init__.py | marbaloo/marbaloo_validators | 16e07a61b55fdb94322c5b3b8bcd9bf481177fed | [
"MIT"
] | null | null | null | import cherrypy
from cherrypy.process import plugins
import validators
class Plugin(plugins.SimplePlugin):
def __init__(self, bus):
plugins.SimplePlugin.__init__(self, bus)
self.validators = validators
def start(self):
self.bus.subscribe('get-validators', self.get_validators)
def stop(self):
self.bus.unsubscribe('get-validators', self.get_validators)
def get_validators(self):
return self.validators
class Tool(cherrypy.Tool):
def __init__(self):
cherrypy.Tool.__init__(self, 'on_start_resource',
self.set_tool,
priority=20)
def _setup(self):
cherrypy.Tool._setup(self)
@staticmethod
def set_tool():
cherrypy.request.validators = cherrypy.engine.publish('get-validators').pop()
| 25.666667 | 85 | 0.645809 | 93 | 847 | 5.612903 | 0.333333 | 0.149425 | 0.097701 | 0.076628 | 0.126437 | 0.126437 | 0 | 0 | 0 | 0 | 0 | 0.00316 | 0.252656 | 847 | 32 | 86 | 26.46875 | 0.821485 | 0 | 0 | 0 | 0 | 0 | 0.069658 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.304348 | false | 0 | 0.130435 | 0.043478 | 0.565217 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
edb2896c849fd59d9ffd1837d2988bb586c9fa8b | 6,176 | py | Python | scripts/user_info.py | alemottura/PyCAPI | 2b1c5c1698495c52afec640f3f9005f8c0f59223 | [
"MIT"
] | 1 | 2017-03-12T20:22:29.000Z | 2017-03-12T20:22:29.000Z | scripts/user_info.py | alemottura/PyCAPI | 2b1c5c1698495c52afec640f3f9005f8c0f59223 | [
"MIT"
] | null | null | null | scripts/user_info.py | alemottura/PyCAPI | 2b1c5c1698495c52afec640f3f9005f8c0f59223 | [
"MIT"
] | 1 | 2019-07-01T15:17:46.000Z | 2019-07-01T15:17:46.000Z | import sys
sys.path.append("../module/") # First two lines are needed for import of PyCAPI without python directory modifications
import PyCAPI
import json
import datetime
capi = PyCAPI.CanvasAPI()
"""
Function for taking the datetime string returned from Canvas
and comparaing it with computer time
"""
def overdue(assignment_due_date,current_datetime):
is_overdue = False
if current_datetime > assignment_due_date:
is_overdue = True
return is_overdue
print ''
requested_user_id = 123178
user = capi.get_user(requested_user_id)
courses = capi.get_courses()
current_datetime = datetime.datetime.now()
"""
Returns the selected users details
"""
print user['name'] + ' (ID: ' + str(user['id']) + ')'
print 'Email: ' + user['primary_email']
print ''
"""
Returns users courses
"""
print 'See user courses? y/n'
request_courses = raw_input()
print ''
if request_courses == 'y' or request_courses == 'Y' or request_courses == 'yes' or request_courses == 'Yes':
print 'Courses enrolled on: '
for course in courses:
print str(course['id']) + ': ' + course['name']
print ''
"""
Returns users assignments
"""
print 'See user assignments detail? y/n'
request_assignments = raw_input()
print ''
if request_assignments == 'y' or request_assignments == 'Y' or request_assignments == 'yes' or request_assignments == 'Yes':
for course in courses:
print str(course['id']) + ': ' + course['name']
assignments = capi.get_assignments(course['id'])
print ' Published:'
for assignment in assignments:
print ' ' + str(assignment['id']) + ': ' + assignment['name']
print ' Type: ' + json.dumps(assignment['submission_types'])
print ' Grading type: ' + assignment['grading_type']
print ' Marks available: ' + str(assignment['points_possible'])
print ' Unlocked at: ' + str(assignment['unlock_at'])
print ' Due at: ' + str(assignment['due_at'])
print ' Submitted: ' + str(assignment['has_submitted_submissions'])
print ''
print ''
"""
Get course details - teacher
"""
print 'See courses enrolled as teacher? y/n'
request_teacher_courses = raw_input()
print ''
if request_teacher_courses == 'y' or request_teacher_courses == 'Y' or request_teacher_courses == 'yes' or request_teacher_courses == 'Yes':
print 'Courses enrolled on as teacher:'
for count in range(0,len(courses)):
if courses[count]['enrollments'][0]['type'] == 'teacher':
print str(courses[count]['id']) + ': ' + courses[count]['name']
print ''
"""
Returns users overdue assignments
"""
print 'Check for overdue assignments? y/n'
request_overdue = raw_input()
print ''
if request_overdue == 'y' or request_overdue == 'Y' or request_overdue == 'yes' or request_overdue == 'Yes':
overdue_assignment_no = 0
for course in courses:
print str(course['id']) + ': ' + course['name']
assignments = capi.get_assignments(course['id'])
print ' Overdue:'
for assignment in assignments:
if str(assignment['due_at']) != 'None':
assignment_due_date = datetime.datetime.strptime(assignment['due_at'], '%Y-%m-%dT%H:%M:%SZ')
is_overdue = overdue(assignment_due_date,current_datetime)
if is_overdue and str(assignment['has_submitted_submissions']) == 'False':
print ' ' + str(assignment['id']) + ': ' + assignment['name']
print ' Type: ' + json.dumps(assignment['submission_types'])
print ' Due at: ' + str(assignment_due_date)
overdue_assignment_no = overdue_assignment_no + 1
print ''
print 'Number of overdue assignments: ' + str(overdue_assignment_no)
print ''
"""
Returns submission details for user submissions
This section is commented out because the get_user_submission_details
function does not work in PyCAPI as no information is returned
"""
"""
print 'See user submission summary? y/n'
request_user_submission_summary = raw_input()
print ''
if request_user_submission_summary == 'y' or request_user_submission_summary == 'Y' or request_user_submission_summary == 'yes' or request_user_submission_summary == 'Yes':
for course in courses:
print str(course['id']) + ': ' + course['name']
assignments = capi.get_assignments(course['id'])
for assignment in assignments:
print ' ' + str(assignment['id']) + ': ' + assignment['name']
user_submission_details = capi.get_user_submission_details(course['id'],assignment['id'],requested_user_id)
print user_submission_details
for submission_details in user_submission_details:
print ' Score: ' + str(submission_details['score'])
print ' Out of: ' + str(assignment['points_possible'])
print ' Late: ' + str(submission_details['late'])
"""
"""
Returns users notifications summary
"""
print 'See user notification activity summary? y/n'
request_activity_summary = raw_input()
print ''
if request_activity_summary == 'y' or request_activity_summary == 'Y' or request_activity_summary == 'yes' or request_activity_summary == 'Yes':
user_activity_summary = capi.get_user_activity_summary()
print 'User notification activity summary: | Total(Unread)'
for activity_summary in user_activity_summary:
if activity_summary['type'] == 'DiscussionTopic':
print 'Discussion topic: ' + str(activity_summary['count']) + '(' + str(activity_summary['unread_count']) + ')'
elif str(activity_summary['notification_category']) != 'None':
print activity_summary['type'] + ' (' + activity_summary['notification_category'] + '): ' + str(activity_summary['count']) + '(' + str(activity_summary['unread_count']) + ')'
else:
print activity_summary['type'] + ': ' + str(activity_summary['count']) + '(' + str(activity_summary['unread_count']) + ')'
print ''
| 39.589744 | 186 | 0.641677 | 706 | 6,176 | 5.405099 | 0.185552 | 0.086478 | 0.031447 | 0.023585 | 0.42479 | 0.368449 | 0.246331 | 0.246331 | 0.209382 | 0.168501 | 0 | 0.0021 | 0.229113 | 6,176 | 155 | 187 | 39.845161 | 0.799412 | 0.013925 | 0 | 0.314607 | 0 | 0 | 0.220039 | 0.020083 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.044944 | null | null | 0.494382 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
edcd2b7737806117b9c9fab11ffd6fffb28b8534 | 412 | py | Python | asterioids-pygame-project/source_code_step_5/space_rocks/utils.py | syberflea/materials | 54f44725b40edf00c1b523d7a85b34a85014d7eb | [
"MIT"
] | 3,682 | 2018-05-07T19:45:24.000Z | 2022-03-31T15:19:10.000Z | asterioids-pygame-project/source_code_step_5/space_rocks/utils.py | sribarrow/materials | c17c4a4d6f8487e59eac1df8c88ca92b73d6d2a5 | [
"MIT"
] | 148 | 2018-05-15T21:18:49.000Z | 2022-03-21T11:25:39.000Z | asterioids-pygame-project/source_code_step_5/space_rocks/utils.py | sribarrow/materials | c17c4a4d6f8487e59eac1df8c88ca92b73d6d2a5 | [
"MIT"
] | 5,535 | 2018-05-25T23:36:08.000Z | 2022-03-31T16:55:52.000Z | from pygame.image import load
from pygame.math import Vector2
def load_sprite(name, with_alpha=True):
path = f"assets/sprites/{name}.png"
loaded_sprite = load(path)
if with_alpha:
return loaded_sprite.convert_alpha()
else:
return loaded_sprite.convert()
def wrap_position(position, surface):
x, y = position
w, h = surface.get_size()
return Vector2(x % w, y % h)
| 21.684211 | 44 | 0.677184 | 59 | 412 | 4.576271 | 0.542373 | 0.133333 | 0.133333 | 0.185185 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006231 | 0.220874 | 412 | 18 | 45 | 22.888889 | 0.834891 | 0 | 0 | 0 | 0 | 0 | 0.06068 | 0.06068 | 0 | 0 | 0 | 0 | 0 | 1 | 0.153846 | false | 0 | 0.153846 | 0 | 0.538462 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
edda0949cd71c3bbcd0ce3927166e97732799e42 | 539 | py | Python | pacote_download/PythonExercicios/ex074.py | leandrotune/Python | 2077f9854ed107975de76bfecf99c27a80e38863 | [
"MIT"
] | null | null | null | pacote_download/PythonExercicios/ex074.py | leandrotune/Python | 2077f9854ed107975de76bfecf99c27a80e38863 | [
"MIT"
] | null | null | null | pacote_download/PythonExercicios/ex074.py | leandrotune/Python | 2077f9854ed107975de76bfecf99c27a80e38863 | [
"MIT"
] | null | null | null | # Exercício Python 074: Crie um programa que vai gerar cinco números aleatórios e colocar em uma tupla.
# Depois disso, mostre a listagem de números gerados e também indique o menor e o maior valor que estão na tupla.
from random import randint
numeros = (randint(1, 10), randint(1, 10), randint(1, 10), randint(1, 10), randint(1, 10))
print(f'os valores soteados foram:', end=' ')
for n in numeros:
print(f'{n} ', end='')
print(f'\nO maior valor sorteado foi {max(numeros)}')
print(f'O menor valor sorteado foi {min(numeros)}')
| 33.6875 | 113 | 0.710575 | 91 | 539 | 4.208791 | 0.593407 | 0.104439 | 0.130548 | 0.177546 | 0.130548 | 0.130548 | 0.130548 | 0.130548 | 0.130548 | 0.130548 | 0 | 0.040179 | 0.168831 | 539 | 15 | 114 | 35.933333 | 0.814732 | 0.395176 | 0 | 0 | 0 | 0 | 0.361635 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 0.142857 | 0.571429 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2 |
eddeb48a3b1fe1c0b6f0bab5c87f851ff32f3675 | 2,257 | py | Python | functions.py | regetag/Rodrigo-Qtile-Config | 126634e355bf5b134af9955f25772f43cab37cbd | [
"MIT"
] | null | null | null | functions.py | regetag/Rodrigo-Qtile-Config | 126634e355bf5b134af9955f25772f43cab37cbd | [
"MIT"
] | null | null | null | functions.py | regetag/Rodrigo-Qtile-Config | 126634e355bf5b134af9955f25772f43cab37cbd | [
"MIT"
] | null | null | null | from libqtile.command import lazy
from libqtile import qtile
# from libqtile.command_client import InteractiveCommandClient
class Functions:
##### MOVE WINDOW IN GROUPS #####
@staticmethod
def window_to_prev_group():
@lazy.function
def __inner(qtile):
i = qtile.groups.index(qtile.current_group)
if qtile.current_window and i != 0:
group = qtile.groups[i - 1].name
qtile.current_window.togroup(group, switch_group=True)
return __inner
@staticmethod
def window_to_next_group():
@lazy.function
def __inner(qtile):
i = qtile.groups.index(qtile.current_group)
if qtile.current_window and i != len(qtile.groups):
group = qtile.groups[i + 1].name
qtile.current_window.togroup(group, switch_group=True)
return __inner
##### KILL ALL WINDOWS #####
@staticmethod
def kill_all_windows():
@lazy.function
def __inner(qtile):
for window in qtile.current_group.windows:
window.kill()
return __inner
@staticmethod
def kill_all_windows_minus_current():
@lazy.function
def __inner(qtile):
for window in qtile.current_group.windows:
if window != qtile.current_window:
window.kill()
return __inner
class PWA:
def __init__(self):
pass
@staticmethod
def notion():
return "brave --profile-directory=Default --app=https://notion.so"
@staticmethod
def music():
return "brave --profile-directory=Default --app=https://music.youtube.com/"
@staticmethod
def spotify():
return "brave --profile-directory=Default --app=https://open.spotify.com/"
@staticmethod
def youtube():
return "brave --user-data-dir=Default --app=https://www.youtube.com"
@staticmethod
def calendar():
return "brave --profile-directory=Default --app=https://calendar.google.com/calendar/"
@staticmethod
def habitica():
return "brave --profile-directory=Default --app=https://habitica.com/"
if __name__ == "__main__":
print("This is an utilities module")
| 25.942529 | 94 | 0.615419 | 250 | 2,257 | 5.348 | 0.284 | 0.112191 | 0.067315 | 0.100972 | 0.538519 | 0.495138 | 0.495138 | 0.33807 | 0.33807 | 0.33807 | 0 | 0.001833 | 0.274701 | 2,257 | 86 | 95 | 26.244186 | 0.814905 | 0.044307 | 0 | 0.508475 | 0 | 0 | 0.196814 | 0.074039 | 0 | 0 | 0 | 0 | 0 | 1 | 0.254237 | false | 0.016949 | 0.033898 | 0.101695 | 0.491525 | 0.016949 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 2 |
edfdc96fbdd51ef85725ff3513cac24bfb727aa3 | 189 | py | Python | Intro/36 - differentSymbolsNaive.py | lucasalme1da/codesignal | faff1ae635d04a33a1b59e6f751d266fabca5e71 | [
"MIT"
] | 2 | 2020-04-15T00:15:03.000Z | 2021-02-17T18:43:08.000Z | Intro/36 - differentSymbolsNaive.py | lucasalme1da/codesignal | faff1ae635d04a33a1b59e6f751d266fabca5e71 | [
"MIT"
] | null | null | null | Intro/36 - differentSymbolsNaive.py | lucasalme1da/codesignal | faff1ae635d04a33a1b59e6f751d266fabca5e71 | [
"MIT"
] | null | null | null | def differentSymbolsNaive(s):
diffArray = []
for i in range(len(list(s))):
if list(s)[i] not in diffArray:
diffArray.append(list(s)[i])
return len(diffArray) | 31.5 | 40 | 0.603175 | 26 | 189 | 4.384615 | 0.538462 | 0.131579 | 0.105263 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.253968 | 189 | 6 | 41 | 31.5 | 0.808511 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
edff4be693f3c15a51b63496578cc756b0a0c7be | 671 | py | Python | uwsgidns/listener.py | 20tab/uwsgi-local-dns-resolver | e558a230a3e42ee6b077b08cc65c875acb087d4a | [
"MIT"
] | 2 | 2015-06-05T12:16:33.000Z | 2015-06-05T12:26:11.000Z | uwsgidns/listener.py | 20tab/uwsgi-local-dns-resolver | e558a230a3e42ee6b077b08cc65c875acb087d4a | [
"MIT"
] | 2 | 2015-05-18T14:09:59.000Z | 2015-06-05T11:11:14.000Z | uwsgidns/listener.py | 20tab/uwsgi-local-dns-resolver | e558a230a3e42ee6b077b08cc65c875acb087d4a | [
"MIT"
] | 1 | 2015-05-18T13:32:25.000Z | 2015-05-18T13:32:25.000Z | #!/usr/bin/env python
# encoding: utf-8
try:
import socketserver
except ImportError:
import SocketServer as socketserver
from uwsgidns.utils import uwsgi_packet_to_dict
class SubscriptionHandler(socketserver.BaseRequestHandler):
"""Handle UDP subscription requests from uWSGI."""
"""
trigger is called, if set, after handling a new uWSGI subscription.
It MUST be a callable accepting a uWSGI dictionary as an argument.
"""
trigger = None
def handle(self):
data = self.request[0]
d = uwsgi_packet_to_dict(data)
if callable(SubscriptionHandler.trigger):
SubscriptionHandler.trigger(d)
| 23.964286 | 75 | 0.697466 | 79 | 671 | 5.848101 | 0.64557 | 0.077922 | 0.056277 | 0.073593 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.003861 | 0.228018 | 671 | 27 | 76 | 24.851852 | 0.888031 | 0.120715 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.083333 | false | 0 | 0.333333 | 0 | 0.583333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 2 |
610b09f34c2015d7d661aa92410902c39399df36 | 195 | py | Python | CustomCode/validator.py | BuildForSDG/wasteCoin-Backend | 8155ba89222cc16104b09c8ebd1d5f2b9a44353c | [
"MIT"
] | null | null | null | CustomCode/validator.py | BuildForSDG/wasteCoin-Backend | 8155ba89222cc16104b09c8ebd1d5f2b9a44353c | [
"MIT"
] | 16 | 2020-05-03T14:52:17.000Z | 2022-02-10T10:23:57.000Z | CustomCode/validator.py | BuildForSDG/wasteCoin-Backend | 8155ba89222cc16104b09c8ebd1d5f2b9a44353c | [
"MIT"
] | 3 | 2020-05-01T16:27:47.000Z | 2020-06-23T16:01:05.000Z | import re
#Email Validator
re_email = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$'
def checkmail(email):
if(re.search(re_email,email)):
return True
else:
return False | 19.5 | 58 | 0.523077 | 27 | 195 | 3.703704 | 0.555556 | 0.08 | 0.09 | 0.08 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.012903 | 0.205128 | 195 | 10 | 59 | 19.5 | 0.632258 | 0.076923 | 0 | 0 | 0 | 0 | 0.25 | 0.25 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0 | 0.571429 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
611e3c7610b9a55b8c4c9152e2b53af46fc69434 | 304 | py | Python | checkprocess-4terminal.py | linuxkay/Process_Monitoring | 54e4b0e57fd432bdfe4c847c5282aa68ab70dfd1 | [
"MIT"
] | null | null | null | checkprocess-4terminal.py | linuxkay/Process_Monitoring | 54e4b0e57fd432bdfe4c847c5282aa68ab70dfd1 | [
"MIT"
] | null | null | null | checkprocess-4terminal.py | linuxkay/Process_Monitoring | 54e4b0e57fd432bdfe4c847c5282aa68ab70dfd1 | [
"MIT"
] | null | null | null | #!/usr/bin/python2.7
import commands
import os
while True:
output = commands.getoutput('ps -aux')
if '/usr/bin/python2.7 /home/user/Workspace/silenceisgolden.py' in output:
# print "ITS ALIVE!!!"
continue
else:
os.system('/usr/bin/python2.7 /home/user/Workspace/silenceisgolden.py &')
| 27.636364 | 77 | 0.697368 | 43 | 304 | 4.930233 | 0.604651 | 0.084906 | 0.183962 | 0.198113 | 0.45283 | 0.45283 | 0.45283 | 0.45283 | 0.45283 | 0 | 0 | 0.023077 | 0.144737 | 304 | 10 | 78 | 30.4 | 0.792308 | 0.141447 | 0 | 0 | 0 | 0 | 0.482625 | 0.301158 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 0.25 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
b623e5a03659faa473148786f864709a11470c38 | 294 | py | Python | vaultier/nodes/roles.py | dz0ny/Vaultier | e23d86c7576f4785b4e369242d7b5f7125e4d8c6 | [
"BSD-3-Clause"
] | 30 | 2015-07-13T11:11:23.000Z | 2021-01-25T14:21:18.000Z | vaultier/nodes/roles.py | corpusops/vaultier | 3baef4346add0b3bdff322257467f74b2a0c856c | [
"BSD-3-Clause"
] | null | null | null | vaultier/nodes/roles.py | corpusops/vaultier | 3baef4346add0b3bdff322257467f74b2a0c856c | [
"BSD-3-Clause"
] | 31 | 2015-08-10T12:10:16.000Z | 2020-09-18T09:43:28.000Z | from django_mptt_acl.rules import DefaultRoleRule
class ManageRole(object):
name = 'manage'
permissions = ('read', 'update', 'delete', 'invite', 'create')
required_permissions_ancestors = ('read',)
required_permissions_descendants = permissions
rules = (DefaultRoleRule,) | 29.4 | 66 | 0.721088 | 28 | 294 | 7.357143 | 0.75 | 0.184466 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.159864 | 294 | 10 | 67 | 29.4 | 0.834008 | 0 | 0 | 0 | 0 | 0 | 0.128814 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.142857 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
b6285806339045de81140d6078437ac587eb23ef | 6,145 | py | Python | src/lib/board_support/scripts/Generate_TBTemplate.py | GaloisInc/BESSPIN-BSC | 21a0a8cba9e643ef5afcb87eac164cc33ea83e94 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | 1 | 2022-02-11T01:52:42.000Z | 2022-02-11T01:52:42.000Z | src/lib/board_support/scripts/Generate_TBTemplate.py | GaloisInc/BESSPIN-BSC | 21a0a8cba9e643ef5afcb87eac164cc33ea83e94 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | null | null | null | src/lib/board_support/scripts/Generate_TBTemplate.py | GaloisInc/BESSPIN-BSC | 21a0a8cba9e643ef5afcb87eac164cc33ea83e94 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | null | null | null | #!/usr/bin/python
# Copyright (c) 2105 Bluespec, Inc. All Rights Reserved
# Author: J Schwartz
# ================================================================
# Usage: Generate_TBTemplate.py pin_file tb_src_dir cpp_src_dir
# XXX ...
# ================================================================
# Standard Python lib imports
import sys
import os
# ================================================================
# Project imports
from ParsePin import * # The parser for .pin files
from Generate_TestBench import genTclGui
from Generate_TestBench import genTclTb
from Generate_TestBench import genDutXactor
# ================================================================
# Generate TclTb.cpp
def genUserTemplate (output_dir, dut_ifc, new_module_name):
template_filename = os.path.join (output_dir, "usertb.cpp")
try:
f_template = open (template_filename, "w")
except:
print "Error opening file: ", template_filename
return 1
print "Generating file: ", template_filename
genUserTemplateFile (f_template, dut_ifc, new_module_name)
f_template.close()
return 0
def genUserTemplateFile (f_out, dut_ifc, new_module_name):
f_out.write ("// Copyright Bluespec Inc. 2010-2011\n")
f_out.write ("// By: GenTestbench tool\n\n")
f_out.write ("#include <iostream>\n\n")
f_out.write ("// Boilerplate file in $BLUESPECDIR/SceMi/capi/\n")
f_out.write ("#include \"usertb.h\"\n\n")
f_out.write ("// Locally generated file specific to the DUT pin file, which includes\n")
f_out.write ("// boilerplate from $BLUESPECDIR/SceMi/capi/semu_capi.h\n")
f_out.write ("#include \"capi.h\"\n\n")
f_out.write ("////////////////////////////////////////////////////////////////////////////////\n")
f_out.write ("//\n")
f_out.write ("// This is a basic template for a C++ user testbench\n")
f_out.write ("//\n")
f_out.write ("// Please refer to the capi.h file in $project_dir/build/cpp for the C API.\n")
f_out.write ("// The capi.h file documents all of the C API calls for Semu, including\n")
f_out.write ("// the interface-customized calls to communicate to your DUT.\n")
f_out.write ("//\n")
f_out.write ("////////////////////////////////////////////////////////////////////////////////\n\n")
f_out.write ("int do_test() {\n\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n")
f_out.write (" //\n")
f_out.write (" // If you do NOT plan to actively control the DUT clock from within your C\n")
f_out.write (" // testbench, then you should UNcomment the following lines of code. When\n")
f_out.write (" // this code is active, then the DUT clock will start running as soon as\n")
f_out.write (" // the user clicks 'Run' in the Emulation Control Panel.\n")
f_out.write (" //\n")
f_out.write (" // If, instead, you plan to control the clock (e.g. single-step the clock)\n")
f_out.write (" // from within your C testbench, then leave it 'as is' (that is, commented\n")
f_out.write (" // out).\n")
f_out.write (" //\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n\n")
f_out.write ("/*\n")
f_out.write (" if (!semu_start_controlled_clock()) {\n")
f_out.write (" cerr << \"Something wrong, cannot start controlled clock\" << endl;\n")
f_out.write (" return 0;\n")
f_out.write (" }\n")
f_out.write ("*/\n\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n\n\n")
f_out.write (" // ************ Here's where you insert testbench code *************\n\n\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n")
f_out.write (" //////////////////////////////////////////////////////////////////////////////\n\n")
f_out.write (" return 1;\n")
f_out.write ("}\n\n")
# ================================================================
# Main program when executed from the cmd line
def main (argv = None):
if (len (sys.argv) != 4):
print "Usage: %s <pin_file_name> <tb_src_dir> <cpp_src_dir>" % os.path.basename(sys.argv [0])
return 1
pin_filename = sys.argv [1]
tb_src_dir = sys.argv [2]
cpp_src_dir = sys.argv [3]
usertb = True
if not os.path.exists(tb_src_dir):
os.makedirs(tb_src_dir)
if not os.path.exists(cpp_src_dir):
os.makedirs(cpp_src_dir)
(dut_name, ext) = os.path.splitext (os.path.basename (pin_filename))
BsvDUT = "Bsv" + dut_name
try:
f_pin = open (pin_filename, "r")
except:
print "Error opening pin file: ", pin_filename
return 1
dut_ifc = parse_pin_file (f_pin, pin_filename)
#if isinstance (dut_ifc, DUT_IFC):
# dut_ifc.show (" ")
# Generate a template TB that uses the C API.
#
if genUserTemplate (tb_src_dir, dut_ifc, BsvDUT):
# error message will have been displayed
return 1
# Generate the usertb DUT GUI in the TB directory
# (The user may want to edit it, though this is not necessary.)
if genTclGui (tb_src_dir, dut_ifc, BsvDUT, usertb):
# error message will have been displayed
return 1
# Generate a TclTb.cpp file, and place it in the TB directory
# (user should not edit this file, though)
if genTclTb (tb_src_dir, dut_ifc, BsvDUT, usertb):
# error message will have been displayed
return 1
# The template files will refer to the DutXactor and C CAPI.
# If those files haven't already been created, create it here.
#
if genDutXactor (cpp_src_dir, dut_ifc, BsvDUT):
# error message will have been displayed
return 1
return 0
# ================================================================
# For non-interactive invocations, call main() and use its return value
# as the exit code.
if __name__ == '__main__':
sys.exit (main ())
| 37.469512 | 104 | 0.538324 | 804 | 6,145 | 3.950249 | 0.25995 | 0.057935 | 0.127519 | 0.138539 | 0.285894 | 0.204975 | 0.16971 | 0.16971 | 0.163413 | 0.150189 | 0 | 0.005425 | 0.16013 | 6,145 | 163 | 105 | 37.699387 | 0.609959 | 0.221806 | 0 | 0.276596 | 1 | 0.031915 | 0.473152 | 0.196041 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.06383 | null | null | 0.042553 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
b628c08ba4eedb48de4710fd1ee2c9a1c7fd435a | 1,046 | py | Python | infobip_channels/sms/models/response/core.py | infobip-community/infobip-api-python-sdk | 5ffc5ab877ee1748aa29391f991c8c5324387487 | [
"MIT"
] | null | null | null | infobip_channels/sms/models/response/core.py | infobip-community/infobip-api-python-sdk | 5ffc5ab877ee1748aa29391f991c8c5324387487 | [
"MIT"
] | null | null | null | infobip_channels/sms/models/response/core.py | infobip-community/infobip-api-python-sdk | 5ffc5ab877ee1748aa29391f991c8c5324387487 | [
"MIT"
] | null | null | null | from typing import Dict, List, Optional
from pydantic import StrictBool
from infobip_channels.core.models import CamelCaseModel, ResponseBase, ResponseStatus
class ServiceException(CamelCaseModel):
message_id: str
text: str
validation_errors: Optional[Dict[str, List[str]]] = None
class RequestError(CamelCaseModel):
service_exception: ServiceException
class SMSResponseError(ResponseBase):
request_error: RequestError
class Error(ResponseStatus):
permanent: Optional[StrictBool] = None
class Price(CamelCaseModel):
price_per_message: Optional[float] = None
currency: Optional[str] = None
class CoreResult(CamelCaseModel):
bulk_id: Optional[str] = None
message_id: Optional[str] = None
to: Optional[str] = None
sent_at: Optional[str] = None
done_at: Optional[str] = None
sms_count: Optional[int] = None
price: Optional[Price] = None
status: Optional[ResponseStatus] = None
error: Optional[Error] = None
class ScheduledSMSMessages(ResponseBase):
bulk_id: str
| 23.244444 | 85 | 0.741874 | 117 | 1,046 | 6.521368 | 0.393162 | 0.06422 | 0.117955 | 0.044561 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.17304 | 1,046 | 44 | 86 | 23.772727 | 0.882081 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.107143 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 2 |
b62dc95007ce81605c25123f4173743e53016547 | 280 | py | Python | det/configs/involution/mask_rcnn_red50_neck_fpn_head_1x_coco.py | shikishima-TasakiLab/involution | 7734b83ae7ff7eeefbb6f8c7b545a4fd03fa93cf | [
"MIT"
] | 1,260 | 2021-03-11T01:48:36.000Z | 2022-03-31T13:46:33.000Z | det/configs/involution/mask_rcnn_red50_neck_fpn_head_1x_coco.py | Magnety/involution | c920bf67dcd962ae1692a0da69edb174ca0dec5b | [
"MIT"
] | 54 | 2021-03-11T23:02:55.000Z | 2022-03-10T11:56:46.000Z | det/configs/involution/mask_rcnn_red50_neck_fpn_head_1x_coco.py | Magnety/involution | c920bf67dcd962ae1692a0da69edb174ca0dec5b | [
"MIT"
] | 177 | 2021-03-12T05:38:47.000Z | 2022-03-29T00:33:20.000Z | _base_ = [
'../_base_/models/mask_rcnn_red50_neck_fpn_head.py',
'../_base_/datasets/coco_instance.py',
'../_base_/schedules/schedule_1x_warmup.py', '../_base_/default_runtime.py'
]
optimizer_config = dict(grad_clip(dict(_delete_=True, max_norm=5, norm_type=2)))
| 40 | 81 | 0.714286 | 39 | 280 | 4.487179 | 0.769231 | 0.102857 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.02008 | 0.110714 | 280 | 6 | 82 | 46.666667 | 0.682731 | 0 | 0 | 0 | 0 | 0 | 0.558394 | 0.558394 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
b6307c61684e9bbf18238bb62285c04fbb112524 | 5,122 | py | Python | trypython/stdlib/__init__.py | devlights/try-python | 67d1d26476794da81c8c76662486108ce03f8fb4 | [
"MIT"
] | 4 | 2019-10-21T11:42:11.000Z | 2020-03-12T16:35:51.000Z | trypython/stdlib/__init__.py | devlights/try-python | 67d1d26476794da81c8c76662486108ce03f8fb4 | [
"MIT"
] | 80 | 2017-02-08T07:55:37.000Z | 2021-10-06T06:30:30.000Z | trypython/stdlib/__init__.py | devlights/try-python | 67d1d26476794da81c8c76662486108ce03f8fb4 | [
"MIT"
] | 1 | 2020-03-12T04:37:17.000Z | 2020-03-12T04:37:17.000Z | """
初期処理を実施します.
"""
from typing import Dict, Callable
from trypython.stdlib.argparse_ import argparse01
from trypython.stdlib.atexit_ import atexit01
from trypython.stdlib.binascii_ import binascii01
from trypython.stdlib.collections_ import collections01, collections02, collections03, collections04, collections05, \
collections06, collections07
from trypython.stdlib.contextlib_ import contextlib01, contextlib02
from trypython.stdlib.csv_ import csv01, csv02
from trypython.stdlib.dataclasses_ import dataclasses01, dataclasses02
from trypython.stdlib.datetime_ import datetime01, datetime02
from trypython.stdlib.dis_ import dis01
from trypython.stdlib.functools_ import functools01, functools02, functools03
from trypython.stdlib.gc_ import gc01
from trypython.stdlib.itertools_ import itertools01, itertools02, itertools03, itertools04, itertools05, itertools06, \
itertools07, itertools08
from trypython.stdlib.json_ import json01
from trypython.stdlib.keyword_ import keyword01
from trypython.stdlib.logging_ import logging01, logging02, logging03, logging04, logging05, logging06, logging07, \
logging08, logging09
from trypython.stdlib.mmap_ import mmap01
from trypython.stdlib.multiprocessing_ import multiprocessing01
from trypython.stdlib.operator_ import operator01
from trypython.stdlib.pathlib_ import pathlib01, pathlib02
from trypython.stdlib.pickle_ import pickle01
from trypython.stdlib.re_ import re01, re02, re03, re04, re05, re06, re07
from trypython.stdlib.reprlib_ import reprlib01
from trypython.stdlib.secrets_ import secrets01
from trypython.stdlib.signal_ import signal01
from trypython.stdlib.socket_ import socket01
from trypython.stdlib.struct_ import struct01
from trypython.stdlib.sys_ import sys01, sys02, sys03, sys_getsizeof_vs_dunder_sizeof_diff
from trypython.stdlib.tempfile_ import tempfile01, tempfile02, tempfile03
from trypython.stdlib.textwrap_ import textwrap01
from trypython.stdlib.time_ import time01
from trypython.stdlib.tracemalloc_ import tracemalloc01
from trypython.stdlib.typing_ import typing01
from trypython.stdlib.weakref_ import weakref01, weakref02
from trypython.stdlib.xml_ import xml01
def regist_modules(m: Dict[str, Callable[[], None]]):
########################################
# trypython.stdlib
########################################
m["argparse_01"] = argparse01.go
m["atexit_01"] = atexit01.go
m["binascii_01"] = binascii01.go
m["collections_01"] = collections01.go
m["collections_02"] = collections02.go
m["collections_03"] = collections03.go
m["collections_04"] = collections04.go
m["collections_05"] = collections05.go
m["collections_06"] = collections06.go
m["collections_07"] = collections07.go
m["contextlib_01"] = contextlib01.go
m["contextlib_02"] = contextlib02.go
m["csv_01"] = csv01.go
m["csv_02"] = csv02.go
m["dataclasses_01"] = dataclasses01.go
m["dataclasses_02"] = dataclasses02.go
m["datetime_01"] = datetime01.go
m["datetime_02"] = datetime02.go
m["dis_01"] = dis01.go
m["functools_01"] = functools01.go
m["functools_02"] = functools02.go
m["functools_03"] = functools03.go
m["gc_01"] = gc01.go
m["itertools_01"] = itertools01.go
m["itertools_02"] = itertools02.go
m["itertools_03"] = itertools03.go
m["itertools_04"] = itertools04.go
m["itertools_05"] = itertools05.go
m["itertools_06"] = itertools06.go
m["itertools_07"] = itertools07.go
m["itertools_08"] = itertools08.go
m["json_01"] = json01.go
m["keyword_01"] = keyword01.go
m["logging_01"] = logging01.go
m["logging_02"] = logging02.go
m["logging_03"] = logging03.go
m["logging_04"] = logging04.go
m["logging_05"] = logging05.go
# m["logging_06"] = logging06.go
# m["logging_07"] = logging07.go
# m["logging_08"] = logging08.go
m["logging_09"] = logging09.go
m["mmap_01"] = mmap01.go
m["multiprocessing_01"] = multiprocessing01.go
m["operator_01"] = operator01.go
m["pathlib_01"] = pathlib01.go
m["pathlib_02"] = pathlib02.go
m["pickle_01"] = pickle01.go
m["re_01"] = re01.go
m["re_02"] = re02.go
m["re_03"] = re03.go
m["re_04"] = re04.go
m["re_05"] = re05.go
m["re_06"] = re06.go
m["re_07"] = re07.go
m["reprlib_01"] = reprlib01.go
m["secrets_01"] = secrets01.go
m["signal_01"] = signal01.go
m["socket_01"] = socket01.go
m["struct_01"] = struct01.go
m["sys_01"] = sys01.go
m["sys_02"] = sys02.go
m["sys_03"] = sys03.go
m["sys_getsizeof_vs_dunder_sizeof_diff"] = sys_getsizeof_vs_dunder_sizeof_diff.go
m["tempfile_01"] = tempfile01.go
m["tempfile_02"] = tempfile02.go
m["tempfile_03"] = tempfile03.go
m["textwrap_01"] = textwrap01.go
m["time_01"] = time01.go
try:
from trypython.stdlib.tkinter_ import messagebox01
m["tkinter_01"] = messagebox01.go
except:
pass
m["tracemalloc_01"] = tracemalloc01.go
m["typing_01"] = typing01.go
m["weakref_01"] = weakref01.go
m["weakref_02"] = weakref02.go
m["xml_01"] = xml01.go
| 39.4 | 119 | 0.715346 | 658 | 5,122 | 5.378419 | 0.212766 | 0.061034 | 0.187906 | 0.016954 | 0.025431 | 0.025431 | 0 | 0 | 0 | 0 | 0 | 0.102446 | 0.153846 | 5,122 | 129 | 120 | 39.705426 | 0.714121 | 0.023819 | 0 | 0 | 0 | 0 | 0.152169 | 0.00713 | 0 | 0 | 0 | 0 | 0 | 1 | 0.008696 | false | 0.008696 | 0.313043 | 0 | 0.321739 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 |
b636167d8e873e440c5907cd30302e00734da220 | 5,142 | py | Python | tste.py | thedognexttothetrashcan/taobao | c796ec1f61a5443406686f65badc1df6aaf7b711 | [
"Apache-2.0"
] | null | null | null | tste.py | thedognexttothetrashcan/taobao | c796ec1f61a5443406686f65badc1df6aaf7b711 | [
"Apache-2.0"
] | 1 | 2020-12-05T15:32:37.000Z | 2020-12-05T15:32:37.000Z | tste.py | xwh-p/taobao | c796ec1f61a5443406686f65badc1df6aaf7b711 | [
"Apache-2.0"
] | null | null | null | # # from selenium import webdriver
# # import time
# # from selenium.webdriver.chrome.options import Options
# #
# # chrome_options = Options()
# # # chrome_options.add_argument('--headless')
# # # chrome_options.add_argument('--disable-gpu')
# #
# # path = r'/usr/bin/chromedriver'
# # driver = webdriver.Chrome(chrome_options=chrome_options)
# #
# # # url = 'https://login.tmall.com/?redirectURL=https%3A%2F%2Flist.tmall.com%2Fsearch_product.htm%3Fq%3D%25CA%25B3%25C6%25B7%26type%3Dp%26spm%3Da220m.1000858.a2227oh.d100%26from%3D.list.pc_1_searchbutton'
# # url = 'https://login.tmall.com/?redirectURL=https%3A%2F%2Flist.tmall.com%2Fsearch_product.htm%3Fspm%3Da220m.1000858.0.0.2c467adcD1Hb2U%26s%3D120%26q%3D%25CA%25B3%25C6%25B7%26sort%3Ds%26style%3Dg%26smAreaId%3D110100%26type%3Dpc%23J_Filter'
# # driver.get(url)
# # time.sleep(3)
# # login = driver.find_element_by_id('J_Quick2Static')
# # # login = driver.find_element_by_class_name('forget-pwd J_Quick2Static')
# # login.click()
# # print('kjgkjgk')
# # time.sleep(3)
# # zanghu = driver.find_elements_by_link_text('密码登录')
# # # zanghu = driver.find_elements_by_xpath('//*[@id="J_Form"]/div[2]/span')
# # zanghu.send_keys('18611138595')
# # pd = driver.find_element_by_id('TPL_password_1')
# # time.sleep(3)
# # pd.send_keys('5921haohao')
# # login = driver.find_element_by_id('J_SubmitStatic')
# # login.click()
# # driver.save_screenshot('ta11212.png')
# # time.sleep(3)
# #
# # driver.quit()
# #
# #
# #
# # url = 'http://www.baidu.com/'
# # driver.get(url)
# # # time.sleep(20)
# # driver.save_screenshot('l1.png')
# # driver.implicitly_wait(20)
# #
# # # 通过driver查找的到input输入框
# # myinput = driver.find_element_by_id('kw')
# # # 往框里面写内容
# # myinput.send_keys('气质美女')
# # time.sleep(3)
# # driver.save_screenshot('l2.png')
# #
# # # 点击百度一下
# # mybutton = driver.find_element_by_id('su')
# # mybutton.click()
# # time.sleep(4)
# # driver.save_screenshot('l3.png')
# # # 找到指定美女点击
# # # image = driver.find_element_by_xpath('//div[@id="1"]/div[1]/a[1]')
# # # image.click()
# # # time.sleep(3)
# #
# # # 点击美女图片的链接
# # oa = driver.find_element_by_link_text('气质美女_海量精选高清图片_百度图片')
# # driver.save_screenshot('l4.png')
# # oa.click()
# #
# #
# import json
# import random
#
# from selenium import webdriver
# import time
# from selenium.webdriver.chrome.options import Options
# from selenium.webdriver import ActionChains
#
# chrome_options = Options()
# # chrome_options.add_argument('--headless')
# # chrome_options.add_argument('--disable-gpu')
#
# from lxml import etree
# from selenium import webdriver
#
# mUA = 'User-Agent, Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'
# mWidth = 375
# mHeight = 667
# PIXEL_RATIO = 3.0
#
# mobileEmulation = {"deviceMetrics": {"width": mWidth, "height": mHeight, "pixelRatio": PIXEL_RATIO},
# "userAgent": mUA}
#
#
# def create_chrome():
# ops = webdriver.ChromeOptions()
# ops.add_experimental_option('mobileEmulation', mobileEmulation)
# # ops.add_argument('--headless')
# # ops.add_argument('--disable-gpu')
#
# web = webdriver.Chrome(chrome_options=ops)
# web.set_page_load_timeout(10)
# web.set_script_timeout(10)
# web.set_window_size(mWidth, mHeight)
# return web
#
#
# driver = create_chrome()
#
#
#
#
#
# # path = r'/usr/bin/chromedriver'
# # driver = webdriver.Chrome(executable_path=path, chrome_options=chrome_options)
# # driver.maximize_window()
# url = 'https://login.m.taobao.com/login.htm?loginFrom=wap_tmall&assets_js=mui%2Ffeloader%2F4.0.22%2Ffeloader-min.js,mui%2Ftmapp-standalone%2F4.0.3%2Fseed.js,mui%2Ftmapp-standalone%2F4.0.3%2Flogin-download.js&assets_css=3.0.8%2Fmobile%2Ftmallh5.css&redirectURL=https%3A%2F%2Fwww.tmall.com'
# driver.get(url)
# # er wei ma
# # itchat = driver.find_element_by_id('J_Quick2Static')
# # itchat.click()
#
# # dian ji
# time.sleep(10)
# coun = driver.find_element_by_id('username')
# coun.click()
# time.sleep(2)
# coun.send_keys('18611138595')
# time.sleep(3)
# pwd = driver.find_element_by_id('password')
# pwd.click()
# time.sleep(2)
# pwd.send_keys('xwh123456')
# with open('cookies.json', 'r', encoding='utf-8') as f:
# listCookies = json.loads(f.read())
# # hua kuai
# # action = ActionChains(driver)
# # dragger = driver.find_element_by_id('nc_1_n1z')
# # action.click_and_hold(dragger).perform()
# # action.release()
# # action.move_by_offset(180, 0).perform()
# # action.click_and_hold(dragger).move_by_offset(8000, 0).perform()
#
# # x = 258
# # # while x < 190:
# # # x += random.randint(100, 160)
# # # print(x)
# # action.click_and_hold(dragger).move_by_offset(x,0).perform()
# #
# # time.sleep(0.3)
# # # login
# # time.sleep(3)
# # login = driver.find_element_by_id('J_SubmitStatic')
# # login.click()
#
# # driver.quit()
#
#
#
#
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
}
r = requests.get(url='https://s.taobao.com/search?q=%E5%8D%AB%E8%A1%A3',headers=headers)
print(r.text)
#
| 30.607143 | 290 | 0.688643 | 717 | 5,142 | 4.767085 | 0.372385 | 0.043885 | 0.064658 | 0.072264 | 0.361908 | 0.264775 | 0.264775 | 0.235518 | 0.188122 | 0.188122 | 0 | 0.064595 | 0.123882 | 5,142 | 167 | 291 | 30.790419 | 0.694118 | 0.862505 | 0 | 0 | 0 | 0.333333 | 0.392694 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0.166667 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
b63c20d732ad8c737abc5edc8b447090d094faef | 1,562 | py | Python | SocialNetwork/Author/migrations/0002_auto_20190221_1645.py | cmput404-ahyyy/group-webproject | 822f12fa2579aebee596150509c2109625e79414 | [
"Apache-2.0"
] | null | null | null | SocialNetwork/Author/migrations/0002_auto_20190221_1645.py | cmput404-ahyyy/group-webproject | 822f12fa2579aebee596150509c2109625e79414 | [
"Apache-2.0"
] | 9 | 2019-02-02T00:32:05.000Z | 2019-02-18T17:24:11.000Z | SocialNetwork/Author/migrations/0002_auto_20190221_1645.py | cmput404-ahyyy/group-webproject | 822f12fa2579aebee596150509c2109625e79414 | [
"Apache-2.0"
] | 1 | 2019-03-26T00:22:10.000Z | 2019-03-26T00:22:10.000Z | # Generated by Django 2.1.7 on 2019-02-21 16:45
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Author', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='author',
name='githubUrl',
field=models.URLField(),
),
migrations.AlterField(
model_name='author',
name='hostName',
field=models.CharField(max_length=100),
),
migrations.AlterField(
model_name='friendrequest',
name='from_author',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='friend_request_sent', to='Author.Author'),
),
migrations.AlterField(
model_name='friendrequest',
name='to_author',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='friend_request_recieved', to='Author.Author'),
),
migrations.AlterField(
model_name='friends',
name='author1',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='friend1', to='Author.Author'),
),
migrations.AlterField(
model_name='friends',
name='author2',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='friend2', to='Author.Author'),
),
]
| 34.711111 | 152 | 0.612036 | 161 | 1,562 | 5.801242 | 0.329193 | 0.051392 | 0.1606 | 0.186296 | 0.683084 | 0.683084 | 0.53212 | 0.486081 | 0.486081 | 0.37045 | 0 | 0.022569 | 0.262484 | 1,562 | 44 | 153 | 35.5 | 0.788194 | 0.028809 | 0 | 0.473684 | 1 | 0 | 0.151155 | 0.015182 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.052632 | 0 | 0.131579 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.