index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
6,600 | 7d25a8eb61b6fb9069616745c2b68fd3ceeca9fb | # Generated by Django 2.2.2 on 2019-10-19 14:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='account',
name='phone_number',
... |
6,601 | a757bbb9ad2f6f5bf04cdf4091b97841b8e40432 | import os
import pickle
import collections
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython import embed
from optimizers.utils_1 import Model_1, Architecture_1
from optimizers.utils import Model, Architecture
colors={
'BOHB-PC-DARTS': 'darkorange',
'BOHB-DARTS': 'dod... |
6,602 | e5e7856d752f14e0671bae8d8b7997207c667ae1 | from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
from django.views.generic.base import View
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
# from com_search.get_info import Search as Search_1
# from com_search.models import CompanyType
import json
# Cr... |
6,603 | b52807a15cef8f07f685f8761a470d4a24d9c3dc | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/6/20 下午4:00
# @Author : Huang HUi
# @Site :
# @File : query_parse.py
# @Software: PyCharm
from mysqlConnection import mysqlConnection
import yaml
import copy
import time
import csv
import json
from collections import OrderedDict
import ast
#
# GIV... |
6,604 | 51ed99a68486bd52499bbc28e68ff2312e02ea1f | from django.db import models
from datetime import datetime
# Create your models here.
class Notifications(models.Model):
username= models.CharField(max_length=20)
phone_number= models.BigIntegerField(default= 0)
email= models.EmailField()
firstname= models.CharField(max_length=20)
app_name= models... |
6,605 | dd053da45d2577772414b1373ba324b0bfdc0d94 | from pyrogram import Client, filters
from pyrogram.errors import MessageNotModified
from db.models import *
@Client.on_callback_query(filters.regex('^change_lg_'))
async def on_change_language(_, callback):
settings_id = int(callback.data.split('_')[2])
with db_session:
settings = SettingsInstance.g... |
6,606 | 965db2523f60d83bd338bcc62ab8e5705550aa89 | import csv
import json,os
mylist=[]
clist=["North Indian","Italian","Continental","Chinese","Mexican","South Indian"]
for filename in os.listdir("/home/asket/Desktop/DBMS/menu"):
print(filename) |
6,607 | 0b36bf9ac7887101be5503a0edce19e1111e5ca0 | # Import other modules
from zelda_utilities.constants import *
# Helps establish the current frame for sprite animation/image changing
class Animation:
def __init__(self):
# Animation clock
self.next_frame = pygame.time.get_ticks()
# Starting frame
self.frame = 0
# ~12 fr... |
6,608 | 9706b9ba81f41b131c364a16bb17a0c1e31e3a04 | import numpy as np
import skimage
def preprocess_img(img, size):
img = np.rollaxis(img, 0, 3) # It becomes (640, 480, 3)
img = skimage.transform.resize(img, size)
img = skimage.color.rgb2gray(img)
return img
# data = minerl.data.make("MineRLNavigateDense-v0", data_dir="../dataset/navigate")
#
# # I... |
6,609 | 46bf5866d5353c58e130b20ffa4d95df8abf986b | import os
import pickle
import PySimpleGUI as sg
from typing import Dict
sg.ChangeLookAndFeel('Black')
import string
from nltk.tokenize import word_tokenize
from itertools import chain
from glob import glob
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.stem import PorterStemmer
fro... |
6,610 | 02cd99f0a265fe01835a6adc211e750a58d993fd | import Pyro4
from Pyro4 import Daemon, Proxy
from threading import Thread
import thread
import pickle
import socket
Pyro4.config.REQUIRE_EXPOSE = False
def register(obj):
''' Register an object with daemon '''
daemon = Pyro4.Daemon(host="localhost")
uri = daemon.register(obj) # Scheduler
serve_daemon(... |
6,611 | 8d8df517ca5486e62cc1b5ac23bbcfa65ed9c1ff | 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() |
6,612 | b3a07107ef64bb50f4768954cbb579d8e66bd003 | #!/usr/bin/python
# The program was written by YU Ho Yung and LEUNG Kin Tung in group 24.
# The program is written with stubs for the phase 3
#
import pymongo
from scrapy.selector import Selector
import pandas as pd
# import numpy as np
import datetime
import re
import pprint
import subprocess
import scrapy
from pym... |
6,613 | c7558486fc50623f6e64b58668153b75bb6149b9 | # Generated by Django 2.2.10 on 2020-05-06 14:43
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('planner', '0023_auto_20191226_1330'),
]
operations = [
migrations.AddField(
model_name='employee'... |
6,614 | d983cb4ae79d8370ed0809b86762c1e2ea125320 | import pandas as pd
def ranked(country, variety, price, num):
data = pd.read_csv("wine_final.csv")
if num == 0:
return None
if country !='':
data = data.query("country==\"{}\"".format(country))
if variety !='':
data = data.query("variety==\"{}\"".format(variety))
if pric... |
6,615 | a12fe733e607b1ce4cf0f3f4adc3ea85d082e769 | from pyftpdlib.authorizers import DummyAuthorizer # Autorizaciones
from pyftpdlib.handlers import FTPHandler # Comandos del usuario
from pyftpdlib.servers import FTPServer # Creacion del servidor
import logging
import os
def main():
# Instancia un autorizador dummy para controlar usuarios "virtuales"
auth... |
6,616 | e9fff1fb0a79493d4d7f3417c7d554eb10a978a0 | def fun1(fun):
return "Hai!!!! "+fun
def message():
return "How are you"
res = fun1(message())
print(res)
|
6,617 | 056636e2220e529d3f66872a4a48c0984cda1ce4 | def sort(L):
n = len(L)
if n < 2:
return L
L1, L2 = L[:n // 2], L[n // 2:]
return merge(sort(L1), sort(L2))
def merge(L1, L2):
if L1 == []:
return L2
if L2 == []:
return L1
x1, R1 = L1[0], L1[1:]
x2, R2 = L2[0], L2[1:]
if x1 <= x2:
return [x1] + merge... |
6,618 | 79c7a2f2e5f0301c15efe1b26a7839a12098f793 | # coding: utf-8
'''
Precision, Recall, F1で評価する
Leave-one-outの結果
K-foldの結果
'''
import sys
import os.path
import snlocest.util as util
import numpy as np
import pandas as pd
from sklearn.model_selection import KFold
from sklearn.metrics import precision_recall_fscore_support, classification_report
def precision_re... |
6,619 | 3378ce72ae67d09258554048138b7f9023000922 | from django.shortcuts import render
import datetime
from django.http import*
from django.core.files.storage import FileSystemStorage
import uuid
import os
import cv2
import numpy as np
from pathlib import Path
def index(request):
print(request.session);
today=datetime.datetime.now()
return render(request,'index.h... |
6,620 | 5707e24596dfe2d85e9a7caa93aa3e253a41ae40 | # -*- encoding: utf-8 -*-
from django.conf.urls import patterns, url
urlpatterns = patterns('apps.profiles.views',
url(r'^$', 'index', name='profiles'),
# Show a specific profile.
url(r'^view/(?P<username>[a-zA-Z0-9_-]+)/$', 'view_profile', name='profiles_view'),
url(r'^edit/$', 'edit_profile', name... |
6,621 | 24635989ccdb0f35f1e618dd8dc07f2cf84faddb | a = [1, 1, 2, 3, 4, 4, 5, 7, 12, 30, 49]
for i in range(0, len(a)):
if a[i] < 5:
print(str(a[i]) + " ")
i += 1
else:
i += 1
|
6,622 | 5dc17db0aca109720d1ba62d65b86d9b81714063 | import os
import flask_sqlalchemy as sqlalchemy
from flask import Flask, jsonify, request,render_template,redirect,url_for,json,flash
from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class
from flask_cors import CORS
import datetime
from flask_bootstrap import Bootstrap
from flask_login i... |
6,623 | 4d7e30714ae209e1d09d895dadf7a19928fe253f | # coding: utf-8
# 02. 「パトカー」+「タクシー」=「パタトクカシーー」
# 「パトカー」+「タクシー」の文字を先頭から交互に連結して文字列「パタトクカシーー」を得よ.
s1 = "パトカー"
s2 = "タクシー"
ans = ""
for c1, c2 in zip(s1, s2):
ans += c1 + c2
print(ans)
#パタトクカシーー
|
6,624 | 1e929bc3c97de859a16a4ac8d5ac2ebadefd0516 | from __future__ import absolute_import
import numpy as np
import matplotlib.pyplot as pl
import seaborn as sb
sb.set_color_codes('muted')
import scipy.optimize as op
from scipy import stats
def errorbar(t, f, s, fp=None, **kwargs):
with sb.axes_style('white'):
fig, ax = pl.subplots(1, 1, figsize=(10,3))
... |
6,625 | 23160c2f030b0bd862360e944fbbc283c6cb45b2 | from rest_framework import serializers
class BillBaseSerializer(serializers.Serializer):
vendor = serializers.CharField(required=False)
amount = serializers.FloatField()
bill_date = serializers.DateField()
due_date = serializers.DateField()
class BillListSerializer(BillBaseSerializer):
id = se... |
6,626 | 8c1718f56a73fdd962154abfaedc7c0c3cb0d9ba | from django.urls import path
from . import views
app_name = 'adverts'
urlpatterns = [
path('', views.AdvertListView.as_view(), name="list"),
path('create/', views.AdvertFormView.as_view(), name='adverts-create'),
path('<str:category>/', views.AdvertListView.as_view(), name="adverts-list-categories"),
]
|
6,627 | d1d293a5d2c394e69d93488605f27b5468220286 | import pymongo
import time
client = pymongo.MongoClient('localhost', 27017);
db = client['zhihu']; # 类似dict,若不存在,则新建;
# client.drop_database('zhihu') # 删除db
collection = db['zhihu']; # 若不存在,则新建;
# db.drop_collection('zhihu') # 删除collection
document_test = {'name': 'test', 'time': time.strftime('%Y-%m-%d %H:%M:%... |
6,628 | c3c82b9ba198b7818cc8e63710140bbb6e28a9ea |
"""
クリップボードのamazonのURLから不要な部分を削除する
"""
# -*- coding: utf-8 -*-
import re
import pyperclip as clip
from urllib.parse import urlparse
#print(clip.paste())
def urlShortner():
# text = "https://www.amazon.co.jp/Jupyter-Cookbook-Dan-Toomey/dp/1788839447/ref=sr_1_5?s=books&ie=UTF8&qid=1535164277&sr=1-5&keywords=Jupyte... |
6,629 | 3e305cee2f814698729c008320e326c4bd42640d | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('grid2', '0003_auto_20161231_2329'),
]
operations = [
migrations.RemoveField(
model_name='grid',
name... |
6,630 | 2ca40a53291a62bbdb4386decc5a2dfa84431836 | #https://www.geeksforgeeks.org/count-of-substrings-of-length-k-with-exactly-k-distinct-characters/
#https://www.geeksforgeeks.org/count-number-of-substrings-with-exactly-k-distinct-characters/
|
6,631 | 70373c74e459efb2a310d94ae906910423e8bfd4 | import re
from mapa import graficar_lista, graficar_matriz
class nodo:
def __init__(self, x, y, n, c):
self.columna = x
self.fila = y
self.nombre = n
self.color = c
pattern_matriz = r"[M|m][A|a][T|t][R|r][I|i][Z|z]\s*\(.*,.*,.*,.*,.*\)\{"
pattern_fila = r"[F|f][I|i][L|l][A|a]\s*\(... |
6,632 | aae280e049c00e70e2214662a07eee8bfa29227e | import sys
import pygame
import pygame.camera
from pygame.locals import *
from PIL import Image
pygame.init()
pygame.camera.init()
camlist = pygame.camera.list_cameras()
print(camlist)
# images = map(Image.open, ['Test1.jpg', 'Test2.jpg', 'Test3.jpg'])
# widths, heights = zip(*(i.size for i in images))
# total_wi... |
6,633 | d0bd08bea65878f5fccfc4affecdf53cc36179df | import cv2 as cv
#! THESE ARE IMAGES THAT AREN'T DOWNSIZED
#original_image_1 = cv.imread("hamburger_face.JPG")
#original_image_2 = cv.imread("hammock_reading.JPG")
#original_image_3 = cv.imread("sofa_face.JPG")
#original_image_4 = cv.imread("frisbee_team.JPG")
original_image_5 = cv.imread("mans_face.JPG")
# ... |
6,634 | fd04f6f4a03fdbe40e400d04e5759ef9ef30f974 | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 2 16:07:25 2018
@author: Yigao
"""
import re
from nltk.tokenize import TweetTokenizer
from nltk.corpus import stopwords
from wordcloud import WordCloud
import matplotlib.pyplot as plt
## create a tokenizer
hfilename = "file.txt"
linecount=0
hashcount=0
wordcount=0
BagO... |
6,635 | f2c96b3133137019dc6bd462f096f3b4c5f12648 | # Generated by Django 3.1.1 on 2020-10-29 13:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('registered_user', '0005_auto_20201029_1710'),
]
operations = [
migrations.AlterField(
model_name='user_details',
nam... |
6,636 | 3eca3066a6c6484257ca17164d35654812a87b80 | n, imp = list(map(int, input().split()))
villagers = {}
peoples = []
susList = set()
for i in range(n):
peeps = set(list(map(int, input().split()))[1:])
# Initialize the set
villagers[i+1] = villagers.get(i+1, set())
for p in peeps:
if i+1 in peeps:
susList.add(i+1)
break... |
6,637 | 15134d7e4036c102bc9d2ba4d321fadd0467100f | from django.contrib import admin
from django.db import models
from tinymce.widgets import TinyMCE
from .models import UserInfo
# Register your models here.
class UserInfoAdmin(admin.ModelAdmin):
list_display=[
'user_name',
'user_profession',
'user_phone',
'user_email',
... |
6,638 | 70c084dab8469ca34b0e3e5174101111e695f1ca | class TflearnDataSourceExtraTemplate(object):
"""
Base class for TFLearn's DataSource (if we use wrapping).
Parameters:
----------
rewrite_data_aug : bool
use wrapper for data augmentation
"""
def __init__(self, rewrite_data_aug=False):
self.rewrite_data_aug = rewrite_data_... |
6,639 | d988cfebeec37df700f46bbb027a4980ba624d30 | import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
print("chars: ", chars)
#one-hot encoding
char_to_ix = { ch:i for i,ch in enumerate(chars) }
ix_to_char = { i:ch for i,ch in enumerate(chars) }
it... |
6,640 | b6527a09f346ee1b7dd446a0ff21995a995481a8 | import argparse
def parse_args():
"""
Parse command-line arguments to train and evaluate a multimodal network for activity recognition on MM-Fit.
:return: Populated namespace.
"""
parser = argparse.ArgumentParser(description='baseline Mask R-CNN')
parser.add_argument('--dataset', required=True... |
6,641 | 05144338cc9c0c65010e0b8a3dd6fb50f6343214 | def climb_ways(n, k): |
6,642 | 1d1f1c9b70ca487b48593c85c3e0b5afc10f0b07 | import os
import sys
import random
import pygame
import time
from pygame import locals
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 1024
class Moto(pygame.sprite.Sprite):
def __init__(self, player_num, start_direction):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("motor" + str(pla... |
6,643 | 2238345a69c2d7a1958a23a470dcb2be6469caeb | import math3d
import math
import pygame
import random
class PBody(object):
""" A physics-enabled object. """
def __init__(self, pos, mass=1, rad=10, vel=(0,0), color=(255,255,255)):
self.pos = math3d.VectorN(pos)
self.vel = math3d.VectorN(vel)
self.rad = 10 # in pixe... |
6,644 | aad3c104432a1a028d96263236133e495536ee69 | from locations.storefinders.storelocatorwidgets import StoreLocatorWidgetsSpider
class Pharmacy4LessAUSpider(StoreLocatorWidgetsSpider):
name = "pharmacy_4_less_au"
item_attributes = {"brand": "Pharmacy 4 Less", "brand_wikidata": "Q63367608"}
key = "6c0hBJeL5yk8cmaKJGNjTu0JhWNaMQpX"
|
6,645 | 65b90fccd0ee74b369475aa9fe33f159881c8b82 | class cal4:
def setdata(self,n1):
self.n1 = n1
def display(self):
return n1*n1
n1 = int(input("Enter number: "))
c = cal4()
print(c.display()) |
6,646 | 36bdd6f7c130914856ddf495c50f928405c345aa | # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-23 19:31
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mocbackend', '0034_auto_20181122_1903'),
]
operations = [
migrations.AddFi... |
6,647 | b1530c664fa236e61ff50bca502bf79730c3386c | #!/usr/bin/python
# -*- coding: utf-8 -*-
#
# All about users.
#
# author: ze.apollo@gmail.com
#
from client import ClientHelper
from mongodb import MongoDBClient
class FixedData:
def get_data( self, id ):
data = self.get_data_from_mongodb( id )
if ( data ):
return data
else:
... |
6,648 | 1dd235ecfe577b508d0777e8c70026114aeb154f | from tdm.lib.device import DddDevice, DeviceAction, DeviceWHQuery, Validity
class CallJohnDevice(DddDevice):
class MakeCall(DeviceAction):
def perform(self, select_contact, select_number):
contact = self.device.CONTACTS.get(select_contact)
number_type = self.device.CONTACT... |
6,649 | a382edb861a43ac3065a781ea996a8d1dd819954 | def game_manager(info_list):
dictionary = {}
for piece_info in info_list:
piece_info = piece_info.split('||')
piece_info[2] = int(piece_info[2])
if piece_info[2] not in dictionary:
dictionary[piece_info[2]] = {(piece_info[1],piece_info[0])}
dictionary[piece_info[2]].a... |
6,650 | d18c0fa29ccdabdd9e11622e8aaec91ff96117df | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Alonso Vidales"
__email__ = "alonso.vidales@tras2.es"
__date__ = "2013-11-11"
class ConnectedSets:
"""
This is a classic percolation problem, the algorithms uses an array
of integer to represent tees, each tree will be a set of connected element... |
6,651 | 1947bd280234189ed35277c449cd708a204ea7a4 | '''
The MIT License (MIT)
Copyright (c) 2016 WavyCloud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, p... |
6,652 | 87d1c28819d187944a3cf99b35b1d41eab11b139 | # 1.Create a list of 10 elements of four different data types like int, string, complex and float.
i=[1,2,3,4,5,6,7,8,9,10]
f=[10.5,12.2,13.7,14.9,14.9,18.8,19.7,23.6,90.9,25.7]
s=['Arpi','world','Hello','Python','Consultadd','job','c++','Concepts','interesting']
c=[1+2j,2+3j,4+5j,5+6j,56+7j,8+9j,7+8j,3+6j,7+9j]
print... |
6,653 | 21172985bf36302f6b0b2101e353d9fbcafb0673 | from typing import Dict, List, Sequence, Iterable, Tuple
from allennlp.data.dataset_readers.dataset_reader import DatasetReader
from allennlp.data.instance import Instance
from allennlp.common.file_utils import cached_path
import logging
from overrides import overrides
import itertools
from allennlp.data.tokenizers imp... |
6,654 | 51ff1181f0ddac3a8f7cbd9f9d2eedae29a6c559 | from django.db import models
from django.contrib.auth.models import User
from django.db.models.deletion import CASCADE
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=CASCADE)
# portfolio = models.ManyToOneRel(User, on_delete=)
def __str__(self):
return f"{self.user.user... |
6,655 | 54c1b294d826deb43978591cad590c5e969bebd7 | __author__ = 'Or'
|
6,656 | 2458b8169029b3af501b650d548925770b0da74e |
from django.contrib import admin
from django.urls import path
from petsApp import views
urlpatterns = [
path('user/<int:id>/', views.getUser),
path('user/addImage/', views.addImage),
path('user/getImage/<int:id>/', views.getImage),
path('user/signup/', views.signUp),
path('user/login/', views.logI... |
6,657 | c0376d94b34ea43e562e68cd65d4e5d2c5b04fb3 | for name in ["Madan", "Mohan", "Reddy", "Govindu"]:
print("My name includes "+name)
# Tables
# for i in range(1, 11):
# for j in range(1, 11):
# print("{0} * {1} = {2}".format(i,j, i*j))
# print("\n")
for i in range(1, 3):
for j in range(4, 7):
if j==5:
break
print... |
6,658 | 555646a5d57152034b467cbce16b6c183bcfbb37 | import copy
from basics.binary_tree.binary_tree import TreeNode
from basics.binary_tree.traversals import level_order_traversal
def max_depth_bottom_up(root):
if not root:
return 0
max_so_far = 0
def max_depth(node, depth):
nonlocal max_so_far
if not node.left and not node.right... |
6,659 | fbba928d51ccd08dbac25fcf2098be3a0d494d34 | ii = [('CoolWHM.py', 1), ('SoutRD.py', 1), ('BrewDTO.py', 2), ('FitzRNS2.py', 1), ('LyelCPG3.py', 1), ('TaylIF.py', 2)] |
6,660 | ad170f67e5b9f54d950ead91dd60cd4f3b753eca | from Config_paar import *
from Envelopefkt import *
from Kinematik import *
def A_m_n(M,N,x_plus,p_el,p_pos,k_photon,k_laser):
def f1(p):
return -(m*a0)/(pk(p)) * g(phi,sigma,Envelope) *( pe(1,p) * cos(ksi) * cos(phi) + pe(2,p) * sin(ksi) * sin(phi) )
def f2(p):
return -(m*a0)**2/(2.... |
6,661 | 619d2df45d0823930484f030a9a78e71ec718cb7 | # -*- coding: utf-8 -*-
from django.apps import AppConfig
class AcademyConfig(AppConfig):
name = 'academy'
verbose_name = u"Академия"
|
6,662 | 23d15c719cd26ea67a032a91a3e73f0d8d3bcfd1 | from django.views import generic
from .models import Project
class IndexView(generic.ListView):
template_name = "projects/index.html"
context_object_name = "projectz"
def get_queryset(self):
"""Return all projects."""
return Project.objects.all()
class DetailView(generic.DetailView):
... |
6,663 | a3e655350fb5fe7999bea4a87fb62c7698fb63f1 | from typing import List
import tensorflow as tf
from tensorflow.keras.layers import Dense
"""Possible agent network structures implemented as Tensorflow Modules"""
class QNetwork:
"""Create the neural network architecture for the DQN agent."""
def __init__(
self,
state_dim: int,
act... |
6,664 | 2e1ad83bcd16f59338032f8ad5ca8ebd74e92200 | from typing import Any, List
__all__: List[str]
record: Any
recarray: Any
format_parser: Any
fromarrays: Any
fromrecords: Any
fromstring: Any
fromfile: Any
array: Any
|
6,665 | 8c6b7f29b8dca61a5218b51c85149c9642af5649 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from dynamic_rest import viewsets
from django.shortcuts import render
import os
from rest_framework import permissions
from rest_framework.response import Response
from rest_framework.permissions import AllowAny
from rest_framework.decorators import api_vi... |
6,666 | 3d10f8810594303beb0ccabce3497de86149b2e5 | from models import Person
from models import Skeleton
from models import Base_dolni
from models import Dolen_vrata
st = Person("Stoian")
Stoian = Person("Ivanov")
dolni = Skeleton(st, 900, 600, 2, 18, 28, 40)
dolni_st = Skeleton(Stoian, 900, 590, 2, 18, 28, 40)
dol_001 = Base_dolni(dolni_st, 550)
dol_001.set_descrip... |
6,667 | b3c1843a742a82bca61650ab89ea8afdf3c9010d | from . import UbuntuPackageManager, RedHatPackageManager, SolarisPackageManager, RpmMixin
from infi import unittest
from infi.run_as_root import RootPermissions
from contextlib import contextmanager
from infi import pkgmgr
from mock import patch
import distro
# pylint: disable-all
class TestOnUbuntu(unittest.TestCa... |
6,668 | a0059563b2eed4ca185a8e0971e8e0c80f5fb8f8 | import random
import copy
random.seed(42)
import csv
import torch
import time
import statistics
import wandb
from model import Net, LinearRegression, LogisticRegression
def byGuide(data, val=None, test=None):
val_guides = val
if val == None:
val_guides = [
"GGGTGGGGGGAGTTTGCTCCTGG",
"GA... |
6,669 | 777dc2056443f0404ccb75d570f2ddc3a3aa747b | import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions
class TestTa... |
6,670 | 8cd54362680aa3a96babe100b9231f6f16b3f577 | import librosa
import soundfile
import os, glob
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import accuracy_score
emotionsRavdessData = {
'01': 'neutral',
'02': 'calm',
'03': 'happy',
'04': 'sad',
'05'... |
6,671 | db309283137383cd698f235e7326c6e5c50f6cf3 | from django.urls import path, include
from rest_framework.routers import SimpleRouter
from board_api.views import PostViewSet, UpvoteView, CommentViewSet
router = SimpleRouter()
router.register(r"post", PostViewSet)
router.register(r"post_upvote", UpvoteView)
router.register(r"comment", CommentViewSet)
urlpatterns ... |
6,672 | 113572682ca83408b7c22e0e178f29945d741142 | from ..lib import read_input, write_output
def link_bits(num: str = None, bit_i: str = '0', bit_j: str = '0', write: bool = True) -> int:
if num is None:
num, bit_i, bit_j = read_input()
num = int(num, 2)
num_len = num.bit_length()
mask = 2 ** num_len - 1
first_i = (num >> (num_len - int(b... |
6,673 | b8219c21dc2cdd497d3de48c59c146a1fd1509ec | # leetcode 718 最长重复子数组
# 给两个整数数组 A 和 B ,返回两个数组中公共的、长度最长的子数组的长度。
#
# 示例 1:
# 输入:
# A: [1,2,3,2,1]
# B: [3,2,1,4,7]
# 输出: 3
# 解释:
# 长度最长的公共子数组是 [3, 2, 1]。
#
# 说明:
# 1 <= len(A), len(B) <= 1000
# 0 <= A[i], B[i] < 100
class Solution:
def findLength(self, A: [int], B: [int])->int:
"""
动态规划, 维护... |
6,674 | 7864138459caf469a0148420718b2282598141de | #!/usr/bin/env python
# coding: utf-8
import sys
sys.path.insert(0, "/code/huggingface/transformers-fair-wmt/src")
import logging
logging.disable(logging.INFO) # disable INFO and DEBUG logger everywhere
from transformers.tokenization_fsmt import FSMTTokenizer
from transformers.modeling_fsmt import FSMTForConditional... |
6,675 | e79e4eb1640d5ad6e360dfb18430fbf261cf9d3b | # encoding=utf-8
######
# 遗传算法应用于旅行商问题(TSP)
# Python 3.6
# https://morvanzhou.github.io/tutorials/machine-learning/evolutionary-algorithm/2-03-genetic-algorithm-travel-sales-problem/
######
|
6,676 | 287d4c2d490c9dcdd7be7e86fe577139a3d30f54 | a=list(input("enter the string or sentence to perform caesar cipher : "))
b=int(input('enter the frequency to perform ceasar cipher '))
e=[]
#print(a)
#print (a[4])
c=len(a)
#print(c)
for i in range (0,c):
d=ord(a[i])
#print(d)
if b> 0:
for j in range (1,b+1):
if a[i] >='a' ... |
6,677 | 4744d594c0599f1aa807eefa0cb40a2a2a3c7926 | import io
import json
import sys
import time
from coord_tools import get_elevation
if len(sys.argv) != 3:
print('Wrong number of arguments! Exiting.')
infile_name = sys.argv[1]
outfile_name = sys.argv[2]
# Declare dict to hold coordinates
node_coords = {}
fail_count = 0
nodes_processed = 0
# Read in each node fro... |
6,678 | f4ae34be2be2b47b3394e6da751c53c51a1c3174 | #!/usr/local/bin/python3
"""
Copyright (c) 2015-2019 Ad Schellevis <ad@opnsense.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain th... |
6,679 | be5147efda879165107378527ebf44890c03be75 | import numpy as np
z = np.linspace(2,10,5) #from 2 to 10, with 5 elements
# OUT: array( [ 2. , 4. , 6. , 8. , 10. ] )
np.random.seed(0)
z1 = np.random.randint(10, size = 6)
# OUT: array( [5, 0, 3, 3, 7, 9] )
z = np.array([1,2,3,4,5])
z < 3
# OUT: array([T,T,F,F,F])
z[z<3]
# OUT: array([1,2])
a = np.array([1,2,3,4,... |
6,680 | 47f6c4b3c279a065b8f21dab2faa71271db8d6ab | from django.db import models
from datetime import datetime
# Message model for testing purposes
class Message(models.Model):
type = models.CharField(max_length=10)
body = models.CharField(max_length=50)
def __str__(self):
return self.type + ":" + self.body
# Company model
class Co... |
6,681 | a6617934c5e6527cf59225a5d159d1ce8a33db50 | import http.client
import json
conn = http.client.HTTPSConnection("v3.football.api-sports.io")
headers = {
'x-rapidapi-host': "v3.football.api-sports.io",
'x-rapidapi-key': ""
}
conn.request("GET", "/teams/statistics?season=2016&team=768&league=4", headers=headers)
res = conn.getresponse()
data = res.re... |
6,682 | 2f714ed54a19ec26d7ecb1979e79366721b3d0fe | import matplotlib.pyplot as plt
import numpy as np
# 描画用サンプルデータ
#x= np.array([0,1,2,3,4])
y = np.array([2, 2, 3, 4, 5])
print(y)
#print(range(y))
plt.figure(figsize=(10,1))
plt.bar(range(len(y)), y)
plt.savefig('test.png')
plt.clf() |
6,683 | 9cff227eeeaffda777668aa3b90e3839426da811 | import tkinter as tk
import classejogo
class Tabuleiro():
def __init__(self):
self.jogo = classejogo.Jogo()
self.window = tk.Tk()
self.window.title("Jogo da Velha")
self.window.geometry("300x360+100+100")
self.window.rowconfigure(0, minsize=30, weight=1)
self.window... |
6,684 | 4a118f9081a8b3baf0b074c8dc14eaeef4559c08 | # -*- 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... |
6,685 | cc5b22a0246fcc9feaed6a0663095a6003e6cef1 | import json, re, bcrypt, jwt
from datetime import datetime, timedelta
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Avg
from django.http import JsonResponse
from django.views import View
from room.models import Room, Category, Ro... |
6,686 | 041f1d7c482fe4f65e8cc5a508da62ee6ccf59ff | from ...routes import Route
from .providers import SQSProvider
from .message_translators import SQSMessageTranslator, SNSMessageTranslator
class SQSRoute(Route):
def __init__(self, provider_queue, provider_options=None, *args, **kwargs):
provider_options = provider_options or {}
provider = SQSProv... |
6,687 | 20e5220ce23aaaedbfafe599b352f5d3a220e82e | from django.db import models
class faculdades(models.Model):
codigo = models.IntegerField(primary_key = True)
nome = models.CharField(max_length=50)
cidade = models.CharField(max_length=30)
estado = models.CharField(max_length=20)
pais = models.CharField(max_length=20)
def __str__(self):
... |
6,688 | 9f40162348d33d70639692dac87777a2799999e9 | #!/usr/bin/env python
from ks_auth import sess
from ks_auth import trust_auth
from ks_auth import ks
from ks_auth import utils
from novaclient import client
import novaclient.exceptions
from time import sleep
from uuid import uuid4
import sys
# RDTIBCC-1042
VERSION = '2'
nova = client.Client(VERSION, session=sess)
u... |
6,689 | 8e9db58488f6ee8aa0d521a19d9d89504d119076 | tp = 1, 2, 3
print(tp + (4,))
|
6,690 | 28cdb59e97f3052dd80f8437574f9ffe09fc1e84 | from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.model_selection import StratifiedShuffleSplit
from sklearn.metrics import classification_report
from BlogTutorials.pyimagesearch.preprocessing.imagetoarraypreprocessor import ImageToArrayPreprocessor
from Bl... |
6,691 | d340ac979f57cf4650131665e4fa5b9923f22a3e | from collections.abc import Iterator
import json
import click
def print_json(obj, err=False):
if isinstance(obj, Iterator):
obj = list(obj)
click.echo(json.dumps(obj, sort_keys=True, indent=4, ensure_ascii=False),
err=err)
def show_fields(*fields):
def show(obj, verbose=False):
... |
6,692 | 792f62c72f1667f651567314b062d862abbc9aa5 | # created by Angus Clark 9/2/17 updated 27/2/17
# ToDo impliment traceroute function into this
# Perhaps get rid of unnecessary itemediate temp file
import socket
import os
import json
import my_traceroute
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = '130.56.253.43'
#print host
port = 5201 # Change ... |
6,693 | 3d16f2da03c067d410bec7bfe96d874322533d30 | import numpy
d1 = numpy.array([1.,0.,0.])
d2 = numpy.array([0.,1.,0.])
d3 = numpy.array([0.,0.,1.])
s0 = numpy.array([0.,0.,1.])
m2 = numpy.array([1.,0.,0.])
print "x y zeta"
for x in xrange(-100, 101):
for y in xrange(-100, 101):
s = x*d1 + y*d2 + 100*d3
e1 = numpy.cross(s, s0)
e1 /= numpy.linalg.norm(... |
6,694 | 5fa91a5061a5e87a4a2b8fece0378299e87e5a48 | # Interprets the AST
class Program:
def __init__(self, code):
self.code = code
def eval(self, binding):
return self.code.eval(binding)
class Code:
def __init__(self, statements):
self.statements = statements
def eval(self, binding):
val = 0
for statement in ... |
6,695 | 3457a7c080da041ad279239bd6a3d214a3b8e49f | """
Routes and views for the flask application.
"""
from datetime import datetime
from flask import render_template, redirect, url_for, request, jsonify
from athena_App import app
from athena_App.formClass import QuestionForm
import time
#attention:
#this module include large word vector which need a lot of time to ... |
6,696 | afecbb46a98fbf6b5c26f5b6c8026aec035fadf1 | from typing import List, Tuple
from unittest import TestCase
from solutions.python.common.timing import decompose, parse_decomposed_duration, format_duration
class TestTiming(TestCase):
def test_decompose_ns(self):
# Given
duration: int = 234
# When
decomposition: List[Tuple[int... |
6,697 | be69a9981fe6b53c3b9c4d2893913e4f9f7efb26 | from google.cloud import vision
from google.cloud.vision import types
from google.oauth2 import service_account
import os
# import re
import io
import pdf2image
import tempfile
import datetime
# Google API
credentials = service_account.Credentials.from_service_account_file("APIKey.json")
client = vision.ImageAnnot... |
6,698 | ad1ec5dd8fae290ab6cb73b17c5522e062261359 | import os
import inspect
import pytest
from ._common import copy_default_profile_collection, patch_first_startup_file
from bluesky_queueserver.manager.profile_tools import global_user_namespace, load_devices_from_happi
from bluesky_queueserver.manager.profile_ops import load_profile_collection
def create_local_impor... |
6,699 | 835beebe452a252fb744a06d3e6ff221469af6bf | data = [] ##用來裝reviews.txt的留言
count = 0 ##計數目前檔案讀取到第幾筆
with open('reviews.txt', 'r') as f:
for line in f:
data.append(line)
count += 1
if count % 1000 == 0:
print(len(data))
total = len(data)
print('檔案讀取完了,總共有', len(data), '筆資料')
print(len(data)) #印出data串列的--項目數量
print(le... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.