code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
# coding: utf-8
# Copyright 2020. ThingsBoard
# #
# 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
# #
# Unl... | normal | {
"blob_id": "9b30075183cf9611307afa74aa45979872e7e9d5",
"index": 8132,
"step-1": "<mask token>\n\n\nclass DeviceControllerApi(DeviceControllerApi):\n <mask token>\n <mask token>\n\n def claim_device_using_post(self, device_name, **kwargs):\n \"\"\"claimDevice # noqa: E501\n\n This method ... | [
10,
11,
13,
14,
17
] |
class Area :
def circle(self):
rad = int(input("Enter the radius:"))
area = (22/7)*(rad**2)
print("Area is :" , area , "cm square")
def square(self):
side = int(input("Enter the length of a side:"))
area = side**2
print("Area is :" , area , "cm s... | normal | {
"blob_id": "4f36c7e98c54d38aaef9f2ebdafd0c34a157fcd7",
"index": 8268,
"step-1": "class Area:\n <mask token>\n\n def square(self):\n side = int(input('Enter the length of a side:'))\n area = side ** 2\n print('Area is :', area, 'cm square')\n\n def rect(self):\n print('Enter ... | [
4,
5,
6,
8,
10
] |
import os
import pubmed_parser as pp
nlpPath = "/Users/kapmayn/Desktop/nlp"
articlesFolderPath = nlpPath + "/articles"
abstractsFilePath = nlpPath + "/abstracts.txt"
articlesFileNameList = os.listdir(articlesFolderPath)
articlesFileNameList(reverse = True)
resultFile = open(abstractsFilePath, 'w')
for fileName in ar... | normal | {
"blob_id": "32f9b5c32acbb6411fe6ab99616d8459acfd7c74",
"index": 719,
"step-1": "<mask token>\n",
"step-2": "<mask token>\narticlesFileNameList(reverse=True)\n<mask token>\nfor fileName in articlesFileNameList:\n print(fileName)\n dictOut = pp.parse_medline_xml(articlesFolderPath + '/' + fileName)\n f... | [
0,
1,
2,
3,
4
] |
from pymongo import MongoClient
from datetime import datetime
import sys
import requests
import urllib
import json
import xml.etree.ElementTree as ET
import xmltodict
import pandas
from lxml import etree
from bson.json_util import dumps
bornTables = pandas.read_html("http://statis.moi.gov.tw/micst/stmain.jsp?sys=220&y... | normal | {
"blob_id": "7deaee28674c465694c348c21e87addbcc8ea923",
"index": 8237,
"step-1": "from pymongo import MongoClient\nfrom datetime import datetime\nimport sys\nimport requests\nimport urllib\nimport json\nimport xml.etree.ElementTree as ET\nimport xmltodict\nimport pandas\nfrom lxml import etree\nfrom bson.json_ut... | [
0
] |
import giraffe.configuration.common_testing_artifactrs as commons
from giraffe.business_logic.ingestion_manger import IngestionManager
from redis import Redis
def test_parse_redis_key(config_helper, ingestion_manager):
im = ingestion_manager
job_name = config_helper.nodes_ingestion_operation
operation = c... | normal | {
"blob_id": "13451352e8dcdfe64771f9fc188b13a31b8109f5",
"index": 4555,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_parse_redis_key(config_helper, ingestion_manager):\n im = ingestion_manager\n job_name = config_helper.nodes_ingestion_operation\n operation = config_helper.nodes_in... | [
0,
2,
3,
4,
5
] |
'''
The MIT License (MIT)
Copyright (c) 2016 WavyCloud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, p... | normal | {
"blob_id": "1947bd280234189ed35277c449cd708a204ea7a4",
"index": 6651,
"step-1": "<mask token>\n\n\ndef create_backup(ServerName=None, Description=None):\n \"\"\"\n Creates an application-level backup of a server. While the server is BACKING_UP , the server can not be modified and no additional backup can ... | [
11,
12,
16,
19,
20
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
from tp_global import *
from cgibase import cgibase
from tp_mongodb import *
import json
import requests
class Ccase_model(cgibase):
def __init__(self):
return cgibase.__init__(self)
def onInit(self):
cgibase.SetNoCheckCookie(self)
opr = cgiba... | normal | {
"blob_id": "5282e9a9e87fd7fd6053f816048f371fbe190046",
"index": 5650,
"step-1": "<mask token>\n\n\nclass Ccase_model(cgibase):\n\n def __init__(self):\n return cgibase.__init__(self)\n <mask token>\n\n def cmadd(self):\n self.log.debug('cmadd in.')\n req = self.input['input']\n ... | [
6,
9,
10,
11,
13
] |
import sys
import datetime
training = False if (sys.argv[1]=='0') else True
def read_file(filename):
with open(filename) as f:
aux = [str(x) for x in f.readline().split()]
array = []
for line in f: # read rest of lines
s=line.split()
array2=[s[0]] + [float(x) for x in s[1:]]
ar... | normal | {
"blob_id": "dd4892c5a0b675d1c97fb91a5ca8115801a2bbca",
"index": 9034,
"step-1": "\nimport sys\nimport datetime\n\ntraining = False if (sys.argv[1]=='0') else True\n\ndef read_file(filename):\n\n with open(filename) as f:\n aux = [str(x) for x in f.readline().split()]\n array = []\n for line in f: # re... | [
0
] |
from . import views
from django.urls import path, re_path
app_name = "blogs"
urlpatterns = [
path('', views.index, name='index'),
re_path(r'^blogs/(?P<blog_id>\d+)/$', views.blog, name='blog'),
path('new_blog/', views.new_blog, name='new_blog'),
re_path(r'^edit_blog/(?P<blog_id>\d+)/$', views.edit_blog, name='edit_bl... | normal | {
"blob_id": "d73491d6673abdabad85176c5f75a191995c806d",
"index": 1260,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp_name = 'blogs'\nurlpatterns = [path('', views.index, name='index'), re_path(\n '^blogs/(?P<blog_id>\\\\d+)/$', views.blog, name='blog'), path(\n 'new_blog/', views.new_blog, nam... | [
0,
1,
2,
3
] |
processed_lines = []
for line in open('9.in'):
if line:
processing_pattern = False
new_line = ''
for idx, char in enumerate(line):
pattern_found = False
if line[idx] == '(' and line[idx + 1].isnumeric() and line[idx + 2
] == 'x' and line[idx + 3].isnum... | normal | {
"blob_id": "3605f46da25eb98767ca8d7248beaa07572d3171",
"index": 644,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in open('9.in'):\n if line:\n processing_pattern = False\n new_line = ''\n for idx, char in enumerate(line):\n pattern_found = False\n ... | [
0,
1,
2
] |
short_train <- read.csv('short_train.csv', header=TRUE)
#delete unnecessary columns
short_train[1] <- NULL
#remove ngrams containing @user_
regexp <- "@[a-zA-Z0-9_]*"
gsubtry <- gsub(pattern = regexp, replacement = "", x = short_train$Tweet)
#merge gsubtry back into short_train, rename as Tweet
short_train_clean <- ... | normal | {
"blob_id": "48a970b35aa7fd677828f5d7bd5f1dcf24511b01",
"index": 9098,
"step-1": "short_train <- read.csv('short_train.csv', header=TRUE)\n\n#delete unnecessary columns\nshort_train[1] <- NULL\n\n#remove ngrams containing @user_\nregexp <- \"@[a-zA-Z0-9_]*\"\ngsubtry <- gsub(pattern = regexp, replacement = \"\",... | [
0
] |
#!/usr/bin/env python3
"""Initiates connection to AWSIoT and provides helper functions
deviceshadowhandler.py
by Darren Dunford
"""
import json
import logging
import queue
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTShadowClient
LOGGER = logging.getLogger(__name__)
class DeviceShadowHandler:
def status_pos... | normal | {
"blob_id": "a6d409b806dbd1e174cac65a26c5e8106a8b93ea",
"index": 3760,
"step-1": "<mask token>\n\n\nclass DeviceShadowHandler:\n\n def status_post(self, status, state=None):\n \"\"\"Post status message and device state to AWSIoT and LOGGER\n\n :param status: status string\n :param state: ... | [
6,
8,
9,
10,
12
] |
# coding: utf-8
#ack program with the ackermann_function
""" ackermann_function """
def ack(m,n):
#n+1 if m = 0
if m is 0:
return n + 1
#A(m−1, 1) if m > 0 and n = 0
if m > 0 and n is 0:
return ack(m-1, 1)
#A(m−1, A(m, n−1)) if m > 0 and n > 0
if m > 0 and n > 0:
re... | normal | {
"blob_id": "0ecd2a298203365b20b2369a99c3c1d7c0646f19",
"index": 34,
"step-1": "# coding: utf-8\n#ack program with the ackermann_function\n\n\"\"\" ackermann_function \"\"\"\ndef ack(m,n):\n #n+1 if m = 0\n if m is 0:\n \treturn n + 1\n #A(m−1, 1) if m > 0 and n = 0 \n if m > 0 and n is 0:... | [
0
] |
file = open('thegazelle.wordpress.2016-06-22.xml', 'r')
text = file.read()
authors = []
start = text.find("<wp:author_display_name>")
length = len("<wp:author_display_name>")
end = text.find("</wp:author_display_name")
authors.append(text[start+length+len("<![CDATA["):end-len("]]>")])
while text.find("<wp:author_displa... | normal | {
"blob_id": "cf5062c999c6c29f103428c247d8d1a4550f9d75",
"index": 8086,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nauthors.append(text[start + length + len('<![CDATA['):end - len(']]>')])\nwhile text.find('<wp:author_display_name>', start + 1) != -1:\n start = text.find('<wp:author_display_name>', ... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
import logging
from django.shortcuts import render, redirect, HttpResponse
from django.core.urlresolvers import reverse
from django.conf import settings
from django.contrib.auth import logout, login, authenticate
from django.contrib.auth.hashers import make_password
from django.core.paginator im... | normal | {
"blob_id": "0b1e6a95ee008c594fdcff4e216708c003c065c8",
"index": 4873,
"step-1": "# -*- coding: utf-8 -*-\nimport logging\nfrom django.shortcuts import render, redirect, HttpResponse\nfrom django.core.urlresolvers import reverse\nfrom django.conf import settings\nfrom django.contrib.auth import logout, login, au... | [
0
] |
if __name__ == '__main__':
print('--------------------------------------')
query = 'user=pilgrim&database=master&password=PapayaWhip'
a_list = query.split('&')
print(a_list)
print('--------------------------------------')
a_list_of_lists = [v.split('=', 1) for v in a_list if '=' in v]
print(... | normal | {
"blob_id": "5c3bf49f88dec429ec85cceb8130cccf2691363b",
"index": 1538,
"step-1": "<mask token>\n",
"step-2": "if __name__ == '__main__':\n print('--------------------------------------')\n query = 'user=pilgrim&database=master&password=PapayaWhip'\n a_list = query.split('&')\n print(a_list)\n pr... | [
0,
1
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import random
import helper as hp
def insertion_sort(items, start, end):
"""
Arguments:
- `items`:
"""
n = end - start + 1
for i in range(start+1, end+1):
for j in range(i, start, -1):
if items[j] < items[j-1]:
... | normal | {
"blob_id": "e2e34db52e17c188cab63a870f0bc77cbc9ef922",
"index": 3355,
"step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\nimport random\n\nimport helper as hp\n\ndef insertion_sort(items, start, end):\n \"\"\"\n\n Arguments:\n - `items`:\n \"\"\"\n n = end - start + 1\n for ... | [
0
] |
# -*- coding: utf-8 -*-
class Library(object):
def __init__(self, backend):
self._backend = backend
@property
def cache(self):
return self._backend.cache
def cache_key(self, key):
return self._backend.cache_key(key)
def get_url(self, track):
raise NotImplemented... | normal | {
"blob_id": "ccee0e3c47fd3809e0670be24aaa6fd0a9bad3bc",
"index": 888,
"step-1": "class Library(object):\n <mask token>\n <mask token>\n\n def cache_key(self, key):\n return self._backend.cache_key(key)\n <mask token>\n",
"step-2": "class Library(object):\n <mask token>\n <mask token>\n... | [
2,
3,
4,
5,
6
] |
import cv2 as cv
import numpy as np
import sys
from meio_tom_lib import *
imgname = sys.argv[1]
imgpath = "img/" + imgname
try:
img = cv.imread(imgpath)
newimg1 = jarvis_judice_ninke_1(img)*255
newimg2 = jarvis_judice_ninke_2(img)*255
cv.imshow("Imagem original",img)
cv.imshow("Jarvis, Judice e... | normal | {
"blob_id": "bf764457e6af25d2d9406b18af51f63b36ab823a",
"index": 8564,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n img = cv.imread(imgpath)\n newimg1 = jarvis_judice_ninke_1(img) * 255\n newimg2 = jarvis_judice_ninke_2(img) * 255\n cv.imshow('Imagem original', img)\n cv.imshow('J... | [
0,
1,
2,
3,
4
] |
import cv2
import numpy as np
result=cv2.VideoCapture(0)
while True:
ret,square=result.read()
area=square[100:200,100:200]
cv2.imshow("video",square)
cv2.imshow("video2",area)
print(square)
if cv2.waitKey(25) & 0xff == ord('q'):
break
result.release()
cv2.destroyAllWindows()
| normal | {
"blob_id": "934921b22d036bd611134ce74f6eba3a2710018e",
"index": 529,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n ret, square = result.read()\n area = square[100:200, 100:200]\n cv2.imshow('video', square)\n cv2.imshow('video2', area)\n print(square)\n if cv2.waitKey(25... | [
0,
1,
2,
3,
4
] |
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
import os
# Init app
app = Flask(__name__)
basedir = os.path.abspath(os.path.dirname(__file__))
# Database
app.config['SQLALCHEM_DATABASE_URI'] = 'sqlite///' + \
os.path.join(basedir, 'db.sql... | normal | {
"blob_id": "ccb131171472d0a92d571e94453be97b323b4484",
"index": 7081,
"step-1": "<mask token>\n\n\nclass ProductSchema(ma.Schema):\n\n\n class Meta:\n fields = 'id', 'name', 'description', 'price', 'qty'\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Product(db.Model):\n id = db.Column(... | [
1,
3,
4,
5,
7
] |
import random
from connectfour.agents.monte_carlo import Node, MTCS
from connectfour.agents.agent import Agent
MAX_DEPTH = 3
class MonteCarloAgent(Agent):
def __init__(self, name):
super().__init__(name)
def get_move(self, board):
best_move = self.find_best_move(board)
return self._... | normal | {
"blob_id": "e99cf5a7058db984b323af1375003e4e21e36612",
"index": 9305,
"step-1": "<mask token>\n\n\nclass MonteCarloAgent(Agent):\n <mask token>\n <mask token>\n <mask token>\n\n def _find_move_from_new_board_state(self, old, new):\n \"\"\"\n Making a move in Connect Four makes exactly ... | [
5,
8,
9,
10,
11
] |
# Generated by Django 3.2.5 on 2021-07-27 17:12
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', ... | normal | {
"blob_id": "d145f4c061c8f364756012832a07adc305e35e5c",
"index": 5772,
"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
] |
from __future__ import print_function
from __future__ import absolute_import
#
# LinkedIn Sales Module
#
import requests
from bs4 import BeautifulSoup
import logging
from plugins.base import PageGrabber
from plugins.colors import BodyColors as bc
import json
try:
import __builtin__ as bi
except:
import builtins... | normal | {
"blob_id": "570e0d46aa1ea88d1784447e8f693199e3c3b6ad",
"index": 9488,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass LinkedInGrabber(PageGrabber):\n\n def get_info(self, email):\n client = requests.Session()\n print('[' + bc.CPRP + '?' + bc.CEND + '] ' + bc.CCYN + 'LinkedIn' +... | [
0,
2,
3,
4,
5
] |
# the age of some survivors
survived_age = [48.0, 15.0, 40.0, 36.0, 47.0, \
32.0, 60.0, 31.0, 17.0, 36.0, 39.0, 36.0, 32.5, \
39.0, 38.0, 36.0, 52.0, 29.0, 35.0, 35.0, 49.0, \
16.0, 27.0, 22.0, 27.0, 35.0, 3.0, 11.0, 36.0, \
1.0, 19.0, 24.0, 33.0, 43.0, 24.0, 32.0, 49.0, \
30.0, 49.0, 60.0, 23.0, 26.0, 24.0, 40.0, 25.0... | normal | {
"blob_id": "85c51f155439ff0cb570faafc48ac8da094515bf",
"index": 3362,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('The ave_age of survivors is {}'.format(ave_survived_age))\nprint('The ave_age of victims is {}'.format(ave_non_survived_age))\n",
"step-3": "survived_age = [48.0, 15.0, 40.0, 36.... | [
0,
1,
2,
3
] |
import turtle
def draw_triangle(brad):
brad.color("blue", "green")
brad.fill(True)
brad.forward(300)
brad.left(120)
brad.forward(300)
brad.left(120)
brad.forward(300)
brad.end_fill()
#jdjjdd brad.color("blue", "white")
brad.fill(True)
brad.left(180)
brad.forward(150)
... | normal | {
"blob_id": "33f766bf12a82e25e36537d9d3b745b2444e1fd7",
"index": 7042,
"step-1": "<mask token>\n\n\ndef draw():\n window = turtle.Screen()\n window.bgcolor('white')\n brad = turtle.Turtle()\n brad.shape('turtle')\n brad.color('blue')\n brad.speed(6)\n draw_triangle(brad)\n window.exitoncl... | [
1,
2,
3,
4,
5
] |
"""
Remove tool_consumer_info_product_family_code from GradingInfo.
Revision ID: 106d94be7705
Revises: 973c9358b616
Create Date: 2023-07-06 11:23:10.850486
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "106d94be7705"
down_revision = "973c9358b616"
def upgrad... | normal | {
"blob_id": "46d85a3babab4b18f4e0e0384f254f6105cf691d",
"index": 1490,
"step-1": "<mask token>\n\n\ndef upgrade():\n op.drop_column('lis_result_sourcedid',\n 'tool_consumer_info_product_family_code')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef upgrade():\n op.drop_column('lis_result_sou... | [
1,
2,
3,
4,
5
] |
from interpreter import Interpreter
from pretty_print import PrettyPrint
from ast import Operator, Operation, Element
class Token:
operator = False
empty = False
def __init__(self, token):
self.token = token
if token == '+':
self.operator = True
elif token == '-':
... | normal | {
"blob_id": "0d6c1e74a274b3e8ad9c63ecaa125f79976db9b4",
"index": 1734,
"step-1": "<mask token>\n\n\nclass Token:\n operator = False\n empty = False\n\n def __init__(self, token):\n self.token = token\n if token == '+':\n self.operator = True\n elif token == '-':\n ... | [
10,
11,
13,
15,
16
] |
def solution(n):
answer = []
for i in range(1,n+1):
if n % i == 0:
answer.append(i)
return sum(answer)
def solution2(n):
return sum([i for i in range(1,n+1) if n % i == 0])
print(solution(12))
print(solution(5))
print(solution2(12))
print(solution2(5))
# n return
# 12 28
# 5 6 | normal | {
"blob_id": "7cfbc36cc6cd6ff7c30f02d979667448f2003546",
"index": 9267,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef solution2(n):\n return sum([i for i in range(1, n + 1) if n % i == 0])\n\n\n<mask token>\n",
"step-3": "def solution(n):\n answer = []\n for i in range(1, n + 1):\n ... | [
0,
1,
2,
3,
4
] |
class ClickAction:
Click = 0
DoubleClick = 1
class MouseButton:
Left = 0
Right = 1
Middle = 2
| normal | {
"blob_id": "cabebeb5ca02da2505df4a138e8b28f74dd108fa",
"index": 4362,
"step-1": "<mask token>\n\n\nclass MouseButton:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass MouseButton:\n Left = 0\n Right = 1\n Middle = 2\n",
"step-3": "class ClickAction:\n ... | [
1,
2,
3,
4
] |
import unittest
from FileFeatureReader.featurereaders import RFEFeatureReader, DTFeatureReader
from FileFeatureReader.featurereader import FeatureReader
from unittest import mock
from unittest.mock import patch
import builtins
class TestFeatureReader(unittest.TestCase):
def setUp(self):
self.rfe_feat_reade... | normal | {
"blob_id": "5436e9270e61f5f9ab41fc1f35a80f4b8def65ee",
"index": 2048,
"step-1": "<mask token>\n\n\nclass TestFeatureReader(unittest.TestCase):\n <mask token>\n\n def testRFEFull(self):\n feat = ['column1', 'column2', 'column3']\n read_data = 'Header\\n---- column1\\n---- column2\\n---- colum... | [
14,
16,
17,
18,
19
] |
#THIS IS PYTHON3
import tkinter as tk
from tkinter import *
from PIL import ImageTk
from PIL import Image #to handle non-gif image formats
import cv2
import numpy as np
from statistics import mode
import time
import random
import predict as ml
def calcSuccess(predictedCounter, randAssault):
vidLabel.pack_forge... | normal | {
"blob_id": "8cf6a9243182a4f6b68199a8967e06790396dc10",
"index": 5967,
"step-1": "<mask token>\n\n\ndef calcSuccess(predictedCounter, randAssault):\n vidLabel.pack_forget()\n if predictedCounter == 'parry_R':\n instructionLabel.config(text='RIGHT PARRY')\n if randAssault == 4 or randAssault =... | [
3,
5,
6,
7,
8
] |
from setuptools import setup, find_packages
from os.path import join, dirname, abspath
import io
here = abspath(dirname(__file__))
with open(join(here, 'VERSION')) as VERSION_FILE:
__versionstr__ = VERSION_FILE.read().strip()
with open(join(here, 'requirements.txt')) as REQUIREMENTS:
INSTALL_REQUIRES = REQU... | normal | {
"blob_id": "8d5978bc579115eb3065dce1bae08f1790f2d83c",
"index": 2832,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(join(here, 'VERSION')) as VERSION_FILE:\n __versionstr__ = VERSION_FILE.read().strip()\nwith open(join(here, 'requirements.txt')) as REQUIREMENTS:\n INSTALL_REQUIRES = REQ... | [
0,
1,
2,
3,
4
] |
import hashlib
hash = 'yzbqklnj'
int = 0
while not hashlib.md5("{}{}".format(hash, int).encode('utf-8')).hexdigest().startswith('000000'):
print("Nope luck for {}{}".format(hash, int))
int += 1
print("Key: {}{}".format(hash, int))
print("Number: {}").format(int) | normal | {
"blob_id": "9ae9fd6da5c3d519d87af699dd4ea9b564a53d79",
"index": 5481,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile not hashlib.md5('{}{}'.format(hash, int).encode('utf-8')).hexdigest(\n ).startswith('000000'):\n print('Nope luck for {}{}'.format(hash, int))\n int += 1\nprint('Key: {}{}'... | [
0,
1,
2,
3,
4
] |
import os
import requests
import json
from web import *
from libs_support import *
from rss_parser import *
from database import *
class Solr_helper:
""" Ho tro He thong tu dong cap nhat du lieu - su dung post.jar de tu dong cap nhat du lieu moi vao he thong theo
tung khoang thoi gian nhat dinh """
de... | normal | {
"blob_id": "deaaf7620b9eba32149f733cd543399bdc2813a1",
"index": 6553,
"step-1": "\nimport os\nimport requests\nimport json\n\nfrom web import *\nfrom libs_support import *\nfrom rss_parser import *\nfrom database import *\n\nclass Solr_helper:\n\n \"\"\" Ho tro He thong tu dong cap nhat du lieu - su dung pos... | [
0
] |
from .context import mango
from solana.publickey import PublicKey
def test_token_lookup():
data = {
"tokens": [
{
"address": "So11111111111111111111111111111111111111112",
"symbol": "SOL",
"name": "Wrapped SOL",
"decimals": 9,
... | normal | {
"blob_id": "5e7a589af69a604021ed9558fcce721a8e254fee",
"index": 5269,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_token_lookups_with_full_data():\n token_lookup = mango.SplTokenLookup.load(mango.SplTokenLookup.\n DefaultDataFilepath)\n assert token_lookup.find_by_symbol('BTC... | [
0,
1,
2,
3,
4
] |
#! /usr/bin/env python
# import ros stuff
import rospy
from std_srvs.srv import *
#to check if the service is active
active_ = False
def unable_service(req):
"""
This function contains the variable declared above that is
used to enable the service.
"""
global active_
active_ = req.data
res = SetBoolRespo... | normal | {
"blob_id": "0f6737b9e9e9a13d75c20352e9ef9c1db6c0c8a3",
"index": 828,
"step-1": "#! /usr/bin/env python\n\n# import ros stuff\nimport rospy\nfrom std_srvs.srv import *\n\n#to check if the service is active\nactive_ = False\n\ndef unable_service(req):\n\t\"\"\"\n\tThis function contains the variable declared abov... | [
0
] |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
from contextlib import contextmanager
import yaml
from omegaconf import OmegaConf
class CrypTenConfig:
... | normal | {
"blob_id": "501ca508df5d72b0190b933f07c4bd505d7090c0",
"index": 6464,
"step-1": "<mask token>\n\n\nclass CrypTenConfig:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @contextmanager\n de... | [
2,
7,
10,
12,
13
] |
"""
100 4 200 1 3 2
100
4
200
1
3
2
6:35
"""
class Solution:
def longestConsecutive(self, nums: List[int]) -> int:
numset = set(nums)
ans = 0
# visited = set(nums)
maxnum = float('-inf')
if not nums:
return 0
for n in numset:
... | normal | {
"blob_id": "50c7ce95f17cbd40a753d16d9f9fab349ad4f4ce",
"index": 3801,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def longestConsecutive(self, nums: List[int]) ->int:\n numset = set(nums)\n a... | [
0,
1,
2,
3
] |
#!usr/bin/env python
#-*- coding:utf-8 -*-
# this model is for decision tree
# objective: To cluster different service
# JialongLi 2017/03/18
import re
import os
import sys
import pickle
import copy
import random
import pydotplus
USER_NUM = 1000
reload(sys)
sys.setdefaultencoding( "utf-8" )
from ... | normal | {
"blob_id": "65c0d940bacc2d016121812c435cc60f3fc1ba90",
"index": 7233,
"step-1": "#!usr/bin/env python\r\n#-*- coding:utf-8 -*-\r\n\r\n# this model is for decision tree\r\n# objective: To cluster different service\r\n# JialongLi 2017/03/18\r\n\r\nimport re\r\nimport os\r\nimport sys\r\nimport pickle\r\nimport co... | [
0
] |
#adapted from https://github.com/DeepLearningSandbox/DeepLearningSandbox/tree/master/transfer_learning
import os
import sys
import glob
import argparse
import matplotlib.pyplot as plt
from keras.applications.imagenet_utils import preprocess_input
from keras.models import Model
from keras.layers import GlobalAveragePo... | normal | {
"blob_id": "39b9106a3b0305db8cc7316be3b76e58e5577b92",
"index": 4980,
"step-1": "<mask token>\n\n\ndef setup_to_transfer_learn(model):\n \"\"\"Freeze all layers and compile the model\"\"\"\n for layer in model.layers:\n layer.trainable = False\n\n\ndef add_new_last_layer(base_model, nb_classes):\n ... | [
5,
6,
7,
9,
10
] |
import nltk
class Text(object):
def __init__(self, text):
self.text = text
self.words = nltk.word_tokenize(text)
self.sents = nltk.sent_tokenize(text)
class Passage(Text):
def __init__(self, title, story, questions):
Text.__init__(self,story)
self.title = title
... | normal | {
"blob_id": "5830a6001d7db50002c44aede6fb10938fa01dd1",
"index": 320,
"step-1": "import nltk\n\nclass Text(object):\n \n def __init__(self, text):\n self.text = text\n self.words = nltk.word_tokenize(text)\n self.sents = nltk.sent_tokenize(text)\n\nclass Passage(Text):\n\n def __ini... | [
0
] |
from mbc import MBC
import random
import sys
from typing import Dict
from interface import Interface
from reg import Register, HandlerProxy
# I/O Registers
IE = 0xFFFF
DIV = 0xFF04
TIMA= 0xFF05
TMA = 0xFF06
TAC = 0xFF07
IF = 0xFF0F
LY = 0xFF44
class MMU():
#0000 3FFF 16KB ROM bank 00 From cartridge, usual... | normal | {
"blob_id": "1a7363736076620b7704d7264b2f0bb24514165c",
"index": 9816,
"step-1": "<mask token>\n\n\nclass MMU:\n <mask token>\n\n def dma(self, val: int) ->None:\n dest = 65024\n offset = val * 256\n for n in range(160):\n self.mem[dest + n] = self.mem[n + offset]\n <mask... | [
4,
6,
7,
8,
9
] |
from meross_iot.model.http.exception import HttpApiError
from logger import get_logger
from typing import Dict
from flask import Blueprint
from authentication import _user_login
from decorator import meross_http_api
from messaging import make_api_response
auth_blueprint = Blueprint('auth', __name__)
_LOGGER = get_... | normal | {
"blob_id": "afccd33e4c6bc5b7907a6af4ab698489fc9ea70d",
"index": 5299,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@auth_blueprint.route('/Login', methods=['POST'])\n@meross_http_api(login_required=False)\ndef login(api_payload: Dict, *args, **kwargs):\n email = api_payload.get('email')\n pa... | [
0,
1,
2,
3,
4
] |
# encoding=utf-8
'''
Finding log2() using sqrt()
原理: sqrt( 2**l * 2**h ) = 2**( (l+h)/2 )
而 a+b /2 正好是binary search, 与sqrt对应上了
题目应当是要求
意思就是找到2**x == y
'''
class Solution:
def log2(self, val):
if 0<val<1: return -self.log2(1.0/val)
if val==1: return 0
h = 1; accuracy = 0.001; ... | normal | {
"blob_id": "6ea41b0a76ddde04bcaffacea604f218eac9ac71",
"index": 1783,
"step-1": "# encoding=utf-8\n'''\nFinding log2() using sqrt()\n\n\n原理: sqrt( 2**l * 2**h ) = 2**( (l+h)/2 )\n而 a+b /2 正好是binary search, 与sqrt对应上了\n\n题目应当是要求\n\n意思就是找到2**x == y\n'''\n\nclass Solution:\n def log2(self, val):\n ... | [
0
] |
import chars2vec
import sklearn.decomposition
import matplotlib.pyplot as plt
import csv
# Load Inutition Engineering pretrained model
# Models names: 'eng_50', 'eng_100', 'eng_150' 'eng_200', 'eng_300'
from sklearn.cluster import KMeans
c2v_model = chars2vec.load_model('eng_50')
words=[]
etichette=[]
with open('da... | normal | {
"blob_id": "084579152a2cc7feb2c31e0209ce1e32f4905d81",
"index": 5316,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('datasetParsing2DEF.csv') as csv_file:\n csv_reader = csv.reader(csv_file, delimiter=',')\n line_count = 0\n for row in csv_reader:\n if line_count == 0:\n ... | [
0,
1,
2,
3,
4
] |
import dash_html_components as html
import dash_core_components as dcc
layout = html.Div([
html.Div([
html.Div([
html.H6('Répartition des biens'),
dcc.Graph(
id = "pieGraph",
figure = {
"data": [{
"values"... | normal | {
"blob_id": "83c3193ea40c9328d16fb91774762a76352d8e09",
"index": 8417,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlayout = html.Div([html.Div([html.Div([html.H6('Répartition des biens'),\n dcc.Graph(id='pieGraph', figure={'data': [{'values': [2878001, 2342181,\n 1773296, 521395], 'labels': ['Ma... | [
0,
1,
2,
3
] |
# coding: utf-8
from datetime import datetime
#from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils import timezone
from persol_users.models import PersolUser
from django.db.models import Q, Count
# アンケート
from questions.m... | normal | {
"blob_id": "ca0bca24509df2bf0bd07fb2f31d3e7909957405",
"index": 3483,
"step-1": "<mask token>\n\n\nclass Event(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <... | [
11,
13,
15,
16,
21
] |
import datetime
from random import SystemRandom
import re
import string
import time
from django.db import models
from django.utils import timezone
from app.translit import translit
# Each model extends models.Model
class alumni(models.Model):
alumnus_id = models.AutoField(primary_key=True)
full_name = model... | normal | {
"blob_id": "192e789129a51aa646a925fc4f8c3f8f4e14d478",
"index": 7988,
"step-1": "<mask token>\n\n\nclass invites(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ... | [
13,
16,
18,
22,
24
] |
"""
Prog: helloworld.py
Name: Samuel doyle
Date: 18/04/18
Desc: My first program!
"""
print('Hello, world!')
| normal | {
"blob_id": "513a2bbcf7a63baf900b73b18cf25618937dc7d0",
"index": 1054,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Hello, world!')\n",
"step-3": "\"\"\"\nProg: helloworld.py\nName: Samuel doyle\nDate: 18/04/18\nDesc: My first program!\n\"\"\"\n\nprint('Hello, world!')\n",
"step-4": ... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Member',
fields=[
('id', models.AutoField(verbo... | normal | {
"blob_id": "4e383130b185c6147315517d166ffe66be1be40d",
"index": 4577,
"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 = []\n operat... | [
0,
1,
2,
3,
4
] |
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.tools.mo.ops.pack import PackOp
from openvino.tools.mo.front.extractor import FrontExtractorOp
from openvino.tools.mo.front.mxnet.extractors.utils import get_mxnet_layer_attrs
class StackFrontExtractor(FrontExtractorOp):
... | normal | {
"blob_id": "dd71feda1ed5ff7ef9dee1573ad63939a3e09691",
"index": 7526,
"step-1": "<mask token>\n\n\nclass StackFrontExtractor(FrontExtractorOp):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass StackFrontExtractor(FrontExtractorOp):\n <mask token>\n <mask token... | [
1,
2,
3,
4,
5
] |
def quick_sort(arr):
q_sort(arr, 0, len(arr) - 1)
def q_sort(arr, left, right):
if left < right:
pivot_index = partition(arr, left, right)
q_sort(arr, left, pivot_index - 1)
q_sort(arr, pivot_index + 1, right)
def partition(arr, left, right):
pivot = arr[left]
while left < ... | normal | {
"blob_id": "09a5c96b7f496aca6b34d7f0a83d5b1e182ca409",
"index": 1627,
"step-1": "def quick_sort(arr):\n q_sort(arr, 0, len(arr) - 1)\n\n\ndef q_sort(arr, left, right):\n if left < right:\n pivot_index = partition(arr, left, right)\n q_sort(arr, left, pivot_index - 1)\n q_sort(arr, piv... | [
2,
3,
4,
5,
6
] |
import sys
def read(inp):
res = []
n, v = map(int, inp.readline().split())
for i in range(n):
x, y = map(int, inp.readline().split())
res.append((x, y))
return v, res
def solve(v, items):
res = 0
rem_v = v
for item in items:
if rem_v > item[1]:
res +... | normal | {
"blob_id": "8b0e7e8f2031df217894e980758e15d7401c0981",
"index": 2750,
"step-1": "<mask token>\n\n\ndef read(inp):\n res = []\n n, v = map(int, inp.readline().split())\n for i in range(n):\n x, y = map(int, inp.readline().split())\n res.append((x, y))\n return v, res\n\n\n<mask token>\n... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python
import argparse
import csv
import glob
import os
import sys
def run_main():
"""
Main function to process user input and then generate the description files for each run
:return: exit code -- 0 on success, 1 otherwise
"""
parser = argparse.ArgumentParser(description="Scan a... | normal | {
"blob_id": "6e6c6c5795e8723a86ae5dfc8f40df57d3dd10f7",
"index": 3336,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef run_main():\n \"\"\"\n Main function to process user input and then generate the description files for each run\n\n :return: exit code -- 0 on success, 1 otherwise\n \... | [
0,
1,
2,
3,
4
] |
def firstMissingPositive(nums):
if len(nums) == 0:
return 1
if len(nums) == 1:
if nums[0] == 1:
return 2
else:
return 1
nums.sort()
current = 1
nums = [ele for ele in nums if ele > 0]
if len(nums) == 0:
return 1
if len(nums) == 1:
... | normal | {
"blob_id": "89addbf2c49d568250cd5a48d3fdb73914ce50c4",
"index": 2899,
"step-1": "<mask token>\n",
"step-2": "def firstMissingPositive(nums):\n if len(nums) == 0:\n return 1\n if len(nums) == 1:\n if nums[0] == 1:\n return 2\n else:\n return 1\n nums.sort()\n... | [
0,
1,
2
] |
from . import UbuntuPackageManager, RedHatPackageManager, SolarisPackageManager, RpmMixin
from infi import unittest
from infi.run_as_root import RootPermissions
from contextlib import contextmanager
from infi import pkgmgr
from mock import patch
import distro
# pylint: disable-all
class TestOnUbuntu(unittest.TestCa... | normal | {
"blob_id": "b3c1843a742a82bca61650ab89ea8afdf3c9010d",
"index": 6667,
"step-1": "<mask token>\n\n\nclass TestUbuntuMock(TestOnUbuntu):\n\n def _should_skip(self):\n pass\n\n def _dpkg_query_s(self):\n from textwrap import dedent\n if self._installed:\n return Output(stdout=... | [
27,
33,
43,
46,
53
] |
import logging.config
import os
import sys
import yaml
sys.path.append(os.path.join(os.path.abspath('.'), '..', '..'))
def setup_logging(default_path='common/config/logging.yaml'):
path = default_path
if os.path.exists(path):
with open(path, 'rt') as f:
config = yaml.safe_load(f.read())
... | normal | {
"blob_id": "6657f0b51bc021e6b5867bbdd1a520c2b0cb92b3",
"index": 2367,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef setup_logging(default_path='common/config/logging.yaml'):\n path = default_path\n if os.path.exists(path):\n with open(path, 'rt') as f:\n config = yaml.sa... | [
0,
1,
2,
3
] |
__author__ = 'cromox'
from time import sleep
import inspect
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from Forex_CFD.features.main_page import FxMainPage
class FxBuySell(FxMainPage):
def _... | normal | {
"blob_id": "5850be6aef6e4adb36a122cb8e5ffe044b1c9009",
"index": 4589,
"step-1": "<mask token>\n\n\nclass FxBuySell(FxMainPage):\n <mask token>\n\n def buy(self, amount):\n self.log.info('--> ' + inspect.stack()[0][3] + ' started')\n if self.driver.find_element_by_xpath(\n \"//div[... | [
3,
5,
8,
9,
11
] |
from django.conf.urls import url
#from .views import CommandReceiveView
from .views import index, send_message
urlpatterns = [
#url(r'^bot/(?P<bot_token>.+)/$', CommandReceiveView.as_view(), name='command'),
url(r'^send_message$', send_message, name='send_message'),
url(r'^$', index, name='index'),
]
| normal | {
"blob_id": "6cc56f73e58366a3906da537cc27fdd5a066ee34",
"index": 2647,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('^send_message$', send_message, name='send_message'),\n url('^$', index, name='index')]\n",
"step-3": "from django.conf.urls import url\nfrom .views import index, ... | [
0,
1,
2,
3
] |
def build_shift_dict(self, shift):
'''
Creates a dictionary that can be used to apply a cipher to a letter.
The dictionary maps every uppercase and lowercase letter to a
character shifted down the alphabet by the input shift. The dictionary
should have 52 keys of all the uppercase letters and all th... | normal | {
"blob_id": "07d2da14d0122ad2c8407bb13b8567ca62356bef",
"index": 7515,
"step-1": "<mask token>\n",
"step-2": "def build_shift_dict(self, shift):\n \"\"\"\n Creates a dictionary that can be used to apply a cipher to a letter.\n The dictionary maps every uppercase and lowercase letter to a\n characte... | [
0,
1,
2
] |
import re
f = open('q4text.txt')
text = f.read()
f.close()
pattern = r'''[0-9]+[,][0-9]+|[0-9]+[.][0-9]+|[0-9]+|\b[A-Z][a-z]+[.]|\b[A-Za-z]+['][a-z]+|[A-Z.]+[A-Z]|\b[A-Za-z-]+|[.]+|[.,'"!?:;]'''
word_token = re.findall(pattern, text)
token_dictionary = {}
for element in word_token:
if element in token_dictionary... | normal | {
"blob_id": "2e27302abbe239c1a6067a9eb52f5a857fff7dd2",
"index": 1736,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nf.close()\n<mask token>\nfor element in word_token:\n if element in token_dictionary:\n token_dictionary[element] += 1\n else:\n token_dictionary[element] = 1\nfor key... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: wenshu/actions.py
# Author: Carolusian <https://github.com/carolusian>
# Date: 22.09.2018
# Last Modified Date: 22.09.2018
#
# Copyright 2018 Carolusian
import time
import itertools
import re
import requests
import json
import os
from random import randint
from se... | normal | {
"blob_id": "01de85b0d480c105c8cc1a8154c3de936ab3226d",
"index": 9143,
"step-1": "<mask token>\n\n\ndef sleep(min_seconds=1, max_seconds=10):\n \"\"\"Allow a browser instance to wait for a few seconds before do something\"\"\"\n time.sleep(randint(min_seconds, max_seconds))\n\n\ndef click(elem):\n try:\... | [
5,
6,
7,
8,
9
] |
#
# PySNMP MIB module ADTRAN-ATLAS-HSSI-V35-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADTRAN-ATLAS-HSSI-V35-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 16:59:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.... | normal | {
"blob_id": "309807e04bfbf6c32b7105fe87d6ad1247ae411a",
"index": 3192,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmibBuilder.exportSymbols('ADTRAN-ATLAS-HSSI-V35-MIB', adtran=adtran, adMgmt\n =adMgmt, adATLASHSSIV35IfceReact=adATLASHSSIV35IfceReact, adGenATLASmg=\n adGenATLASmg, adATLASmg=adATL... | [
0,
1,
2,
3
] |
h = int(input())
a = int(input())
b = int(input())
c = (h - b + a - b - 1) // (a - b)
print(int(c))
| normal | {
"blob_id": "eea962d6c519bee802c346fcf8d0c7410e00c30b",
"index": 9587,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(int(c))\n",
"step-3": "h = int(input())\na = int(input())\nb = int(input())\nc = (h - b + a - b - 1) // (a - b)\nprint(int(c))\n",
"step-4": null,
"step-5": null,
"step-ids"... | [
0,
1,
2
] |
import requests
import time
import csv
import os
import pandas as pd
col_list1 = ["cardtype","username_opensea", "address", "username_game"]
df1 = pd.read_csv("profiles.csv", usecols=col_list1)
#
for j in range(0,len(df1) ): #usernames in opensea
print(j)
user=[]
proto=[]
purity=[]
... | normal | {
"blob_id": "93909ab98f1141940e64e079e09834ae5ad3995f",
"index": 6537,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor j in range(0, len(df1)):\n print(j)\n user = []\n proto = []\n purity = []\n card_name = []\n card_effect = []\n god = []\n rarity = []\n mana = []\n typ... | [
0,
1,
2,
3,
4
] |
from Task2.src.EmailInterpreter import EmailInterpreter
import os
# Part B:
# -------
# Write a child-class of the previously written base class, which
# implements the 'split_file' function, simply by treating each line as a
# unit (it returns the list of lines).
class LineBreaker(EmailInterpreter):
def split_file... | normal | {
"blob_id": "1c6077d965f5bc8c03344b53d11851f5cd50bca8",
"index": 3346,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass LineBreaker(EmailInterpreter):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass LineBreaker(EmailInterpreter):\n\n def split_file(self, file_name):\n with op... | [
0,
1,
2,
3,
4
] |
# Simple read based on the py _sql context
from pyspark.sql import SQLContext
sqlContext = SQLContext(sc)
flow_data = sc._jvm.com.tetration.apps.IO.read(sqlContext._ssql_ctx, "/tetration/flows/", "PARQUET", "LASTHOUR")
flow_data.registerTempTable("flowtab")
# show the unique src_address and dst_address pairs
df = sq... | normal | {
"blob_id": "691075aa5c629e2d0c486ec288cd39bc142cdc7a",
"index": 3448,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nflow_data.registerTempTable('flowtab')\n<mask token>\ndf.show(1000)\n<mask token>\ndf.show(1000)\n<mask token>\nfor dstip in dstIPs:\n sql = (\n \"select src_address, dst_addres... | [
0,
1,
2,
3,
4
] |
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under t... | normal | {
"blob_id": "53127de883fb5da3214d13904664566269becba6",
"index": 3570,
"step-1": "<mask token>\n\n\nclass BaseLoader(metaclass=abc.ABCMeta):\n\n @property\n def plugin_class(self):\n raise NotImplementedError()\n <mask token>\n\n @abc.abstractmethod\n def get_options(self):\n \"\"\"R... | [
4,
11,
13,
14,
15
] |
# What is the 10 001st prime number?
primes = [2]
def is_prime(a, primes):
b = a
for x in primes:
d, m = divmod(b, x)
if m == 0:
return False
else:
return True
a = 3
while len(primes) <= 10001:
# There's something faster than just checking all of them, but this
... | normal | {
"blob_id": "e5e516b6a39a6df03f1e5f80fe2d9e3978e856aa",
"index": 2310,
"step-1": "# What is the 10 001st prime number?\n\nprimes = [2]\n\n\ndef is_prime(a, primes):\n b = a\n for x in primes:\n d, m = divmod(b, x)\n if m == 0:\n return False\n else:\n return True\n\n\na =... | [
0
] |
from flask_wtf import FlaskForm
from wtforms import (
StringField, TextAreaField, PasswordField, HiddenField)
from wtforms.fields.html5 import URLField, EmailField
from flask_wtf.file import FileField
from wtforms.validators import (
InputRequired, Length, Email,
Optional, URL, ValidationError, Regexp)
from... | normal | {
"blob_id": "47b2857ac20e46897cc1f64371868ce5174799d6",
"index": 4790,
"step-1": "<mask token>\n\n\nclass AddReportForm(ReportBaseForm):\n \"\"\"Form for adding new report.\"\"\"\n pass\n\n\nclass EditReportForm(ReportBaseForm):\n \"\"\"Form for editing a report.\"\"\"\n cleared_file = HiddenField('c... | [
5,
14,
20,
22,
24
] |
import os
import RPi.GPIO as GPIO
import time
import neopixel
import board
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #Setup button pins
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(19, GPIO.I... | normal | {
"blob_id": "4a711642af753ba2c82ce3351b052a4973e17e7d",
"index": 9672,
"step-1": "<mask token>\n\n\ndef setStep(w1, w2, w3, w4):\n GPIO.output(A1Pin, w1)\n GPIO.output(A2Pin, w2)\n GPIO.output(B1Pin, w3)\n GPIO.output(B2Pin, w4)\n\n\ndef wheel(pos):\n if pos < 0 or pos > 255:\n r = g = b = ... | [
4,
5,
6,
7,
8
] |
"""
You have a number and you need to determine which digit in this number is the biggest.
Input: A positive int.
Output: An Int (0-9).
Example:
max_digit(0) == 0
max_digit(52) == 5
max_digit(634) == 6
max_digit(10000) == 1
"""
def max_digit(number: int) -> int:
return max(int(i) for i in str(number))
print(m... | normal | {
"blob_id": "b25e9374458ead85535495e77a5c64117a8b1808",
"index": 5761,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef max_digit(number: int) ->int:\n return max(int(i) for i in str(number))\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef max_digit(number: int) ->int:\n return max(i... | [
0,
1,
2,
3
] |
import pandas as pd #@UnusedImport
import matplotlib.pyplot as plt
import matplotlib #@UnusedImport
import numpy as np #@UnusedImport
class Plotter():
def __init__(self):
self.red_hex_code = '#ff0000'
def AlkDMIonStatsSplitPlot(self, df):
PV1_DataSets_lst = df[df['inst'] == 'PV1']['DataSet'].unique()
... | normal | {
"blob_id": "81b920ab5417937dc0fc1c9675d393efc6a4d58d",
"index": 5453,
"step-1": "<mask token>\n\n\nclass Plotter:\n\n def __init__(self):\n self.red_hex_code = '#ff0000'\n\n def AlkDMIonStatsSplitPlot(self, df):\n PV1_DataSets_lst = df[df['inst'] == 'PV1']['DataSet'].unique()\n PV2_Da... | [
5,
6,
8,
9,
10
] |
#!/usr/bin/env python2
import socket
import struct
RHOST = "10.10.10.2"
RPORT = 110
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((RHOST, RPORT))
# OFFSETS
# EIP 4654
# ESP 342
# EBP 4650
# jmp_esp in slmfc.dll at 5f4a358f
jmp_esp = 0x5f4a358f
nop_sled = "\x90" * 32
buf_totlen = 5000
offset_srp =... | normal | {
"blob_id": "280a4e1fb35937bb5a5c604f69337d30a4b956a9",
"index": 6302,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ns.connect((RHOST, RPORT))\n<mask token>\nshellcode_calc += b'\\xba\\xd5\\x90\\xd2}\\xdb\\xd5\\xd9t$'\nshellcode_calc += b'\\xf4X1\\xc9\\xb161P\\x13\\x83'\nshellcode_calc += b\"\\xe8\\xfc\... | [
0,
1,
2,
3,
4
] |
#
# Copyright (c) 2011-2014 The developers of Aqualid project - http://aqualid.googlecode.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitati... | normal | {
"blob_id": "cbfccffce2884e1cbebe21daf7792eebc1f88571",
"index": 6864,
"step-1": "<mask token>\n\n\nclass _NodesTree(object):\n <mask token>\n <mask token>\n <mask token>\n\n def __hasCycle(self, node, new_deps):\n if node in new_deps:\n return True\n deps = set(new_deps)\n ... | [
68,
84,
88,
95,
105
] |
# -*- coding: utf-8 -*-
import requests
import json
url = "http://39.108.188.34:9090/spider/zhongdengdengji.go"
# url = "http://localhost:9090/spider/zhongdengdengji.go"
input = {
"timelimit": "1年",
"title": "GD20190305001",
"maincontractno": "YT20181228001",
"maincontractcurrency": "人民币",
"mainc... | normal | {
"blob_id": "ad024a2001dc6a6fa3a2a9c1b51f79132e914897",
"index": 7592,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(response.text)\n",
"step-3": "<mask token>\nurl = 'http://39.108.188.34:9090/spider/zhongdengdengji.go'\ninput = {'timelimit': '1年', 'title': 'GD20190305001', 'maincontractno':\n ... | [
0,
1,
2,
3,
4
] |
import pandas as pd
import csv
import numpy as np
import matplotlib.pyplot as plt
#import csv file with recorded left, right servo angles and their corresponding roll and pitch values
df = pd.read_csv('C:/Users/yuyan.shi/Desktop/work/head-neck/kinematics/tabblepeggy reference tables/mid_servo_angle_2deg_3.csv') ... | normal | {
"blob_id": "fd7961d3a94b53ae791da696bb2024165db8b8fc",
"index": 5354,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nplt.scatter(df['left_rel_angle'], df['right_rel_angle'])\nplt.xlabel('Left servo angle(deg)')\nplt.ylabel('Right servo angle(deg)')\nplt.title('Plot of left and right servo values')\nplt.... | [
0,
1,
2,
3,
4
] |
# 14. Sort dataframe (birds) first by the values in the 'age' in decending order, then by the value in the 'visits' column in ascending order.
import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["divya_db"]
mycol = mydb["vani_data"]
# age column in decending order
myquery = my... | normal | {
"blob_id": "d91bacfd4b45832a79189c0f1ec4f4cb3ef14851",
"index": 2210,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(list(myquery))\n<mask token>\nprint(list(myquery))\n",
"step-3": "<mask token>\nmyclient = pymongo.MongoClient('mongodb://localhost:27017/')\nmydb = myclient['divya_db']\nmycol = ... | [
0,
1,
2,
3,
4
] |
#This is just a test
print("this is something new")
for a in range(10):
print(sum(a))
print("the loop worked")
| normal | {
"blob_id": "df317e914073f5b236f73b616b87f86ae378ef38",
"index": 8755,
"step-1": "<mask token>\n",
"step-2": "print('this is something new')\nfor a in range(10):\n print(sum(a))\nprint('the loop worked')\n",
"step-3": "#This is just a test\nprint(\"this is something new\")\nfor a in range(10):\n print(su... | [
0,
1,
2
] |
A, B = map(int, input().split())
K = (B ** 2 - A ** 2) / (2 * A - 2 * B)
print(int(abs(K))) if K.is_integer() else print('IMPOSSIBLE')
| normal | {
"blob_id": "36a7d3ed28348e56e54ce4bfa937363a64ee718f",
"index": 6981,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(int(abs(K))) if K.is_integer() else print('IMPOSSIBLE')\n",
"step-3": "A, B = map(int, input().split())\nK = (B ** 2 - A ** 2) / (2 * A - 2 * B)\nprint(int(abs(K))) if K.is_intege... | [
0,
1,
2
] |
from openvino.inference_engine import IENetwork, IECore
import numpy as np
import time
from datetime import datetime
import sys
import os
import cv2
class MotionDetect:
# Klasse zur Erkennung von Bewegung
def __init__(self):
self.static_back = None
def detect_motion(self, frame, reset=False):
... | normal | {
"blob_id": "fbd7868a37a2270e5dc86843adff50a94436404d",
"index": 5899,
"step-1": "<mask token>\n\n\nclass MotionDetect:\n\n def __init__(self):\n self.static_back = None\n <mask token>\n <mask token>\n\n\nclass InferenceModel:\n\n def __init__(self, device='MYRIAD'):\n self.ie = IECore(... | [
9,
10,
11,
12,
13
] |
from selenium import selenium
class SharedSeleniumExecutionContext:
host =None
port =None
browserStartCommand =None
url = None
seleniumInstance=None
isInitialized=False
lastVisitedLocation=None
optionBeingHandled=None
itemToDrag=None
def __init__(self, host, port, brow... | normal | {
"blob_id": "e75fb023e2e3d3fd258a316a6827b2601c9f4b2d",
"index": 3762,
"step-1": "<mask token>\n\n\nclass SharedSeleniumExecutionContext:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask to... | [
9,
12,
13,
14,
16
] |
new_tuple = (11,12,13,14,15,16,17)
new_list = ['one' ,12,'three' ,14,'five']
print("Tuple: ",new_tuple)
print("List: ", new_list)
tuple_2= tuple (new_list)
print("Converted tuple from the list : ", tuple_2) | normal | {
"blob_id": "889fdca3f92f218e6d6fd3d02d49483f16a64899",
"index": 9117,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Tuple: ', new_tuple)\nprint('List: ', new_list)\n<mask token>\nprint('Converted tuple from the list : ', tuple_2)\n",
"step-3": "new_tuple = 11, 12, 13, 14, 15, 16, 17\nnew_list ... | [
0,
1,
2,
3
] |
#Alexis Langlois
'''
Fichier de test pour l'algorithme Adaboost avec arbres de décision (@nbTrees).
'''
import numpy as np
from sklearn.utils import shuffle
from sklearn.metrics import classification_report
from sklearn.metrics import accuracy_score
from adaboost_trees import AdaboostTrees
#Trees
nbTrees = 20
#Tr... | normal | {
"blob_id": "b750673829873c136826ae539900451559c042c8",
"index": 5398,
"step-1": "#Alexis Langlois\n'''\nFichier de test pour l'algorithme Adaboost avec arbres de décision (@nbTrees).\n'''\n\nimport numpy as np\n\nfrom sklearn.utils import shuffle\nfrom sklearn.metrics import classification_report\nfrom sklearn.... | [
0
] |
import thumt.utils.bleu as bleu
import argparse
parser = argparse.ArgumentParser("Compute sentence bleu.")
parser.add_argument("-pred_path", type=str, required=True)
parser.add_argument("-n_list_path", type=str, required=True)
parser.add_argument("-refer_path", type=str, required=True)
args = parser.parse_args()
n_l... | normal | {
"blob_id": "4437075901751adeaf3df63345e270a9b0090c14",
"index": 1918,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nparser.add_argument('-pred_path', type=str, required=True)\nparser.add_argument('-n_list_path', type=str, required=True)\nparser.add_argument('-refer_path', type=str, required=True)\n<mas... | [
0,
1,
2,
3,
4
] |
import os
import time
import pickle
from configparser import ConfigParser
from slackbot import bot
from slackbot.bot import Bot
from slackbot.bot import listen_to
from elasticsearch_dsl.connections import connections
from okcom_tokenizer.tokenizers import CCEmojiJieba, UniGram
from marginalbear_elastic.query import p... | normal | {
"blob_id": "3630f83e7e6a10f42e96f8bd6fa9714232d9176b",
"index": 4552,
"step-1": "<mask token>\n\n\n@listen_to('(.*)')\ndef receive_question(message, question_string):\n if message._body['channel'] == SLACK_CHANNEL:\n try:\n query_ccjieba = ccjieba.cut(question_string.strip())\n q... | [
2,
3,
4,
5,
6
] |
#source: https://www.pyimagesearch.com/2015/05/25/basic-motion-detection-and-tracking-with-python-and-opencv/
from imutils.video import VideoStream
import argparse
import datetime
import imutils
import time
import cv2
#capture the video file
b="blood.mp4"
c="Center.avi"
d="Deformed.avi"
i="Inlet.avi"
... | normal | {
"blob_id": "4bd928c16cd0f06931aad5a478f8a911c5a7108b",
"index": 5850,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Width x: ', width, ' Height y: ', height)\nprint('Frame Number,x coordinate of ROI,Weidth,Height,Width/Height')\n<mask token>\nwhile True:\n j += 1\n if j % 1000 != 0:\n ... | [
0,
1,
2,
3,
4
] |
#Write a function remove_duplicates that takes in a list and removes elements of the list that are the same.
#For example: remove_duplicates([1,1,2,2])
#should return [1,2].
#Do not modify the list you take as input! Instead, return a new list.
def remove_duplicates(lst_of_items):
new_list=list()
#dict={}
... | normal | {
"blob_id": "b4d31fd05f8a9d66dcfffb55d805ab93d7ff9cdf",
"index": 5441,
"step-1": "#Write a function remove_duplicates that takes in a list and removes elements of the list that are the same.\n\n#For example: remove_duplicates([1,1,2,2])\n#should return [1,2].\n\n#Do not modify the list you take as input! Instead... | [
0
] |
#coding=utf-8
# ycat 2017-10-20 create
# AGV的控制
import sys,os
import json
import setup
if __name__ == '__main__':
setup.setCurPath(__file__)
import utility
import enhance
import threading
import time
import log
import re
import lock
import json_codec
import driver.agv.hdcAgvApi as api
g_threads =[]
g_carts = No... | normal | {
"blob_id": "e2feb12b88babbbfa4cc8447c91e8a5b6c30f78b",
"index": 1466,
"step-1": "<mask token>\n\n\n@utility.init()\ndef init():\n if utility.is_test():\n return\n api.init()\n time.sleep(3)\n\n\ndef wait():\n global g_threads\n for t in g_threads:\n t.join()\n g_threads.clear()\n... | [
26,
29,
30,
34,
38
] |
from django.db import models
# Create your models here.
class Remedio(models.Model):
nome = models.CharField(max_length=100, unique=True, help_text='Nome')
valor = models.FloatField(null=False, help_text='Valor')
detalhe = models.CharField(max_length=500, null=True)
foto = models.ImageField(upload_to='... | normal | {
"blob_id": "07cce6802ab3259dbc78ab86a8dd6d6a4a617c7e",
"index": 5242,
"step-1": "<mask token>\n\n\nclass Remedio(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Remedio(models.Model):\n <mask token>\n <mask t... | [
1,
2,
3,
4,
5
] |
import datetime
from ..core.indicator import Indicator, IndicatorState
from ..core.toolwindow import ToolWindow
class HaakePhoenix(ToolWindow):
required_devices = ['haakephoenix']
def __init__(self, *args, **wargs):
self.indicators = {}
super().__init__(*args, **wargs)
def init_gui(self... | normal | {
"blob_id": "25aa0766505b22588107d44e15c3596e9383d4e9",
"index": 486,
"step-1": "<mask token>\n\n\nclass HaakePhoenix(ToolWindow):\n <mask token>\n\n def __init__(self, *args, **wargs):\n self.indicators = {}\n super().__init__(*args, **wargs)\n\n def init_gui(self, *args, **kwargs):\n ... | [
8,
10,
13,
14,
15
] |
import datetime
# weightloss script
currentWeight = 73
goalWeight = 67
avgKgPerWeek = 0.45
startDate = datetime.date.today()
endDate = startDate
while currentWeight > goalWeight:
# adding 7 days to simulate a week passing
endDate += datetime.timedelta(days=7)
currentWeight -= avgKgPerWeek
print... | normal | {
"blob_id": "7fb568880c40895870a0c541d9a88a8070a79e5b",
"index": 5762,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile currentWeight > goalWeight:\n endDate += datetime.timedelta(days=7)\n currentWeight -= avgKgPerWeek\n print(endDate, round(currentWeight, 2))\nprint(f'Start date: {startDat... | [
0,
1,
2,
3,
4
] |
# Given an unsorted integer array nums, find the smallest missing positive integer.
class Solution:
def firstMissingPositive(self, nums: List[int]) -> int:
# if nums is emtpy, first pos int is 1
if not nums:
return 1
maxnum = max(nums) # for speed we assign max of nums to var max... | normal | {
"blob_id": "09905d4b5ad2e59578d874db171aafb6c42db105",
"index": 8609,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def firstMissingPositive(self, nums: List[int]) ->int:\n if not nums:\n return 1\n maxnum = max(nums)\... | [
0,
1,
2,
3
] |
# open a converted base to bits file and convert it back to the base sequences
seq2 = ''
with open('chr01.txt') as a:
while 1:
seq = a.read(2)
# print(seq)
seq = seq.replace('00', 'c').replace('01', 'g').replace('10', 'a').replace('11', 't')
seq2 += seq
if not seq:
... | normal | {
"blob_id": "c2f859e0ed0e812768dec04b2b1f9ddd349350f6",
"index": 9780,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('chr01.txt') as a:\n while 1:\n seq = a.read(2)\n seq = seq.replace('00', 'c').replace('01', 'g').replace('10', 'a'\n ).replace('11', 't')\n s... | [
0,
1,
2,
3
] |
from __future__ import division
import torch
import torch.nn as nn
import math
def conv_bn(inp, oup, stride):
return nn.Sequential(
nn.Conv2d(inp, oup, 3, stride, 1, bias=False),
nn.BatchNorm2d(oup),
nn.ReLU(inplace=True)
)
def conv_1x1_bn(inp, oup):
return nn.Sequential(
... | normal | {
"blob_id": "be1638638c70cf761bf5d2f0eb474b44684dfa47",
"index": 4657,
"step-1": "<mask token>\n\n\nclass SmallMobileNetV2(nn.Module):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass SmallMobileNetV2Part(nn.Module):\n\n def __init__(self, widen_factor=1.0, num_classes=68 * 2):\n super(... | [
7,
11,
13,
15,
17
] |
import sys
character_dict = {}
f = open(sys.argv[1], 'r')
while True:
pinyin = f.readline().strip()
character = f.readline().strip()
if not character: break
character_dict[pinyin] = character
import time
fout = open(sys.argv[1][:-3] + "_guess_char.out", 'w')
fout.write("-----------------------------")
fout.write(... | normal | {
"blob_id": "226bb323597100b57ef83eb0d5e4a9b894b77fd2",
"index": 9830,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n pinyin = f.readline().strip()\n character = f.readline().strip()\n if not character:\n break\n character_dict[pinyin] = character\n<mask token>\nfout.writ... | [
0,
1,
2,
3,
4
] |
#coding=utf-8
import urllib.parse
import json
'''转化从charles复制下来的字串,转为json格式'''
def to_str(body_str):
'''检查需要转化的str是否符合标准'''
if not body_str == '':
par = body_str.split("&")
# print(par)
_temp = []
try:
for each in par:
if "=" not in each:
... | normal | {
"blob_id": "d8e9b9f7a8d5ec2a72f083ec2283e8c0724dbe0d",
"index": 9119,
"step-1": "<mask token>\n\n\ndef to_json(body_str):\n \"\"\"转化格式\"\"\"\n try:\n body_str = to_str(body_str)\n except:\n return False\n body_dict = {}\n for each in body_str.split('&'):\n body_dict[str(each.... | [
1,
2,
3,
4,
5
] |
from collections import Counter
class Solution:
def minDominoRotations(self, A: List[int], B: List[int]) ->int:
if not A or not B:
return 0
if len(A) != len(B):
return -1
cnt_a, cnt_b = Counter(A), Counter(B)
check_list = []
for num, freq in cnt_a.i... | normal | {
"blob_id": "069d85370d8358aa884b5195a1b52c0014efd161",
"index": 7637,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def minDominoRotations(self, A: List[int], B: List[int]) ->int:\n if not A or not B:... | [
0,
1,
2,
3
] |
from turtle import *
while True:
n=input("Right or left? ")
if n == 'right':
right(60)
forward(100)
elif n == 'left':
left(60)
forward(100)
| normal | {
"blob_id": "6f698196e9391d73bd99cda0a098a5bf7a3832ff",
"index": 963,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n n = input('Right or left? ')\n if n == 'right':\n right(60)\n forward(100)\n elif n == 'left':\n left(60)\n forward(100)\n",
"step-3": ... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.