index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
8,600 | e9659555938211d067919ee5e0083efb29d42d7b | # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-05-22 00:19
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('classroom', '0003_remove_anouncements_classroom'),
]
... |
8,601 | 2432e2b4da8af284055e7edf6e0bd94b7b293f0b | from __future__ import annotations
from .base import * # noqa
SECRET_KEY = "django-insecure-usp0sg081f=9+_j95j@-k^sfp+9c*!qrwh-m17%=_9^xot#9fn"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "puka-test",
"USER": "jeff",
"PASSWORD": "",
"HOST... |
8,602 | 7727896d4e1b2b415c398b206f9fb7e228e6f26d | # DO NOT EDIT THIS FILE!
#
# Python module managedElementManager generated by omniidl
import omniORB
omniORB.updateModule("managedElementManager")
# ** 1. Stub files contributing to this module
import managedElementManager_idl
# ** 2. Sub-modules
# ** 3. End
|
8,603 | 9447d0d0481df3d0ee4273256d02977bc8044e4e | # -*- coding: utf-8 -*-
"""
python3
description :Fingerprint image enhancement by using gabor
"""
import os
import cv2
import math
import scipy
import numpy as np
from scipy import signal
def normalise(img):
normed = (img - np.mean(img)) / (np.std(img))
return normed
def ridge_segment(im, blksze, thresh):
... |
8,604 | 3b7c30718838a164eaf3aa12cd7b6a68930346f8 | '''Mock classes that imitate idlelib modules or classes.
Attributes and methods will be added as needed for tests.
'''
from idlelib.idle_test.mock_tk import Text
class Editor:
'''Minimally imitate EditorWindow.EditorWindow class.
'''
def __init__(self, flist=None, filename=None, key=None, root=None):
... |
8,605 | fc2748d766ebce8c9577f1eebc8435e2aa58ae25 |
import numpy as np
import random
import argparse
import networkx as nx
from gensim.models import Word2Vec
from utils import read_node_label, plot_embeddings
class node2vec_walk():
def __init__(self, nx_G, is_directed, p, q):
self.G = nx_G
self.is_directed = is_directed
self.p = p
... |
8,606 | 3c8352ff2fc92ada1b58603df2a1a402e57842be | # coding: utf-8
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
elem = driver.find_element_by_xpath('//*[@id="kw"]')
elem.send_keys("python selenium", Keys.ENTER)
print(driver.page_source)
|
8,607 | 7f62af951b49c3d1796c2811527ceb30ca931632 | import pandas as pd
from datetime import datetime
from iFinDPy import *
thsLogin = THS_iFinDLogin("iFind账号","iFind账号密码")
index_list = ['000001.SH','399001.SZ','399006.SZ']
result = pd.DataFrame()
today =datetime.today().strftime('%Y-%m-%d')
for index in index_list:
data_js = THS_DateSerial(index,'ths_pre_clo... |
8,608 | 465d5baae8d5be77fbf3d550d10667da420a8fbe | import sys
sys.path.append("../")
import numpy as np
import tensorflow as tf
from utils import eval_accuracy_main_cdan
from models import mnist2mnistm_shared_discrepancy, mnist2mnistm_predictor_discrepancy
import keras
import argparse
import pickle as pkl
parser = argparse.ArgumentParser(description='Traini... |
8,609 | 09905d4b5ad2e59578d874db171aafb6c42db105 | # Given an unsorted integer array nums, find the smallest missing positive integer.
class Solution:
def firstMissingPositive(self, nums: List[int]) -> int:
# if nums is emtpy, first pos int is 1
if not nums:
return 1
maxnum = max(nums) # for speed we assign max of nums to var max... |
8,610 | 45d57f8392b89776f9349c32b4bb2fa71a4aaa83 | # -*- coding: utf-8 -*-
"""
A customised logger for this project for logging to the file and console
Created on 29/07/2022
@author: PNimbhore
"""
# imports
import os
import logging
class Logger:
"""
A custom logger which will take care
of logging to console and file.
"""
def __init__(self, filepat... |
8,611 | 530ec3df27cc4c8f0798566f0c66cfbffe510786 | import os
import subprocess
import sys
import time
# print sys.argv
start = time.time()
subprocess.call(sys.argv[1:], shell=True)
stop = time.time()
print "\nTook %.1f seconds" % (stop - start)
|
8,612 | 02c32cf04529ff8b5edddf4e4117f8c4fdf27da9 | class Formater():
def clean_number (posible_number):
sanitize_number = posible_number.replace(' ', '')
number_of_dots = sanitize_number.count('.')
if number_of_dots > 1:
return None
if number_of_dots == 1:
dot_position = sanitize_number.index('.')
... |
8,613 | 2ccc3bb63445572610f6dbdfe5b1cbeef506c9a9 | from pygraphblas.matrix import Matrix
from pygraphblas.types import BOOL
from pyformlang.regular_expression import Regex
class Graph:
def __init__(self):
self.n_vertices = 0
self.label_matrices = dict()
self.start_vertices = set()
self.final_vertices = set()
def from_trans(self... |
8,614 | 55acae8129ddaba9a860d5d356e91f40607ac95a | def func(n):
return n*2
def my_map(f, seq):
return [f(item) for item in seq]
def main():
numbers = [1, 2, 3, 4]
result = list(map(func, numbers))
print(result)
result = [func(item) for item in numbers]
print(result)
if __name__ == '__main__':
main()
|
8,615 | acd2d84529e197d6f9d134e8d7e25a51a442f3ae | # MÁSTER EN BIG DATA Y BUSINESS ANALYTICS
# MOD 1 - FINAL EVALUATION - EX. 2: dado un archivo que contiene en cada línea
# una palabra o conjunto de palabras seguido de un valor numérico denominado
# “sentimiento” y un conjunto de tweets, se pide calcular el sentimiento de
# aquellas palabras o conjunto de palabras que... |
8,616 | c485466a736fa0a4f183092e561a27005c01316d | import pylab,numpy as np
from numpy import sin
from matplotlib.patches import FancyArrowPatch
fig=pylab.figure()
w=1
h=1
th=3.14159/25.
x=np.r_[0,0,w,w,0]
y=np.r_[0,h,h-w*sin(th),0-w*sin(th),0]
pylab.plot(x,y)
x=np.r_[0,0,w/2.0,w/2.0,0]
y=np.r_[0,h/6.0,h/6.0-w/2.0*sin(th),0-w/2.0*sin(th),0]
pylab.plot(x... |
8,617 | 4e6e4917aee2385fe118d6e58c359a4c9fc50943 | # -*- coding: utf-8 -*-
'''
File Name: bubustatus/utils.py
Author: JackeyGao
mail: junqi.gao@shuyun.com
Created Time: 一 9/14 12:51:37 2015
'''
from rest_framework.views import exception_handler
def custom_exception_handler(exc, context):
# Call REST framework's default exception handler first,
# to get the st... |
8,618 | c65969bba72142f4a328f978d78e0235cd56e393 | from huobi import RequestClient
from huobi.constant.test import *
request_client = RequestClient(api_key=g_api_key, secret_key=g_secret_key)
obj_list = request_client.get_cross_margin_loan_orders()
if len(obj_list):
for obj in obj_list:
obj.print_object()
print()
... |
8,619 | 4e538251dedfe0b9ffb68de2de7dc50681320f1f | #
# @lc app=leetcode id=267 lang=python3
#
# [267] Palindrome Permutation II
#
# https://leetcode.com/problems/palindrome-permutation-ii/description/
#
# algorithms
# Medium (33.28%)
# Total Accepted: 24.8K
# Total Submissions: 74.4K
# Testcase Example: '"aabb"'
#
# Given a string s, return all the palindromic perm... |
8,620 | 1b71789ba7c2191b433a405723fe6c985c926610 | # Generated by Django 2.2.6 on 2020-04-06 16:47
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='User',
fie... |
8,621 | dfe7f0e25f340601886334c61a50806491a4ae2b | """Tests for our `neo login` subcommand."""
import pytest
import os
from neo.libs import login
from neo.libs import utils
class TestAuth:
@pytest.mark.run(order=0)
def test_do_login(self, monkeypatch):
login.load_env_file()
username = os.environ.get('OS_USERNAME')
passwd = os.environ.g... |
8,622 | a4eca0f5b7d5a03ca3600554ae3fe3b94c59fc68 | from os import environ
from process import process
from s3Service import put_object
environ['ACCESS_KEY'] = '1234567890'
environ['SECRET_KEY'] = '1234567890'
environ['ENDPOINT_URL'] = 'http://localhost:4566'
environ['REGION'] = 'us-east-1'
environ['BUCKET_GLOBAL'] = 'fl2-statement-global'
environ['BUCKET_GLOBAL_BACKUP... |
8,623 | 09b2c1e69203f440754e82506b42e7856c94639a | from robotcar import RobotCar
import pdb
class RobotCar_Stub(RobotCar):
def forward(self):
print("Forward")
def backward(self):
print("Backward")
def left(self):
print("Left")
def right(self):
print("Right")
def stop(self):
print("Stop")
if __name__ == '__main__':
... |
8,624 | 27e66b2a03bc626d5babd804e736a4652ba030d5 | #!/usr/bin/python2
import unittest
import luna_utils as luna
import time
API_URL = "com.webos.service.videooutput/"
VERBOSE_LOG = True
SUPPORT_REGISTER = False
SINK_MAIN = "MAIN"
SINK_SUB = "SUB0"
#TODO(ekwang): If you connect SUB, HAL error occurs. Just test MAIN in the current state
#SINK_LIST = [SINK_MAIN, SINK_... |
8,625 | 49b007b723b9c43fb79d5dffa2546c856faf4937 | # _*_ coding:utf-8 _*_
from __future__ import unicode_literals
from django.db import models
from django.core.urlresolvers import reverse
# Create your models here.
# 本文件中,用__unicode__代替了__str__,以免在admin界面中显示中文而引发错误。
# 参考:http://blog.csdn.net/jiangnanandi/article/details/3574007
# 或者另一个解决方案:http://blog.sina.com.cn/s... |
8,626 | 45b2b611a80b93c9a7d8ec8a09e5838147e1ea76 | # Generated by Django 3.0.2 on 2020-08-27 16:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('info', '0010_auto_20200808_2117'),
]
operations = [
migrations.AddField(
model_name='profile',
name='annual_income',... |
8,627 | 5fe4f2738285d2f4b8bbfee2c4c6d15665737ea4 | from django.urls import path
from .views import *
urlpatterns = [
path('', ListUser.as_view() , name = 'list'),
path('register/', UserRegister.as_view() , name = 'register'),
path('login/', UserLogin.as_view() , name = 'login'),
path('delete/' , UserDelete.as_view() , name ='delete'),
path('update/... |
8,628 | d3b6a105b14d9c3485a71058391a03c2f4aa5c10 | import pickle as pickle
import os
import pandas as pd
import torch
import numpy as np
import random
from sklearn.metrics import accuracy_score
from transformers import XLMRobertaTokenizer, XLMRobertaForSequenceClassification, Trainer, TrainingArguments, XLMRobertaConfig, ElectraForSequenceClassification, Electra... |
8,629 | 5f56838ad0717c4f7a2da6b53f586a88b0166113 | from django.urls import path
from . import apiviews
from rest_framework.authtoken.views import obtain_auth_token
urlpatterns = [
path('contacts', apiviews.ContactsView.as_view(), name='contacts'),
path('contact/<int:pk>', apiviews.ContactView.as_view(), name='contact'),
path('signup', apiviews.create_user... |
8,630 | fa5cbbd03641d2937e4502ce459d64d20b5ee227 |
import matplotlib.pyplot as plt
import numpy as np
from tti_explorer.contacts import he_infection_profile
plt.style.use('default')
loc = 0
# taken from He et al
gamma_params = {
'a': 2.11,
'loc': loc,
'scale': 1/0.69
}
t = 10
days = np.arange(t)
mass = he_infection_profile(t, gamma_params)
fig, ax = pl... |
8,631 | 9a62a57f6d9af7ef09c8ed6e78a100df7978da6e | ID = '113'
TITLE = 'Path Sum II'
DIFFICULTY = 'Medium'
URL = 'https://oj.leetcode.com/problems/path-sum-ii/'
BOOK = False
PROBLEM = r"""Given a binary tree and a sum, find all root-to-leaf paths where each path's
sum equals the given sum.
For example:
Given the below binary tree and `sum = 22`,
... |
8,632 | 492c416becc44deaafef519eae8c9a82ac00cc0e | #!/usr/bin/python
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
ledPin = 4
pinOn = False
GPIO.setup(ledPin, GPIO.OUT)
GPIO.output(ledPin, GPIO.LOW)
def print_pin_status(pin_number):
GPIO.setup(pin_number, GPIO.IN)
value = GPIO.input(pin_number)
print(f'Current Value of {pin_number} is {value}')
G... |
8,633 | 61232ec951cf378798220c00280ef2d351088d06 | import random
#liste de choix possibles
liste = ["rock", "paper", "scissors"]
#si le joueur veut jouer il répond y
answer = "y"
while answer == "y":
#choix du joueur
user_choice = input("rock,paper,scissors ?")
#verifie si le joueur a mis la réponse correcte
if user_choice in liste :
#choix d... |
8,634 | bf7676dc2c47d9cd2f1ce2d436202ae2c5061265 | from .base import GnuRecipe
class CAresRecipe(GnuRecipe):
def __init__(self, *args, **kwargs):
super(CAresRecipe, self).__init__(*args, **kwargs)
self.sha256 = '45d3c1fd29263ceec2afc8ff9cd06d5f' \
'8f889636eb4e80ce3cc7f0eaf7aadc6e'
self.name = 'c-ares'
self.ve... |
8,635 | f28222625e28939b34b1b5c21d28dbf9c49c6374 | import knn
datingDataMat,datingLabels = knn.file2matrix('datingTestSet2.txt')
normMat,ranges,minVals = knn.autoNorm(datingDataMat)
print normMat
print ranges
print minVals |
8,636 | e01b1f57a572571619d6c0981370030dc6105fd2 | import urllib.request
import urllib.parse
import json
content = input("请输入需要翻译的内容:")
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
data = {}
data['action'] = 'FY_BY_CLICKBUTTION'
data['bv'] = '1ca13a5465c2ab126e616ee8d6720cc3'
data['client'] = 'fanyideskweb'
data['doctype'] = 'json'
dat... |
8,637 | c34ff2bbb0ba743268ace77c110ce0b283a25eba | f=open('p102_triangles.txt')
def cross(a,b,c):
t1=b[0]-a[0]
t2=b[1]-a[1]
t3=c[0]-a[0]
t4=c[1]-a[1]
return t1*t4-t2*t3
x=[0,0]
y=[0,0]
z=[0,0]
origin=(0,0)
ans=0
for i in f.xreadlines():
x[0],x[1],y[0],y[1],z[0],z[1]=map(int,i.split(','))
area1=abs(cross(x,y,z))
area2=abs(cross(x,y,orig... |
8,638 | 47587cce572807922344523d8c5fefb09552fe34 | import urllib, json
from PyQt4.QtCore import QRectF, Qt
from PyQt4.Qt import QPrinter, QPainter, QFont, QBrush, QColor, QPen, QImage
from PyQt4.QtGui import QApplication
# bkgimg = QImage()
# bkgimg.load("KosyMost.jpg", format = "jpg")
#
# print bkgimg
# exit()
def background(painter, bkgimg):
maxx = painter.d... |
8,639 | 75833617996549167fa157ff78cc1a11f870784f | import os
import sys
import glob
import shutil
import json
import codecs
from collections import OrderedDict
def getRegionClass(image_path, data_id, imgName):
region_class = ['nosmoke_background', 'nosmoke_face', 'nosmoke_suspect', 'nosmoke_cover', 'smoke_hand', 'smoke_nohand', 'smoke_hard']
label_class = ['nosmok... |
8,640 | 894d8d00fd05bf8648f1b95ecf30b70e7b4e841b | #Copyright [2017] [Mauro Riva <lemariva@mail.com> <lemariva.com>]
#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 ... |
8,641 | 8f17c1ed0cb273a88b986cd7fe7a45439211d536 | ### Global parameters ###
seconds_per_unit_time = 0.01
#########################
pars_spont = {
"tau_p": 2.5,
"tau_d": 5.0,
"amp_p": 0.08,
"amp_d": -0.0533,
"rho": 0.0015,
"N": 50,
"w_max": 0.05,
"mu": 0.07,
"seed": None,
"tend": 50_000_000,
"r_in": 0.04,
"w_in": 0.05,... |
8,642 | 7b5a16fdc536eb4ae3fdc08f827663613560187a | import subprocess
from whoosh.index import create_in
from whoosh.fields import *
import os
import codecs
from whoosh.qparser import QueryParser
import whoosh.index as index
import json
from autosub.autosub import autosub
from azure.storage.blob import AppendBlobService
vedio_formats = ['mp4','avi','wmv','mov'] # 1
aud... |
8,643 | b1b9840fabc96c901e5ed45e22ee63af2f3550cb |
from os import listdir
from os.path import isfile, join
import sys
cat_list = dict();
def onImport():
mypath = "../../data/roget_processed";
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))];
for f_name in onlyfiles:
f_temp = open(mypath + "/" + f_name);
f_lines = f_temp.readlines();
for l... |
8,644 | 85bc304c69dac8bb570f920f9f12f558f4844c49 | listtuple = [(1,2), (2,3), (3,4), (4,5)]
dictn = dict(listtuple)
print(dictn) |
8,645 | dce6ef64cf1a758ed25e11f626ce31206d18f960 | import os
from matplotlib import pyplot as plt
from matplotlib import colors
import numpy as np
class figure:
def __init__(self, dire, dpi, span, data, CIM,
learn_loss=None, eval_loss=None, different_dir_app=True, reference_steps=0, reveal_trend=1):
self.dire = self.new_num_directory(di... |
8,646 | 4e31619efcaf6eeab3b32116b21e71de8202aee2 | from framework import *
from pebble_game import *
from constructive_pebble_game import *
from nose.tools import ok_
import numpy as np
# initialise the seed for reproducibility np.random.seed(102)
fw_2d = create_framework([0,1,2,3], [(0,1), (0,3), (1,2), (1,3), (2,3)], [(2,3), (4,4), (5,2), (1,1)])
# a 3d fw constric... |
8,647 | 24274dddbeb1be743cfcac331ee688d48c9a46dd | import requests
from bs4 import BeautifulSoup
'''
OCWから学院一覧を取得するスクリプト(6個くらいだから必要ない気もする)
gakuinListの各要素は次のような辞書に鳴っている
{
'name' : 学院名,
'url' : その学院の授業の一覧のurl,
}
'''
def getGakuinList():
url = "http://www.ocw.titech.ac.jp/"
response = requests.get(url)
soup = BeautifulSoup(response.content,"lxml")
topMainNav = sou... |
8,648 | 4293ad0b2a4a352d6bdc4b860448c4a3b14ca629 | import torch
from torchvision import transforms
from torch.autograd import Variable
class NormalizeImageDict(object):
"""
Normalize image in dictionary
normalize range is True, the image is divided by 255
"""
def __init__(self,image_keys, normalizeRange=True):
self.image_keys = image_keys
... |
8,649 | b1dce573e6da81c688b338277af214838bbab9dd | def simple_formatter(zipcode: str, address: str) -> str:
return f'{zipcode}は「{address}」です'
|
8,650 | 16dd73f2c85eff8d62cf0e605489d0db1616e36e | # Copyright The Linux Foundation and each contributor to CommunityBridge.
# SPDX-License-Identifier: MIT
"""
Holds the AWS SNS email service that can be used to send emails.
"""
import boto3
import os
import cla
import uuid
import json
import datetime
from cla.models import email_service_interface
region = os.enviro... |
8,651 | d508cb0a8d4291f1c8e76d9d720be352c05ef146 | """
Given a list of partitioned and sentiment-analyzed tweets, run several trials
to guess who won the election
"""
import json
import math
import sys
import pprint
import feature_vector
def positive_volume(f):
return f['relative_volume'] * f['positive_percent']
def inv_negative_volume(f):
return 1.0 - f['r... |
8,652 | 2b3a42fed98b43cdd78edd751b306ba25328061a | import PyPDF2
from pathlib import Path
def get_filenames():
"""
Get PDF files not yet reordered in the current directory
:return: list of PDF file names
"""
filenames = []
for filename in Path('.').glob('*.pdf'):
if 'reordered' not in filename.stem:
filenames.append(filenam... |
8,653 | f0c082968e26d414b0dbb679d4e5077056e99979 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import xmlrunner
import os
import sys
import glob
import yaml
ASSETS_DIR = ""
class GenerateMachineConfig(unittest.TestCase):
def setUp(self):
self.machine_configs = []
for machine_config_path in glob.glob(
f'{ASSETS_D... |
8,654 | c5bdbcc8ba38b02e5e5cf8b53362e87ba761443d | from django.db import models
# Create your models here.
class Advertisement(models.Model):
title = models.CharField(max_length=1500, db_index=True, verbose_name='Заголовок')
description = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeFiel... |
8,655 | b84b3206e87176feee2c39fc0866ada994c9ac7a | from django.shortcuts import render
from PIL import Image
from django.views.decorators import csrf
import numpy as np
import re
import sys
import os
from .utils import *
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
import base64
sys.path.append(os.path.abspath("./models"))
O... |
8,656 | 19962e94afdd3edf298b28b9954f479fefa3bba8 | #1. Create a greeting for your program.
print("Welcome to the Band Name Generator")
#2. Ask the user for the city that they grew up in.
city = input("Which city did you grew up in?\n")
#3. Ask the user for the name of a pet.
pet = input("What is the name of the pet?\n")
#4. Combine the name of their city and pet an... |
8,657 | 129df937d7d295bae2009cfb65b2f85228206698 | # !/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Copyright (c) 2021 Baidu, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LI... |
8,658 | bb6d6061365fad809448d09a1c031b984423b5e0 | __author__ = 'liwenchang'
#-*- coding:utf-8 -*-
import os
import time
import win32api, win32pdhutil, win32con, win32com.client
import win32pdh, string
def check_exsit(process_name):
WMI = win32com.client.GetObject('winmgmts:')
processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % pro... |
8,659 | 2286aa1581ca7d6282b35847505a904980da275e | import cv2
import numpy as np
kernel = np.ones((3, 3), np.uint8)
def mask(image):
# define region of interest
green_frame = image[50:350, 50:350]
cv2.rectangle(image, (50, 50), (350, 350), (0, 255, 0), 0)
hsv = cv2.cvtColor(green_frame, cv2.COLOR_BGR2HSV)
# define range of skin color in HSV
lowe... |
8,660 | 687ab41e9ce94c8d14154a941504845a8fa9f2d9 | def test_number():
pass
|
8,661 | e6d506dd45e72ee7f0162a884981ee1156153d3d | import json
import os
from lib.create import create_server, create_user
os.chdir(r'/home/niko/data/Marvin')
def edit_user_stats(server_id: str, user_id: str, stat: str, datas):
create_user(server_id, user_id)
if os.path.isfile("Server/{}/user.json".format(server_id)):
with open("Server/{}... |
8,662 | e44c4b2c3b60d34d4540ec2d3a782c777c52fbc0 | name = input("Введите ваше имя ")
print("Добрый день,", name)
|
8,663 | ddb81e3ce0df44ee503c558b68b41c35935358a0 | #!/usr/bin/env python
"""Server that accepts and executes control-type commands on the bot."""
import sys
import os
from inspect import getmembers, ismethod
from simplejson.decoder import JSONDecodeError
import zmq
import signal
# This is required to make imports work
sys.path = [os.getcwd()] + sys.path
import bot.l... |
8,664 | 3fed96e9bedb157a14cf9c441de5aae8b4f6edc8 | import sys
import os
# Module "sys"
#
# See docs for the sys module: https://docs.python.org/3.7/library/sys.html
# Print out the command line arguments in sys.argv, one per line:
# Print out the plaform from sys:
# for arg in sys.argv:
# print(arg)
# Print out the Python version from sys:print(sys.platform)
... |
8,665 | 0279057b3962e4b9839a86fc2e2683ac1da11b1a | from amqpstorm import management
if __name__ == '__main__':
# If using a self-signed certificate, change verify=True to point at your CA bundle.
# You can disable certificate verification for testing by passing in verify=False.
API = management.ManagementApi('https://rmq.amqpstorm.io:15671', 'guest',
... |
8,666 | 03a13037a9a102397c8be4d9f0f4c5e150965808 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'mapGraph.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MapGraphTab(object):
def setupUi(self, MapGraphTab):
MapGra... |
8,667 | 2611d7dd364f6a027da29c005754ac2465faa8be | from numpy import pi,sqrt,cross,dot,zeros,linalg
from defs import *
##from numba import njit, prange
##
##@njit(parallel=True)
def engparallelb2(MU,NU,b1,b2,x1,x2,y1,y2,eta,a):
#For use in enginteract below
#HL p.154 Eq.(6-45)
b1x=b1[0]
b1y=b1[1]
b1z=b1[2]
b2x=b2[0]
b2y=b2[1]
b2z=b2[2]
... |
8,668 | 2350c2ab05499f1b40ba61f2101c51d9581d57f6 |
def addnumber(i,j):
sum= i+j
print(sum)
num1 = int(input("Enter 1st number"))
num2 = int(input("Enter 2nd number"))
z = addnumber(num1,num2)
|
8,669 | 5f8303ce91c5de779bbddbaafb3fb828596babe5 | # orm/relationships.py
# Copyright (C) 2005-2023 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: https://www.opensource.org/licenses/mit-license.php
"""Heuristics related to join conditions as used in
:func:`_orm.relationship`.... |
8,670 | e486e0ab91a8f5671435f5bbcf5340a62a970d3a | class SmartChineseAnalyzer:
def __init__(self):
pass
def create_components(self, filename):
#tokenizer = SentenceTokenize(filename)
#result = WordTokenFilter(tokenizer)
#result = PorterStemFilter(result)
if self.stopwords:
result = StopFilter(result,... |
8,671 | ef5c51a5c706387b62ef3f40c7cadf7dbef6d082 | from flask_minify.utils import get_optimized_hashing
class MemoryCache:
def __init__(self, store_key_getter=None, limit=0):
self.store_key_getter = store_key_getter
self.limit = limit
self._cache = {}
self.hashing = get_optimized_hashing()
@property
def store(self):
... |
8,672 | 42187f460a64572d2581ed5baec41eaff47466f8 | version https://git-lfs.github.com/spec/v1
oid sha256:91f725dc0dba902c5c2c91c065346ab402c8bdbf4b5b13bdaec6773df5d06e49
size 964
|
8,673 | 83be35b79dcaa34f9273281976ebb71e81c58cdd | import logging
import os
import time
from datetime import datetime
from pathlib import Path
from configargparse import ArgumentParser
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.x509.oid import ExtensionOID
from cryptography.x509.extensions import ExtensionN... |
8,674 | dac8dbb0eba78d4f8dfbe3284325735324a87dc2 | """
时间最优
思路:
将和为目标值的那 两个 整数定义为 num1 和 num2
创建一个新字典,内容存在数组中的数字及索引
将数组nums转换为字典,
遍历字典, num1为字典中的元素(其实与数组总的元素一样),
num2 为 target减去num1, 判定num2是否在字典中,如果存在,返回字典中num2的值(也就是在数组nums中的下标)和 i(也就是num1在数组中的下标)
如果不存在,设置字典num1的值为i
"""
def two_sum(nums, target):
dct = {}
for i, num1 in enumerate(nums):
... |
8,675 | 60d8276a5715899823b12ffdf132925c6f2693bd | from __future__ import annotations
from typing import TYPE_CHECKING
from datetime import datetime
from sqlalchemy import Column, ForeignKey, String, DateTime, Float, Integer
from sqlalchemy.orm import relationship
from app.db.base_class import Base
if TYPE_CHECKING:
from .account import Account # noqa: F401
... |
8,676 | c87ede0e3c6d4cc305450f68b4cf61fb63986760 | import uvicore
from uvicore.support import module
from uvicore.typing import Dict, List
from uvicore.support.dumper import dump, dd
from uvicore.contracts import Email
@uvicore.service()
class Mail:
def __init__(self, *,
mailer: str = None,
mailer_options: Dict = None,
to: List = [],
... |
8,677 | 4a8a733a965e25ad7ef53600fad6dd47343655b0 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 12 16:38:22 2017
@author: secoder
"""
import io
import random
import nltk
from nltk.tokenize import RegexpTokenizer
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from collections import Ordered... |
8,678 | 74028a7b317c02c90603ad24c1ddb35a1d5d0e9d | student = []
while True:
name = str(input('Name: ')).capitalize().strip()
grade1 = float(input('Grade 1: '))
grade2 = float(input('Grade 2: '))
avgrade = (grade1 + grade2) / 2
student.append([name, [grade1, grade2], avgrade])
resp = ' '
while resp not in 'NnYy':
resp = str(input('Ano... |
8,679 | 606abf8501d85c29051df4bf0276ed5b098ee6c5 | from django.contrib import admin
from search.models import PrimaryCategory,PlaceCategory
class PrimaryCategoryAdmin(admin.ModelAdmin):
list_display = ('primary_name','is_active','description','image',)
actions = None
def has_delete_permission(self,request,obj=None):
return False
... |
8,680 | 932502c93dd7dfc095adfe2ab88b4404396d9845 | # 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
# d... |
8,681 | 7c6ada250770e04b395dda774a78042da69e2854 | from collections import Counter
def main():
N = int(input())
A = tuple(map(int, input().split()))
c = Counter(A).most_common()
if c[0][0] == 0 and c[0][1] == N:
print("Yes")
elif len(c) == 2 and c[0][1] == 2*N//3 and c[1][0] == 0 and c[1][1] == N//3:
print("Yes")
elif ... |
8,682 | 130581ddb0394dcceabc316468385d4e21959b63 | import unittest
from domain.Activity import Activity
from domain.NABException import NABException
from domain.Person import Person
from domain.ActivityValidator import ActivityValidator
from repository.PersonRepository import PersonRepository
from repository.PersonFileRepository import PersonFileRepository
from reposit... |
8,683 | e7d63c3b56459297eb67c56e93a3c640d93e5f6d | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tensorflow
from pyspark.sql.functions import split
from pyspark.ml.fpm import FPGrowth
from pyspark.sql import SparkSession
from pyspark import SparkConf
from pyspark.sql.functions import udf, array
import re
from pyspark.sql.types import *
import pyspark.sql.functi... |
8,684 | e403be68894ba283d71a0b71bb0bfd0adfab8c41 | import logging
def log_func(handler):
if handler.get_status() < 400:
log_method = logging.info
elif handler.get_status() < 500:
log_method = logging.warning
else:
log_method = logging.error
request_time = 1000.0 * handler.request.request_time()
log_method("%d %s %s (%s) %s ... |
8,685 | 5c179752f4c4e1d693346c6edddd79211a895735 | valor1=input("Ingrese Primera Cantidad ")
valor2=input("Ingrese Segunda Cantidad ")
Total = valor1 + valor2
print "El total es: " + str(Total)
|
8,686 | ec2d3bbfce06c498790afd491931df3f391dafbe | ../PyFoam/bin/pyFoamPlotWatcher.py |
8,687 | 022f588455d8624d0b0107180417f65816254cb1 | class car:
def info(self):
print(self.speed,self. color,self.model)
def increment(self):
print('increment')
def decrement(self):
print ('decrement')
BMW = car()
BMW.speed = 320
BMW.color = 'red'
BMW.model = 1982
BMW.info()
Camry = car()
Camry.speed = 220
Camry.col... |
8,688 | a494b3469682a909b76e67e1b78ad25affe99f24 | # Your code here
d = dict()
count = 0
fave_fast_food = input("Fave fast food restaurant: ")
for i in range(1, 11):
if fave_fast_food in d:
d[fave_fast_food] += 1
else:
d[fave_fast_food] = 1
count+= 1
fave_fast_food = input("Fave fast food restaurant: ")
for k,v in d.items():
print('Fast Food R... |
8,689 | a87ab07bb1502a75a7e705cd5c92db829ebdd966 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import json
from flask import jsonify
from flask import make_response
from MultipleInterfaceManager.settings import STATUS_CODE
def _render(resp):
response = make_response(jsonify(resp))
# response.headers["Access-Control-Allow-Origin"] = "*"
return ... |
8,690 | 24891cdefcd061f04e7b7768b1bde4e32b78adcc | import heapq
from util import edit_distance
def autocomplete(suggest_tree, bktree, prefix, count=5):
"""Suggest top completions for a prefix given a SuggestTree and BKTree.
Completions for a given prefix are weighted primarily by their weight in the
suggest tree, and secondarily by their Levenshtein... |
8,691 | b934770e9e57a0ead124e245f394433ce853dec9 | import time
import machine
from machine import Timer
import network
import onewire, ds18x20
import ujson
import ubinascii
from umqtt.simple import MQTTClient
import ntptime
import errno
#Thrown if an error that is fatal occurs,
#stop measurement cycle.
class Error(Exception):
pass
#Thrown if an error that is not ... |
8,692 | 5d3b9005b8924da36a5885201339aa41082034cd | from selenium.webdriver.common.by import By
class BasePageLocators:
LOGIN_LINK = (By.CSS_SELECTOR, "#login_link")
BASKET_LINK = (By.CSS_SELECTOR, '[class="btn btn-default"]:nth-child(1)')
USER_ICON = (By.CSS_SELECTOR, ".icon-user")
class LoginPageLocators:
LOG_IN_FORM = (By.CSS_SELECTOR, "#login_for... |
8,693 | 252a6b97f108b7fdc165ccb2a7f61ce31f129d3d | import sys
from collections import namedtuple
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, \
QHBoxLayout, QStackedWidget, QListWidget, QListWidgetItem
from PyQt5.QtCore import Qt, QSize
from runWidget import RunWidget
from recordWidget import RecordWidget
def QListWidget_qss():
return ... |
8,694 | 57bc34c6a23c98fd031ea6634441d4d135c06590 | import sys
sys.path.append("./")
from torchtext.datasets import Multi30k
from torchtext.data import Field
from torchtext import data
import pickle
import models.transformer as h
import torch
from datasets import load_dataset
from torch.utils.data import DataLoader
from metrics.metrics import bleu
import numpy as np
fro... |
8,695 | f6401eca2dc0ea86a934e859c35fa2d6c85a61b3 | import turtle
hexagon = turtle.Turtle()
for i in range (6):
hexagon.forward(100)
hexagon.left(60)
|
8,696 | 4932a357cfd60cb65630345e75794ebf58b82c82 | import matplotlib; matplotlib.use('agg')
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
from uncertainties import ufloat
#Holt Werte aus Textdatei
I, U = np.genfromtxt('werte2.txt', unpack=True)
#Definiert Funktion mit der ihr fitten wollt (hier eine Gerade)
def f(x,... |
8,697 | 641cbe2f35925d070249820a2e3a4f1cdd1cf642 | # -*- coding: utf-8 -*-
"""
app definition
"""
from django.apps import AppConfig
class CoopHtmlEditorAppConfig(AppConfig):
name = 'coop_html_editor'
verbose_name = "Html Editor"
|
8,698 | 3164eab8dc221149c9f865645edf9991d810d2ac | import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
import time
import sys
class ConsensusSimulation:
"""Class to model a general consensus problem
see DOI: 10.1109/JPROC.2006.887293"""
def __init__(self,
topology,
dynamics,
dynami... |
8,699 | 5ccfad17ede9f685ea9ef9c514c0108a61c2dfd6 | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 18 13:39:05 2017
@author: jaredhaeme15
"""
import cv2
import numpy as np
from collections import deque
import imutils
import misc_image_tools
frameFileName = r"H:\Summer Research 2017\Whirligig Beetle pictures and videos\large1.mp4"
cap = cv2.VideoCapture(r"H:\Summer ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.