code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
from room import Room
class Office(Room):
def __init__(self):
pass
| normal | {
"blob_id": "d3af5ac87474a99f1ade222995884bc8e035ce35",
"index": 6142,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Office(Room):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Office(Room):\n\n def __init__(self):\n pass\n",
"step-4": "from room import Room\n\n\nclass... | [
0,
1,
2,
3
] |
from flask import Flask, render_template , request
import joblib
# importing all the important libraires
import numpy as np
import pandas as pd
import nltk
import string
from nltk.corpus import stopwords
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfV... | normal | {
"blob_id": "df92166378c8a8cc0ba02d0ba33d75bbd94510a7",
"index": 4754,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return render_template('form.html')\n\n\n@app.route('/submit', methods=['POST'])\ndef form_data():\n user_data = request.form.get('user_data')\n user_data1 = [user_data]\n ... | [
2,
3,
4,
5,
6
] |
from HiddenLayer import HiddenLayer
from Vector import Vector
import IO
import Loss
import Utils
import Activation
import Backpropagation
import Rate
# As a test, let's simulate the OR-gate with a single perceptron
""" training = []
training.append(Vector(2, arr=[1, 1]))
training.append(Vector(2, arr=[1, 0]))
trainin... | normal | {
"blob_id": "1f86fe72c90c8457715a2f400dae8d355a9a97cf",
"index": 8577,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Images & labels read!')\n<mask token>\nfor i, l in zip(images, labels):\n images_flat.append(Vector(Utils.normalize(Utils.flatten_2d(i), 0, 1)))\n labels_oh.append(Utils.oneh... | [
0,
1,
2,
3,
4
] |
import time
from sqlalchemy import Column, Unicode, UnicodeText, Integer
from models.base_model import SQLMixin, db, SQLBase
class Messages(SQLMixin, SQLBase):
__tablename__ = 'Messages'
title = Column(Unicode(50), nullable=False)
content = Column(UnicodeText, nullable=False)
sender_id = Column(Intege... | normal | {
"blob_id": "6fbf64e2dc2836a54e54ee009be1d0d8d7c7037a",
"index": 1688,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Messages(SQLMixin, SQLBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Messages(SQLMixin... | [
0,
1,
2,
3
] |
# Copyright (c) 2017, Matt Layman
import bisect
import configparser
import os
import smartypants
from werkzeug.contrib.atom import AtomFeed, FeedEntry
from handroll import logger
from handroll.exceptions import AbortError
from handroll.extensions.base import Extension
from handroll.i18n import _
class BlogPost(obj... | normal | {
"blob_id": "c3d9ad49b62c56dfbd9674cb1ac5c206e6401a27",
"index": 830,
"step-1": "<mask token>\n\n\nclass BlogBuilder(object):\n <mask token>\n\n def _generate_output(self):\n \"\"\"Generate output that belongs in the destination file.\n\n Subclasses must implement this method.\n \"\"\"... | [
13,
24,
28,
32,
38
] |
# -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# ex: set expandtab softtabstop=4 shiftwidth=4:
#
# Copyright (C) 2008,2009,2010,2011,2012,2013,2014,2015,2016 Contributor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You ma... | normal | {
"blob_id": "a9e0659c6a18ffc954079845b7d0de04c46a78c9",
"index": 7204,
"step-1": "<mask token>\n\n\nclass ServiceMap(Base):\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 <mas... | [
9,
10,
11,
13,
14
] |
from numba import jit
@jit
def resolve():
N = int(input())
ans = 0
for n in range(1, N+1):
for m in range(n, N+1, n):
ans += m
print(ans)
if __name__ == "__main__":
resolve() | normal | {
"blob_id": "8d8df517ca5486e62cc1b5ac23bbcfa65ed9c1ff",
"index": 6611,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@jit\ndef resolve():\n N = int(input())\n ans = 0\n for n in range(1, N + 1):\n for m in range(n, N + 1, n):\n ans += m\n print(ans)\n\n\n<mask token>\n"... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
"""
Neverland2 Colorscheme
~~~~~~~~~~~~~~~~~~~~~~
Converted by Vim Colorscheme Converter
"""
from pygments.style import Style
from pygments.token import Token, Keyword, Comment, Number, Generic, Operator, Name, String
class Neverland2Style(Style):
background_color = '#121212'
... | normal | {
"blob_id": "9dccc19abb6dac9e9606dc1fd83a227b4da9bf1f",
"index": 4047,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Neverland2Style(Style):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Neverland2Style(Style):\n background_color = '#121212'\n styles = {Tok... | [
0,
1,
2,
3,
4
] |
# Generated by Django 2.0 on 2018-03-06 16:21
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('digressions', '0004_auto_20180303_1158'),
]
operations = [
migrations.RemoveField(
model_name='ex... | normal | {
"blob_id": "38c21fb959d8b98b616006ea48bd720cc6f9995c",
"index": 1462,
"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 = [('digressions... | [
0,
1,
2,
3,
4
] |
#=======================================================================
__version__ = '''0.0.01'''
__sub_version__ = '''20130714221105'''
__copyright__ = '''(c) Alex A. Naanou 2011'''
#-----------------------------------------------------------------------
import os
import sha
import md5
import base64
... | normal | {
"blob_id": "d03f87b7dfa8fe2c63500effda1bea5e41f17ffc",
"index": 3787,
"step-1": "#=======================================================================\r\n\r\n__version__ = '''0.0.01'''\r\n__sub_version__ = '''20130714221105'''\r\n__copyright__ = '''(c) Alex A. Naanou 2011'''\r\n\r\n\r\n#---------------------... | [
0
] |
from distributions.zero_inflated_poisson import ZeroInflatedPoisson
from distributions.negative_binomial import NegativeBinomial
from distributions.zero_inflated_negative_binomial import ZeroInflatedNegativeBinomial
from distributions.zero_inflated import ZeroInflated
from distributions.categorized import Categorized
f... | normal | {
"blob_id": "dfae1007adc557a15d03b78f2bf790fb5b06141a",
"index": 4442,
"step-1": "<mask token>\n",
"step-2": "from distributions.zero_inflated_poisson import ZeroInflatedPoisson\nfrom distributions.negative_binomial import NegativeBinomial\nfrom distributions.zero_inflated_negative_binomial import ZeroInflated... | [
0,
1
] |
# 나의 풀이
def solution(prices):
# 초 단위로 기록된 주식가격이 담긴 배열 prices # 가격이 떨어지지 않은 기간을 리턴
answer = [0]*len(prices)
for i in range(len(prices)-1):
for j in range(i+1, len(prices)):
answer[i] += 1
# 가격이 떨어졌을 경우
if prices[i] > prices[j]:
break
retur... | normal | {
"blob_id": "23b6d754adf1616bc6ea1f8c74984fbd8dade6dd",
"index": 4238,
"step-1": "<mask token>\n",
"step-2": "def solution(prices):\n answer = [0] * len(prices)\n for i in range(len(prices) - 1):\n for j in range(i + 1, len(prices)):\n answer[i] += 1\n if prices[i] > prices[j... | [
0,
1,
2
] |
from setup import app, manager
from Users.controller import user_controller
from Test.controller import test_controller
app.register_blueprint(test_controller, url_prefix="/test") #registeting test_controller blueprint with the main "app" and asking it to handle all url that begins with "/test". For eg: http://127.0.0... | normal | {
"blob_id": "afa22db946f77e9b33a443657592c20fbea21eb1",
"index": 6146,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp.register_blueprint(test_controller, url_prefix='/test')\napp.register_blueprint(user_controller, url_prefix='/')\nif __name__ == '__main__':\n app.run(debug=True)\n",
"step-3": "... | [
0,
1,
2,
3
] |
speed, lic_plate = input().split()
salary = int(0)
while lic_plate != "A999AA":
if int(speed) > 60:
if lic_plate[1] == lic_plate[2] and lic_plate [2] == lic_plate[3]:
salary += 1000
elif lic_plate[1] == lic_plate[2] or lic_plate [1] == lic_plate[3]:
salary += 500
elif... | normal | {
"blob_id": "ff8ffeb418bf4f9bc7d5dadd126ebc7c34c5c2cd",
"index": 4454,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile lic_plate != 'A999AA':\n if int(speed) > 60:\n if lic_plate[1] == lic_plate[2] and lic_plate[2] == lic_plate[3]:\n salary += 1000\n elif lic_plate[1] == ... | [
0,
1,
2,
3
] |
import os
import json
basedir = os.path.abspath(os.path.dirname(__file__))
# CHECK IF PRODUCTION CONFIG EXISTS
if os.path.exists('/etc/config.json'):
with open('/etc/config.json') as config_file:
config = json.load(config_file)
else:
with open('dev_config.json') as config_file:
config = json.l... | normal | {
"blob_id": "1f7147c914eee37776c0418575e93e3d36ee3aa5",
"index": 7099,
"step-1": "<mask token>\n\n\nclass Config:\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 <mask token>\n... | [
7,
9,
10,
11,
13
] |
# coding=utf-8
# @FileName: test_json.py
# @Author: ZhengQiang
# Date: 2020/1/15 5:26 下午
import json
a = "{\"ddd\": {{}}}"
def boyhook(dic):
print('test')
if dic['name']:
return dic['name'], dic['age']
return dic
new_boy = json.loads(a, object_hook=boyhook)
print(new_boy) | normal | {
"blob_id": "2bc5711839ccbe525551b60211d8cd79ddb7775a",
"index": 7019,
"step-1": "<mask token>\n\n\ndef boyhook(dic):\n print('test')\n if dic['name']:\n return dic['name'], dic['age']\n return dic\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef boyhook(dic):\n print('test')\n if d... | [
1,
2,
3,
4,
5
] |
from django.shortcuts import render
from django.contrib import messages
from django.views.generic import View
from django.views.decorators.http import require_GET, require_POST
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse,HttpResponsePermanentRedirect,HttpResponseRedirect
... | normal | {
"blob_id": "11952e60ab95bc1896fd899a5ced126dcafec63a",
"index": 9882,
"step-1": "<mask token>\n\n\n@require_GET\ndef Follow(request, shorturl):\n link = get_object_or_404(Link, shorturl=shorturl)\n link.vi += 1\n print(link.vi)\n link.save()\n return HttpResponseRedirect(link.link)\n\n\ndef FormV... | [
2,
4,
5,
6,
7
] |
#!/usr/bin/python
from PyMca5.PyMcaGui import PyMcaQt as qt
from RixsTool import mainWindow
app = qt.QApplication([])
win = mainWindow.RIXSMainWindow()
win.show()
app.exec_()
| normal | {
"blob_id": "34c8541e640596f51a5232cba06172df5814db14",
"index": 7734,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwin.show()\napp.exec_()\n",
"step-3": "<mask token>\napp = qt.QApplication([])\nwin = mainWindow.RIXSMainWindow()\nwin.show()\napp.exec_()\n",
"step-4": "from PyMca5.PyMcaGui import P... | [
0,
1,
2,
3,
4
] |
# Generated by Django 3.0.4 on 2021-03-27 19:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('electra', '0009_remove_response_img'),
]
operations = [
migrations.AddField(
model_name='response',
name='date_time'... | normal | {
"blob_id": "049d83bc1a31ef170654fda47d1f58e024befb44",
"index": 8220,
"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 = [('electra', '... | [
0,
1,
2,
3,
4
] |
"""Test Spotify module"""
from spoetify.spotify import Spotify
from nose.tools import assert_equal
def test_search_track():
sp = Spotify()
t = sp.search_track("avocado")
assert_equal(t.id, "1UyzA43l3OIcJ6jd3hh3ac")
| normal | {
"blob_id": "337309da79ce9d90010fef5c171b6b344e6dc63f",
"index": 5937,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_search_track():\n sp = Spotify()\n t = sp.search_track('avocado')\n assert_equal(t.id, '1UyzA43l3OIcJ6jd3hh3ac')\n",
"step-3": "<mask token>\nfrom spoetify.spotify... | [
0,
1,
2,
3
] |
import tensorflow as tf
from tensorflow.python.framework import graph_util
from net import siameseNet_batchnorm as siameseNet
import dataset
import numpy as np
import cv2
import os
batch_size=64
input_height=32
input_width=32
total_epoch_num=50
snapshot=100
support_image_extensions=[".jpg",".png",".jpeg",".bmp"]
margi... | normal | {
"blob_id": "97bbb181cbc0f5bfbf0b2298133fc226b6217d91",
"index": 399,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif not os.path.exists(pb_path):\n os.makedirs(pb_path)\nif not os.path.exists(ckpt_path):\n os.makedirs(ckpt_path)\n<mask token>\nif __name__ == '__main__':\n first_shape = None\n... | [
0,
1,
2,
3,
4
] |
from ortools.sat.python import cp_model
import os
import math
import csv
import sys
def ortoolsSolverReduceVar(num, cap, refill, fun, goal):
model = cp_model.CpModel()
token = [model.NewIntVar(-2147483648, 2147483647, 't%i' % i)
for i in range(1, num + 1)]
play = [model.NewIntVar(-2147483648, ... | normal | {
"blob_id": "da98835e48a759cbe7bd29ddba1fac20c006827d",
"index": 4996,
"step-1": "<mask token>\n\n\ndef ortoolsSolverRange(num, cap, refill, fun, goal):\n model = cp_model.CpModel()\n token = [model.NewIntVar(1, cap, 't%i' % i) for i in range(1, num + 1)]\n play = [model.NewIntVar(1, cap, 'q%i' % i) for... | [
2,
4,
5,
6,
7
] |
try:
from LoggerPlugin import LoggerPlugin
except ImportError:
from RTOC.LoggerPlugin import LoggerPlugin
from .holdPeak_VC820.vc820py.vc820 import MultimeterMessage
import serial
import sys
import traceback
from PyQt5 import uic
from PyQt5 import QtWidgets
import logging as log
log.basicConfig(level=log.INFO... | normal | {
"blob_id": "c3efaeab600ec9a7a9fffdfad5c9dc1faad8fee7",
"index": 726,
"step-1": "<mask token>\n\n\nclass Plugin(LoggerPlugin):\n <mask token>\n\n def __init__(self, *args, **kwargs):\n super(Plugin, self).__init__(*args, **kwargs)\n self.setDeviceName(devicename)\n self.smallGUI = True... | [
5,
8,
10,
11,
12
] |
import scipy.constants as const
import scipy.optimize as opt
import numpy as np
import pum.algorithms as alg
from pum.lines import *
from pum.net import *
mu = 1
eps = 2.56
b = 2.8 * const.milli
C = 13.0
Z0 = 50
f0 = 1.34 * const.giga
k = 10 ** ( - np.abs(C) / 20)
print 'k = {}' .format( k)
Z0e = ... | normal | {
"blob_id": "f81e4c9a502855dca31c6c991a08a12af1c2e2a6",
"index": 7745,
"step-1": "import scipy.constants as const\nimport scipy.optimize as opt\nimport numpy as np\nimport pum.algorithms as alg\nfrom pum.lines import *\nfrom pum.net import *\n\nmu = 1\neps = 2.56\nb = 2.8 * const.milli \nC = 13.... | [
0
] |
from django.test import TestCase
# Create your tests here.
import pymongo
client = pymongo.MongoClient(host='127.0.0.1', port=27017)
db = client.NBA_china_spider
collection = db.data
data = [title for title in collection.find()]
print(data[0]['url'])
| normal | {
"blob_id": "52ebe80e2d520bf07b21dc668223348002eb6d42",
"index": 2790,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(data[0]['url'])\n",
"step-3": "<mask token>\nclient = pymongo.MongoClient(host='127.0.0.1', port=27017)\ndb = client.NBA_china_spider\ncollection = db.data\ndata = [title for titl... | [
0,
1,
2,
3,
4
] |
from channels.routing import route
from .consumers import message_consumer
channel_routing = [
route("slack.rtm.message", message_consumer)
] | normal | {
"blob_id": "8439972b4458ba66d98f6a80a82a35576df472a4",
"index": 8096,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nchannel_routing = [route('slack.rtm.message', message_consumer)]\n",
"step-3": "from channels.routing import route\nfrom .consumers import message_consumer\nchannel_routing = [route('sl... | [
0,
1,
2,
3
] |
#
# linter.py
# Linter for SublimeLinter version 4.
#
# Written by Brian Schott (Hackerpilot)
# Copyright © 2014-2019 Economic Modeling Specialists, Intl.
#
# License: MIT
#
"""This module exports the D-Scanner plugin class."""
from SublimeLinter.lint import Linter, STREAM_STDOUT
class Dscanner(Linter):
"""Pro... | normal | {
"blob_id": "fda73b5dac038f077da460d6ebfb432b756909d9",
"index": 3125,
"step-1": "<mask token>\n\n\nclass Dscanner(Linter):\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",
"step-2": "<mask token>\n\n\nclass Dsca... | [
1,
2,
3,
4,
5
] |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
import json
import os
import convlab
from convlab.modules.dst.multiwoz.dst_util import init_state
from convlab.modules.dst.multiwoz.dst_util import normalize_value
from convlab.modules.dst.state_tracker import Tracker
from convlab.mo... | normal | {
"blob_id": "8de82d09c8a9a1c1db59b0cac9cf8dda04f35847",
"index": 3335,
"step-1": "<mask token>\n\n\nclass RuleDST(Tracker):\n <mask token>\n\n def __init__(self):\n Tracker.__init__(self)\n self.state = init_state()\n prefix = os.path.dirname(os.path.dirname(convlab.__file__))\n ... | [
3,
4,
5,
6,
7
] |
from enum import unique
from django.db import models
import secrets
import string
CARD_PACK_CHOICES = (
('1', 'Traditional Cards'),
('2', 'Special Cards'),
('3', 'Other Themed Cards')
)
MARKER_CHOICES = (
('1', 'Plastic Dots'),
('2', 'Quarters'),
('3', 'Beans')
)
def generate_game_code() -> ... | normal | {
"blob_id": "2fd33439d4403ec72f890a1d1b4f35f2b38d033b",
"index": 9268,
"step-1": "<mask token>\n\n\nclass Game(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Player(models.Model):\n \"\"\" Model that descr... | [
4,
7,
9,
10,
11
] |
default_app_config = 'child.apps.ChildConfig'
| normal | {
"blob_id": "290f96bb210a21183fe1e0e53219ad38ba889625",
"index": 1602,
"step-1": "<mask token>\n",
"step-2": "default_app_config = 'child.apps.ChildConfig'\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
'''
-Medium-
*BFS*
You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the ... | normal | {
"blob_id": "50b2b9d1edc8eaa44050e2b3b2375e966f16e10c",
"index": 6997,
"step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n\n def minimumOperations(self, nums: List[int], start: int, goal: int) ->int:\n que = deque([(start... | [
1,
2,
3,
4,
5
] |
from bisect import bisect_left as bisect
while True:
xp, yp = set(), set()
veneer = []
W, H = map(int, input().split())
if not W:
break
N = int(input())
for i in range(N):
x1, y1, x2, y2 = map(int, input().split())
veneer.append((x1, y1, x2, y2))
xp.add(x1)
... | normal | {
"blob_id": "e0fbb5ad6d822230865e34c1216b355f700e5cec",
"index": 7822,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n xp, yp = set(), set()\n veneer = []\n W, H = map(int, input().split())\n if not W:\n break\n N = int(input())\n for i in range(N):\n x1, y1, ... | [
0,
1,
2,
3
] |
import pygame
import utils
from random import randint
class TileSurface():
tileGroup = pygame.sprite.Group()
tileGrid = []
def __init__(self, x, y, width, height):
self.x = x
self.y = y
self.width = width
self.height = height
self.surface = pygame.Surface((width, height))
def updatePos(self, x, y):
... | normal | {
"blob_id": "0c8eb90c1d8a58f54186a30ce98a67310955a367",
"index": 3024,
"step-1": "<mask token>\n\n\nclass Tile(pygame.sprite.Sprite):\n <mask token>\n <mask token>\n\n def __init__(self, sprite, x, y, surface):\n super().__init__()\n self.image = pygame.image.load(sprite).convert_alpha()\n... | [
7,
13,
14,
15,
16
] |
from django.shortcuts import render,redirect
from django.contrib.auth.decorators import login_required
from .form import UserForm, ProfileForm, PostForm
from django.contrib import messages
from .models import Profile, Projects
from django.contrib.auth.models import User
from django.http import HttpResponseRedirect
# ... | normal | {
"blob_id": "67de51e2a176907fd89793bd3ec52f898130e104",
"index": 3713,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@login_required(login_url='/accounts/login/')\ndef postpoject(request):\n if request.method == 'POST':\n postform = PostForm(request.POST, request.FILES)\n if postfor... | [
0,
3,
4,
5,
8
] |
"""
Simple python script to help learn basic socket API
"""
import sys, socket
HOSTNAME = sys.argv[-2]
PORT = sys.argv[-1]
options = ( HOSTNAME, int(PORT) )
print options
print 'creating socket...'
sock = socket.socket()
print 'socket created'
print 'connecting...'
sock.connect(options)
print 'connected'
print 's... | normal | {
"blob_id": "e41b5ee0dff30cca51593e737420889bce8f419f",
"index": 8563,
"step-1": "\"\"\"\nSimple python script to help learn basic socket API\n\"\"\"\n\nimport sys, socket\n\nHOSTNAME = sys.argv[-2]\nPORT = sys.argv[-1]\n\noptions = ( HOSTNAME, int(PORT) )\nprint options\n\nprint 'creating socket...'\nsock = soc... | [
0
] |
from django import template
register = template.Library()
@register.filter(name='phone_number')
def phone_number(number): # Convert a 10 character string into (xxx) xxx-xxxx.
first = number[0:3]
second = number[3:6]
third = number[6:10]
return '(' + first + ')' + ' ' + second + '-' + third
| normal | {
"blob_id": "5e79a8a8fe79aac900fc0c2ff1caaa73ea08ada2",
"index": 5697,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@register.filter(name='phone_number')\ndef phone_number(number):\n first = number[0:3]\n second = number[3:6]\n third = number[6:10]\n return '(' + first + ')' + ' ' + sec... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
class interceptThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.curPkt = None
self.seq = 0
self.foundUAV = False
def run(self):
sniff(prn=self.interceptPkt, filter='udp port 5556')
def interceptPkt(self, pkt):
... | normal | {
"blob_id": "d9908d1ff155390dcd456dd15f92db03f093089e",
"index": 8146,
"step-1": "#!/usr/bin/env python3\n\nclass interceptThread(threading.Thread):\n def __init__(self):\n threading.Thread.__init__(self)\n self.curPkt = None\n self.seq = 0\n self.foundUAV = False\n def run(self... | [
0
] |
from __future__ import annotations
from .base import * # noqa
SECRET_KEY = "django-insecure-usp0sg081f=9+_j95j@-k^sfp+9c*!qrwh-m17%=_9^xot#9fn"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "puka-test",
"USER": "jeff",
"PASSWORD": "",
"HOST... | normal | {
"blob_id": "2432e2b4da8af284055e7edf6e0bd94b7b293f0b",
"index": 8601,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nSECRET_KEY = (\n 'django-insecure-usp0sg081f=9+_j95j@-k^sfp+9c*!qrwh-m17%=_9^xot#9fn')\nDATABASES = {'default': {'ENGINE': 'django.db.backends.postgresql', 'NAME':\n 'puka-test', 'U... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
# coding=utf-8
from django.core.management.base import BaseCommand
from BanBanTong.utils import task_scheduler
class Command(BaseCommand):
'''
启动BanBanTong.tasks定时任务
'''
def handle(self, *args, **options):
task_scheduler.start()
| normal | {
"blob_id": "e9c81be79d9107433e00182c27488e64f1ca779f",
"index": 1458,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Command(BaseCommand):\n <mask token>\n\n def handle(self, *args, **options):\n task_scheduler.start()\n",
"step-3": "<mask token>\n\n\nclass Command(BaseCommand):... | [
0,
2,
3,
4,
5
] |
from time import sleep
from uuid import uuid1
from pprint import pprint
from shutil import copy2
from multiprocessing import Process, Queue, Pool, Manager
from ad_grabber_classes import *
from adregex import *
from pygraph.classes.digraph import digraph
import os
import json
import jsonpickle
import subprocess
import ... | normal | {
"blob_id": "fdae984f7cf5e1c20dee197d3f2518a0c7c38bdc",
"index": 8085,
"step-1": "<mask token>\n\n\ndef check_duplicate(fp1, fp2):\n \"\"\"takes two files, does a diff on them, returns True if same\"\"\"\n try:\n subprocess.check_output(['diff', fp1, fp2])\n return True\n except subprocess... | [
10,
14,
15,
16,
18
] |
import control.matlab as ctrl
import matplotlib.pylab as plt
def process_data(num11, den11, num21, den21):
w11 = ctrl.tf(num11, den11)
w21 = ctrl.tf(num21, den21)
print('результат w11={} w21={}'.format(w11, w21))
TimeLine = []
for i in range (1, 3000):
TimeLine.append(i/1000)
plt.figur... | normal | {
"blob_id": "c08e6cee61e9f32a9f067a9554c74bb2ddbd7cf3",
"index": 2288,
"step-1": "<mask token>\n\n\ndef process_data(num11, den11, num21, den21):\n w11 = ctrl.tf(num11, den11)\n w21 = ctrl.tf(num21, den21)\n print('результат w11={} w21={}'.format(w11, w21))\n TimeLine = []\n for i in range(1, 3000... | [
1,
2,
3,
4,
5
] |
import fnmatch
import tempfile
from contextlib import contextmanager
from os import (
makedirs,
unlink,
)
from os.path import (
abspath,
basename,
dirname,
exists,
join,
sep,
)
from re import (
compile,
escape,
)
from typing import (
Any,
Dict,
List,
Type,
)
from ... | normal | {
"blob_id": "1a5c189b9a2bed35fbbb7df40ec80a1d02402d7f",
"index": 6860,
"step-1": "<mask token>\n\n\nclass TransferAction(BaseAction):\n <mask token>\n action_type = 'transfer'\n staging = STAGING_ACTION_LOCAL\n\n\nclass CopyAction(BaseAction):\n \"\"\" This action indicates that the Pulsar client sho... | [
84,
86,
97,
122,
127
] |
import time
import DHT22
import pigpio
import Sensor
class MagicBoxDHT22(object):
def DHT22(self):
self.s.trigger()
time.sleep(0.2)
self.tempF=round(self.s.temperature()*1.8+32,2) -3.7 #+adjustment
self.humidity=round(self.s.humidity())
def __init__(self):
self.pi=pigp... | normal | {
"blob_id": "179b07870d656fb24b73d8b0a1f76ffed08aa5c2",
"index": 9665,
"step-1": "<mask token>\n\n\nclass MagicBoxDHT22(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass MagicBoxDHT22(object):\n <mask token>\n\n def __init__(self):\n self.pi = pigpio.pi()\n ... | [
1,
2,
3,
4,
5
] |
A = int(input())
B = int(input())
C = int(input())
number = A * B * C
num = str(number)
for i in range(10): # 9를 입력해서 첨에 틀림 !
count = 0
for j in range(len(num)):
if i == int(num[j]):
count += 1
else:
continue
print(count)
| normal | {
"blob_id": "b43ea8c32207bf43abc3b9b490688fde0706d876",
"index": 4633,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(10):\n count = 0\n for j in range(len(num)):\n if i == int(num[j]):\n count += 1\n else:\n continue\n print(count)\n",
"step-... | [
0,
1,
2,
3
] |
from enum import Enum
class VariableType(Enum):
uint8 = "uint8",
int8 = "int8"
uint16 = "uint16"
int16 = "int16"
uint32 = "uint32"
int32 = "int32"
float = "float"
double = "double"
bool = "bool"
custom = "custom"
class Variable:
def __init__(self, type_str: str, name:... | normal | {
"blob_id": "434ec7791345ad869d8ce86aa1cdc08344203171",
"index": 2028,
"step-1": "<mask token>\n\n\nclass Variable:\n\n def __init__(self, type_str: str, name: str):\n self.original_type = type_str\n self.__map_variable_type(type_str)\n self.name = name\n\n def __str__(self):\n ... | [
4,
5,
6,
7,
8
] |
from app.exceptions import UserAlreadyExist, UserDoesNotExist
class Accounts(object):
""" Creates an Account where users can be stored """
def __init__(self):
self.users = {}
def add_user(self, user):
if user.id in self.users:
raise UserAlreadyExist
else:
s... | normal | {
"blob_id": "88cc4ae4137cf9c0e9c39874b36f7a2770550f96",
"index": 5431,
"step-1": "<mask token>\n\n\nclass Accounts(object):\n <mask token>\n\n def __init__(self):\n self.users = {}\n\n def add_user(self, user):\n if user.id in self.users:\n raise UserAlreadyExist\n else:\... | [
4,
5,
6,
7,
9
] |
# Generated by Django 3.0 on 2019-12-15 16:20
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('blog', '0013_auto_20191215_1619'),
]
operations = [
migrations.AlterField(
m... | normal | {
"blob_id": "38a79f5b3ce1beb3dc1758880d42ceabc800ece7",
"index": 8818,
"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 = [('blog', '001... | [
0,
1,
2,
3,
4
] |
from tkinter import *
from tkinter import messagebox as mb
from tkinter.scrolledtext import ScrolledText
from tkinter import filedialog as fd
from child_window import ChildWindow
# from PIL import Image as PilImage
# from PIL import ImageTk, ImageOps
class Window:
def __init__(self, width, height, title="MyWindow... | normal | {
"blob_id": "02d4e1ddb0b4cf75c9902e13263c5a80417de01b",
"index": 6530,
"step-1": "<mask token>\n\n\nclass Window:\n\n def __init__(self, width, height, title='MyWindow', resizable=(False, \n False), icon='resources/feather.ico'):\n self.root = Tk()\n self.root.title(title)\n self.r... | [
8,
9,
10,
12,
14
] |
weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday', 'Sunday']
i = input('Enter a day of the week and number of days: ').split()
e = int(i[-1])
starting_point = weekdays.index(i[0])
a = e + starting_point - len(weekdays)
print(weekdays[a])
| normal | {
"blob_id": "5f7d05c642339ce0ab02a65ca41f9ee89c2faf57",
"index": 4240,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(weekdays[a])\n",
"step-3": "weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',\n 'Saturday', 'Sunday']\ni = input('Enter a day of the week and number of days: ... | [
0,
1,
2
] |
import numpy as np
import os
# ----------------------------------------------------------------------------
# Common variables
# shifting channels based on rules:
# CH_SHIFT[rule_name] = {src_1_based_ch:new_1_based_ch}
CH_SHIFT = {}
CH_SHIFT[None] = None
# for 1-to-1 cards
CH_SHIFT['1to1'] = {}
for ch1 in xrange(1,... | normal | {
"blob_id": "c2ee716b72652035502a1f07dfe8aa68a104b2bb",
"index": 8255,
"step-1": "import numpy as np\nimport os\n\n# ----------------------------------------------------------------------------\n# Common variables\n\n# shifting channels based on rules:\n# CH_SHIFT[rule_name] = {src_1_based_ch:new_1_based_ch}\n... | [
0
] |
import sys
'''
Given a string, does the string contain an equal number of uppercase and
lowercase letters? Ignore whitespace, numbers, and punctuation. Return the
string “true” if balanced or the string “false” if not balanced.
'''
for line in sys.stdin:
lower = 0
upper = 0
# Count number of lowercase a... | normal | {
"blob_id": "4b3664153940b064b424bd77de473a6409437f88",
"index": 3279,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in sys.stdin:\n lower = 0\n upper = 0\n for x in range(0, len(line)):\n if 'a' <= line[x] <= 'z':\n lower = lower + 1\n elif 'A' <= line[x] <= '... | [
0,
1,
2,
3
] |
def checkRaiz():
a = int(input("Informe o primeiro coeficiente: "))
b = int(input("Informe o segundo coeficiente: "))
c = int(input("Informe o terceiro coeficiente: "))
delta = (b*b) - (4*a*c)
if (delta < 0):
print("Não tem raiz real")
elif (delta == 0):
print("Existe uma raiz... | normal | {
"blob_id": "603a73a7cc0487fcabb527ebc21d44cb95817ecb",
"index": 5909,
"step-1": "<mask token>\n",
"step-2": "def checkRaiz():\n a = int(input('Informe o primeiro coeficiente: '))\n b = int(input('Informe o segundo coeficiente: '))\n c = int(input('Informe o terceiro coeficiente: '))\n delta = b * ... | [
0,
1,
2,
3
] |
# This file is part of the Adblock Plus web scripts,
# Copyright (C) 2006-present eyeo GmbH
#
# Adblock Plus is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# Adblock Plus is distributed in the hop... | normal | {
"blob_id": "bfc6f6acef26e3dc4f6bf2b76363daec68c53cd1",
"index": 5709,
"step-1": "# This file is part of the Adblock Plus web scripts,\n# Copyright (C) 2006-present eyeo GmbH\n#\n# Adblock Plus is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License version... | [
0
] |
#https://www.hackerrank.com/challenges/caesar-cipher-1/problem
n=int(input())
stringy=input()
k=int(input())
s=""
for i in stringy:
if ord(i)>=65 and ord(i)<=90:
temp=(ord(i)+k-65)%26
s+=chr(temp+65)
elif ord(i)>=97 and ord(i)<=122:
temp=(ord(i)+k-97)%26
s+=chr(temp+97)
else... | normal | {
"blob_id": "acf787885834961a71fb2655b9d8a1eb026942c7",
"index": 4089,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in stringy:\n if ord(i) >= 65 and ord(i) <= 90:\n temp = (ord(i) + k - 65) % 26\n s += chr(temp + 65)\n elif ord(i) >= 97 and ord(i) <= 122:\n temp = (ord... | [
0,
1,
2,
3
] |
from django.shortcuts import render
from rest_framework import generics
from rest_framework import mixins
from django.contrib.auth.models import User
from rest_framework import permissions
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework.request import Req... | normal | {
"blob_id": "4c43c181dbba1680e036750a2a2ea1185bbe91da",
"index": 3218,
"step-1": "<mask token>\n\n\nclass InstitutionViewSet(viewsets.ModelViewSet):\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 def get_permi... | [
5,
8,
10,
11,
13
] |
# -*- coding: utf-8 -*-
"""
Created on 11/03/2020
@author: stevenp@valvesoftware.com
"""
import sys
from PyQt5.QtWidgets import (QApplication, QWidget, QLabel, QRadioButton, QVBoxLayout, QCheckBox, QProgressBar,
QGroupBox, QComboBox, QLineEdit, QPushButton, QMessageBox, QInputDialog, QDialog, QDialogButton... | normal | {
"blob_id": "33464f19c42d1a192792a73297f4d926df78ab71",
"index": 2906,
"step-1": "<mask token>\n\n\nclass MainWindow(QWidget):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def initUI(self):\n self.setGeometry(300, 300, 500, 600)\n self.setWindowTi... | [
4,
6,
9,
10,
11
] |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
from django.core.urlresolvers import reverse
from google_product_feeder.feed import CSVMerchantFeed, MERCHANT_FEED_COLUMNS
CSV_HEADINGS = ','.join(MERCHANT_FEED_COLUMNS) + '\r\n'
class AttrNameF... | normal | {
"blob_id": "924fd89a835528fa28e1226912a2e4be9c4e1d5d",
"index": 152,
"step-1": "<mask token>\n\n\nclass UppercaseBrandFeed(CSVMerchantFeed):\n\n def get_brand(self, obj):\n return obj.brand.upper()\n\n\nclass CSVMerchantFeedTest(TestCase):\n\n def test_csv_empty(self):\n feed = CSVMerchantFe... | [
10,
13,
14,
16,
17
] |
import requests
import json
def get():
market = 'Premium'
url = 'https://coinpremiums.herokuapp.com/json'
try:
result = ""
premiums = requests.get(url).json()
for exchange, exchange_currencies in premiums['premium'].items():
result += '[[{} | '.format(exchange.title()... | normal | {
"blob_id": "b5581be044013df9ff812f285f99ca67c4f96a62",
"index": 2927,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get():\n market = 'Premium'\n url = 'https://coinpremiums.herokuapp.com/json'\n try:\n result = ''\n premiums = requests.get(url).json()\n for exchan... | [
0,
1,
2,
3
] |
from django.contrib.auth.models import User
from rt.models import Movie_Suggestion, MovieDB, ActorDB, TVDB
def user_present(username):
if User.objects.filter(username=username).count():
return True
return False
#Takes in a list of MovieDB/TVDB objects
#Outputs a list of sorted titles
def sort_title(movies):
ti... | normal | {
"blob_id": "1e84b28580b97e77394be0490f3d8db3d62a2ccb",
"index": 1213,
"step-1": "<mask token>\n\n\ndef sort_id(movies, titles):\n ids = []\n for i in titles:\n try:\n movie_id = MovieDB.objects.get(title=i).id\n ids.append((i, movie_id))\n except MovieDB.DoesNotExist:\n... | [
3,
5,
6,
7,
8
] |
#!/usr/bin/env python2
# A basic example of sending Blue a command in cartesian space.
from blue_interface import BlueInterface
import numpy as np
import time
import sys
import argparse
import Leap
from utils.rotations import quat2euler, euler2quat, mat2euler
from utils.leap_listener import SampleListener
import mat... | normal | {
"blob_id": "b34e293b509328c728909262594bdf3d3ecf5360",
"index": 4364,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nparser.add_argument('--IK', default=False, action='store_true', help=\n 'switch to IK-control')\n<mask token>\nblue.calibrate_gripper()\n<mask token>\nwhile True:\n hands_data = lis... | [
0,
1,
2,
3,
4
] |
import numpy as np
a = np.array([1, 2, 3])
b = np.r_[np.repeat(a, 3), np.tile(a, 3)]
print(b)
| normal | {
"blob_id": "f39945f35b13c0918c3ef06224bca65ae6166ebc",
"index": 5892,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(b)\n",
"step-3": "<mask token>\na = np.array([1, 2, 3])\nb = np.r_[np.repeat(a, 3), np.tile(a, 3)]\nprint(b)\n",
"step-4": "import numpy as np\na = np.array([1, 2, 3])\nb = np.r... | [
0,
1,
2,
3
] |
# Merge sort is used to sort the elements
def merge_sort(arr):
if len(arr) > 1:
# Recursion is used to continuously split the array in half.
mid = len(arr) // 2
# Using Auxiliary storage here
left = arr[:mid]
right = arr[mid:]
# Traverse the left side of the array
... | normal | {
"blob_id": "264b48c2b9ce4ec948ca5ba548e708848760f3dc",
"index": 8271,
"step-1": "<mask token>\n\n\ndef rearrange_digits(input_list):\n if len(input_list) == 0:\n return []\n merge_sort(input_list)\n first_number = ''\n second_number = ''\n for i in range(0, len(input_list)):\n if i ... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
from math import acos, pi, sqrt
from decimal import Decimal, getcontext
getcontext().prec = 30
class Vector(object):
NO_NONZERO_ELTS_FOUND_MSG = 'No nonzero elements found'
def __init__(self, coordinates):
try:
if not coordinates:
raise ValueError
self.coordin... | normal | {
"blob_id": "1253e052865860a6895f91204a70152745b04652",
"index": 8498,
"step-1": "<mask token>\n\n\nclass Vector(object):\n <mask token>\n\n def __init__(self, coordinates):\n try:\n if not coordinates:\n raise ValueError\n self.coordinates = tuple([Decimal(x) fo... | [
15,
17,
23,
27,
29
] |
import requests
from urllib.parse import urlparse
from bs4 import BeautifulSoup
import re
import datetime
import random
pages = set()
# Retrieve a list of all Internal links foound on a page.
def getInternalLinks(bs, includeUrl):
includeUrl = f'{urlparse(includeUrl).scheme}://{urlparse(includeUrl).netloc}'
in... | normal | {
"blob_id": "5ddfeb49c16a7452c99126f1a837f3c0bed0ec10",
"index": 300,
"step-1": "<mask token>\n\n\ndef getExternalLinks(bs, excludeUrl):\n externalLinks = []\n for link in bs.find_all('a', href=re.compile('^(http|www)((?!' +\n excludeUrl + ').)*$')):\n if link.attrs['href'] is not None:\n ... | [
2,
3,
4,
5,
8
] |
import array
from PIL import Image
from generic.editable import XEditable as Editable
class PLTT(Editable):
"""Palette information"""
FORMAT_16BIT = 3
FORMAT_256BIT = 4
def define(self, clr):
self.clr = clr
self.string('magic', length=4, default='PLTT') # not reversed
self... | normal | {
"blob_id": "2fadc5c90d1bae14c57fc3bf02582e12aa8abdf6",
"index": 790,
"step-1": "<mask token>\n\n\nclass PLTT(Editable):\n <mask token>\n <mask token>\n <mask token>\n\n def define(self, clr):\n self.clr = clr\n self.string('magic', length=4, default='PLTT')\n self.uint32('size_'... | [
13,
14,
15,
16,
19
] |
import pytest
from eth_utils import encode_hex, remove_0x_prefix
from ethereum.tester import keys
import os
import json
from microraiden.client.client import CHANNEL_MANAGER_ABI_NAME, TOKEN_ABI_NAME
from microraiden.crypto import privkey_to_addr
@pytest.fixture
def contracts_relative_path():
return 'data/contrac... | normal | {
"blob_id": "438fe1ccf265706e202d7cc6044e57590f29801f",
"index": 9375,
"step-1": "<mask token>\n\n\n@pytest.fixture\ndef contracts_relative_path():\n return 'data/contracts.json'\n\n\n@pytest.fixture\ndef compiled_contracts_path(test_dir, contracts_relative_path):\n return os.path.join(test_dir, contracts_... | [
10,
11,
17,
18,
21
] |
from marshmallow import fields
from server.common.database import Media
from server.common.schema.ref import ma
class MediaSchema(ma.SQLAlchemyAutoSchema):
class Meta:
model = Media
fields = ('id', 'name', 'mimetype', 'extension', 'owner', '_links')
dump_only = ('id', 'owner', '_links')
... | normal | {
"blob_id": "1810fee40ff8a99871ecc1d024f6794a68ee54e8",
"index": 3543,
"step-1": "<mask token>\n\n\nclass MediaSchema(ma.SQLAlchemyAutoSchema):\n\n\n class Meta:\n model = Media\n fields = 'id', 'name', 'mimetype', 'extension', 'owner', '_links'\n dump_only = 'id', 'owner', '_links'\n ... | [
1,
2,
3,
4,
5
] |
from leapp.models import Model, fields
from leapp.topics import TransactionTopic
class TargetRepositoryBase(Model):
topic = TransactionTopic
repoid = fields.String()
class UsedTargetRepository(TargetRepositoryBase):
pass
class RHELTargetRepository(TargetRepositoryBase):
pass
class CustomTargetRe... | normal | {
"blob_id": "47dc9212a1059cbca8ec6732deaa835fa9967fd8",
"index": 2990,
"step-1": "<mask token>\n\n\nclass RHELTargetRepository(TargetRepositoryBase):\n pass\n\n\nclass CustomTargetRepository(TargetRepositoryBase):\n name = fields.Nullable(fields.String())\n baseurl = fields.Nullable(fields.String())\n ... | [
9,
10,
11,
12,
14
] |
from django.shortcuts import render
from .models import Votings
from .serializers import VotingsSerializer
from rest_framework.response import Response
from rest_framework import status
from rest_framework.decorators import api_view
import requests, json
@api_view(['GET'])
def votings(request):
votings = Votings.... | normal | {
"blob_id": "c3ecac1c0facbf6f0905bb03fd337a7f4f5bbeff",
"index": 4376,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@api_view(['GET'])\ndef votings(request):\n votings = Votings.objects.all()\n if votings:\n return Response({}, status=status.HTTP_404_NOT_FOUND)\n else:\n seri... | [
0,
1,
2
] |
#!/usr/bin/python2
import sys
import argparse
"""
This program generates an extract table having the following format:
<S1> <S2> <S3> ... <Sn> ||| <T1> <T2> <T3> ... <Tk> ||| 0-0
Each line is a mapping from a source sentence to target sentence
with special delimiter characters.
You can give the output of this s... | normal | {
"blob_id": "cf0cf028d5f67e8deca8ebd3ad76d9c1e3563002",
"index": 258,
"step-1": "#!/usr/bin/python2\n\nimport sys\nimport argparse\n\n\"\"\"\nThis program generates an extract table having the following format:\n <S1> <S2> <S3> ... <Sn> ||| <T1> <T2> <T3> ... <Tk> ||| 0-0\n\nEach line is a mapping from a sour... | [
0
] |
import os
def get_os_env_value(key):
return os.getenv(key)
def get_mysql_uri(user, password, host, database):
return f'mysql+pymysql://{user}:{password}@{host}/{database}'
MASTER_MYSQL_DATABASE_USER = get_os_env_value('MASTER_MYSQL_DATABASE_USER')
MASTER_MYSQL_DATABASE_PASSWORD = get_os_env_value('MASTER_... | normal | {
"blob_id": "8247b045a5aed4d0f3db6bc2c0edd985f2c4ba30",
"index": 5305,
"step-1": "<mask token>\n\n\ndef get_mysql_uri(user, password, host, database):\n return f'mysql+pymysql://{user}:{password}@{host}/{database}'\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_os_env_value(key):\n return os.... | [
1,
2,
3,
4,
5
] |
# Generated by Django 2.0.5 on 2019-06-12 08:03
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('doctor', '0257_merge_20190524_1533'),
('doctor', '0260_merge_20190604_1428'),
]
operations = [
]
| normal | {
"blob_id": "a5dff32dfbe93ba081144944381b96940da541ad",
"index": 7802,
"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 = [('doctor', '0... | [
0,
1,
2,
3,
4
] |
from pyplasm import *
doorY = [.2,.18,.08,.18,.08,.18,.4,.18,.08,.18,.08,.18,.2]
doorX = [.2,.5,.2,1.8,.08,.18,.08,.18,.2]
doorOccurrency = [[True]*13,
[True, False, True, False, True, False, True, False, True, False, True, False, True],
[True]*13,
[True, False, True, False, True, False, True, False, T... | normal | {
"blob_id": "9bc955def6250908050a1f3046dd78480f25e0a1",
"index": 1898,
"step-1": "<mask token>\n\n\ndef resizeXY(X, Y, occurrency, dx, dz):\n \"\"\"This function takes in input X,Y,occurrency, two dimensions dx, dz and scales the values\n\tcontained in X and Y, in such a way that only empty spaces are scaled ... | [
3,
4,
5,
6,
7
] |
from flask import Flask
from flask import request, redirect, render_template
from flask_bootstrap import Bootstrap
import urllib.request
import urllib.parse
import json
import uuid
import yaml
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
import base64
app = Flask(__name__)
Bootstrap(app)
... | normal | {
"blob_id": "e55115a65ebee5d41dcd01a5cbabc328acf152da",
"index": 6079,
"step-1": "<mask token>\n\n\ndef encrypt(message, passphrase):\n passphrase = trans(passphrase)\n IV = Random.new().read(BLOCK_SIZE)\n aes = AES.new(passphrase, AES.MODE_CFB, IV)\n return base64.b32encode(IV + aes.encrypt(message)... | [
7,
9,
10,
12,
13
] |
from src.MultiValueDictApp import MultiValueDictApp
def main():
app = MultiValueDictApp()
print("Welcome to Multivalue Dictionary App")
print("COMMANDS and format:")
print("KEYS")
print("MEMBERS key")
print("ADD key value")
print("REMOVE key value")
print("REMOVEALL key")
print("CLE... | normal | {
"blob_id": "21e83369c4100c41885e9ee8a8d7310556bfe51d",
"index": 7271,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n app = MultiValueDictApp()\n print('Welcome to Multivalue Dictionary App')\n print('COMMANDS and format:')\n print('KEYS')\n print('MEMBERS key')\n prin... | [
0,
1,
2,
3,
4
] |
from __future__ import absolute_import
from . import utils
from . import bert_model
from . import transformer
from .utils import *
from .bert_model import *
from .transformer import *
| normal | {
"blob_id": "6415b08795975698e8e2019cafb82561b35f8e71",
"index": 2037,
"step-1": "<mask token>\n",
"step-2": "from __future__ import absolute_import\nfrom . import utils\nfrom . import bert_model\nfrom . import transformer\nfrom .utils import *\nfrom .bert_model import *\nfrom .transformer import *\n",
"step... | [
0,
1
] |
S = input()
T = int(input())
B = abs(S.count('L') - S.count('R')) + abs(S.count('U') - S.count('D'))
print(B + S.count('?') if T == 1 else max(B - S.count('?'), (B - S.count(
'?')) % 2))
| normal | {
"blob_id": "ce263424b856c07e04bd66cda7ebda646583b1fe",
"index": 5962,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(B + S.count('?') if T == 1 else max(B - S.count('?'), (B - S.count(\n '?')) % 2))\n",
"step-3": "S = input()\nT = int(input())\nB = abs(S.count('L') - S.count('R')) + abs(S.cou... | [
0,
1,
2
] |
import os
import factorStatFileCreator
dirName = 'NoPerms/'
dirName2 = 'AllPerms/'
freqAgentDic = dict()
lenAgentDic = dict()
contAgentDic = dict()
def freqModAvgFunc(dirName):
fullList = factorStatFileCreator.directoryFreq(dirName)
UA = dirName.split("/")[1]
avgList = []
sum = 0
i = 0
while ... | normal | {
"blob_id": "8ac84aa29e9e4f3b85f1b3c27819feb5f41e8d8e",
"index": 598,
"step-1": "<mask token>\n\n\ndef freqModAvgFunc(dirName):\n fullList = factorStatFileCreator.directoryFreq(dirName)\n UA = dirName.split('/')[1]\n avgList = []\n sum = 0\n i = 0\n while i <= len(fullList) - 2:\n diff =... | [
7,
8,
9,
10,
12
] |
from model import WSD
from data_preprocessing import load_dataset, create_mapping_dictionary, reload_word_mapping,get_bn2wn,get_bn2wndomains, get_bn2lex
from typing import List, Dict, Tuple
from prova import convert_sentence_to_features_no_padding
import numpy as np
import os
from nltk.corpus import wordnet
mfs_count... | normal | {
"blob_id": "e3631a2a003f98fbf05c45a019250e76d3366949",
"index": 2582,
"step-1": "<mask token>\n\n\ndef predict_babelnet(input_path: str, output_path: str, resources_path: str\n ) ->None:\n global mfs_counter\n \"\"\"\n DO NOT MODIFY THE SIGNATURE!\n This is the skeleton of the prediction function... | [
7,
9,
11,
12,
15
] |
import os
import shutil
# root_path = '../from_1691'
root_path = 'C:/Users/koyou/Desktop/test'
# 실수할 수도 있으므로 dry_run 을 설정해서 로그만 찍을 것인지
# 실제 작동도 진행할 것인지 결정한다.
# dry_run = True
dry_run = False
def move_directory(input_directory_path, output_directory_path):
print("moving %s to %s" % (input_directory_path, output_d... | normal | {
"blob_id": "7de19a85a6a05bd2972b11571d5f05219c6beb1a",
"index": 916,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef move_directory(input_directory_path, output_directory_path):\n print('moving %s to %s' % (input_directory_path, output_directory_path))\n if not dry_run:\n shutil.move... | [
0,
1,
2,
3,
5
] |
import datetime
from django.db import models
from django.utils import timezone
class Acoount(models.Model):
first_name = models.CharField("Ім\'я", max_length=50)
last_name = models.CharField('Прізвище', max_length=50)
username = models.CharField('Псевдонім', max_length=50)
email = models.CharField('Е... | normal | {
"blob_id": "18c2fe40b51ad1489d55aa2be068a1c4f381a2a5",
"index": 553,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Acoount(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name = 'А... | [
0,
1,
2,
4,
5
] |
from page_parsing import get_item_info_from,url_list,item_info,get_links_from
# ================================================= < <链接去重 > > =====================================================
# 设计思路:
# 1.分两个数据库,第一个用于只用于存放抓取下来的 url (ulr_list);第二个则储存 url 对应的物品详情信息(item_info)
# 2.在抓取过程中在第二个数据库中写... | normal | {
"blob_id": "4f2017632d905c80c35fbaead83ecb7e1ac95760",
"index": 9868,
"step-1": " from page_parsing import get_item_info_from,url_list,item_info,get_links_from\n\n\n # ================================================= < <链接去重 > > =====================================================\n\n # 设计思路:\n # ... | [
0
] |
#Function to remove spaces in a string
def remove(string_input):
return string_input.replace(" ", "")
| normal | {
"blob_id": "f327f408ae2759407ac9f01ad4feff5c6a0845f1",
"index": 9524,
"step-1": "<mask token>\n",
"step-2": "def remove(string_input):\n return string_input.replace(' ', '')\n",
"step-3": "#Function to remove spaces in a string\n\ndef remove(string_input):\n return string_input.replace(\" \", \"\")\n"... | [
0,
1,
2
] |
import requests
import json
import pandas as pd
n1 = 'ADS'
api_url = 'https://www.quandl.com/api/v3/datasets/WIKI/%s.csv' % n1
df = pd.read_csv(api_url)
df = df.head(100)
print(df.head())
#print(list(data))
| normal | {
"blob_id": "3dd4b4d4241e588cf44230891f496bafb30c6153",
"index": 46,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(df.head())\n",
"step-3": "<mask token>\nn1 = 'ADS'\napi_url = 'https://www.quandl.com/api/v3/datasets/WIKI/%s.csv' % n1\ndf = pd.read_csv(api_url)\ndf = df.head(100)\nprint(df.head(... | [
0,
1,
2,
3,
4
] |
# coding=utf-8
# Copyright 2019 The Google Research Authors.
#
# 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 applicab... | normal | {
"blob_id": "f253816d08407950caad28f1ce630ac2b099aa70",
"index": 3241,
"step-1": "<mask token>\n\n\ndef make_experiment_dir(postfix):\n home = os.path.expanduser('~')\n exp_dir = os.path.join(home, postfix)\n mkdir_p(exp_dir)\n return exp_dir\n\n\ndef save_fig(folder, filename):\n if folder is Non... | [
10,
12,
13,
14,
16
] |
import bluetooth
import serial
import struct
# Definition of Bluetooth rfcomm socket
bd_addr = "98:D3:37:00:8D:39" # The address from the HC-05 sensor
port = 1
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((bd_addr,port))
# Definition of Serial port
ser = serial.Serial("/dev/ttyACM0", 57600)
def BT... | normal | {
"blob_id": "605c78795b5a072d330d44a150f26ad410d9d084",
"index": 2962,
"step-1": "import bluetooth\nimport serial\nimport struct\n\n# Definition of Bluetooth rfcomm socket\nbd_addr = \"98:D3:37:00:8D:39\" # The address from the HC-05 sensor\nport = 1\nsock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)\nsock.conn... | [
0
] |
from os.path import dirname
import binwalk
from nose.tools import eq_, ok_
def test_firmware_squashfs():
'''
Test: Open hello-world.srec, scan for signatures
verify that only one signature is returned
verify that the only signature returned is Motorola S-rec data-signature
'''
expected_result... | normal | {
"blob_id": "d55043c2a18b935478d9be442aaf7305231edc7d",
"index": 5828,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_firmware_squashfs():\n \"\"\"\n Test: Open hello-world.srec, scan for signatures\n verify that only one signature is returned\n verify that the only signature ret... | [
0,
1,
2,
3
] |
import typing
from pydantic import AnyUrl
from .base import FBObject
class MediaPayload(FBObject):
url: AnyUrl
class Coors(FBObject):
lat: float
long: float
class LocationPayload(FBObject):
coordinates: Coors
class AttachmentFallback(FBObject):
title: str
url: AnyUrl
payload: typin... | normal | {
"blob_id": "1f6176e9285d810934ae745cf8759b5cd6f408c8",
"index": 8767,
"step-1": "<mask token>\n\n\nclass LocationPayload(FBObject):\n coordinates: Coors\n\n\nclass AttachmentFallback(FBObject):\n title: str\n url: AnyUrl\n payload: typing.Any = None\n type: str = 'fallback'\n\n\nclass Attachment(... | [
3,
4,
5,
6,
7
] |
"""
This file contains the general data storage classes used throughout Logician.
"""
import csv
import json
import os
from collections import OrderedDict
VALID_CHANNEL_COUNTS = [4]
class Acquisition:
"""
The acqusition object contains data from all of the acquired channels.
Parameters
----------
... | normal | {
"blob_id": "ec44e12624fbee3148cfa4f886e86ba437e920ec",
"index": 4158,
"step-1": "<mask token>\n\n\nclass Acquisition:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def csv_string(self):\n out_string = '#sample_rate=%d' % self.sample_rate\n for row... | [
13,
15,
19,
20,
24
] |
"""
Write two functions:
1. `to_list()`, which converts a number to an integer list of its digits.
2. `to_number()`, which converts a list of integers back to its number.
### Examples
to_list(235) ➞ [2, 3, 5]
to_list(0) ➞ [0]
to_number([2, 3, 5]) ➞ 235
to_number([0]) ➞ 0
### No... | normal | {
"blob_id": "5cced6d9f5e01b88951059bc89c5d10cfd160f60",
"index": 8826,
"step-1": "\"\"\"\r\n\n\nWrite two functions:\n\n 1. `to_list()`, which converts a number to an integer list of its digits.\n 2. `to_number()`, which converts a list of integers back to its number.\n\n### Examples\n\n to_list(235) ➞ [2, ... | [
0
] |
#!/usr/bin/env python3
import os
import subprocess
import emailgen
#
# Header information
#
recipient = input("recipient: ")
sender = input("sender: ")
password = input("sender password: ")
subject = "hdd temp alert"
#
# Get hdd temp, format for email
#
output = subprocess.check_output('sudo hddtemp /dev/sda /dev/sd... | normal | {
"blob_id": "26a6fe0b2a98aa77b63a336cd6c2afcfe81d9058",
"index": 7680,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntext += '\\nHostname: ' + os.uname().nodename\nemailgen.sendAlert(recipient, subject, text, sender, password)\n",
"step-3": "<mask token>\nrecipient = input('recipient: ')\nsender = inp... | [
0,
1,
2,
3,
4
] |
import csv
with open('./csvs/users.csv', encoding='utf-8', newline='') as users_csv:
reader = csv.reader(users_csv)
d = {}
for row in reader:
userId, profileName = row
if profileName == 'A Customer':
continue
value = d.get(profileName)
if not value:
d... | normal | {
"blob_id": "3b77f7ea5137174e6723368502659390ea064c5a",
"index": 8968,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('./csvs/users.csv', encoding='utf-8', newline='') as users_csv:\n reader = csv.reader(users_csv)\n d = {}\n for row in reader:\n userId, profileName = row\n ... | [
0,
1,
2,
3
] |
import numpy as np
raw = np.load("raw_with_freq.npy").item()
for i in list(raw.keys()):
if len(i) > 8:
del(raw[i])
print(raw)
print(len(list(raw.keys())))
np.save("shorten_raw_with_freq.npy", raw)
| normal | {
"blob_id": "ffb17b370c892696b341f6d37a2cfe106a5670a5",
"index": 4265,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in list(raw.keys()):\n if len(i) > 8:\n del raw[i]\nprint(raw)\nprint(len(list(raw.keys())))\nnp.save('shorten_raw_with_freq.npy', raw)\n",
"step-3": "<mask token>\nraw ... | [
0,
1,
2,
3,
4
] |
def lengthOfLongestSubstring(s):
max_len = 0
for i in range(len(s)):
storage = set()
count = 0
for j in range(i, len(s)):
if not s[j] in storage:
storage.append(s[j])
count += 1
else:
break
max_len = max(max_... | normal | {
"blob_id": "7e83d11bb43229eaa199514b4be6a0acf3ab36ce",
"index": 4395,
"step-1": "<mask token>\n",
"step-2": "def lengthOfLongestSubstring(s):\n max_len = 0\n for i in range(len(s)):\n storage = set()\n count = 0\n for j in range(i, len(s)):\n if not s[j] in storage:\n ... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
"""
VorRun
Runs Vorlax and plots wireframe output from Vorlax
(https://github.com/GalaxyHobo/VORLAX)
NOTE! Type: "%matplotlib auto" in iPython console to
switch to interactive plots, or "%matplotlib inline"
to switch to inline, in the console.
NOTE! Reads path to Vorlax .exe in "... | normal | {
"blob_id": "9aee715e976db632f0829a06cb9e0101c90512be",
"index": 2150,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfout.close()\n<mask token>\nif not drive:\n drive = 'C:'\n<mask token>\nos.system(runString)\n<mask token>\nfout.close()\n<mask token>\nfor index, line in enumerate(lines):\n panelD... | [
0,
1,
2,
3,
4
] |
#-*- coding: utf-8 -*-
import argparse
import pickle
def str2bool(v):
return v.lower() in ('true', '1')
arg_lists = []
parser = argparse.ArgumentParser()
def add_argument_group(name):
arg = parser.add_argument_group(name)
arg_lists.append(arg)
return arg
# Network
net_arg = add_argument_group('Network')
n... | normal | {
"blob_id": "dfaea1687238d3d09fee072689cfdea392bc78f9",
"index": 8967,
"step-1": "<mask token>\n\n\ndef str2bool(v):\n return v.lower() in ('true', '1')\n\n\n<mask token>\n\n\ndef add_argument_group(name):\n arg = parser.add_argument_group(name)\n arg_lists.append(arg)\n return arg\n\n\n<mask token>\... | [
2,
3,
5,
6,
7
] |
# -*- coding: utf-8 -*-
# !/usr/bin/env python3
import pathlib
from PIL import Image
if __name__ == '__main__':
img_path = (pathlib.Path('..') / 'images' / 'tiger.jpg').resolve()
# image load
with Image.open(str(img_path)) as img:
# image info
print('IMAGE: {}'.format(str(img_path)))
... | normal | {
"blob_id": "05edbf3662936465eee8eee0824d1a0cca0df0e5",
"index": 4855,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n img_path = (pathlib.Path('..') / 'images' / 'tiger.jpg').resolve()\n with Image.open(str(img_path)) as img:\n print('IMAGE: {}'.format(str(img_pa... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from rest_framework.views import APIView
from ..Models.ConnectToDBModel import *
from ..Models.RegionInfoModel import *
from .CommonView import *
def get_one_spot(region):
comments_data = get_comment_data();
data = {};
data['id'] = region.id;
data['name'] = r... | normal | {
"blob_id": "0b0b22043dda94ea57344fb3bf47255ad85c7f5b",
"index": 1408,
"step-1": "<mask token>\n\n\nclass SpotListView(APIView):\n <mask token>\n",
"step-2": "<mask token>\n\n\ndef get_one_spot(region):\n comments_data = get_comment_data()\n data = {}\n data['id'] = region.id\n data['name'] = re... | [
1,
3,
4,
5,
6
] |
class player:
def __init__(self, name: str, symbol: str):
self._name = name
self._symbol = symbol
def decide_next_move(self):
"""
Checks all possible combinations to decide best next move
:return: board position
"""
pass
def get_next_move(self):
... | normal | {
"blob_id": "3cc894570189fe545f5db3150d0b69c16dc211dc",
"index": 981,
"step-1": "class player:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class player:\n\n def __init__(self, name: str, symbol: str):\n self._name = name\n self._symbol = symbol\n <mask token>\n <... | [
1,
2,
3,
4
] |
#-*- coding = utf-8-*-
#@Time : 2020/6/26 11:02
#@Author :Ella
#@File :app.py
#@Software : PyCharm
import time
import datetime
from flask import Flask,render_template,request #render_template渲染模板
app = Flask(__name__) #初始化的对象
#路由解析,通过用户访问的路径,匹配想要的函数
@app.route('/')
def hello_world():
return '你好'
#通过访问路径,获取用户的... | normal | {
"blob_id": "d68bd9c90a106a9eac767607ad77bdd84d0f18d2",
"index": 1006,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef hello_world():\n return '你好'\n\n\n@app.route('/test1/<name>')\ndef test1(name):\n return '你好,%s' % name\n\n\n@app.route('/test2/<int:id>')\ndef test2(id):\n return '你好,%d' % id\n\n\n<... | [
5,
6,
7,
9,
10
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.