index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
16,300 | 0d09823014dce7cd11b4513e09c5e879beeef766 | import redis
def init_client():
client = redis.StrictRedis(host='192.168.204.128', port=6379, db=0)
return client
def set_key(key, value):
client = init_client()
client.set(key, value)
def set_key_expire(key, value, time):
client = init_client()
client.set(key, value, time)
... |
16,301 | d0e8af8ff44af8268d76a472ff6595762a6ceb86 | from data_structures import DataStructures
import inspect
class Interface:
def __init__(self):
self.objDataStructures = DataStructures()
print("initialized Interface")
def MethodsCount(self, chapter):
if chapter == '1':
return inspect.getmembers(DataStructures)
|
16,302 | b225968f85322e50052feb56b9742b3271f58e32 | import FWCore.ParameterSet.Config as cms
from RecoLocalCalo.HcalRecProducers.HBHEIsolatedNoiseReflagger_cfi import *
hcalGlobalRecoTask = cms.Task(hbhereco)
hcalGlobalRecoSequence = cms.Sequence(hcalGlobalRecoTask)
#--- for Run 3 and later
from Configuration.Eras.Modifier_run3_HB_cff import run3_HB
from RecoLocalCal... |
16,303 | d73a8ed4540f665de2dfd74bb0bc13d7aaa5ef43 | from __future__ import absolute_import, print_function, division
import warnings
import numpy as np
from matplotlib.collections import LineCollection
import astropy.units as u
# from . import math_util
# from . import wcs_util
# from . import angle_util as au
# from .ticks import tick_positions, default_spacing
# f... |
16,304 | 4d7f9e387281b05167f0869486f56016516cfbc0 | from templates.utils import settings, templater
template = """
country_event = {{
id = dmm_mod_clear.{count}
hide_window = yes
is_triggered_only = yes
trigger = {{
has_global_flag = dmm_mod_{count}
}}
immediate = {{
remove_global_flag = dmm_mod_{count} ... |
16,305 | 415bb1338253331da6df6fcf9a683bddf4e4fb61 | """
Populate the operons table based on information found
in ./SampleFiles/OperonSet.txt
"""
import pymysql
import subprocess
import getpass
# open sql connection
sqlconn = pymysql.connect(host='bm185s-mysql.ucsd.edu', user='kkchau',
pa... |
16,306 | a1ce5a995b1ec0691fec0ce1a863c11797cac594 | import numpy as np
def kneeThresholding(_Y):
"""
Perform knee (or elbow) thresholding.
To determine the number of clusters:
1. Order the input.
2. Plot the input (x-axis: input index, y-axis: input)
3. Compute the line crosses the points marked by the fi... |
16,307 | b5268f033d7c168d5c61d5646883a22f8b55626a | import threading
import time
import gremlin
t16000 = gremlin.input_devices.JoystickDecorator(
"T.16000M",
72331530,
"Default"
)
# Maximum duration of a "short" press
g_timeout = 0.3
# Seconds to hold the button pressed
g_hold_time = 0.1
# Seconds to wait between releasing and pressing the button again
g_... |
16,308 | 4209dfa47bc996bb304fc0354e14bfe74d597982 | # Generated by Django 3.0 on 2019-12-17 13:29
import datetime
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('products', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Rented... |
16,309 | 2373bf67a42cfe0eb567197577be11b730446eea | from __future__ import annotations
from abc import abstractmethod
from uuid import uuid4
from django.conf import settings
from django.core.validators import RegexValidator
from django.db import models
from django_extensions.db.models import TimeStampedModel
from dandiapi.api.storage import (
get_embargo_storage,... |
16,310 | 2d6375c8b944b8b264ac4f1bbbfac3b0b4718eed | class Solution:
def longestIncreasingPath(self, matrix: List[List[int]]) -> int:
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
def dp(x, y):
if f[x][y] != -1:
return f[x][y]
f[x][y] = 1
for i in range(4):
a, b = x+dx[i], y+... |
16,311 | c246e68d3fac9d5609a8b3f9da138471c84bde30 | """
Django settings for app project.
Generated by 'django-admin startproject' using Django 1.8.1.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths in... |
16,312 | 1260431c408bc73ad7bfe7d639e4b13135120c74 | import collections
import nltk
import wordcount as wordcount
from sklearn.model_selection import train_test_split
from nltk.corpus import stopwords
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.tree import DecisionTreeClassif... |
16,313 | 1196d182a98a67ee8064c7932fb3b0adf3e41d92 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import rospy
import actionlib
import tf_conversions
import math
from sensor_msgs.msg import Joy
from move_base_msgs.msg import MoveBaseActionGoal, MoveBaseActionFeedback, MoveBaseAction, MoveBaseGoal
from geometry_msgs.msg import Pose
import actionlib_msgs
############# ... |
16,314 | 31da7d83d0424717fa7e75ac6dae28b295b24086 | import ipaddress
ip = '192.168.0.1'
rede = '192.168.0.0/24'
endereco = ipaddress.ip_address(ip)
network = ipaddress.ip_network(rede)
print(endereco)
print(network)
print(endereco + 1500)
print("#"*60)
for n in network:
print(n) |
16,315 | 9bdec41b9e02b1373d7462dd8a3daea70af13462 | class StopWordRemover(object):
"""description of class"""
def __init__(self, dictionary):
self.dictionary = dictionary
def get_dictionary(self):
return self.dictionary
def remove(self, text):
"""Remove stop words."""
words = text.split(' ')
for word in words:
... |
16,316 | 651358028ce154dfae12d639d33e3b49bf148e83 | # Generated by Django 3.1.6 on 2021-05-24 04:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('MyWeb', '0006_auto_20210517_1304'),
]
operations = [
migrations.CreateModel(
name='Tip',
fields=[
('... |
16,317 | 4d4677833e2be093bc09fef2c86330a88e9e69f3 | # coding=utf-8
import os
import glob
import csv
import time
from urllib.parse import urljoin, urlencode, quote_plus
import spider
import utils
if __name__ == "__main__":
csv_file = open("gametree.csv", "w", encoding="utf-8")
csv_writer = csv.writer(csv_file)
csv_writer.writerow(
["gamename", "game... |
16,318 | 90cdcfbd5b87010288ea4f7ca3e5333bfa3a53f1 | """
173. Binary Search Tree Iterator
"""
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class BSTIterator:
def __init__(self, root: TreeNode):
self.stack = []
temp = root
while temp:
... |
16,319 | 42894b20a30101258c0c73f702b75506575bf3c4 | from DFTtoolbox.elk import postproc
import os
# Parameters =======================================
run_task=[1,2,3,4,5,6]
wkdir=os.path.dirname(os.path.realpath(__file__))
klabel=['$\Gamma$','X','W','K','$\Gamma$','L','U','W','L','K']
Ebound=[-5,5]
state_grp=[['1:1/1/a/a'],['2:2/2/a/a']]
# Main =======================... |
16,320 | fef24d3cb5fe9460bd107d3a9ca0b5dcdc137454 | import plugins.qq_namelist
import plugins.show_group_id
import plugins.for_fun
import plugins.alipay_redpack
import plugins.recall
import plugins._002_water_meter_control
import plugins._000_admins
import plugins._001_group_invite
import plugins._1002_command
import plugins._1001_filter_old_message
import plugins._10... |
16,321 | 1e225a6c0d781b9a5241178541f4212068752e20 | class Solution(object):
def compress(self, chars):
"""
:type chars: List[str]
:rtype: int
"""
p1 = 0
p2 = 0
while p2 < len(chars):
temp=chars[p2]
counter = 0
while p2 < len(chars) and chars[p2] == temp:
p2+=1... |
16,322 | 6a00e49197df9648edf21f0628baaa45afd03a4a | import scrapy
class ShiyanlouGithubSpider(scrapy.Spider):
name = "shiyanlou_github"
@property
def start_urls(self):
url_tmpl = "https://github.com/shiyanlou?page={}&tab=repositories"
return (url_tmpl.format(i) for i in range(1, 5))
def parse(self, response):
for repos in r... |
16,323 | a4364dd327d3ad1b3c5179d031ec2b1ba4a1fd1a | # Inspired by http://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/00-classification.ipynb
import numpy as np
import os
import caffe
import dlib
import glob
from skimage import io
import scipy.misc
proto = 'age.prototxt'
model = 'dex_imdb_wiki.caffemodel'
image = 'test.JPG'
cur_path = os.path.dirname(os... |
16,324 | 044b6cc70a2492c5e374219e3d0268cd76215431 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
16,325 | f2670a169957ce6e5c81009f24555c9bfb37ef17 | # Generated by Django 3.1 on 2020-10-22 02:07
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('viveros', '0006_remove_productocontrol_fecha_aplicado'),
]
operations = [
migrations.AddField(
model... |
16,326 | c0ebcc55405059b3043d2dee634f1d3c0fa1e07a | from flask import Flask, render_template
from flask_socketio import SocketIO
import time
import temp
import random
import json
from threading import Thread, Event
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
thread = Thread()
thread_stop_event = Event()
class RandomThread(Thre... |
16,327 | 972e0ffbd85663af4089feb682f8e0f5537fcffc | """test stt module."""
import random
import string
try: # py3
from unittest import mock
except ImportError: # py2
import mock
import pytest
skip_because_stt_removed = pytest.mark.skip(reason='stt module removed.')
def get_random_string(exclude_list=None):
"""get random gender which is not 'female' or ... |
16,328 | b8aafefdced260881554266d3ad1748b0a02f086 | # -*- coding: utf-8 -*-
# Original Source by ssml-builder(https://github.com/Reverseblade/ssml-builder)
import re
class Speech:
#interpret-as
#단일 사용 가능
#spell-out : 영어 단어를 개별 알파벳으로 읽어줌
#digits : 숫자를 개별적으로 읽어줌 (일, 이, 삼..)
#telephone: 전화번호로 읽어줌
#kakao:none : kakao:effect의 tone 처리 시, 원형 그대로를 보호해... |
16,329 | 7b0675d7340de0a5630139932c19ad00eb4ff5d1 | # Generated by Django 2.2.5 on 2019-09-13 11:41
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('perfis', '0002_auto_20190913_1141'),
('publicacoes', '0001_initial'),
]
operations = [
migrations.A... |
16,330 | cc474d3c5ad3552a4e8ea405318ecf71e4f43380 | # coding: utf-8
from common.constDefine import *
from protocol import game_pb2
from utils.eventUtils import EventUtils
from utils.timerUtils import TimerUtils
class Judge:
"""法官"""
room = None # 房间实例
timer = None # 定时器
event = None # 事件对象
kill_info = None ... |
16,331 | 4013bd3bebdfd8c7c947e161a9038109f8e9c6e1 | # pylint: disable=W5101
"""
Assuntos são importantes para cruzar os segmentos atendidos por um evento e,
por sua vez, saber quais os assuntos de interesses das pessoas participantes
de eventos.
"""
from django.db import models
class Subject(models.Model):
""" Modelo para as 'Assuntos' """
name = models.Char... |
16,332 | 6ec5c732c04a6c136ed9be71ed4274af16dd5dd5 | import numpy as nump
from matplotlib import pyplot as graphic
import seaborn as plate
#------------------------------------------------------------
A = 2
B = 1
u_0 = lambda x, y: nump.arctan(nump.cos(nump.pi * x / A))
u_0_part = lambda x, y: nump.sin(2 * nump.pi * x / A) * nump.sin(nump.pi * y / B)
T = 4
n_x = 100
n_y ... |
16,333 | cf56126976718b82ae69d340980bc61a03e09e3a | import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n,m=map(int,input().split())
a=sorted([tuple(map(int,input().split())) for _ in range(m)])
i=0
cnt=0
k=n
while i<m:
k=a[i][1]
if a[i][0]<k:
while i<m and a[i][0]<k:
k=min(k,a[i][1])
i+=1
if i<m and a[i][0... |
16,334 | 5de09ee1dc0c0392363497980f23672014687d1e | ii = [('BailJD2.py', 1), ('LyttELD.py', 1), ('MartHRW.py', 1)] |
16,335 | f702956352d6867d788437bbb00c42de8ed3c0df | print('--------Crawling Started--------')
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
import requests
def SubwayInfoCrawling():
# crawling option = headless
options = webdriver.ChromeOptions()
options.add_argument('headless')
# Use chromedriver from selenium <htt... |
16,336 | 612cccd85a736fe56678474cbbe2312eaef0a1f2 | """
Utilizando Lambdas
- Conhecidas por expressões lambdas, ou simplesmente lambdas, são funções sem nome, ou seja, funções anônimas
Sintaxe - lambda x1, x2, x3, ..., xn: <expressão>
dois pontos separam os parâmetros da expressão a ser executada
"""
# Modo básico de expressão lambda ---------------------------------... |
16,337 | ddcb2cf8d661bbc82268cef7f68dd58929c16bda | try:
from unittest import skipIf
except ImportError:
from django.utils.unittest import skipIf
try:
from django.conf.urls.defaults import url
except ImportError:
from django.conf.urls import url
try:
from django.conf.urls.defaults import include
except ImportError:
from django.conf.urls import ... |
16,338 | 587f5913e7284c79e12171ca26e3b36e21e6265e | from django.apps import AppConfig
class BiografiConfig(AppConfig):
name = 'Biografi'
verbose_name = 'Biografia'
|
16,339 | bac290550f9a52b2b5a0e58fdc201dfee2f022d1 | """
created by Nagaj at 22/04/2021
"""
from constants import SHORT_TEXT, ALL_CHARS_ARE_NUMBERS
class ShortLenError(Exception):
message = SHORT_TEXT
class TextAsNumber(Exception):
message = ALL_CHARS_ARE_NUMBERS
|
16,340 | f2079d98dab6bf74f677788cba5610d3dfdde074 | import Dijkstra_with_DLL as dijk
import GUI as gui
def run(station1, station2, time):
"""Function to run the Dijkstra algorithm and also format the output in a way that can be displayed in the
interface """
route = dijk.Dijkstra(station1, station2)
path_results = route.find_path(dijk.builder(t... |
16,341 | 4e214a87d565d0948bcd82a5115d5f8da95f8584 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
created by gjwei on 9/22/17
"""
import numpy as np
def sigmoid(z):
return 1.0 / (1.0 + np.exp(-z))
def identity(z):
return z
def binary_step(z):
return np.where(z < 0, 0, 1)
def logistic(z):
return 1.0 / (1 + np.exp(-z))
def tanh(z):
... |
16,342 | 6d43881e60ab221a5a9e9deedd264e50437995ce | #!/usr/bin/env python3
#encoding: windows-1252
import brickpi3
import math
import time
# Global
BP = brickpi3.BrickPi3()
# Constants
WHEEL_DIAMETER = 8.2 # CM
GEAR_RATIO = 12 / 20 # 12t:20t
WHEEL_TRACK_WIDTH = 15.00 # CM (nice round number, what are the chances!)
LEFT_MOTOR = BP.PORT_B
RIGHT_MOTOR = BP.PORT_C
def ... |
16,343 | 6a8578bc01abd1cb603764c05c8d2bbaa3ff7aa1 | import os
import re
from pathlib import Path
import cv2
import numpy as np
import requests
from upres.utils.environment import env
class Image:
def __init__(self, path: Path, greyscale: bool, scaling: int):
self.path = path
self.greyscale = greyscale
self.read_type = cv2.IMREAD_GRAYSCALE... |
16,344 | 55a1f718eeb0b0d37ab67ab65255c64ec15e572d | import GenerateData.calc_breast_tmap as calc_breast
import GenerateData.draw_axe as draw_axe
import matplotlib.pyplot as plt
def create(left_up_t_values, right_up_t_values, left_dawn_t_values, right_dawn_t_values):
(l_deep_table, l_deep_min, l_deep_max) = calc_breast.calc_t_map(t_values=left_up_t_values, breast_s... |
16,345 | 796183bf2116d19a2c65403b47a56828ab9f0a8c | from django.apps import AppConfig
class PollutionappConfig(AppConfig):
name = 'PollutionApp'
|
16,346 | 65b987cf8f80081cafe46777da5750935c7fbdd8 | ZODIACS = ["Козирог", "Водолей", "Риби", "Овен", "Телец", "Близнаци",
"Рак", "Лъв", "Дева", "Везни", "Скорпион", "Стрелец", "Козирог"]
SPLIT = [19, 18, 20, 20, 20, 20, 21, 22, 22, 22, 21, 21]
def what_is_my_sign(day, month):
if day <= SPLIT[month - 1]:
return ZODIACS[month - 1]
return ZODI... |
16,347 | 5c3991c4dbb4bb7a58a6cd4fb7574687dfd92d69 | import unittest
from random import *
import string
from user import User
from credential import Credential
class TestUser(unittest.TestCase):
'''
Test class that defines test cases for the user class behaviours.
Args:
unittest.TestCase: TestCase class that helps in creating test cases
'''
... |
16,348 | 9075391a4fe75da4ffa78b0cb788a418d093b51c | #202 ac
def nextSquareSum(x):
tmparr = []
while x >= 10:
tmparr.append(x%10)
x/=10
tmparr.append(x)
return sum([i*i for i in tmparr])
class Solution(object):
def isHappy(self, n):
"""
:type n: int
:rtype: bool
"""
tmpSet= set(... |
16,349 | 88bf25a34c54ff9a4a62fd7213044d22c6ead530 | #!/usr/bin/env python3
"""
This script extracts docstrings from modules and generates the appropriate
files. It is intended to be run by the instructor before distributing the
starter code.
It really has no reason to exist (pytest supports running from the modules
directly) other than:
1. Students tend to be silly so... |
16,350 | 9825c5a1e43e85876f8cef50e6a8ce75eb747bd3 | from math import ceil
from django.shortcuts import render
from django.http import HttpResponse
from .models import Product, Women, Men, Watch, Kids, Other, Shoes
from .models import Contact
from .models import Order
def index(request):
# # product = Product.objects.all()
# price = Product.objects.values('pr... |
16,351 | 7c2fa0e70d84c247699538158ab78391e6a2c25a | import pytest
from galois_field.GFp import GFp
from galois_field.core.ElementInGFp import ElementInGFp
@pytest.mark.parametrize('p', [(5), (2), (123456791)])
def test_GFp_init(p):
gf = GFp(p)
assert gf.p == p
@pytest.mark.parametrize('p, expected', [
(5, True),
(2, True),
(123456791, True),
... |
16,352 | 70bcb26014e3ba899d064cc8325c59ddf78e10d2 | from typing import Iterable, List
from collector.core.models.user import User
from collector.core.models.photo import Photo
from collector.core.models.image import Image
from collector.core.http.request import Request
from collector.core.collector import Collector
class UnsplashCollector(Collector):
name = "unspl... |
16,353 | 4a25629cc7e5e6a8371be0b48f430398b97f3a88 | from setuptools import setup
import app
setup(
name='Example Flask API',
version=app.__version__,
packages=['app'],
)
|
16,354 | 1cfc124e082457f2a82dbe037d8fe08400119fe3 | '''
Created on 22 de mar de 2018
@author: I844141
'''
from lexer.TokenModule import Token
import re
WHITESPACE = 'whitespace'
BEGIN_COMMENT_BLOCK = 'BEGIN_COMMENT_BLOCK'
END_COMMENT_BLOCK = 'END_COMMENT_BLOCK'
COMMENT_LINE = 'COMMENT_LINE'
class Lexer(object):
'''
Lexical Analyzer for language C
'''
... |
16,355 | 75871b8c673dc4f77e4cc42a4563a422106d211f | # This code is intended for the MagicLight Wifi LED Lightbulb
# http://www.amazon.com/MagicLight%C2%AE-WiFi-LED-Light-Bulb/dp/B00SIDVZSW
# as seen here.
import socket
import binascii
IP = "192.168.2.37"
PORT = 5577
mode = "31" # "default" mode
magicBytes = "00f00f"
s = socket.socket(socket.AF_INET, socket.SOCK_STRE... |
16,356 | ea2d8a03a5b7f9100d5c3f3f8d099803272f55fb | zoo = 'python', 'elephant', 'penguin'
print('Number of animals in the zoo is', len(zoo))
newzoo = 'monkey', 'camel', zoo
print('Number of cages in the new zoo is', len(newzoo))
print('All animals in new zoo are', newzoo)
print('Animals brought from old zoo are', newzoo[2])
print('Last animals brought from old zoo is'... |
16,357 | e3960aca73ac0a7da6f4237f651bad7a4b549ed0 | from django.db import models
# Create your models here.
class Todo(models.Model):
task=models.CharField(max_length=20)
isComplete=models.BooleanField(default=False)
def __str__(self):
return (self.task) |
16,358 | fe954d96b24b95f458c96ba05d924e18c4febdb2 | class Solution:
def canJump(self, nums: list[int]) -> bool:
if len(nums) == 1:
return True
if nums[0] == 0:
return False
index = 0
steps = nums[index]
target = len(nums)-1
explored = []
stack = list(range(1,steps+1)) #store index
... |
16,359 | f36224664a87694cc0d57b9147217974f4e10290 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... |
16,360 | 2fea33feb328d518187252b11cb07626e06e5ce1 | import sys
import os
import time
import re
import json
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
try: # Python 3.x
from urllib.parse import quote as urlencode
from urllib.request import urlretrieve
except ImportError: # Python 2.x
from urllib import... |
16,361 | 590f8b6458d11642f67d99ddc283fad98b9954df | # File transfer server side
'''
Program for server multithreading
Allows massive transfer from a specific folder in the server side to another folder in the client
'''
import socket
import os, sys
import threading
import time
#import SocketServer
# Main variables and constants
port = 8080
host = " 1... |
16,362 | 1fddc86c367058e26d1189c31a1691f22293c960 | import string
with open("MGKmodlyrics.txt", "r") as MGKreader:
with open ("MGKdicLyrics.txt", "w") as MGKwriter:
text = set(MGKreader.read().split(" "))
for word in text:
if word == "" or word =="\n":
continue
for punc in string.punctuation:
wo... |
16,363 | 9ab6f8ccc4c7b82d98f6577cf1be7b1a128a7ad0 | class Visitor:
def __init__(self, _id, name, address, phone_number):
self.id = _id
self.name = name
self.address = address
self.phone_number = phone_number
@property
def serialize(self):
return {
'id': self.id,
'name': self.name,
'... |
16,364 | 0a0a77ce910f5b9135debfbf14a6d602cf19b7e7 |
#lab 6-1
from collections import Counter
L = [1,1,7,7,7,4,4,4,2,1,5,5,9,11,3,'a','x',9,8,'b','b','z','b']
counts = Counter(L)
for key in counts.keys():
#(==)------------------
#for key in counts : 해도 키만 꺼내는 것이 됨
if counts[key] >= 3:
print(key)
#lab 6-2
import math
y = math.exp(math.pi) + 10
print(... |
16,365 | 501f36426d38be5077b2cca968a65c4620866c67 | import requests
import json
import time
total_count = 0
for day in range(11, 27):
items = []
total_count = 0
if len(str(day)) == 1:
date = '2020-02-' + '0' + str(day)
else:
date = '2020-02-' + str(day)
print('Processing date ', date)
for hour in range(24):
time_str = '... |
16,366 | 21a8ad7fce6472249ea03e4ff0b5c5cd3eadda87 | #!/usr/bin/python3
def simple_delete(adict, key=""):
return adict.del(key)
|
16,367 | 34281d116e0964a9444adca156c46455c15ae2ac | import classes
def cadastroMateria(lista, nome, codigo):
lista.append(classes.Materia(nome, codigo))
def cadastroProfessor(lista, nome, departamento):
lista.append(classes.Professor(nome, departamento))
def cadastroAluno(lista, nome, dre, periodo):
lista.append(classes.Aluno(nome, dre, periodo))
def... |
16,368 | f79f12b6de1fa82661c1dd926b9ab5c7a3299db0 | import getopt
import hashlib
import sys
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from os import curdir, sep
import subprocess
#from subprocess import subprocess,Popen,PIPE
import os
import urllib2
#import try_listen as t
from lrucache import LRUCache
class RequestHandler(BaseHTTPRequestHandler):
... |
16,369 | e2ff8eafeed253bcc264141a6c27a80b403e1ff1 | # linked list
# stack
# queue
# D queue
ll = []
ll.append("A")
ll.append("B")
ll.append("C")
print(f"The link list is {ll}")
choice = 0
while choice < 5:
print('Linked list operations')
print('1 to add the elements')
print('2 to remove the elements')
print('3 to replace the elements')
print... |
16,370 | 03283967bae56ba0f2d81348d0c35bc48b38c1ba | #!/usr/bin/env python3.3
# -*- coding: utf-8 -*-
#
# Interface for the database connection
#
# Copyright (c) 2014-2015 Pieter-Jan Moreels
#
# Software is free software released under the "Original BSD license"
import os
import sys
_runPath = os.path.dirname(os.path.realpath(__file__))
code = (open(os.path.join(_run... |
16,371 | 91012de02406063ed93d953e4225e7b5ba8bb872 | import os
import unittest
import json
from flask_sqlalchemy import SQLAlchemy
from flaskr import create_app
from models import setup_db, Question, Category, db
class TriviaTestCase(unittest.TestCase):
"""This class represents the trivia test case"""
def setUp(self):
"""Define test variables and init... |
16,372 | 7d6af6b2d71c0273703bfe63ca5dec1eb350fb63 | import jieba
import random
import glob
def load_stop_words(path):
with open(path, 'r', encoding='utf8', errors='ignore') as f:
return [line.strip() for line in f]
def load_content(path):
with open(path, 'r', encoding='gbk', errors='ignore') as f:
content = ''
for line in f:
... |
16,373 | e0822c1a108b3b79ece344abcabc3cf6735de9d0 | #-*- coding:utf-8; mode:python; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*-
from bes.system.check import check
from collections import namedtuple
class ingest_method_field(namedtuple('ingest_method_field', 'key, optional')):
def __new__(clazz, key, optional = False):
check.check_string(key)
... |
16,374 | 73f941284d31a668d6002299c80e140492ccea0e | import distutils.version
import logging
import os
import sys
from gym import error
from gym.configuration import logger_setup, undo_logger_setup
from gym.utils import reraise
from gym.version import VERSION as __version__
logger = logging.getLogger(__name__)
# Do this before importing any other gym modules, as most ... |
16,375 | 3295229dd011a2df7d60a159994aa4d52af6d059 | import arcpy
import os
import sys
import shutil
projectdir="D:/CCW20"
targetgeodatabase=projectdir+"/GIS/"+"geocover.gdb"
targetworkspace=targetgeodatabase+"/GC_ROCK_BODIES"
bedrock="GC_BEDROCK"
exploit_PLG="GC_EXPLOIT_GEOMAT_PLG"
exploit_PT="GC_EXPLOIT_GEOMAT_PT"
fossils="GC_FOSSILS"
linearobjects="GC_LINEAR_OBJECTS"... |
16,376 | 60e2cdaee577a426d31c0601fafbbf16b5e45879 | # -*- coding: utf-8 -*-
"""
@author: Brandon Langley
bplangl
CPSC 4820
Project 4
"""
#import pandas as pd
import os.path
def main():
spam =0
ham=0
counted=dict()
#trainig data
fName="GEASTrain.txt"
fName=input("Please Enter the file name of the Training Data: ")
while os.path.exists(fN... |
16,377 | 7aeaa2b387e272dea8b46e045fabe4b5837516ed | me = 'protein_frequency_num.txt'
neighbor1 = '0724_protein_frequency_num.txt'
neighbor2 = '2390_protein_frequency_num.txt'
neighbor3 = '2987_protein_frequency_num.txt'
neighbor4 = '8971_protein_frequency_num.txt'
## attention!! this file can't run again!! 会毁了已有文件!
DNA_table = 'protein_table.txt'
file_me = open(me,'r')... |
16,378 | e9bcb586d78c5d7ea592f6e398b59d2de11a54b9 | from app.models.instagram import InstagramScraper
from app.models.dbmodel import MongoDBModel
from app.models import config
from app.tasks import worker
from time import sleep
mongo = MongoDBModel(config.DB_NAME, config.MONGODB_URI)
ig = InstagramScraper()
@worker.task(name='instagram_scraper.ig_profile')
def ig_pro... |
16,379 | 7e30ed8d054d3f4fcc6d7c6f9a91ecbe4350441b | """add active to appear_records
Revision ID: 9f7ce1a0a181
Revises: 507273553149
Create Date: 2020-01-13 10:36:31.040976
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9f7ce1a0a181'
down_revision = '507273553149'
branch_labels = None
depends_on = None
def up... |
16,380 | fc2d7eddfdeecf446289dd93f91df2caff38c6d6 | __author__ = 'hooda'
def intersection(line1, line2):
[line1, line2] = sorted([line1, line2])
if line1[0] == line2[0]:
print("INVALID")
m1, c1, m2, c2 = line1[0], line1[1], line2[0], line2[1]
x = (c2 - c1) / (m1 - m2)
y = (m2 * c1 - m1 * c2) / (m2 - m1)
print('interstection', line1, li... |
16,381 | 024b045fd2ed8a7c3c38a08ea3cede920f58e061 | import json
import boto3
from botocore.exceptions import ClientError
dynamodb = boto3.resource('dynamodb')
def lambda_handler(event, context):
res = None
try:
symbol = event['queryStringParameters']['symbol']
if event['path'] == '/shareprice':
[price, price_alarm] = get_price(symbo... |
16,382 | 8cd4a9c28d87f25b24b3ea33d601b192d38c367a | from __future__ import division
import unittest
from chainer import testing
from chainer import training
@testing.parameterize(
# single iteration
{
'iter_per_epoch': 2, 'schedule': (2, 'iteration'), 'resume': 3,
'expected': [False, True, False, False, False, False, False]},
# multiple i... |
16,383 | 83260230430108481e83e85469f0b4465f567cda | # Generated by Django 3.0 on 2019-12-20 01:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('registration', '0003_auto_20191220_0104'),
]
operations = [
migrations.AlterField(
model_name='scraperesult',
name='va... |
16,384 | 0b025f7129ed9d5f4866ba7a26bd0c7b12fd9d42 | from django.db import models
from datetime import datetime
class Contact(models.Model):
name = models.CharField(max_length=50)
email = models.EmailField(max_length=100)
phone = models.CharField(max_length=15, blank=True)
message = models.TextField()
date = models.DateTimeField(default=datetime.now... |
16,385 | 3301b8d9d1e0c40f105eecca0eb15a9b0c031d8b | import itertools
from itertools import chain, combinations
def all_subsets(ss):
return chain(*map(lambda x: combinations(ss, x), range(0, len(ss)+1)))
def func(F):
Parts = f2p(F)
n=len(Parts)
final=[]
#Final=[[f1,f2,f3...fn],[f1&f2,f2&f3,f1&fn ...],[f1&f2&f3,f2&f3&f4,...],...[]]
num=[[i] for... |
16,386 | 3b41235974b6661630512b9c5cc84c4aa210bc83 | """Defines environment dynamics for paraphrase generation task as RL problem"""
import torch
import numpy as np
import random
import os
import config
import data
import model_evaluation
import supervised_model as sm
from train_ESIM import load_ESIM_model
DEVICE = config.DEVICE
MAX_LENGTH = config.M... |
16,387 | 8e9336000948c83e86c755e1c52b6e01284f698f | from .transaction import SimpleTransaction, AllowedTransaction
from .account import Account
from .event import EventLightweightPush |
16,388 | 7f3e640dc1d3294a67e4a5d22c7c71176f130873 | # https://atcoder.jp/contests/agc029/tasks/agc029_a
# A - Irreversible operation
import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
s = input()
# 操作が不可能になった時点で、石の配置は必ず・・・WWWWWBBBBB・・・となる
# つまり、Wを左に移動する回数を求めれば良く、これは初期配置でWの左側にあるBを数え上げることで求まる
cnt_B = 0
r... |
16,389 | b35f5689e7c9649434c224777731fddf51b22861 | import pytest
import sys
import threading
import traceback
try:
from queue import Queue
except:
from Queue import Queue
from .util import run_test, destroy_window
def url_load():
import webview
def _change_url(webview):
try:
webview.load_url('https://www.google.org')
... |
16,390 | c0056f40b6bf02ef8255f37e02310fa741ee3367 | from datetime import datetime
from backtesting.strategies.trend.SuperTrendStrategy import SuperTrendStrategy
from backtesting.tests.Test import Test
class SuperTrendTest(Test):
def __init__(self):
self.strategies = [SuperTrendStrategy]
super().__init__(self.__class__.__name__, self.strategies)
... |
16,391 | 34e6c90a9da668618280e8d5654af966c6393ce8 | #opencv3.3
#https://www.pyimagesearch.com/2017/09/11/object-detection-with-deep-learning-and-opencv/
from imutils.video import VideoStream
from imutils.video import FPS
import numpy as np
import argparse as arg
import imutils
import time
import cv2
ap=arg.ArgumentParser()
ap.add_argument("-p","--prototxt",required=Tru... |
16,392 | c8372a5e1aca095a5ba2f84a157c604e7ad197fc | import jaccardIndex
def calculate(base,term):
return 1.0 - jaccardIndex.calculate(base,term) |
16,393 | 2cc3fbc31ed4a3a7b8b18ab3fbc98e3ab58b9892 | import numpy as np
from scipy.ndimage import morphological_gradient
def _is_iterable(x):
try:
iter(x)
except TypeError:
return False
else:
return True
def _norm_along_last_axis(x):
"""Compute the norm of x along the last axis.
"""
return np.sqrt(np.sum(np.square(x), a... |
16,394 | 226fcbdc43073f610624da574227762cfc85f363 | # *****************************************************************************
# Copyright (c) 2017 Keith Ito
#
# 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... |
16,395 | 654e857cf6c608fa6bc0ac22c57a794f41f8705e | import pickle
import time
from random import *
from tkinter import *
caughtt=["caught","missed"]
backpack=["Bulbasaur", "Charmander"]
ballcaught=["Poke Ball", "Poke Ball"]
for i in range(0,10):
for i in range(0,10):
time.sleep(0.5)
balls=["Great Ball","Master Ball","Poke Ball","Ultra Ball"]
things=[... |
16,396 | 479708aeb5b98179fd7769677445b9376d400ac3 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 14 14:36:04 2019
@author: vnandanw
"""
#import relevant libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import tensorflow as tf
#Read the data set from file
FlatData = pd.read_csv('Insurance.csv')
#Separate features and labels from the... |
16,397 | 07d4c13a04d32e6ea847ba7ace31306cd8b48527 | from PIL import Image,ImageDraw
def addTransparency(img, factor = 0.7 ):
# 调整图片的透明程度
img = img.convert('RGBA')
img_blender = Image.new('RGBA', img.size, (0,0,0,0))
img = Image.blend(img_blender, img, factor)
return img
def circle_corner(img, radii):
"""
圆角处理
:param img: 源图象。
:param... |
16,398 | 5f24ab42b4f80d32e4b4059d471f5c3a462ab283 | import importlib
import inspect
import logging
import sys
from pathlib import Path
from unittest.mock import Mock
import pytest
from aio_wx_widgets import widgets
logging.basicConfig(level=logging.DEBUG)
_LOGGER = logging.getLogger(__name__)
IMAGE_PATH = Path(__file__).parent
def load_module(module_file: Path):
... |
16,399 | b75bbbc8e7c031267b2d55b14e75048c294c52df | import numpy as np
import sys
import math
from scipy.spatial.distance import euclidean
from lib import fastdtw
from os import listdir
from os.path import isfile, join
from plotData import PlotData
class ReviewClassifier(object):
def __init__(self, recipe_name, max_line):
self.recipe_name = recipe_name
path = "da... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.