code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
from aws_cdk import core as cdk # For consistency with other languages, `cdk` is the preferred import name for # the CDK's core module. The following line also imports it as `core` for use # with examples from the CDK Developer's Guide, which are in the process of # being updated to use `cdk`. You may delete this im...
normal
{ "blob_id": "12cd3dbf211b202d25dc6f940156536c9fe3f76f", "index": 3385, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass kdECSDemo(cdk.Stack):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass kdECSDemo(cdk.Stack):\n\n def __init__(self, scope: cdk.Construct, construct_id: str, **kwarg...
[ 0, 1, 2, 3, 4 ]
from flask import Flask, request, render_template from random import choice, sample app = Flask(__name__) horoscopes = [ 'your day will be awesome', 'your day will be terrific', 'your day will be fantastic', 'neato, you have a fantabulous day ahead', 'your day will be oh-so-not-meh', 'this day...
normal
{ "blob_id": "09d32b48ae88b1066dd0aa435a351c4fb1fc04ec", "index": 9759, "step-1": "from flask import Flask, request, render_template\nfrom random import choice, sample\n\napp = Flask(__name__)\n\nhoroscopes = [\n 'your day will be awesome',\n 'your day will be terrific',\n 'your day will be fantastic',\n...
[ 0 ]
#!/bin/usr/python2.7.x import os, re, urllib2 def main(): ip = raw_input(" Target IP : ") check(ip) def check(ip): try: print "Loading Check File Uploader...." print 58*"-" page = 1 while page <= 21: bing = "http://www.bing.com/search?q=ip%3A" + \ ip + "+upload&count=50&first=" + str(...
normal
{ "blob_id": "21af630bf383ee1bdd0f644283f0ddadde71620a", "index": 236, "step-1": "#!/bin/usr/python2.7.x\r\n\r\nimport os, re, urllib2\r\n\r\ndef main():\r\n\tip = raw_input(\" Target IP : \")\r\n\tcheck(ip)\r\n\r\ndef check(ip):\r\n\ttry:\r\n\t\tprint \"Loading Check File Uploader....\"\r\n\t\tprint 58*\"-\"\r\n...
[ 0 ]
""" BCXYZ company has up to employees. The company decides to create a unique identification number (UID) for each of its employees. The company has assigned you the task of validating all the randomly generated UIDs. A valid UID must follow the rules below: It must contain at least 2 uppercase English alphabet chara...
normal
{ "blob_id": "3a5c8ee49c50820cea201c088acca32e018c1501", "index": 3715, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(int(input())):\n imp = input()\n if bool(re.search('[a-zA-Z0-9]{10}', imp)) and bool(re.search(\n '([A-Z].*){2}', imp)) and bool(re.search('([0-9].*){3}', imp)...
[ 0, 1, 2, 3 ]
print(60 * 60) seconds_per_hour = 60 * 60 print(24 * seconds_per_hour) seconds_per_day = 24 * seconds_per_hour print(seconds_per_day / seconds_per_hour) print(seconds_per_day // seconds_per_hour)
normal
{ "blob_id": "358879d83ed3058530031d50fb69e3ce11fbd524", "index": 1057, "step-1": "<mask token>\n", "step-2": "print(60 * 60)\n<mask token>\nprint(24 * seconds_per_hour)\n<mask token>\nprint(seconds_per_day / seconds_per_hour)\nprint(seconds_per_day // seconds_per_hour)\n", "step-3": "print(60 * 60)\nseconds_...
[ 0, 1, 2 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from operation import * import math class InsertWord(Operation): @classmethod def getValue(cls, t, h, w, b, arg=None): return math.log(arg["prob"]) * w[cls] @classmethod def getKBest(cls, t, h , args, w, b, k): valueList = [] for ...
normal
{ "blob_id": "355e3932c8bd9105e0c1ce9259e3b7416997523c", "index": 3668, "step-1": "<mask token>\n\n\nclass InsertWord(Operation):\n\n @classmethod\n def getValue(cls, t, h, w, b, arg=None):\n return math.log(arg['prob']) * w[cls]\n <mask token>\n <mask token>\n\n @classmethod\n def transF...
[ 3, 4, 5, 6, 7 ]
import functools import shutil import tempfile import unittest import unittest.mock from pathlib import Path import numpy as np import pandas as pd import one.alf.io as alfio from ibllib.io.extractors import training_trials, biased_trials, camera from ibllib.io import raw_data_loaders as raw from ibllib.io.extractors...
normal
{ "blob_id": "f17d33f1d035da42dc9a2b4c0c60beefc6a48dea", "index": 64, "step-1": "<mask token>\n\n\nclass TestExtractTrialData(unittest.TestCase):\n\n def setUp(self):\n self.main_path = Path(__file__).parent\n self.training_lt5 = {'path': self.main_path / 'data' /\n 'session_training_l...
[ 27, 34, 37, 45, 49 ]
import dnf_converter def parse(query): print("parsing the query...") query = dnf_converter.convert(query) cp_clause_list = [] clause_list = [] for cp in query["$or"]: clauses = [] if "$and" in cp: for clause in cp["$and"]: clauses.append(clause) clause_list.append(clause) else: clause = cp ...
normal
{ "blob_id": "999de0965efa3c1fe021142a105dcf28184cd5ba", "index": 43, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse(query):\n print('parsing the query...')\n query = dnf_converter.convert(query)\n cp_clause_list = []\n clause_list = []\n for cp in query['$or']:\n claus...
[ 0, 1, 2, 3 ]
from psycopg2 import ProgrammingError, IntegrityError import datetime from loguru import logger from db.connect import open_cursor, open_connection _log_file_name = __file__.split("/")[-1].split(".")[0] logger.add(f"logs/{_log_file_name}.log", rotation="1 day") class DataTypeSaveError(Exception): pass class ...
normal
{ "blob_id": "8339ac512d851ea20938a1fbeedcb751cb2b8a6a", "index": 4337, "step-1": "<mask token>\n\n\nclass BaseDataClass:\n\n def _create_insert_query(self):\n column_names = ''\n row_values = ''\n values = []\n for column_name, row_value in self.__dict__.items():\n if co...
[ 6, 12, 18, 19, 20 ]
''' A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Given two integers A and B, print the number of primes between them, inclusively. ''' a = int(input()) b = int(input()) count = 0 for i in range(a, b+1): true_prime = True for num in range(2, i): ...
normal
{ "blob_id": "ed4c97913a9dba5cf6be56050a8d2ce24dbd6033", "index": 1870, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(a, b + 1):\n true_prime = True\n for num in range(2, i):\n if i % num == 0:\n true_prime = False\n if true_prime:\n count += 1\nprint(coun...
[ 0, 1, 2, 3 ]
from django.contrib import admin # from django.contrib.admin import AdminSite # class MyAdminSite(AdminSite): # site_header = 'Finder Administration' # admin_site = MyAdminSite(name='Finder Admin') from finder.models import Database, Column, GpsData, Alarm, System class ColumnInline(admin.TabularInline): mo...
normal
{ "blob_id": "e1968e0d6146ce7656505eeed8e9f31daa4b558a", "index": 5447, "step-1": "<mask token>\n\n\nclass DatabaseAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass AlarmAdmin(admin.ModelAdmin):\n list_display = ['nam...
[ 5, 7, 10, 11, 13 ]
import os, subprocess, time from os.path import isfile, join import shutil # to move files from af folder to another import math def GetListFile(PathFile, FileExtension): return [os.path.splitext(f)[0] for f in os.listdir(PathFile) if isfile(join(PathFile, f)) and os.path.splitext(f)[1] == '.' + FileExtension] d...
normal
{ "blob_id": "8b671404228642f7ef96844c33ac3cee402bdb19", "index": 1279, "step-1": "import os, subprocess, time\nfrom os.path import isfile, join\nimport shutil # to move files from af folder to another\nimport math\n\ndef GetListFile(PathFile, FileExtension):\n return [os.path.splitext(f)[0] for f in os.listdi...
[ 0 ]
# Problem No.: 77 # Solver: Jinmin Goh # Date: 20191230 # URL: https://leetcode.com/problems/combinations/ import sys class Solution: def combine(self, n: int, k: int) -> List[List[int]]: if k == 0: return [[]] ans = [] for i in range(k, n + 1) : for tem...
normal
{ "blob_id": "e4a2c605ef063eee46880515dfff05562916ab81", "index": 9976, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def combine(self, n: int, k: int) ->List[List[int]]:\n if k == 0:\...
[ 0, 1, 2, 3, 4 ]
""" Plot funcs Jan, 2018 Rose Yu @Caltech """ import matplotlib.pyplot as plt import seaborn as sns from util.matutil import * from util.batchutil import * def plot_img(): """ plot ground truth (left) and reconstruction (right) showing b/w image data of mnist """ plt.subplot(121) plt.imshow...
normal
{ "blob_id": "cca9d91fe20e58f233ccfc4100edb748356ed234", "index": 6311, "step-1": "<mask token>\n\n\ndef plot_img():\n \"\"\" \n plot ground truth (left) and reconstruction (right)\n showing b/w image data of mnist\n \"\"\"\n plt.subplot(121)\n plt.imshow(data.data.numpy()[0,].squeeze())\n pl...
[ 1, 2, 3, 4, 5 ]
import logging, os, zc.buildout, sys, shutil class ZipEggs: def __init__(self, buildout, name, options): self.name, self.options = name, options if options['target'] is None: raise zc.buildout.UserError('Invalid Target') if options['source'] is None: raise zc.buildou...
normal
{ "blob_id": "e7bec9018f25ba9e3c3ae8a5bbe11f8bc4b54a04", "index": 5714, "step-1": "import logging, os, zc.buildout, sys, shutil\n\nclass ZipEggs:\n def __init__(self, buildout, name, options):\n self.name, self.options = name, options\n if options['target'] is None:\n raise zc.buildout...
[ 0 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('grid2', '0003_auto_20161231_2329'), ] operations = [ migrations.RemoveField( model_name='grid', name...
normal
{ "blob_id": "3e305cee2f814698729c008320e326c4bd42640d", "index": 6629, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('grid2', '00...
[ 0, 1, 2, 3, 4 ]
class Robot: def __init__(self, name): self.name = name def say_hi(self): print("Hi, I'm from class Robot") print("Hi, Ich bin " + self.name) def say_hi_to_everybody(self): print("Hi to all objects :-)") class PhysicianRobot(Robot): def say_hi_again(self): pr...
normal
{ "blob_id": "6b24c438ca7bb4c37ae356c18c562831767f0569", "index": 9961, "step-1": "<mask token>\n\n\nclass PhysicianRobot(Robot):\n <mask token>\n\n\n<mask token>\n", "step-2": "class Robot:\n\n def __init__(self, name):\n self.name = name\n\n def say_hi(self):\n print(\"Hi, I'm from clas...
[ 1, 6, 7, 8, 9 ]
import rdflib import csv from time import sleep gtypes = {} dtypes = {} atypes = {} g = rdflib.Graph() g.parse("http://geographicknowledge.de/vocab/CoreConceptData.rdf#") g.parse("./ontology.ttl", format="ttl") sleep(.5) results = g.query(""" prefix skos: <http://www.w3.org/2004/02/skos/core#> prefix ccd: ...
normal
{ "blob_id": "eb1fbe2de3c8548175eb3c8720353e466e3b68c7", "index": 7336, "step-1": "<mask token>\n", "step-2": "<mask token>\ng.parse('http://geographicknowledge.de/vocab/CoreConceptData.rdf#')\ng.parse('./ontology.ttl', format='ttl')\nsleep(0.5)\n<mask token>\nfor result in results:\n uri, geometry_type = re...
[ 0, 1, 2, 3, 4 ]
from urllib import request, parse import pandas as pd import json import os class BusInfo: url = 'https://api-tokyochallenge.odpt.org/api/v4/odpt:Bus' url_busstop = 'https://api-tokyochallenge.odpt.org/api/v4/odpt:BusstopPole.json' url_routes = 'https://api-tokyochallenge.odpt.org/api/v4/odpt:BusroutePatt...
normal
{ "blob_id": "7eefcfdb9682cb09ce2d85d11aafc04977016ba4", "index": 8332, "step-1": "<mask token>\n\n\nclass BusInfo:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def init():\n apiKey = os.getenv('BUS_TOKEN')\n Bu...
[ 5, 6, 7, 8, 9 ]
from rest_framework import serializers from users.models import bills, Userinfo class billsSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = bills fields = ('bname', 'bamount', 'duedate', 'user_id') class UserinfoSerializer(serializers.HyperlinkedModelSerializer): class ...
normal
{ "blob_id": "124ece8f2f4ecc53d19657e2463cc608befb1ce7", "index": 3722, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass UserinfoSerializer(serializers.HyperlinkedModelSerializer):\n\n\n class Meta:\n model = Userinfo\n fields = ('fname', 'lname', 'address', 'city', 'state', 'zipc...
[ 0, 1, 2, 3, 4 ]
# from datetime import datetime from datetime import datetime, time, timedelta # today = datetime.now() # previous_day = today - timedelta(days=1) # previous_day = previous_day.strftime("%Y%m%d") # print(today) # print(previous_day) print(datetime.strptime("2013-1-25", '%Y-%m-%d').strftime('%Y-%m-%d 00:00:00')) # def...
normal
{ "blob_id": "4dac8e7e695c473cb73ceaf3887373bcc0a08aff", "index": 5940, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(datetime.strptime('2013-1-25', '%Y-%m-%d').strftime('%Y-%m-%d 00:00:00'))\n", "step-3": "from datetime import datetime, time, timedelta\nprint(datetime.strptime('2013-1-25', '%Y-%...
[ 0, 1, 2, 3 ]
import requests import pandas as pd import time def job_spider(jid="1913e38066dd3c8e1Hd40t--FVE~", ka="search_list_1", i=0): # request info. job_url = "https://www.zhipin.com/job_detail/" + jid + ".html" headers = { 'cache-control': "no-cache", 'user-agent': 'Mozilla/5.0 (Windows NT 10.0;...
normal
{ "blob_id": "5b894eac93bff44931df4ef8d845c23071a03227", "index": 3461, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef job_spider(jid='1913e38066dd3c8e1Hd40t--FVE~', ka='search_list_1', i=0):\n job_url = 'https://www.zhipin.com/job_detail/' + jid + '.html'\n headers = {'cache-control': 'no-c...
[ 0, 1, 2, 3, 4 ]
from search import SearchEngine import tkinter as tk if __name__ == "__main__": ghettoGoogle = SearchEngine() def searchButtonEvent(): search_query = searchQueryWidget.get() search_results = ghettoGoogle.search(search_query) resultsCanvas = tk.Tk() if search_results == None: ...
normal
{ "blob_id": "0cf90cd7704db9f7467e458b402fadb01c701148", "index": 7307, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n ghettoGoogle = SearchEngine()\n\n def searchButtonEvent():\n search_query = searchQueryWidget.get()\n search_results = ghettoGoogle.search...
[ 0, 1, 2, 3 ]
species( label = 'C=C([CH]C)C(=C)[CH]C(24182)', structure = SMILES('[CH2]C(=CC)C([CH2])=CC'), E0 = (249.687,'kJ/mol'), modes = [ HarmonicOscillator(frequencies=([325,375,415,465,420,450,1700,1750,2750,2770,2790,2810,2830,2850,1350,1400,1450,1500,700,800,1000,1100,1350,1400,900,1100,3000,3033.33,...
normal
{ "blob_id": "63093190ee20e10698bd99dcea94ccf5d076a006", "index": 8921, "step-1": "<mask token>\n", "step-2": "species(label='C=C([CH]C)C(=C)[CH]C(24182)', structure=SMILES(\n '[CH2]C(=CC)C([CH2])=CC'), E0=(249.687, 'kJ/mol'), modes=[\n HarmonicOscillator(frequencies=([325, 375, 415, 465, 420, 450, 1700, ...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- from handlers.base import Base class Home(Base): def start(self): from movuca import DataBase, User from datamodel.article import Article, ContentType, Category from datamodel.ads import Ads self.db = DataBase([User, ContentType, Category, Article, Ads]) ...
normal
{ "blob_id": "9d0d4707cc9a654752dd0b98fe0fec6a0c1419a1", "index": 3029, "step-1": "<mask token>\n\n\nclass Home(Base):\n <mask token>\n\n def pre_render(self):\n self.response = self.db.response\n self.request = self.db.request\n self.config = self.db.config\n self.response.meta....
[ 4, 5, 6, 7, 8 ]
from os import listdir from os.path import isfile, join from datetime import date mypath = '/Users/kachunfung/python/codewars/' onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] py_removed = [i.replace('.py','') for i in onlyfiles] file_counter_removed = py_removed.remove('file_counter') day_removed...
normal
{ "blob_id": "592d5074eeca74a5845d26ee2ca6aba8c3d0f989", "index": 8929, "step-1": "from os import listdir\nfrom os.path import isfile, join\nfrom datetime import date\n\nmypath = '/Users/kachunfung/python/codewars/'\nonlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]\n\npy_removed = [i.replace('....
[ 0 ]
from flask import Flask, request, render_template, redirect from stories import Story, stories # from flask_debugtoolbar import DebugToolbarExtension app = Flask(__name__) # app.config['SECRET_KEY'] = "secret" # debug = DebugToolbarExtension(app) # my original approach involved using a global story variable to sto...
normal
{ "blob_id": "08ed57ffb7a83973059d62f686f77b1bea136fbd", "index": 3828, "step-1": "<mask token>\n\n\n@app.route('/')\ndef home_page():\n \"\"\"Offer user choice of Madlib Games\"\"\"\n return render_template('index.html', stories=stories.values())\n\n\n<mask token>\n\n\n@app.route('/story')\ndef show_story(...
[ 2, 4, 5, 6, 7 ]
""" corner cases like: word[!?',;.] word[!?',;.]word[!?',;.]word so don't consider the punctuation will only exist after one word, and followed by a whitespace use re for regular expression match, replace or punctuations, and split words """ class Solution: def mostCommonWord(self, paragraph, banned): ...
normal
{ "blob_id": "3bb50b61c7a3e98ede0a31e574f39b4ea7f22de5", "index": 9197, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def mostCommonWord(self, paragraph, banned):\n \"\"\"\n :ty...
[ 0, 1, 2, 3, 4 ]
""" В массиве случайных целых чисел поменять местами минимальный и максимальный элементы. """ import random SIZE = 10 MIN_ITEM = -100 MAX_ITEM = 100 array = [random.randint(MIN_ITEM, MAX_ITEM) for _ in range(SIZE)] print('Массив случайных чисел:\n', array) min_el = array[0] max_el = array[0] max_el_inx = 0 min_...
normal
{ "blob_id": "6027836b1b5d3cb8b842b1a1b77f5c9777269896", "index": 7177, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Массив случайных чисел:\\n', array)\n<mask token>\nfor el in range(SIZE):\n if array[el] > max_el:\n max_el = array[el]\n max_el_inx = el\n if array[el] < min_e...
[ 0, 1, 2, 3, 4 ]
# Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ if len(s)...
normal
{ "blob_id": "7c39b3927bc0702818c54875785b4657c20c441e", "index": 2272, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def longestPalindrome(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n ...
[ 0, 1, 2, 3 ]
from django.contrib import admin from .models import JobListing from .models import Employer admin.site.register(JobListing) admin.site.register(Employer)
normal
{ "blob_id": "a96575d507a91472176c99d4d55e2a3bbf8111d1", "index": 2707, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(JobListing)\nadmin.site.register(Employer)\n", "step-3": "from django.contrib import admin\nfrom .models import JobListing\nfrom .models import Employer\nadmin.site....
[ 0, 1, 2 ]
''' Created on 14 november 2015 @author: federico ''' import paho.mqtt.client as mosquitto import json import urllib,urllib2 import datetime import threading import time from pygame import mixer from datetime import timedelta #ALARM SOUND PATH alarm_path="/home/pi/SmartBed/Smart_Bed/src/Rooster.wav" #DWEET&FREEBOA...
normal
{ "blob_id": "05bd95966d72dd40b9b828932b0bf70e40ddb573", "index": 1511, "step-1": "'''\nCreated on 14 november 2015\n\n@author: federico\n'''\n\nimport paho.mqtt.client as mosquitto\nimport json\nimport urllib,urllib2\nimport datetime\nimport threading\nimport time\nfrom pygame import mixer\nfrom datetime import ...
[ 0 ]
def play_43(): n=int(input('Enter n :')) l=[] for i in range(n): l.append(int(input())) for i in range(n-1): for j in range(i+1,n): if l[i]<l[j]: continue return "no" return "Yes" play_43()
normal
{ "blob_id": "1605396a6edb31dd6fe9238a0506f8cfeb794d07", "index": 5568, "step-1": "<mask token>\n", "step-2": "def play_43():\n n = int(input('Enter n :'))\n l = []\n for i in range(n):\n l.append(int(input()))\n for i in range(n - 1):\n for j in range(i + 1, n):\n if l[i] <...
[ 0, 1, 2, 3 ]
# Jeremy Jao # University of Pittsburgh: DBMI # 6/18/2013 # # This is the thing that returns the dictionary of the key. we can edit more code to return different values in the keys (gene) in each dictionary inside the dictionary. # my sys.argv isn't working in my situation due to my IDE (nor do I not know how it w...
normal
{ "blob_id": "7016a7dda80c0cfae0e15cf239f6ae64eb9004b7", "index": 9733, "step-1": "# Jeremy Jao\r\n# University of Pittsburgh: DBMI\r\n# 6/18/2013\r\n#\r\n# This is the thing that returns the dictionary of the key. we can edit more code to return different values in the keys (gene) in each dictionary inside the d...
[ 0 ]
#Copyright 2020 Side Li, Arun Kumar # #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...
normal
{ "blob_id": "203e678d565753bb51e1bbd90ffec0f3260b22fb", "index": 119, "step-1": "<mask token>\n\n\ndef line_count(filename, hdfs_used=False, client=None):\n if hdfs_used:\n with client.read(filename, encoding='utf-8') as reader:\n num_lines = sum(1 for _ in reader)\n return num_li...
[ 6, 7, 8, 9, 10 ]
# Generated by Django 3.1.3 on 2020-11-18 13:26 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ...
normal
{ "blob_id": "fa09937ce64952795ae27cb91bf2c52dfb3ef4da", "index": 4532, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request): #return HttpRequest("Hi This is SAU5081 page.") return render(request, "sau5081/sau5081.html")
normal
{ "blob_id": "ac1ac80739bed0cebf7a89a7d55e1b4fa6c68cdf", "index": 3428, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef index(request):\n return render(request, 'sau5081/sau5081.html')\n", "step-3": "from django.shortcuts import render\nfrom django.http import HttpResponse\n\n\ndef index(reque...
[ 0, 1, 2, 3 ]
{"filter":false,"title":"cash.py","tooltip":"/pset6/cash/cash.py","undoManager":{"mark":100,"position":100,"stack":[[{"start":{"row":12,"column":7},"end":{"row":12,"column":8},"action":"insert","lines":[" "],"id":308},{"start":{"row":12,"column":8},"end":{"row":12,"column":9},"action":"insert","lines":[">"]}],[{"start"...
normal
{ "blob_id": "d14c22ba6db90a93a19d61e105e31b3eb8f3a206", "index": 1706, "step-1": "<mask token>\n", "step-2": "{'filter': false, 'title': 'cash.py', 'tooltip': '/pset6/cash/cash.py',\n 'undoManager': {'mark': 100, 'position': 100, 'stack': [[{'start': {\n 'row': 12, 'column': 7}, 'end': {'row': 12, 'colum...
[ 0, 1, 2 ]
from django.contrib import admin from django.urls import include, path urlpatterns = [ path('', admin.site.urls), path('upload/', include('links.urls')), ]
normal
{ "blob_id": "45e8bdacad4ed293f7267d96abc9cbe8c8e192ae", "index": 4148, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', admin.site.urls), path('upload/', include(\n 'links.urls'))]\n", "step-3": "from django.contrib import admin\nfrom django.urls import include, path\nurlpatter...
[ 0, 1, 2, 3 ]
class Solution: def minRemoveToMakeValid(self, s: str) -> str: bracketsToRemove = set() stack = [] for i, c in enumerate(s): if c not in '()': continue if c == '(': stack.append(i) elif not stack: ...
normal
{ "blob_id": "1bab6b039462bb5762aa588d5ba7c3e74362d0a7", "index": 823, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution:\n\n def minRemoveToMakeValid(self, s: str) ->str:\n bracketsToRemove = set()\n stack = []\n f...
[ 0, 1, 2, 3, 4 ]
import ftplib def ftp_download(): file_remote = 'ftp_upload.jpg' file_local = '/home/pi/Desktop/Camera-Rasp-Arduino-sensors/test_download.jpg' bufsize = 1024 fp = open(file_local, 'wb') f.retrbinary('RETR ' + file_remote, fp.write, bufsize) fp.close() def ftp_upload(): file_remote = '...
normal
{ "blob_id": "a1b85d140c45f082ceac54ad8aa9aa5c3659d5cf", "index": 9661, "step-1": "<mask token>\n\n\ndef ftp_download():\n file_remote = 'ftp_upload.jpg'\n file_local = (\n '/home/pi/Desktop/Camera-Rasp-Arduino-sensors/test_download.jpg')\n bufsize = 1024\n fp = open(file_local, 'wb')\n f.re...
[ 1, 2, 3, 4, 5 ]
a = input().split(' ') A = int(a[0]) B = int(a[1]) X = int(a[2]) if A <= X and A + B >= X: print('YES') else: print('NO')
normal
{ "blob_id": "9a60449aa13bc5e7e413d0e47a1972d93ccfe69f", "index": 7194, "step-1": "<mask token>\n", "step-2": "<mask token>\nif A <= X and A + B >= X:\n print('YES')\nelse:\n print('NO')\n", "step-3": "a = input().split(' ')\nA = int(a[0])\nB = int(a[1])\nX = int(a[2])\nif A <= X and A + B >= X:\n pr...
[ 0, 1, 2 ]
# Generated by Django 2.2.10 on 2020-03-13 14:02 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('system', '0005_location'), ] operations = [ migrations.AddField( model_name='setting', name='runned_locations_initi...
normal
{ "blob_id": "211ef4c64e42c54423ac8dab2128952874a2cf5a", "index": 7694, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('system', '0...
[ 0, 1, 2, 3, 4 ]
class Line: def __init__(self,coor1,coor2): self.coor1 = coor1 self.coor2 = coor2 def slope(self): pass def distance(self): #x = self.coor1[0]-self.coor2[0] #y = self.coor2[1]-self.coor2[1] #return ((x**2)+(y**2))**0.5 return ((((self.coor2[0]-s...
normal
{ "blob_id": "f91e997b305348485698d180b97138b040285b60", "index": 9440, "step-1": "<mask token>\n\n\nclass Account:\n\n def __init__(self, name, balance):\n self.name = name\n self.balance = balance\n\n def deposit(self, money):\n self.balance += money\n return 'Deposit accepted'...
[ 5, 15, 16, 19, 20 ]
import os error_msg = '''The default transformer cannot handle slashes (subdirectories); try another transformer in vlermv.transformers.''' def to_path(key): if isinstance(key, tuple): if len(key) == 1: key = key[0] else: raise ValueError(error_msg) if '/' in key or '\...
normal
{ "blob_id": "e4ff6d689a7da5b16786fd59d6a4707b9b6e3e7d", "index": 8076, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef to_path(key):\n if isinstance(key, tuple):\n if len(key) == 1:\n key = key[0]\n else:\n raise ValueError(error_msg)\n if '/' in key or '\...
[ 0, 2, 3, 4, 5 ]
import sys from domain import * from fuzzy_set import * from parser import * class FuzzyControler(object): def __init__(self, angle_rules, acc_rules, domains_angle, domains_acc): self.angle_rules = angle_rules self.acc_rules = acc_rules self.domains_angle = domains_angle self.domains_acc = domains_acc s...
normal
{ "blob_id": "7451b09c54734fb02167d43b96df972420d86853", "index": 7776, "step-1": "import sys\n\nfrom domain import *\nfrom fuzzy_set import *\nfrom parser import *\n\nclass FuzzyControler(object):\n\n\tdef __init__(self, angle_rules, acc_rules, domains_angle, domains_acc):\n\n\t\tself.angle_rules = angle_rules\n...
[ 0 ]
__author__ = 'Administrator' class People: def __init__(self,name,age): self.name = name self.age = age def eat(self): pass print("%s is eating..." % self.name) def sleep(self): print("%s is sleeping..." % self.name) def talk(self): print("%s is talki...
normal
{ "blob_id": "6fdc9b2091652b05d6c1207d2f78b75c880fadda", "index": 9084, "step-1": "<mask token>\n\n\nclass People:\n <mask token>\n\n def eat(self):\n pass\n print('%s is eating...' % self.name)\n <mask token>\n <mask token>\n\n\nclass Man(People):\n\n def __init__(self, name, age, mo...
[ 8, 10, 11, 12, 14 ]
import math_series.series as func """ Testing for fibonacci function """ def test_fibonacci_zero(): actual = func.fibonacci(0) expected = 0 assert actual == expected def test_fibonacci_one(): actual = func.fibonacci(1) expected = 1 assert actual == expected def test_fibonacci_negative():...
normal
{ "blob_id": "49722f640eec02029865fd702e13e485eda6391b", "index": 8126, "step-1": "<mask token>\n\n\ndef test_fibonacci_zero():\n actual = func.fibonacci(0)\n expected = 0\n assert actual == expected\n\n\ndef test_fibonacci_one():\n actual = func.fibonacci(1)\n expected = 1\n assert actual == ex...
[ 8, 9, 11, 13, 14 ]
# -*- coding: utf-8 -*- """ Created on Sat Mar 21 09:46:47 2020 @author: Carlos Jose Munoz """ # se importa el modelo y vista para que sesten comunicados por medio del controlador from Modelo import ventanadentrada from Vista import Ventanainicio,dosventana import sys from PyQt5.QtWidgets import QApplication clas...
normal
{ "blob_id": "3329db63552592aabb751348efc5d983f2cc3f36", "index": 1828, "step-1": "<mask token>\n\n\nclass Controlador(object):\n\n def __init__(self, vista, modelo, vista2):\n self._mi_vista = vista\n self._mi_modelo = modelo\n self._mi2_ventana = vista2\n\n def recibirruta(self, r):\n...
[ 7, 8, 9, 10, 12 ]
# Lahman.py # Convert to/from web native JSON and Python/RDB types. import json # Include Flask packages from flask import Flask from flask import request import copy import SimpleBO # The main program that executes. This call creates an instance of a # class and the constructor starts the runtime. app = Flask(__na...
normal
{ "blob_id": "d03a8076b77851ae4df5cf657ff898eb132c49c3", "index": 5616, "step-1": "<mask token>\n\n\ndef parse_and_print_args():\n fields = None\n in_args = None\n if request.args is not None:\n in_args = dict(copy.copy(request.args))\n fields = copy.copy(in_args.get('fields', None))\n ...
[ 7, 8, 9, 10, 11 ]
# -*- coding: utf-8 -*- # Copyright (c) 2018-2020 Christiaan Frans Rademan <chris@fwiw.co.za>. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the ...
normal
{ "blob_id": "cdbf9427d48f0a5c53b6efe0de7dfea65a8afd83", "index": 87, "step-1": "<mask token>\n\n\ndef request_id():\n global req_c, pid\n if req_c is None:\n req_c = random.randint(1000 * 1000, 1000 * 1000 * 1000)\n if pid is None:\n pid = str(os.getpid())\n req_id = req_c = req_c + 1\n...
[ 1, 2, 3, 4, 5 ]
import pandas as pd import numpy as np from datetime import timedelta import scipy.optimize as optim from scipy import stats import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from gen_utils.gen_io import read_run_params,log_msg ############################################# params = read_run_pa...
normal
{ "blob_id": "dcef5f34a62939d992a109e991552e612bf5bad5", "index": 4619, "step-1": "<mask token>\n\n\ndef my_logistic(x, a, b, c):\n return c / (1 + a * np.exp(-b * x))\n\n\n<mask token>\n", "step-2": "<mask token>\nmatplotlib.use('Agg')\n<mask token>\ndf_mrns.sort_values('COLLECTION_DT', inplace=True)\ndf_mr...
[ 1, 2, 3, 4, 5 ]
"""1) Написать бота-консультанта, который будет собирать информацию с пользователя (его ФИО, номер телефона, почта, адресс, пожелания). Записывать сформированную заявку в БД (по желанию SQl/NOSQL).).""" import telebot from .config import TOKEN from telebot.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeybo...
normal
{ "blob_id": "dcb2351f9489815fbec8694b446d0a93972a6590", "index": 6388, "step-1": "<mask token>\n\n\nclass User(Document):\n surname = StringField(required=True)\n name = StringField(required=True)\n middle_name = StringField(required=True)\n phone = StringField(required=True)\n email = StringField...
[ 10, 12, 13, 14, 16 ]
""" Counted List Create a class for an list like object based on UserList wrapper https://docs.python.org/3/library/collections.html#collections.UserList That object should have a method to return a Counter https://docs.python.org/3/library/collections.html#collections.Counter for all objects in the list Counter should...
normal
{ "blob_id": "1cf4fc37e030a895cb36f537ce9e92df34acfb8b", "index": 7659, "step-1": "<mask token>\n\n\nclass CountedList(UserList):\n\n def Count(self):\n self.cnt = Counter(self.data)\n return self.cnt\n\n def append(self, item):\n super(CountedList, self).append(item)\n global y\...
[ 3, 4, 5, 6, 7 ]
# Copyright (c) 2012, GPy authors (see AUTHORS.txt). # Licensed under the BSD 3-clause license (see LICENSE.txt) import numpy as np import pylab as pb from .. import kern from ..core import model from ..util.linalg import pdinv,mdot from ..util.plot import gpplot,x_frame1D,x_frame2D, Tango from ..likelihoods import E...
normal
{ "blob_id": "2ae953d1d53c47da10ea4c8aace186eba0708ad0", "index": 3874, "step-1": "# Copyright (c) 2012, GPy authors (see AUTHORS.txt).\n# Licensed under the BSD 3-clause license (see LICENSE.txt)\n\n\nimport numpy as np\nimport pylab as pb\nfrom .. import kern\nfrom ..core import model\nfrom ..util.linalg import...
[ 0 ]
# Generated by Django 2.2.16 on 2020-11-04 12:48 import ckeditor_uploader.fields from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('course', '0002_auto_20201103_1648'), ] operations = [ migrations.AddField( model_name='course',...
normal
{ "blob_id": "afacc2c54584c070963c4cb3cabbae64bb0e3159", "index": 1858, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('course', '0...
[ 0, 1, 2, 3, 4 ]
## Filename: name.py # Author: Marcelo Feitoza Parisi # # Description: Report the objects # on the bucket sorted by name. # # ########################### # # DISCLAIMER - IMPORTANT! # # ########################### # # Stuff found here was built as a # Proof-Of-Concept or Study material # and should not b...
normal
{ "blob_id": "562b2c3567e42699cfd0804a5780af7ede142e13", "index": 1056, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef exec(bucket_id, project_id, reverse_opt):\n client = storage.Client()\n bucket = client.bucket(bucket_id, user_project=project_id)\n blobs = bucket.list_blobs()\n blob...
[ 0, 1, 2, 3 ]
from django.db import models # Create your models here. class Position(models.Model): title = models.CharField(max_length=50) def __str__(self): return self.title class Employee(models.Model): nom = models.CharField(max_length=100) prenom = models.CharField(max_length=100) age= models.Cha...
normal
{ "blob_id": "5ab20c1cd2dc0d0ad881ee52008d00c2317084f9", "index": 5308, "step-1": "<mask token>\n\n\nclass Position(models.Model):\n <mask token>\n <mask token>\n\n\nclass Employee(models.Model):\n nom = models.CharField(max_length=100)\n prenom = models.CharField(max_length=100)\n age = models.Cha...
[ 5, 6, 7, 8, 9 ]
import os path = r'D:\python\风变编程\python基础-山顶班\fb_16' path1 = 'test_01' path2 = 'fb_csv-01-获取网页内容.py' print(os.getcwd()) # 返回当前工作目录 print(os.listdir(path)) # 返回path指定的文件夹包含的文件或文件夹的名字的列表 #print(os.mkdir(path1)) # 创建文件夹 print(os.path.abspath(path)) # 返回绝对路径 print(os.path.basename(path)) # 返回文件名 print(os.path.isfi...
normal
{ "blob_id": "c01ea897cd64b3910531babe9fce8c61b750185d", "index": 7912, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(os.getcwd())\nprint(os.listdir(path))\nprint(os.path.abspath(path))\nprint(os.path.basename(path))\nprint(os.path.isfile(path2))\nprint(os.path.isdir(path1))\n", "step-3": "<mask ...
[ 0, 1, 2, 3, 4 ]
import matplotlib.pyplot as plt w1 = [(1, 2, 7), (1, 8, 1), (1, 7, 5), (1, 6, 3), (1, 7, 8), (1, 5, 9), (1, 4, 5)] w2 = [(-1, -4, -2), (-1, 1, 1), (-1, -1, -3), (-1, -3, 2), (-1, -5, -3.25), (-1, -2, -4), (-1, -7, -1)] dataset = [(1, 2, 7), (1, 8, 1), (1, 7, 5), (1, 6, 3)...
normal
{ "blob_id": "15105e22b3c1860735f282a2247ab41b138d75cf", "index": 3452, "step-1": "import matplotlib.pyplot as plt\n\nw1 = [(1, 2, 7), (1, 8, 1),\n (1, 7, 5), (1, 6, 3),\n (1, 7, 8), (1, 5, 9),\n (1, 4, 5)]\nw2 = [(-1, -4, -2), (-1, 1, 1),\n (-1, -1, -3), (-1, -3, 2),\n (-1, -5, -3.25), (...
[ 0 ]
import time from bitfinex_trade_client import BitfinexClient,BitfinexTradeClient KEY = "nBi8YyJZZ9ZhSOf2jEpMAoBpzKt2Shh6IoLdTjFRYvb" SECRET = "XO6FUYbhFYqBflXYSaKMiu1hGHLhGf63xsOK0Pf7osA" class EMA: def __init__(self, duration): self.value = 0 self.duration = duration self.count = 0 ...
normal
{ "blob_id": "6abfd6c0a644356ae0bc75d62472b5c495118a8e", "index": 4466, "step-1": "<mask token>\n\n\nclass BitfinexMMTrader:\n <mask token>\n\n def get_fees(self):\n account_info = self.trade_client.account_info()\n return float(account_info[0]['maker_fees'])\n\n def get_pnl(self):\n ...
[ 11, 16, 20, 21, 22 ]
import socket import time class FileTransProgram(object): def __init__(self, ADDR, file_name): self.ADDR = ADDR self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect(ADDR) self.file_name = file_name def recv(self): self.sock.send(bytes("Connec...
normal
{ "blob_id": "231a07e63e40f2e4d204cde76c52e64b922da1b8", "index": 2619, "step-1": "<mask token>\n\n\nclass FileTransProgram(object):\n\n def __init__(self, ADDR, file_name):\n self.ADDR = ADDR\n self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.sock.connect(ADDR)\n ...
[ 2, 4, 5, 6, 7 ]
# Generated by Django 3.0.7 on 2020-07-05 07:34 from django.db import migrations, models import location_field.models.plain class Migration(migrations.Migration): dependencies = [ ('driver', '0001_initial'), ] operations = [ migrations.RemoveField( model_name='driver', ...
normal
{ "blob_id": "ea918bdf96572b38461dc1810bd0b8c16efd0f0d", "index": 5786, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('driver', '0...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.0.5 on 2020-04-25 12:29 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('api', '0006_order_date'), ] operations = [ migrations.RemoveField( model_name='order', name='product', ), ...
normal
{ "blob_id": "4cc138016cb1f82e12c76c185be19188d3e38bf9", "index": 2186, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('api', '0006...
[ 0, 1, 2, 3, 4 ]
import pandas as pd from scipy.stats import shapiro import scipy.stats as stats df_test = pd.read_excel("datasets/ab_testing_data.xlsx", sheet_name="Test Group") df_control = pd.read_excel("datasets/ab_testing_data.xlsx", sheet_name="Control Group") df_test.head() df_control.head() df_control.info() df_te...
normal
{ "blob_id": "9e01ba8c489791ec35b86dffe12d0cedb5f09004", "index": 3919, "step-1": "<mask token>\n\n\ndef outlier_thresholds(dataframe, variable, low_quantile=0.05, up_quantile=0.95\n ):\n quantile_one = dataframe[variable].quantile(low_quantile)\n quantile_three = dataframe[variable].quantile(up_quantile...
[ 2, 3, 4, 5, 6 ]
from tasks import video_compress, video_upload if __name__ == '__main__': video_compress.apply_async(["a"],queue='high') video_compress.apply_async(["b"],queue='low') video_upload.apply_async(["c"], queue='low') video_upload.apply_async(["d"], queue='high')
normal
{ "blob_id": "2cd7d4fe87de66e85bc0d060e2eaa68be39eed02", "index": 9461, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n video_compress.apply_async(['a'], queue='high')\n video_compress.apply_async(['b'], queue='low')\n video_upload.apply_async(['c'], queue='low')\n ...
[ 0, 1, 2, 3 ]
from flask_opencv_streamer.streamer import Streamer import cv2 import numpy as np MASK = np.array([ [0, 1, 0], [1, -4, 1], [0, 1, 0] ]) port = 3030 require_login = False streamer = Streamer(port, require_login) video_capture = cv2.VideoCapture('http://149.43.156.105/mjpg/video.mjpg') whi...
normal
{ "blob_id": "a19b4928c9423dae6c60f39dbc5af0673b433c8e", "index": 3551, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n _, frame = video_capture.read()\n frame = cv2.medianBlur(frame, 3)\n frame = cv2.filter2D(frame, -1, MASK)\n _, frame = cv2.threshold(frame, 10, 255, cv2.THRESH_...
[ 0, 1, 2, 3, 4 ]
# ????? c=0 for i in range(12): if 'r' in input(): c+=1 # ?? print(c)
normal
{ "blob_id": "294b0dc7587ecd37887591da5a1afe96a4349f6b", "index": 8711, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(12):\n if 'r' in input():\n c += 1\nprint(c)\n", "step-3": "c = 0\nfor i in range(12):\n if 'r' in input():\n c += 1\nprint(c)\n", "step-4": "# ????...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 import sys import os import math import random if hasattr(sys, '__interactivehook__'): del sys.__interactivehook__ print('Python3 startup file loaded from ~/.config/pystartup.py')
normal
{ "blob_id": "5ddde3aa6eaa30b70743272a532874663067eed6", "index": 3157, "step-1": "<mask token>\n", "step-2": "<mask token>\nif hasattr(sys, '__interactivehook__'):\n del sys.__interactivehook__\nprint('Python3 startup file loaded from ~/.config/pystartup.py')\n", "step-3": "import sys\nimport os\nimport m...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # # compare-sorts.py # Copyright (c) 2017 Dylan Brown. All rights reserved. # # Use Python 3. Run from within the scripts/ directory. import os import sys import re import subprocess # Ensure we don't silently fail by running Python 2. assert sys.version_info[0] >= 3, "This script requires P...
normal
{ "blob_id": "501d50fa933f55c178b4b2eba6cfc5b85592beaa", "index": 8473, "step-1": "<mask token>\n\n\ndef main():\n sorts = ['selection-sort', 'insertion-sort', 'shell-sort']\n for sort in sorts:\n exe_path = './build/{}'.format(sort.rstrip())\n if not os.path.isfile(exe_path):\n rai...
[ 1, 2, 3, 4, 5 ]
from flask_wtf import FlaskForm from wtforms import StringField, PasswordField, SubmitField from wtforms.validators import InputRequired, Length, EqualTo, ValidationError from passlib.hash import pbkdf2_sha256 from models import User def invalid_credentials(form, field): ''' Username and password checker ''' userna...
normal
{ "blob_id": "623bd858923d5f9cc109af586fdda01cd3d5fff3", "index": 961, "step-1": "<mask token>\n\n\nclass CreateRoomForm(FlaskForm):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass CreateUsernameForm(FlaskForm):\n username = StringField('username', validators=[InputRequired(message=\n '...
[ 10, 11, 13, 14, 16 ]
import boto3 import os from trustedadvisor import authenticate_support accountnumber = os.environ['Account_Number'] rolename = os.environ['Role_Name'] rolesession = accountnumber + rolename def lambda_handler(event, context): sts_client = boto3.client('sts') assumerole = sts_client.assume_role( Role...
normal
{ "blob_id": "539431649e54469ddbe44fdbd17031b4449abdd9", "index": 5867, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lambda_handler(event, context):\n sts_client = boto3.client('sts')\n assumerole = sts_client.assume_role(RoleArn='arn:aws:iam::' +\n accountnumber + ':role/' + rolena...
[ 0, 1, 2, 3, 4 ]
from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User from . import models class RegisterForm(UserCreationForm): email = forms.EmailField(required=True) class Meta: model = User fields = ("username", "email", "password1", "...
normal
{ "blob_id": "503726cd2d70286189f4b8e02acaa3d5f6e29e12", "index": 8538, "step-1": "<mask token>\n\n\nclass ChangeEmail(forms.Form):\n <mask token>\n\n\nclass ChangePassword(forms.Form):\n oldPassword = forms.CharField(required=True, min_length=8, max_length=\n 80, widget=forms.PasswordInput(attrs={'n...
[ 3, 5, 6, 7, 8 ]
#!/usr/bin/python2 import md5 from pwn import * import time LIMIT = 500 TARGET = "shell2017.picoctf.com" PORT = 46290 FILE = "hash.txt" def generate_hashes(seed): a = [] current_hash = seed for i in range(1000): current_hash = md5.new(current_hash).hexdigest() a.append(current_hash)...
normal
{ "blob_id": "5e78992df94cbbe441495b7d8fb80104ec000748", "index": 6728, "step-1": "<mask token>\n\n\ndef generate_hashes(seed):\n a = []\n current_hash = seed\n for i in range(1000):\n current_hash = md5.new(current_hash).hexdigest()\n a.append(current_hash)\n return a\n\n\ndef find_prev...
[ 5, 7, 9, 10, 11 ]
from turtle import * from shapes import * #1- #1.triangle def eTriangle(): forward(100) right(120) forward(100) right(120) forward(100) right(120) mainloop() #2.square def square(): forward(100) right(90) forward(100) right(90) forward(100) right(90) forwa...
normal
{ "blob_id": "92d689e5caa2d8c65f86af0f8b49b009d162a783", "index": 7379, "step-1": "<mask token>\n\n\ndef square():\n forward(100)\n right(90)\n forward(100)\n right(90)\n forward(100)\n right(90)\n forward(100)\n mainloop()\n\n\ndef pentagon():\n forward(100)\n right(72)\n forward...
[ 8, 10, 12, 14, 20 ]
"""Test the various means of instantiating and invoking filters.""" import types import test test.prefer_parent_path() import cherrypy from cherrypy import filters from cherrypy.filters.basefilter import BaseFilter class AccessFilter(BaseFilter): def before_request_body(self): if not cherrypy.confi...
normal
{ "blob_id": "8a412231c13df1b364b6e2a27549730d06048186", "index": 9978, "step-1": "<mask token>\n\n\nclass AccessFilter(BaseFilter):\n <mask token>\n\n\n<mask token>\n\n\nclass FilterTests(helper.CPWebCase):\n\n def testCPFilterList(self):\n self.getPage('/cpfilterlist/')\n self.assertBody('A ...
[ 4, 5, 7, 8, 9 ]
# -*- coding: utf-8 -*- """Test custom node separator.""" import six from helper import assert_raises, eq_ import anytree as at class MyNode(at.Node): separator = "|" def test_render(): """Render string cast.""" root = MyNode("root") s0 = MyNode("sub0", parent=root) MyNode("sub0B", parent=s0)...
normal
{ "blob_id": "a430b4629ee06dbfb267f839599383624e37451e", "index": 4582, "step-1": "<mask token>\n\n\nclass MyNode(at.Node):\n separator = '|'\n\n\ndef test_render():\n \"\"\"Render string cast.\"\"\"\n root = MyNode('root')\n s0 = MyNode('sub0', parent=root)\n MyNode('sub0B', parent=s0)\n MyNode...
[ 3, 4, 5, 6, 7 ]
from .base import BaseEngine import re class YandexSearch(BaseEngine): base_url = "https://yandex.com" search_url = "https://yandex.com/search/" def get_params(self, query, **params): params["text"] = query params["p"] = None return params def next_url(self, soup): if...
normal
{ "blob_id": "0ec3ca0f952dbc09c7a7a3e746c0aeab28ee9834", "index": 6498, "step-1": "<mask token>\n\n\nclass YandexSearch(BaseEngine):\n <mask token>\n <mask token>\n <mask token>\n\n def next_url(self, soup):\n if (regex := re.findall('\"(/search/\\\\?[^>]+p=[^\"]+)', str(soup))):\n r...
[ 4, 5, 6, 7, 8 ]
#Web Scraping #Make sure you have bs4, webbrowser and request installed as your third party modules import bs4, webbrowser, requests try: data = requests.get("http://en.wikipedia.org/wiki/Python") data.raise_for_status() my_data = bs4.BeautifulSoup(data.text, "lxml") print("List o...
normal
{ "blob_id": "27e9635adf6109f3ab13b9d8dd5809973b61ca03", "index": 413, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n data = requests.get('http://en.wikipedia.org/wiki/Python')\n data.raise_for_status()\n my_data = bs4.BeautifulSoup(data.text, 'lxml')\n print('List of all the header tag...
[ 0, 1, 2, 3 ]
from __future__ import unicode_literals import abc import logging import six import semantic_version from lymph.utils import observables, hash_id from lymph.core.versioning import compatible, serialize_version logger = logging.getLogger(__name__) # Event types propagated by Service when instances change. ADDED = '...
normal
{ "blob_id": "ba41f2a564f46032dbf72f7d17b2ea6deaa81b10", "index": 4332, "step-1": "<mask token>\n\n\nclass Service(InstanceSet):\n <mask token>\n\n def __str__(self):\n return self.name\n\n def __iter__(self):\n return six.itervalues(self.instances)\n\n def __len__(self):\n return...
[ 12, 18, 20, 22, 26 ]
import os, sys import json import paramiko """ Copies the credentials.json file locally from robot """ def copy_credentials_file(hostname, username, password, src_path, dst_path): # create ssh connection ssh_client = paramiko.SSHClient() ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_client....
normal
{ "blob_id": "27f162f2e350fdb284740bd67f4293535f0ab593", "index": 8451, "step-1": "<mask token>\n\n\ndef copy_credentials_file(hostname, username, password, src_path, dst_path):\n ssh_client = paramiko.SSHClient()\n ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())\n ssh_client.connect(hos...
[ 3, 4, 5, 6, 7 ]
from OpenSSL import SSL, crypto from twisted.internet import ssl, reactor from twisted.internet.protocol import Factory, Protocol import os from time import time class Echo(Protocol): def dataReceived(self, data): print "Data received: " + data # define cases options = { "gen...
normal
{ "blob_id": "9951588f581c5045154a77535b36d230d586d8a5", "index": 338, "step-1": "from OpenSSL import SSL, crypto\nfrom twisted.internet import ssl, reactor\nfrom twisted.internet.protocol import Factory, Protocol\n\nimport os\nfrom time import time\n\nclass Echo(Protocol):\n\n def dataReceived(self, data):\n ...
[ 0 ]
# Generated by Django 3.0.4 on 2020-03-11 17:48 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('core', '0003_auto_20200310_1620'), ] operations = [ migrations.AddField( model_name='tag', name='name', ...
normal
{ "blob_id": "ab12468b1da20c896e3578091fd9ba245dcfa0a4", "index": 1350, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('core', '000...
[ 0, 1, 2, 3, 4 ]
"""Plot the output data. """ # Standard library import os import json import math import matplotlib as maplot import matplotlib.pyplot as pyplot from datetime import datetime # User library from sub.inputprocess import CONSTANTS as CONS # **json.loads(json_data) def get_data(): """Read output file to get data."...
normal
{ "blob_id": "f4f08015b7638f4d6ea793350d5d19a3485978cd", "index": 53, "step-1": "<mask token>\n\n\ndef get_objectives(data):\n \"\"\"Get a list of all first chromosomes' objective values.\"\"\"\n objectives = [math.log(population[0]['objective']) for population in data]\n return objectives\n\n\ndef get_n...
[ 2, 4, 5, 6, 7 ]
import os import time from datetime import datetime from typing import List, Tuple from pyspark.sql import SparkSession from Chapter01.utilities01_py.helper_python import create_session from Chapter02.utilities02_py.domain_objects import WarcRecord from Chapter02.utilities02_py.helper_python import extract_raw_records,...
normal
{ "blob_id": "fccdf75fe83ad8388c12a63555c4132181fd349a", "index": 1646, "step-1": "<mask token>\n\n\ndef fall_asleep(record: WarcRecord):\n current_uri: str = record.target_uri\n start_time = str(datetime.now())\n process_id = str(os.getpid())\n print('@@1 falling asleep in process {} at {} processing...
[ 2, 3, 4, 5, 6 ]
# Copyright (c) 2020 Hai Nguyen # # This software is released under the MIT License. # https://opensource.org/licenses/MIT import tensorflow.keras.backend as K def dice_coef(y_true, y_pred): smooth = 1. y_true_f = K.flatten(y_true) y_pred_f = K.flatten(y_pred) intersection = K.sum(y_true_f * y_pred_...
normal
{ "blob_id": "18b10a68b2707b7bfeccbd31c5d15686453b3406", "index": 6253, "step-1": "<mask token>\n\n\ndef false_pos(y_true, y_pred):\n smooth = 1\n y_pred_pos = K.round(K.clip(y_pred, 0, 1))\n y_pos = K.round(K.clip(y_true, 0, 1))\n y_neg = 1 - y_pos\n fp = K.sum(y_neg * y_pred_pos)\n fp_ratio = ...
[ 1, 3, 4, 5, 6 ]
# Code Rodrigo ''' This script, basically generates all he possible combinations to be analyzed according to the Dempster Shafer Theory. It requires to define beforehand, the combination of variables that lead to the higher and lower bound for a given combination of random sets, via the sensitivity analysis ''' impo...
normal
{ "blob_id": "4b44f4343da1677b5436ec2b153e573fda3c0cee", "index": 2280, "step-1": "<mask token>\n\n\ndef read_input_RS():\n low = np.loadtxt('LowerArray.csv', delimiter=',', skiprows=1)\n lower_bound = np.ravel(low)\n upper_bound = np.ravel(np.transpose(np.loadtxt('UpperArray.csv',\n delimiter=','...
[ 2, 3, 4, 5, 6 ]
from collections import deque class Queue: def __init__(self): self.container = deque() def enqueue(self, data): self.container.appendleft(data) def dequeue(self): return self.container.pop() def is_empty(self): return len(self.container) == 0 def size(self): ...
normal
{ "blob_id": "2898506b9fd5b112f93a1ff6b010848244c398bd", "index": 7197, "step-1": "<mask token>\n\n\nclass Queue:\n\n def __init__(self):\n self.container = deque()\n\n def enqueue(self, data):\n self.container.appendleft(data)\n\n def dequeue(self):\n return self.container.pop()\n\n...
[ 6, 7, 8, 9, 11 ]
from gamesim import GameSim from network import Network from player import RemotePlayer from mutator import Mutator from random import * import copy game = GameSim() game.make_players(10) base = "networks/" dir = "" name = "203964_85377" gens = 2000 game.players[0].import_player(base + dir + name + ".network") game...
normal
{ "blob_id": "1aace7b9385aefdc503ce0e43e0f7f0996fe112a", "index": 4284, "step-1": "<mask token>\n", "step-2": "<mask token>\ngame.make_players(10)\n<mask token>\ngame.players[0].import_player(base + dir + name + '.network')\ngame.train(gens)\nif gens % 500 != 0:\n game.players[0].export_player()\n", "step-...
[ 0, 1, 2, 3, 4 ]
from tkinter.ttk import * from tkinter import * import tkinter.ttk as ttk from tkinter import messagebox import sqlite3 root = Tk() root.title('Register-Form') root.geometry("600x450+-2+86") root.minsize(120, 1) def delete(): if(Entry1.get()==''): messagebox.showerror('Register-Form', 'ID Is compolsary fo...
normal
{ "blob_id": "37cafe5d3d3342e5e4070b87caf0cfb5bcfdfd8d", "index": 1613, "step-1": "<mask token>\n\n\ndef sign_in():\n root.destroy()\n import main\n\n\n<mask token>\n", "step-2": "<mask token>\nroot.title('Register-Form')\nroot.geometry('600x450+-2+86')\nroot.minsize(120, 1)\n\n\ndef delete():\n if Ent...
[ 1, 4, 5, 6, 7 ]
# Feito por Kelvin Schneider #12 numero = input("Digite um numero de telefone: ") numero = numero.replace("-","") if (len(numero) < 8): while len(numero) < 8: numero = "3" + numero numero = numero[:4] + "-" + numero[4:] print("Numero: ", numero) elif (len(numero) > 8): print("Numero invalido...
normal
{ "blob_id": "6297256bce1954f041915a1ce0aa0546689850f3", "index": 2256, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(numero) < 8:\n while len(numero) < 8:\n numero = '3' + numero\n numero = numero[:4] + '-' + numero[4:]\n print('Numero: ', numero)\nelif len(numero) > 8:\n print...
[ 0, 1, 2, 3 ]
from googleAPI.drive import * class GoogleSheet(GoogleDrive): """ The base class of Google Sheet API. It aims at dealing with the Google Sheet data extract and append. It is not tied to a specific spreadsheet. This class is powered by pandas. Thus, make sure the data in the spreadshe...
normal
{ "blob_id": "9e793bd0faef65dfe8ac4b722e50d2055837449f", "index": 4701, "step-1": "<mask token>\n\n\nclass GoogleSheet(GoogleDrive):\n <mask token>\n <mask token>\n\n def create_spreadsheet(self, spreadsheet_name: str):\n \"\"\"\n Creates a spreadsheet, returning the newly created spreadshe...
[ 4, 8, 10, 12, 13 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.10 on 2018-08-03 10:25 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Proce...
normal
{ "blob_id": "f15ce7cec032ace65604771fa56e3d9969c98209", "index": 1964, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
import cv2 import numpy as np # THRESHOLDING FUNCTION IMPLEMENTATION def thresholding(img): # visualizing image in HSV parameters imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # the values for lowerWhite and upperWhite are found by tweaking the HSV min/max params in the # trackbar by running ColorPick...
normal
{ "blob_id": "44175d2559f9c7d6171b6e45d24719d50dc80fb7", "index": 7221, "step-1": "<mask token>\n\n\ndef thresholding(img):\n imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)\n lowerWhite = np.array([80, 0, 0])\n upperWhite = np.array([255, 160, 255])\n maskWhite = cv2.inRange(imgHSV, lowerWhite, upperWh...
[ 4, 7, 8, 9, 10 ]
import os, pygame import sys from os import path from random import choice WIDTH = 1000 HEIGHT = 800 FPS = 60 BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) GRAY80 = (204, 204, 204) GRAY = (26, 26, 26) screen = pygame.disp...
normal
{ "blob_id": "7301a521586049ebb5e8e49b604cc96e3acc1fe9", "index": 3512, "step-1": "<mask token>\n\n\ndef draw_text(surf, text, size, x, y):\n font_name = pygame.font.match_font('OCR A Extended')\n font = pygame.font.Font(font_name, size)\n text_surface = font.render(text, True, WHITE)\n text_rect = te...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- from celery import shared_task from djcelery.models import PeriodicTask, CrontabSchedule import datetime from django.db.models import Max, Count from services import * # 测试任务 @shared_task() def excute_sql(x,y): print "%d * %d = %d" % (x, y, x * y) return x * y # 监控任务:查询数据库并进行告警 @sha...
normal
{ "blob_id": "6f259210cbe8969046cba1031ab42d77e913abea", "index": 6265, "step-1": "# -*- coding: utf-8 -*-\nfrom celery import shared_task\nfrom djcelery.models import PeriodicTask, CrontabSchedule\nimport datetime\nfrom django.db.models import Max, Count\n\nfrom services import *\n\n\n# 测试任务\n@shared_task()\ndef...
[ 0 ]
# -*- coding: utf-8 -*- """ plastiqpublicapi This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). """ import json import dateutil.parser from tests.controllers.controller_test_base import ControllerTestBase from tests.test_helper import TestHelper from tests.http_respon...
normal
{ "blob_id": "a4f2418e746cc43bd407b6a212de9802044351e1", "index": 3928, "step-1": "<mask token>\n\n\nclass CategoriesControllerTests(ControllerTestBase):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass CategoriesControllerTests(ControllerTestBase):\n\n @classmethod\n def setUpCl...
[ 1, 2, 3, 4, 5 ]
a = int(input("Enter no. of over: ")) print("total ball:",a*6 ) import random comp_runs = random.randint(0,36) print("computer's run:" ,comp_runs) comp_runs = comp_runs+1 print("runs need to win:",comp_runs) chances_1 = a*6 no_of_chances_1 = 0 your_runs = 0 print("-----------------------------------------...
normal
{ "blob_id": "00312f57e8a78444937f46cecb62a2b684b4fc91", "index": 8779, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('total ball:', a * 6)\n<mask token>\nprint(\"computer's run:\", comp_runs)\n<mask token>\nprint('runs need to win:', comp_runs)\n<mask token>\nprint(\"\"\"--------------------------...
[ 0, 1, 2, 3, 4 ]
import tensorflow as tf import keras import numpy as np def house_model(y_new): xs = np.array([0, 1, 2, 4, 6, 8, 10], dtype=float) # Your Code Here# ys = np.array([0.50, 0.100, 1.50, 2.50, 3.50, 4.50, 5.50], dtype=float) # Your Code Here# model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape...
normal
{ "blob_id": "0b3f16ee9b287c6c77acde674abec9deb4053c83", "index": 946, "step-1": "<mask token>\n\n\ndef house_model(y_new):\n xs = np.array([0, 1, 2, 4, 6, 8, 10], dtype=float)\n ys = np.array([0.5, 0.1, 1.5, 2.5, 3.5, 4.5, 5.5], dtype=float)\n model = tf.keras.Sequential([keras.layers.Dense(units=1, inp...
[ 1, 2, 3, 4, 5 ]
from flask import Flask, abort, url_for, render_template, request app = Flask(__name__) @app.route('/') def index(): return render_template('login.html') # #redirect demo # @app.route('/login', methods=['POST', 'GET']) # def login(): # if request.method == 'POST' and request.form['username'] == 'admin': # ...
normal
{ "blob_id": "82f8bfd95fea3025bed2b4583c20526b0bd5484f", "index": 3535, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('login.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('login.html')\n\n\n@app.route(...
[ 1, 3, 4, 5, 6 ]