index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
986,600 | 62e00944d8d6579b88415dfc137bdfdc466bf41d | # Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... |
986,601 | 0846c9ef18a892d6b0a0ec2a07b1fe4a07e22eeb | #!/usr/bin/env python
def main() :
a = 1
while 1 :
z =str(fibonaci(a))
x = len(z)
if x >= 1000 :
break
else :
a = a+1
print x
print a
#def fibonaci(n) :
#if n == 1 :
#return 1
#elif n == 2 :
#return 1
#else :
#return (fibonaci(n-1) + fibonaci(n-2))
def f... |
986,602 | 4c52455c36def26b14bc79d9d3b875f16cc1be45 | from config import *
import classifier_pool as classifiers
from sklearn import preprocessing
import pickle
def main():
print("Loading Data.")
data = pickle.load(open(FEATURE_SAVE_PATH, 'rb'))
featureMatrixTraining = data["featureMatrixTraining"]
featureMatrixValidation = data["featureMatrixValidation"]... |
986,603 | 50ab2d87b98858201d37cffe07d3ce1c2a80bf0c | import os
import shutil
if __name__ == '__main__':
base = 'data/trainval'
names = os.listdir(base)
gt = 'data/gt'
for name in names:
gt_path = os.path.join(gt, name + '.txt')
old = os.path.join(base, name)
old = os.path.join(old, 'groundtruth.txt')
shutil.move(old, gt_pa... |
986,604 | ee67faf2ec6211dc2c30502aba64427d5fa97aea | import pandas as pd
import numpy as np
import matplotlib.pyplot as pl
'''dataset_tain = pd.read_excel('Final_Train')'''
dataset = pd.read_csv('Restaurant_Reviews.tsv',delimiter = '\t', quoting = 3)
#cleaning the dataset
import re
import nltk
#nltk.download('stopwords') # stopwords is a list which consist ... |
986,605 | d55f61c9b8facb3d90197800543ea7cfb98862a9 | import xml.dom.minidom as Dom
from xml.dom import minidom
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for
)
lb = Blueprint('writexml', __name__, url_prefix='/xml')
def writexml(annotations,filename,width,height):
doc = Dom.Document()
root_node = doc.createElem... |
986,606 | 8c52708744ab5f4ac5f61f50179b256ab710db7f | class AioGeTuiException(Exception):
pass
class AuthSignFailed(AioGeTuiException):
"""验证签名失败"""
pass
|
986,607 | aaf49ca7049b274ccf0cad44bc5c8ab7d771011b | #POS tagger
from nltk import word_tokenize
from nltk import pos_tag
sent1 = "The race officials refused to permit the team to race today"
print(pos_tag(word_tokenize(sent1)))
sent2 = "The gentleman wants some water to water the plants"
print(pos_tag(word_tokenize(sent2)))
text = word_tokenize("They refuse to permit ... |
986,608 | 501508afad6c1a42172c575ac6e1d37161f1d6ec | platform_info = {
'id' : 'hampton',
'location' : 'Hampton Shoals, Neuse River, NC',
'lat' : 35.0184, # degrees true (-) south, (+) north
'lon' : -76.9409, # degrees true (-) west, (+) east
'mvar' : -9.80, # degrees (-) west, (+) east
'institution' : 'nccoos',
#
... |
986,609 | 0b5f2d9628cbd140f264d0c676dfacc8600792e4 | import math
def round_d(number:float, decimals:int=2):
"""
Returns a value rounded down to a specific number of decimal places.
"""
if not isinstance(decimals, int):
raise TypeError("decimal places must be an integer")
elif decimals < 0:
raise ValueError("decimal places has to be 0 ... |
986,610 | ca2a55d4728b76dd0d5ecff5d663c4b953c9ef6e | from flask import Flask, request, jsonify
from flask_httpauth import HTTPBasicAuth
import io
from flask_restplus import Api, Resource, fields, Namespace
from flask_cors import CORS
import requests
import os
from .otstamp import TimeStamp
app = Flask(__name__)
auth = HTTPBasicAuth()
authorizations = {
'token'... |
986,611 | 8f4bec513cbf5a706d71913d1a88e287fca1e980 | from pathlib import Path
import numpy as np
def read_lut(path):
assert Path(path).exists()
data = []
size = -1
for line in Path(path).read_text().split("\n"):
if line.strip() == "":
continue
elif line[0] == "#":
continue
elif line.split()[0] == "LUT_1D_SIZE":
size = int( ... |
986,612 | ee9603baaed271fdf0b99f3a33dc42992dc5f299 | """This module contains error handler utility functions."""
from flask import Blueprint
from flask.json import jsonify
errors = Blueprint('errors', __name__)
@errors.app_errorhandler(Exception)
def handle_exceptions(e):
return {"message": "exception occured"}
@errors.app_errorhandler(404)
def not_found(e):
... |
986,613 | b7dd5c6ec6a0ce54533cde1b526334a03f8b0e7e | from gym.envs.registration import register
register(
id='ps-v0',
entry_point='gym_ps.envs:PSenv',
) |
986,614 | 5d608079a33ac4e3fa789271712e5c4677ba34e0 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 29 16:07:30 2018
@author: fabiangnegel
"""
import numpy as np
import scipy
import cplex
from cplex.exceptions import CplexSolverError
seeds=range(1,6)
dupRanges={'small':[5,15],'medium':[15,25],'large':[20,50]}
#dupRanges={'small':[5,15],'large':[20... |
986,615 | e73f6f57f8718365f4f11d0d0a78ea2068e47824 | import asyncio
import time
async def coroutine_A():
print('coroutine_A starts!')
await asyncio.sleep(3)
print('coroutine_A completed!')
async def coroutine_B():
print('coroutine_B starts!')
await asyncio.sleep(2)
print('coroutine_B completed!')
def main():
loop = asyncio.get_event_loop()
tasks = asyn... |
986,616 | 29285a8dc1ed6644ac679c733a2b9c41920ebe28 | from multiprocessing.managers import BaseManager
import NBM2_functions as nbmf
import step0_functions as s0f
import sqlalchemy as sal
import geopandas as gpd
import pandas as pd
import traceback
import pickle
import json
import time
import csv
import os
import gc
def changeTogeom(db_config, config, start_time):
... |
986,617 | 82035eed3bfa9ff12ed432584b483d34f859cbaa | # -*- coding: utf-8 -*-
# LeetCode 1078-Bigram分词
"""
Created on Sun Dec 26 17:45 2021
@author: _Mumu
Environment: py38
"""
from typing import List
class Solution:
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
flag = -1
ans = []
for word in text.split(' '):
... |
986,618 | 326a3b6bb8e33a2df2244afcfe54fad407c2f92a | import sys
from collections import deque
input = sys.stdin.readline
# solution
def bfs():
while q:
cur = q.popleft()
if cur == K:
return visited[cur]
pushnext(cur+1, cur)
pushnext(cur-1, cur)
pushnext(cur*2, cur)
def pushnext(nxt, cur):
if maxsize > nxt >=... |
986,619 | 14bae44bbbafde0bbb656cb7bb891e3a3c9402d0 | import mariadb
import dbcreds
# def noticeTweetLike(user_id):
# conn = None
# cursor = None
# try:
# conn = mariadb.connect(user=dbcreds.user, password=dbcreds.password, host=dbcreds.host, port=dbcreds.port, database=dbcreds.database)
# cursor = conn.cursor()
# print(user_id)
# ... |
986,620 | 2643a49c01528d9214e307d4538b70bba5df9d6f | country = input().split(', ')
capital = input().split(', ')
pairs = {country: capital for country, capital in zip(country, capital)}
print('\n'. join([f'{country} -> {capital}' for country, capital in pairs.items()]))
|
986,621 | 48ef10851623b47a3fa6454da1c81d5565696980 | class Hotel:
def __init__(self, rooms, floors, Room):
self.rooms = rooms
self.floors = floors
rooms_per_floor = int(self.rooms/self.floors)
last_floor_rooms = self.rooms % self.floors
room_numbers = [int(room) for room in range(1, self.rooms+1)]
self.L... |
986,622 | 052070d6371a3a70e383aa016378a53dd8c26732 | # -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-13 03:28
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.Creat... |
986,623 | d0454e4b7773ad209cd8e210c0fe2157e986b42f | #!/usr/bin/env python
"""
Name: add_land_locked_cells_to_mask.py
Author: Mark Petersen, Adrian Turner
Find ocean cells that are land-locked, and alter the cell
mask so that they are counted as land cells.
"""
import os
import shutil
from netCDF4 import Dataset
import numpy as np
import argparse
def removeFile(fileNam... |
986,624 | ee9f8d3134fb2c07b484750a856db6bea48ad6b7 | """
Key bindings, for scrolling up and down through pages.
This are separate bindings, because GNU readline doesn't have them, but
they are very useful for navigating through long multiline buffers, like in
Vi, Emacs, etc...
"""
from __future__ import unicode_literals
from prompt_toolkit.layout.utils import find_wind... |
986,625 | 6a0be84af25c8692bbc99f3579eab874bdfad99e | # https://leetcode.com/problems/isomorphic-strings/
import unittest
import string
class Solution:
def is_isomorphic(self, str1, str2):
# checks
if not len(str1) == len(str2) \
or any([x for x in list(str1) if x not in string.ascii_letters]) \
or any([x for x in lis... |
986,626 | 1feaa2167bbee90ab7f7da3f7a9814f2a1c830ff | import numpy as np
import Option
import util
import Convert
import numexpr as ne
def solve(Df, bf, alpha, opt):
'''
(D^tD + αI)x = b を解く関数
'''
I_N = np.ones(opt.N)
Dtf = np.conj(Df)
DDtf = np.zeros(opt.N, dtype... |
986,627 | 669e9510d0b5aa5f1406d2a23bb365502f615781 | from django.conf.urls import url
from django.urls import path
from app import views
urlpatterns = [
path('', views.HomeView.as_view(), name='home'),
path('eiou_claim/', views.EIOUClaimViews.as_view(), name='eiou_claim'),
path('upload/', views.upload, name='upload'),
]
|
986,628 | 79f5abc3912d0a4cb936a089c4da81b07be1c751 | import requests, json
file = 'aPrivateOne.json'
apiKey = 'apiKey'
url = 'https://api.github.com/repos/datarepresentationstudent/aPrivateOne'
response = requests.get(url, auth=('token', apiKey))
repoJSON = response.json()
#save as json file
with open(file,"w") as new_file:
json.dump(repoJSON, new_file, indent=4) |
986,629 | 577dec6938532c91892f88f3eac661bc4380f55f | def pesquisa_binaria(lista, item):
baixo = 0
alto = len(lista) - 1
while baixo <= alto:
meio = (baixo + alto) // 2
chute = lista[meio]
if chute == item:
return meio
if chute > item:
alto = meio - 1
else:
baixo = meio + 1
return None
minha_lista = [1, 3, 5, 7, 9, 11, 13, 15, 17, 1... |
986,630 | e7cb029ba4749c7edb25a1d503d0fc9036bd80ac | def myfun(a,b,c):
print("a-->",a)
print("b-->", b)
print("c-->", c)
#位置参数
myfun(1,2,3)
#序列参数,*s 以元组的方式传递给函数,函数按照顺序解析
s = [11,22,33]
myfun(*s)
s2 =(1.1,2.2,3.3)
myfun(*s2)
s3="abc"
myfun(*s3)
print("#"*20, 'key word parameters', "#"*20)
myfun(a='a1', b='a2',c='a3')
print("*"*20)
myfun(c='a1', a='a2', b... |
986,631 | 00e4a413552363350f2300dd3597d5d59aab86ef | #! /usr/bin/env python3
'''
This script decrypt the encrypted content using a rsa private key
'''
import sys
import argparse
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import serialization, hashes
def ... |
986,632 | 775fbecc46df832c5e1e0bad022fdfbb0a2040ff | from django.http.response import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.contrib.auth.mixins import LoginRequiredMixin
from polls.m... |
986,633 | 861a0ee5f5c1e0f2e01c3c65762e1a3e48476050 | #!/usr/bin/env python3
#
# https://www.opavote.com/help/overview#blt-file-format
import sys
import urllib.parse
def foo(fname, out):
rankings = []
with open(fname, 'rt') as fin:
fi = iter(fin)
line = next(fi)
candidates, seats = [int(x.strip()) for x in line.split()]
for line i... |
986,634 | 83fb62802671755304b28ea53a8316fdefe78c28 | # -*- coding: utf-8 -*-
from openerp import models, api
class account_tax(models.Model):
"""
OverWrite Tax Account
"""
_inherit = 'account.tax'
@api.model
def _get_tax_calculation_rounding_method(self, taxes):
if taxes and taxes[0].company_id.tax_calculation_rounding_method:
... |
986,635 | 0ab5afccc44002ea921f79570cfbe4a4f2c4b212 | #!/usr/bin/env python3
from fateadm_api import FateadmApi
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from sele... |
986,636 | 1a5818195d8f56aafcb740a4864764dd39bad168 | #!/usr/bin/env python
from math import *
import numpy as np
import multiprocessing
import time
import srcprop as srcprop
import srclensprop as slp
from input_qg import *
###########################################################
## INPUTS:
## Foreground galaxy catalog which has Ra,Dec,Redshift,Magnitudes,
## major-a... |
986,637 | 6895911122e9efb46407eaee779c6f79c7ef3bc9 | #!/usr/bin/python3
import itertools
from intcode09 import Intcode, MissingInputError
def read_input(fname="day11.in"):
"""
Read the input file and return the list of numbers that it contains.
:param fname: A string name of the file to read.
:return: A list of `int` values contained in the firs line... |
986,638 | 606c99846e5b58e848a9840eb9bc50c7c4d51ffd | import json
import os
import re
import sys
import time
from collections import OrderedDict
""" Hearthstone Pack Statistics Tracker """
# Mac Paths
stats_file = os.path.expanduser('~/Documents/hs_pack_stats.txt')
hs_log_dir = os.path.expanduser('~/Library/Preferences/Blizzard/Hearthstone/Logs')
if not os.path.exists(... |
986,639 | 4cce9aee92d4aab52cf67e83b7cc59aff6e84002 | import torch
import numpy as np
import tqdm as tq
from torch import nn
'''
Transformation 'np.array' to 'torch.tensor'
'''
def To_tensor(np_array, dtype=np.float32) :
if np_array.dtype != dtype :
np_array = np_array.astype(dtype)
return torch.from_numpy(np_array)
'''
Initialize weights of Layers
'''
... |
986,640 | ce42b472970912a02dd47bdf3e7025e3bab0868a | #This script preps the required .RData: pwy_neuroNetwork_prep.R
#Load the .RData (based on: https://stackoverflow.com/questions/21288133/loading-rdata-files-into-python)
#Do this in terminal: pip install pyreadr
import numpy as np
import pandas as pd
import pyreadr
import os
from sklearn.model_selection import trai... |
986,641 | 3fe09b6fb3a9334cb454fb40cc10d7a01de58add | # String
# Problem: 20291
# Memory: 42440KB
# Time: 2440ms
N = int(input())
ans = {}
for i in range(N):
s = input().split('.')[1]
if s in ans:
ans[s] += 1
else:
ans[s] = 1
for k, v in sorted(ans.items()):
print(k + ' ' + str(v))
|
986,642 | 6d3a3895bc8f01370a245e97a55ca4761f9822ed | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Module docstring: One line description of what your program does.
"""
__author__ = "Your Github Username"
import sys
def main(args):
"""Add your code here"""
if __name__ == '__main__':
main(sys.argv)
|
986,643 | a513c23d5b9c9fa866a1f311b292158bb5edde33 | """
循环队列
"""
class CircleQueue(object):
def __init__(self, capacity=10):
# 存放数组元素的下标
self.__front = 0
self.__size = 0
self.__elements = [None] * (10 if capacity < 10 else capacity)
def __str__(self):
string = 'capcacity=' + str(len(self.__elements)) + ', size=' + str(self.__size)
string += ', 起始索引 f... |
986,644 | db843a58dcec7d3edba68811ea695cba20b5ad8c | #!/usr/bin/python
import sys
import os
import csv
from math import radians, cos, sin, asin, sqrt
def usage():
print >> sys.stderr, '\n' + str(THISFILENAME)+" [csv file]" + '\n'
sys.exit(0)
#CLIENT:
if __name__ == '__main__':
#SIGINT
#signal.signal(signal.SIGINT, signal_handler)
... |
986,645 | f48ef8a67a6155e311d25c2c45716d992ffea327 | #!/usr/bin/env python
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name='iohitman',
version='3.0',
description='Parallel I/O tester',
author='stevec7',
packages=['iohitman', 'iohitman.testsuite'],
package_dir = {
'iohitman':... |
986,646 | f32cad1cf8fdc711ed80cdd6b8bbf84111ffbf20 | int_h, int_w = map(int, input().split())
masu = list()
for i in range(int_h):
masu.append(list(input()))
conv = list()
for x in list(map(list, zip(*masu))):
if "#" in x:
conv.append(x)
result = list()
for y in list(map(list, zip(*conv))):
if "#" in y:
result.append(y)
for r in result:
... |
986,647 | f6d3a4f45c54e636188f741289390fcef3d6702f | '''
Description:
Version: 2.0
Author: xuchaoxin
Date: 2021-03-06 20:17:12
LastEditors: xuchaoxin
LastEditTime: 2021-03-07 12:58:14
'''
""" 堆排序
堆中定义以下几种操作:
○ 最大堆调整(Max Heapify堆积化):
§ 将堆的末端子节点作调整,使得子节点永远小于父节点
○ 创建最大堆(Build Max Heap):(核心算法)
§ 将堆中的所有数据重新排序
○ 堆排序(HeapSort):
§ 移除位在第一个数据的根节点,... |
986,648 | 54d57f8a2e92cd9569d78f12c28ec971911207d1 | import os
import sys
import json
import subprocess
import csv
import time
import math
from optparse import OptionParser
from shutil import copyfile
def CliCommand(cmd,cb=None):
print(cmd)
try:
# stdout = subprocess.PIPE lets you redirect the output
res = subprocess.Popen(['/bin/bash', '-c', ... |
986,649 | b101687c1a57b2bc02ee0ddcef6d5aa7c479a6da | class Solution:
def minSwap(self, A: List[int], B: List[int]) -> int:
n = len(A)
swap = [n for _ in range(n)]
not_swap = [n for _ in range(n)]
swap[0], not_swap[0] = 1, 0
for i in range(1, n):
if A[i] > A[i-1] and B[i] > B[i-1]:
not_swap[i] = not_s... |
986,650 | 9edbd4ea9dfedde07662df093f981f4fdfd8013e | import sys
file_name = "binary_num.py"
try:
f = open(file_name, "r")
except FileNotFoundError:
print(f"File {file_name} does not exist")
sys.exit(0)
print ("Name of the file: ", f.name)
print ("Closed or not : ", f.closed)
print ("Opening mode : ", f.mode)
|
986,651 | 25ac7027a85567175e0440042fd5706851a061fc | ###configuration.properties
serial=input('Digite o serial..: ')
print (serial)
cnpj=input ('Digite o CNPJ (Somente Números)..: ')
print (cnpj)
printer = input ('Digite a Porta da Impressora...: ')
print (printer)
config='''configuration
# *************** Geral ******************
# Password para acessar o administ... |
986,652 | 290552a4e97b45409b25a2e29f4cb7635a2fcaef | '''
Cracking the Coding Interview
Question 2-4
p.94
(For a *singly linked* list)
'''
# Define the Linked List Node
class Node:
def __init__(self, data=None, next=None):
self.data = data
self.next = next
def __repr__(self):
cur = self
st = []
while cur:
if c... |
986,653 | 1697338e9ada38ee0fb90da15d7933b1f3cf171c | #! /usr/bin/env python
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
import sys
import time
import datetime
import functions
def main(logPath,hostsPath,hoursPath,resourcesPath,blockedPath):
start = time.time()
print "Parsing the log file ..."
parsedData = functions.parseLogFile(logPath)
end = t... |
986,654 | 03cd2e66f108367d0f8629e7b2a3df468d8265ef | from typing import Iterator
from utils.vector import Vector
def bresenham(v1: Vector, v2: Vector) -> Iterator[Vector]:
yield v1
x1, y1, z1 = v1
x2, y2, z2 = v2
dx, dy, dz = abs(x2 - x1), abs(y2 - y1), abs(z2 - z1)
xs = 1 if x2 > x1 else -1
ys = 1 if y2 > y1 else -1
zs = 1 if z2 > z1 els... |
986,655 | dd4964d8d139db09627d6a10fa72b1eebff71a76 | class Solution:
def averageWaitingTime(self, arr: List[List[int]]) -> float:
waitingTime = 0
finishTime = 0
for i in range(len(arr)):
x, y = arr[i]
if i ==0:
finishTime = x + y
waitingTime += y
elif x >= finishTime:
... |
986,656 | dfd5264a6c47ad672948d93334574ee43f49219e | import os, shutil, numpy, time, math
from shapefile import Reader, Writer
from .rasterutils import get_raster, get_raster_on_poly, get_raster_in_poly
from .merge_shapes import format_shape, combine_shapes
def get_distance(p1, p2):
"""Approximates the distance in kilometers between two points on the
Earth's... |
986,657 | 274c71acf3c21e1df5316b6f9e01ca7f8977caa7 | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.11
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path impo... |
986,658 | baf331bef4dd0df0f9f93ec687565f5517d3260a | import discord
import Session
import UserManager
class Command:
assigned_function = None
command = None
restricted = None
def __init__(self, command: str, restricted: bool, assigned_function):
self.command = command
self.restricted = restricted
self.assigned_function = assign... |
986,659 | 6afd9c1e2f44a6f6b25e2c02a5a0f8b7d44037a6 | s00 = "kitten"
S01 = "sitting"
def get_dist(s00, s01):
print("Nidea") |
986,660 | 02eea9466dc420f9097fef795fce3e9b335ef9ec | """
Name:Kenzin Igor
Date:20/05/2021
Brief Project Description:Reading Tracker
GitHub URL:https://github.com/JCUS-CP1404/assignment-2-reading-tracker-igor5514
"""
# Create your main program in this file, using the ReadingTrackerApp class
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen... |
986,661 | 585c6856b3dc34408d71270302bab915b0030934 | import math
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
class CustomLogisticRe... |
986,662 | f300a66a04c60a0a69b0606bd5a5bb909b1f9b6c | ID = "bmpr"
PASSWORD = "jm0976"
|
986,663 | b788af5b097a5067126018dccb2e5d4394e92534 | print 10/3
print 10./3
print int(10./3)
|
986,664 | 5785082b4cd5d588c1c5a998ea625311f7d9d89e | from mmRemote import *
import os
import mm
import sys
import subprocess32
from subprocess32 import Popen, PIPE, STDOUT
import time
import psutil
import sys
from pathlib import Path
class Mesh(object):
def __init__(self): # Define the location of dependencies
# self.PLY_File = PLY_File
self.remote... |
986,665 | e827732ac80f81f49e5bd708b5d7f31488944902 | import tkinter
from tkinter import ttk
from tkinter import *
def sel():
selection = "You selected the option " + var.get()
#label.config(text = selection)
type_str = var.get()
print(type_str)
def getTemp():
with open(type_str , 'r') as f:
data = f.readlines()
data[1] = TempEntry.get() + '... |
986,666 | 139dfca425343334817b743f732a2bfaf8b62e54 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# our departure point is http://commons.wikimedia.org/wiki/Category:Illustrations_by_subject
import sys
import os
import json
import urllib2
from urllib import quote
from flask import Flask, request, render_template, send_file, make_response
from retrieve import retrieve_u... |
986,667 | dce4cf77cc2d494be18c7a7278abb415617fbf15 | # Add all even numbers in the Fibonacci sequence that are < 4,000,000
import time
def fibsumevens(n):
t,nt,nnt=1,1,1
nnt,runningtotal,stoplight=0,0,0
t0=time.clock()
while stoplight<1:
print t
nnt=t+nt
if nnt>n:
stoplight=1
else:
t=nt
nt=nnt
if nnt%2==0:
runningtotal=runningtotal+nt
pri... |
986,668 | 23ef799f2a9dd23309c5e72532d43ec4ad7ef794 | from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
urlpatterns = patterns("",
url(r"^$", TemplateView.as_view(template_name="homepage.html"), name="home"),
url(r"^escala-de-notas/$", TemplateView.as_view(template_name="escala.html"), name="escala"),
url(r"^tra... |
986,669 | a85d3d5212a4da770f1f1e183321c1839df9d1aa | #!/usr/bin/env python
import sys
import bencode
import hashlib
if __name__ == '__main__':
if len(sys.argv) < 2:
print('usage: %s <torrent>' % sys.argv[0])
sys.exit(1)
filename = sys.argv[1]
with open(filename) as torrent:
content = torrent.read()
content_debencoded = benc... |
986,670 | 5561e023b2c5fb43d0af9061f1403e3e1436d913 |
def find_even_number():
li = []
for i in range(1,51):
if i % 2 == 0:
li.append(i)
return li
|
986,671 | a4ff539cb800487c5f201509278d93390f98c8ff | import flask
import threading
import subprocess
import RPi.GPIO as GPIO
import pafy
import vlc
import time
import datetime
import host_ip
import os
import validators
import sys
import alsaaudio
app = flask.Flask(__name__)
host = host_ip.ip
url_file = "/home/pi/programming/python/doorbell_getter/url.txt"
skip_file = "/... |
986,672 | e53fde9fb11d7d4497c994de43f75222f43064a4 | import multiprocessing as mp
def job(a,b):
print a,b
if __name__=='__main__':
# create start And join
p1 = mp.Process(target=job,args=('Hello','MultiProcessing'))
p1.start()
p1.join()
|
986,673 | 76ae225f13a2de1dcf8cdedea5e12c6b7af93fc4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def rotateRight(self, head: ListNode, k: int) -> ListNode:
# 实例给的好,不然我们可能会很容易忘记如果k大于链表的长度怎么办啊,这道题相当于在k值取余链表长度之后得到 m,然后取出倒数第m个链表节点
if k == 0 or not head or not head.next:
... |
986,674 | 517f9666499a8a12a18d438fd751b4ed5b7e9849 | import pytest
from widgetastic.widget import Checkbox
from widgetastic.widget import View
from widgetastic_patternfly4 import ColumnNotExpandable
from widgetastic_patternfly4 import CompoundExpandableTable
from widgetastic_patternfly4 import ExpandableTable
from widgetastic_patternfly4 import PatternflyTable
from widg... |
986,675 | 23b902105abf4e8fdf51b46137d1a4fa4279be57 | import unittest
from xml.sax.handler import property_dom_node
from dojo import *
input = """
RRLLDDRLLDURLDUUDULDLRLDDDRLDULLRDDRDLUUDLLRRDURRLUDUDULLUUDRUURRDDDDURUULLDULRLRRRDLLLRDLRDULDLRUUDRURLULURUUDRLUUDRDURUUDDDRDLLRDLUDRLUUUUUULDURDRDDURLDDRLUUDLRURRDRLDRDLRRRLURULDLUUURDRLUULRDUDLDRRRDDLDDDRLRLLDRDUURDULUURRR... |
986,676 | 9fbcfe6f01fad1b85c96cb7319100ccc25dc8ea6 | import re
import pytest
from grepper import Grepper
@pytest.fixture(scope="function")
def regex(request):
return re.compile(request.param)
@pytest.mark.parametrize(
"token_capture,regex",
[
("%{0}", "^(?P<token_0>.*?)$"),
("%{1}", "^(?P<token_1>.*?)$"),
("%{0S1}", r"^(?P<token_... |
986,677 | 08958112f1787cfed39d247d865bf8363444da57 | # -*- coding: utf-8 -*-
#
from __future__ import unicode_literals
from django.db import models
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
# Create your models here.
class Hero(models.Model):
CATEGORY_CHOICES = (
("Strength", gettext_lazy("Strength")... |
986,678 | ae9120cbb7a7f5365b4269a206bd710c4ba98116 | from parse import *
def car_start_look_ahead(start, cars, time, class_adj_list):
iter_count = 17
cars_data = []
for car in range(cars):
cars_data.append([start])
max_sum = 0
time_left = time
current_node = start
while time_left > 0:
for edge in class_adj_... |
986,679 | 72c5e10ed29955e83be7e95959053bb033300e99 | from django.contrib import admin
from .models import channel_model,course,course_session
# Register your models here.
admin.site.register(channel_model)
admin.site.register(course)
admin.site.register(course_session)
|
986,680 | 702123ecbb7ae34bc5b5e6e38fe537f2c8c651a9 | # %% Packages
import json
import tensorflow as tf
# %% Loading models and data
# Model
keras_path = "./models/oxford_flower102_fine_tuning.h5"
keras_model = tf.keras.models.load_model(keras_path)
converter = tf.lite.TFLiteConverter.from_keras_model(keras_model)
tflite_model = converter.convert()
with open("./models/... |
986,681 | 37e8c84410947e6778e51850a39932362bea13cf | from django.test import TestCase, Client
from django.db import models
from products.models import Product
from .models import Order, OrderLineItem
# Create your tests here.
class CheckoutModelTests(TestCase):
def setUp(self):
self.client = Client()
self.client.login(username='AutoT... |
986,682 | edc6e6def7a541070204b5075772b79a7b968853 | import pandas as pd
from Backend.Utilities import DictionaryReader
CONST_PATH_TO_FILE = 'resources/ghcnd-stations.txt'
CONST_PATH_TO_TWITTER = 'resources/dataless.text'
colspecs = [(0, 11), (11, 21), (21, 31), (31, 38), (39, 41), (41, 72), (72, 76), (76, 80), (80, 86)]
stations = pd.read_fwf(CONST_PATH_TO_FILE, cols... |
986,683 | 0dc03f4c3824a0e196177dfcc2ec61dfa5f2c12a | #Sam Durst
#10/4/19
import socket
import select
import sys
def main():
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # create tcp client socket
port = 12000
ip = socket.gethostbyname('www.goatgoose.com')
client.connect((ip, port)) # form the connection
message = "HELLO \n"
cli... |
986,684 | 17bd1e450fcb898d0d2ede35314b2a07844be9f2 | #!/usr/bin/env python
import optparse, sys, os
from collections import namedtuple
from collections import defaultdict
import bleu
import random
import math
import numpy
from operator import itemgetter
optparser = optparse.OptionParser()
optparser.add_option("-n", "--nbest", dest="nbest", default=os.path.join("data", ... |
986,685 | 42dd73ff00b71837ad40d1ba37361f7756420a26 | class kdnode:
def __init__(self):
self.dim = -1
self.val = -1
self.st = -1
self.end = -1
self.dist = 0
self.lessChild = 0
self.greaterChild = 0
self.minx = -9999
self.miny = -9999
self.width = -9999
self.height = -9999
def __lt__(self, other):
return self.dist < other.dist;
def __gt__(sel... |
986,686 | 6f2f04bdb8ad94cedea699e692fb06c864fa2af5 | """Script to install Diary Peter."""
# Copyright 2016 Vincent Ahrend
# 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 ... |
986,687 | 1a1251a6bee1c84ace64438c8a01ef5bb51b7401 |
class Calculator implements AdvancedArithmetic
{
@Override
public int divisorSum(int n)
{
int sum = n;
for(int x=1;x<=n/2;x++)
{
if(n%x==0)
{
sum = sum + x;
}
}
return sum;
}
}
|
986,688 | 555fb2057ab3aa9286c3daec5c57aac97fe8e6eb | # Creates On-Demand / Site Array report
from pure_pull import *
from array_report import *
from datetime import datetime, timedelta
import pandas as pd
from math import trunc
from sharepoint import file_upload
def add_data_columns(array_name, used, charge, ondemand):
center = workbook.add_format({'align': 'cente... |
986,689 | c469bfbda1a012e7ec023b622a91484f70dc465b | baseset ="characterset"
subset ="CHARACTER"
if subset and subset.casefold() in baseset.casefold():
print("Gone")
else:
print("present")
for itr in range(-100,10,5):
print(itr)
|
986,690 | bafca5bc932964d2f314e2de09166729e5e24abc | #!/usr/bin/env python
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import base64
from writers import adml_writer
def GetWriter(config):
'''Factory method for creating ADMLWriter objects for the Ch... |
986,691 | a7baf91e35e6720076815f1cd3ec8fd0e4ad461e | import math
class Solution:
def reverse(self, x: int) -> int:
y = x
if x < 0:
x = -x
xlist = list(map(int, str(x)))
result = []
for i in reversed(range(len(xlist))):
result.append(xlist[i])
result = [str(integer) for integer in result]
... |
986,692 | 276cae2ff2fca8b1618124aaa5466b000d607031 | """oh_app_demo URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-b... |
986,693 | 56333389f1b9afbf7c79df2ad98ce2bed66f5164 | from django.shortcuts import render
from cia.LibCIA import XML
from cia.apps.stats.models import StatsTarget
import datetime
# Legacy imports
from cia.LibCIA.Stats.Target import StatsTarget as OldStatsTarget
from cia.LibCIA.Message import FormatterArgs
from cia.LibCIA import Formatters
from cia.LibCIA.Message import M... |
986,694 | f02c414d98b3fff4c6578b9e8400ac516847a7f7 | try:
import tensorflow as tf
from latte.metrics.keras import interpolatability as K
has_tf = True
except:
has_tf = False
import numpy as np
import pytest
from latte.metrics.core import interpolatability as C
@pytest.mark.skipif(not has_tf, reason="requires tensorflow")
class TestSmoothness:
de... |
986,695 | ddcbd0531703d891d485a7e707a85d323819f306 | import pytest
import numpy as np
import torch
import torch.nn as nn
from collections import OrderedDict
from torchmeta.modules import MetaModule
from torchmeta.modules.sparse import MetaEmbedding, MetaEmbeddingBag
def test_metaembedding():
meta_model = MetaEmbedding(5, 3, padding_idx=0)
model = nn.Embedding... |
986,696 | f0f769cbb9865e8152c2cf867ce15ad0b4b0ca12 | __pyarmor__(__name__, __file__, b'\xec\x50\x8c\x64\x26\x42\xd6\x01\x10\x54\xca\x9c\xb6\x33\x81\x05\x30\xdb\x46\xb3\x6d\x0c\xa2\x2d\x19\xe2\x8f\xf9\x44\x25\xd5\x53\xc7\x67\x06\x76\x71\x8d\x42\xe2\xc3\xef\x00\x16\xa3\x91\x11\x67\x09\x92\x9a\x72\x18\xf6\x31\xbd\x95\x78\x69\xe0\x84\xc1\x30\x40\x93\x62\xc4\x8e\xd6\xf0\x0d\x... |
986,697 | 73a1962d3d66207cccfcc91650b21c6f4cd08d63 | from flask import Flask, render_template, request, g, url_for
from cronruntime import CronRunTime
from wtforms import Form, SelectField, SubmitField, validators
import os
import re
app = Flask(__name__)
filename = "crontab_cases.txt"
filepath = os.getcwd()
print(filepath)
app.static_folder = "static"
@app.route("/",... |
986,698 | c6aba95986e76413311a49be797efeaefff8d67c | """Write a Python script using PEFile to enumerate all imports and exports from
Kernel32.dll, KernelBase.dll, and ntdll.dll, and store the results in a text file.
Additionally, enumerate the sections in each of those files."""
import pefile
pe = pefile.PE("C:\\Users\\DOTlaptop\\Desktop\\re_quiz\\re_lab4.1_x86.dll")
... |
986,699 | 09288499b1f50691a57a56aef598c17b0f9f81bc | while True:
diff=10000009
ans = 0
b,n=map(int, input().split())
if b==0 and n==0:
break
for a in range(1, b+1):
result = abs(b-a**n)
if result < diff:
diff = result
ans = a
print(ans)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.