index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
3,900 | 6f107d0d0328c2445c0e1d0dd10e51227da58129 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanyin... |
3,901 | 135401ea495b80fc1d09d6919ccec8640cb328ce | # -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.core.management import call_command
from django.test import TestCase
from django.utils import timezone
from core import models
class ChildTestCase(TestCase):
def setUp(self):
call_command('migrate', verbosity=0)
def test... |
3,902 | 1cc77ed1c5da025d1b539df202bbd3310a174eac | # import gmplot package
import gmplot
import numpy as np
# generate 700 random lats and lons
latitude = (np.random.random_sample(size = 700) - 0.5) * 180
longitude = (np.random.random_sample(size = 700) - 0.5) * 360
# declare the center of the map, and how much we want the map zoomed in
gmap = gmplot.GoogleMapPlotter(0... |
3,903 | 57e9c1a4ac57f68e0e73c2c67c6828de8efb1b16 | import uuid
import json
import pytest
import requests
import httpx
from spinta.testing.manifest import bootstrap_manifest
from spinta.utils.data import take
from spinta.testing.utils import error
from spinta.testing.utils import get_error_codes, RowIds
from spinta.testing.context import create_test_context
from spint... |
3,904 | f2b978b9a4c00469cdd2f5e1e9275df73c7379b8 | 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... |
3,905 | 03bc377bef1de7d512b7982a09c255af1d82fb7d | """4. ะะฐัะฝะธัะต ัะฐะฑะพัั ะฝะฐะด ะฟัะพะตะบัะพะผ ยซะกะบะปะฐะด ะพัะณัะตั
ะฝะธะบะธยป. ะกะพะทะดะฐะนัะต ะบะปะฐัั, ะพะฟะธััะฒะฐััะธะน ัะบะปะฐะด. ะ ัะฐะบะถะต ะบะปะฐัั ยซะัะณัะตั
ะฝะธะบะฐยป,
ะบะพัะพััะน ะฑัะดะตั ะฑะฐะทะพะฒัะผ ะดะปั ะบะปะฐััะพะฒ-ะฝะฐัะปะตะดะฝะธะบะพะฒ. ะญัะธ ะบะปะฐััั โ ะบะพะฝะบัะตัะฝัะต ัะธะฟั ะพัะณัะตั
ะฝะธะบะธ (ะฟัะธะฝัะตั, ัะบะฐะฝะตั, ะบัะตัะพะบั).
ะ ะฑะฐะทะพะฒะพะผ ะบะปะฐััะต ะพะฟัะตะดะตะปะธัั ะฟะฐัะฐะผะตััั, ะพะฑัะธะต ะดะปั ะฟัะธะฒะตะดะตะฝะฝัั
ัะธะฟะพะฒ. ะ ะบะปะฐััะฐั
-ะฝะฐัะปะตะดะฝะธะบะฐ... |
3,906 | 3bfa9d42e3fd61cf6b7ffaac687f66c2f4bc073e | # -*- coding: utf-8 -*-
"""
Created on Mon Nov 9 20:06:32 2020
@author: Supriyo
"""
import networkx as nx
import matplotlib.pyplot as plt
g=nx.Graph()
#l=[1,2,3]
# g.add_node(1)
# g.add_node(2)
# g.add_node(3)
# g.add_nodes_from(l)
# g.add_edge(1,2)
# g.add_edge(2,3)
#... |
3,907 | cf7aeacedec211e76f2bfcb7f6e3cb06dbfdc36e | import hashlib
import math
import random
from set5.ch_4 import get_num_byte_len
class Server:
def __init__(self):
self.private_key = random.randint(0, 2**100)
self.salt = random.randint(0, 2**100)
self.salt_bytes = self.salt.to_bytes(
byteorder="big",
length=get_n... |
3,908 | 72d1a0689d4cc4f78007c0cfa01611e95de76176 | #! /usr/bin/env python3
import arg_parser
import colors
import logging
import sys
def parse_args(argv):
parser = arg_parser.RemoteRunArgParser()
return parser.parse(argv[1:])
def main(argv):
logging.basicConfig(
format='%(levelname)s: %(message)s',
level='INFO',
handlers=[colors... |
3,909 | c651d49c98a4cf457c8252c94c6785dea8e9af60 | import datetime
import logging
import random
import transform
import timelapse
# merge two iterators producing sorted values
def merge(s1, s2):
try:
x1 = next(s1)
except StopIteration:
yield from s2
return
try:
x2 = next(s2)
except StopIteration:
yield from s1
... |
3,910 | 4ee47435bff1b0b4a7877c06fb13d13cf53b7fce | import sys,argparse
import os,glob
import numpy as np
import pandas as pd
import re,bisect
from scipy import stats
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
matplotlib.rcParams['font.size']=11
import seaborn as sns
sns.set(font_scale=1.1)
sns.set_style("whitegrid", {'axes.grid' : False})... |
3,911 | 4a620957b2cd1e5945d98e49a5eae5d5592ef5a2 | import tests.functions as functions
if __name__ == "__main__":
# functions.validate_all_redirects("linked.data.gov.au-vocabularies.json")
conf = open("../conf/linked.data.gov.au-vocabularies.conf")
new = [
"anzsrc-for",
"anzsrc-seo",
"ausplots-cv",
"australian-phone-area... |
3,912 | 3e7d80fdd1adb570934e4b252bc25d5746b4c68e | from py.test import raises
from ..lazymap import LazyMap
def test_lazymap():
data = list(range(10))
lm = LazyMap(data, lambda x: 2 * x)
assert len(lm) == 10
assert lm[1] == 2
assert isinstance(lm[1:4], LazyMap)
assert lm.append == data.append
assert repr(lm) == '<LazyMap [0, 1, 2, 3, 4, 5... |
3,913 | 227e78312b5bad85df562b6ba360de352c305e7b | import sys
word = input()
if word[0].islower():
print('{}{}'.format(word[0].upper(), word[1:]))
sys.exit()
else:
print(word)
sys.exit()
|
3,914 | adae1d7cc2a866c9bc3cd21cb54a0191389f8083 | import sys, os
def carp():
sys.stderr = sys.stdin
print "content-type: text/plain"
print
#carp()
import sesspool
import cornerhost.config
## set up session
pool = sesspool.SessPool("sess/sessions.db")
SESS = sesspool.Sess(pool, REQ, RES)
SESS.start()
ENG.do_on_exit(SESS.stop)
CLERK = cornerhost.config... |
3,915 | e9de42bb8ed24b95e5196f305fe658d67279c078 | import types
from robot.libraries.BuiltIn import BuiltIn
def GetAllVariableBySuffix (endswith):
all_vars = BuiltIn().get_variables()
result = {}
for var_name, var in all_vars.items():
#print var_name
if var_name.endswith(endswith+"}"):
print var_name
#print var
def ... |
3,916 | dd79ffe3922494bcc345aec3cf76ed9efeb5185c | #!/usr/bin/env python3
"""
02-allelefreq.py <vcf file>
"""
import sys
import matplotlib.pyplot as plt
import pandas as pd
vcf = open(sys.argv[1])
maf = []
for line in vcf:
if "CHR" in line:
continue
cols = line.rstrip("\n").split()
values = float(cols[4])
maf.append(values)
fig, ax = pl... |
3,917 | c0f9a1c39ff5d7cc99a16cf00cddcc14705937ba | from datetime import datetime
from random import seed
from pandas import date_range, DataFrame
import matplotlib.pyplot as plt
from matplotlib import style
from numpy import asarray
import strategy_learner as sl
from util import get_data
style.use('ggplot')
seed(0)
def run_algo(sym, investment, start_date, end_date... |
3,918 | ff1346060141ee3504aa5ee9de3a6ec196bcc216 | from skimage.measure import structural_similarity as ssim
import matplotlib.pyplot as plt
import numpy as np
import cv2
import os
import pathlib
import warnings
from PIL import Image
from numpy import array
source_path = "/home/justin/Desktop/FeatureClustering/"
feature_length = len(os.listdir(source_path))
vector_da... |
3,919 | 9e01ba8c489791ec35b86dffe12d0cedb5f09004 | import pandas as pd
from scipy.stats import shapiro
import scipy.stats as stats
df_test = pd.read_excel("datasets/ab_testing_data.xlsx", sheet_name="Test Group")
df_control = pd.read_excel("datasets/ab_testing_data.xlsx", sheet_name="Control Group")
df_test.head()
df_control.head()
df_control.info()
df_te... |
3,920 | 9852d2a15047b110c7f374fd75e531c60c954724 | # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
# (c) Simen Sommerfeldt, @sisomm, simen.sommerfeldt@gmail.com Licensed as CC-BY-SA
import os
import argparse,time
import pygame
import paho.mqtt.client as paho
parser = argparse.ArgumentParser()
parser.add_argument("-s","--server", default="127.0.0.1", help="The I... |
3,921 | bc25338612f525f616fb26c64d8b36667d297d40 | from django.shortcuts import render,get_object_or_404, redirect
from django.contrib import admin #์ด๋๋ฏผ ์ธ๊บผ๋ฉด ์จ์ผ๋จ
from .models import Blog #์ฑ์ ๊ฐ์ง๊ณ ์ค๊ฒ ๋ค๋๊ฑฐ
from django.utils import timezone
admin.site.register(Blog) #๋ธ๋ก๊ทธ ํ์์ ๊ฐ์ ธ์ ๋ฑ๋กํ๊ฒ ๋ค.
# Create your views here.
def home(request):
blogs = Blog.objects
return render(reque... |
3,922 | 2542998c3a7decd6329856a31d8e9de56f82bae1 | from collections import namedtuple
from weakref import ref
l = list()
_l = list()
# Point = namedtuple('Point', ['x', 'y'])
class Point:
def __init__(self,x,y):
self.x = x
self.y = y
def callback(ref):
print ('__del__', ref)
for x in range(10):
p = Point(x,x**2)
t = ref(p,callback)... |
3,923 | 4692b2d19f64b3b4bd10c5eadd22a4b5a2f2ef37 | from custom_layers import custom_word_embedding
from custom_layers import Attention
from utils import load_emb_weights
import torch
from torch import nn
class classifier(nn.Module):
#define all the layers used in model
def __init__(self, embedding_dim, hidden_dim, output_dim, n_layers, embed_weights,
... |
3,924 | ce97da4aab2b9de40267730168690475c899526d | import os,sys,glob
sys.path.append("../../../../libs/VASNet/")
from VASNet_frame_scoring_lib import *
sys.path.append("../../../config")
from config import *
if __name__ == '__main__':
#************************************************************************
# Purpose: frame scoring (Summarizing Videos with A... |
3,925 | fcf19c49bb161305eaa5ba8bc26e276a8e8db8ea | import unittest
from textwrap import dedent
from simplesat import InstallRequirement, Repository
from simplesat.test_utils import packages_from_definition
from ..compute_dependencies import (compute_dependencies,
compute_leaf_packages,
compute_re... |
3,926 | 4f4af4caf81397542e9cd94c50b54303e2f81881 | import datetime
import time
import boto3
from botocore.config import Config
# FinSpace class with Spark bindings
class SparkFinSpace(FinSpace):
import pyspark
def __init__(
self,
spark: pyspark.sql.session.SparkSession = None,
config = Config(retries = {'max_attempts': 0, 'mode': 'sta... |
3,927 | a8ea91797942616779ae0acc884db1e521c7ad28 | from utils import *
name = 'topological'
def topological(above):
"Topologically sort a DAG by removing a layer of sources until empty."
result = []
while above:
sources = set(above) - set(flatten(above.values()))
result.extend(sources)
for node in sources:
del above[nod... |
3,928 | a4f2418e746cc43bd407b6a212de9802044351e1 | # -*- coding: utf-8 -*-
"""
plastiqpublicapi
This file was automatically generated by APIMATIC v3.0 (
https://www.apimatic.io ).
"""
import json
import dateutil.parser
from tests.controllers.controller_test_base import ControllerTestBase
from tests.test_helper import TestHelper
from tests.http_respon... |
3,929 | a84920821982f04b9835391eb267707971f8f7c1 | import hashlib
from ast import literal_eval
# import requests
# from rest_framework import generics
from rest_framework.views import APIView
from rest_framework.response import Response
from django.shortcuts import render, redirect, HttpResponse,get_object_or_404
from django.views.decorators.csrf import csrf_exempt
fro... |
3,930 | c034fba0b9204545b00ba972a17e63cf9c20854e | import pandas as pd
def _get_site_name(f,i):
data_file = f +"\\"+"new_desc_sele_data.csv"
site_name=pd.read_csv(data_file)["SITE_ID"][i]
return site_name
def _get_site_DD_dataset_csv(f,i):
'''่ทๅ็ป่ฟๅ
จ้จๆฐๆฎ้๏ผ็ป่ฟๅ
จ้จ็็นๅพ้ๆฉ๏ผ'''
site_path=_get_site_folder(f,i)
data_path=site_path+"\\data_confirm.csv"
... |
3,931 | 6b0d1de4c77841f20670331db3332cf87be7ad84 | from django.apps import AppConfig
class PersianConfig(AppConfig):
name = 'persian'
|
3,932 | 99c2bd56deccc327faf659e91fc1fd0f6ff7a219 | from mf_app import db
from mf_app.models import User
db.create_all()
#test input data
admin = User('admin', 'admin@admin.com', 'admin')
guest = User('guest', 'guest@guest.com', 'guest')
db.session.add(admin)
db.session.add(guest)
db.session.commit()
users = User.query.all()
print(users) |
3,933 | 95c0ba757b7561ef6cc0ad312034e2695f8420c3 | #!/usr/bin/env python3
x = "Programming is like building a multilingual puzzle\n"
print (x)
|
3,934 | 736861f18936c7a87ecf3deb134f589b9d7eed92 |
import matplotlib
matplotlib.use('Agg')
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.axes_grid1 import make_axes_locatable
def plot_overscan(overscan, img, TITLE, OUT_DIR):
""" plot overscan in 9x2 plots with 16 channels """
fig = plt.figure(figs... |
3,935 | e1eb86480fa4eadabf05f10cc54ff9daa790438c | class Node():
def __init__(self, value):
self.value = value
self.next = None
def linked_list_from_array(arr):
head = Node(arr[0])
cur = head
for i in range(1, len(arr)):
cur.next = Node(arr[i])
cur = cur.next
return head
def array_from_linked_list(head):
arr = []
cur = head
whil... |
3,936 | bcdf1c03d996520f3d4d8d12ec4ef34ea63ef3cf | #!/usr/bin/python3
###################################################
### Euler project
### zdrassvouitie @ 10/2016
###################################################
file_name = '013_largeSum_data'
tot = 0
with open(file_name, "r") as f:
stop = 1
while stop != 0:
line = f.readline()
if len(... |
3,937 | 19ffac718008c7c9279fb8cbc7608597d2d3e708 | print('-'*60)
print('Welcome to CLUB425, the most lit club in downtown ACTvF. Before you can enter, I need you yo answer some question...')
print()
age = input('What is your age today? ')
age = int(age)
if age >= 21:
print('Cool, come on in.')
else:
print('Your gonna need to back up. This club is 21+ only so find som... |
3,938 | 5e4a334b373d912ba37b18f95e4866450bda5570 | # Generated by Django 2.2.2 on 2019-07-30 01:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('usuarios', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='usuario',
name='inicio',
... |
3,939 | 4328d526da14db756fad8d05457724a23e3e3ef6 | from datetime import datetime
import warnings
import numpy as np
import xarray as xr
from .common import HDF4, expects_file_info
pyhdf_is_installed = False
try:
from pyhdf import HDF, VS, V
from pyhdf.SD import SD, SDC
pyhdf_is_installed = True
except ImportError:
pass
__all__ = [
'CloudSat',
]
... |
3,940 | 805bc144a4945b46b398853e79ded17370ada380 | import glob
import os
import partition
import pickle
import matplotlib.pyplot as plt
import numpy as np
from Cluster import fishermans_algorithm
import argparse
parser = argparse.ArgumentParser()
plt.ion()
parser.add_argument("--fish", help="flag for using fisherman's algorithm")
parser.add_argument("--heat", help="... |
3,941 | 8280f321b102cace462761f9ece2aebf9e28a432 | #!/usr/bin/python3
"""display your id from github.
"""
from sys import argv
import requests
if __name__ == "__main__":
get = requests.get('https://api.github.com/user',
auth=(argv[1], argv[2])).json().get('id')
print(get)
|
3,942 | 1daecce86769e36a17fe2935f89b9266a0197cf0 | from django.db import models
class TamLicense(models.Model):
license = models.TextField("Inserisci qui il tuo codice licenza.")
|
3,943 | 7a793c2081032745ae58f92a4572954333742dfd | import os
# __file__: ๅฝๅๆไปถ
# os.path.dirname(): ๆๅจ็ฎๅฝ
# os.path.abspath(): ๅฝๅๆไปถ/็ฎๅฝ็็ปๅฏน่ทฏๅพ
# os.path.join(): ่ทฏๅพ่ฟๆฅ
# ้กน็ฎ่ทฏๅพ
BASEDIR = os.path.abspath(
os.path.dirname(
os.path.dirname(
__file__)))
# ๆฐๆฎๆไปถ็ฎๅฝ
DATA_DIR = os.path.join(BASEDIR, "data")
DATA_FILE = os.path.join(DATA_DIR, 'data.yaml') |
3,944 | ece80a7765674f9d2991029bb86486b616a90f58 | class Solution(object):
def moveZeroes(self, nums):
"""
็ปๅฎไธไธชๆฐ็ป nums๏ผ็ผๅไธไธชๅฝๆฐๅฐๆๆ 0 ็งปๅจๅฐๆฐ็ป็ๆซๅฐพ๏ผๅๆถไฟๆ้้ถๅ
็ด ็็ธๅฏน้กบๅบใ
---
่พๅ
ฅ: [0,1,0,3,12]
่พๅบ: [1,3,12,0,0]
---
ๆ่ทฏ๏ผ
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
num = nums.count(0)
while 0 in nums:
nums.remove... |
3,945 | 83d35c413af0cefb71964671b43df1e815aa2115 | # coding: utf-8
"""
Provides test-related code that can be used by all tests.
"""
import os
DATA_DIR = 'tests/data'
def get_data_path(file_name):
return os.path.join(DATA_DIR, file_name)
def assert_strings(test_case, actual, expected):
# Show both friendly and literal versions.
message = """\
... |
3,946 | d7aa85c2458ee12a8de0f75419945fbe2acdf95d | #! /usr/bin/python3
class Animal:
def eat(self):
print("ๅ")
def bark(self):
print("ๅ")
def run(seft):
print("่ท")
def sleep(self):
print("็ก")
class Dog(Animal):
# ๅญ็ฑปๆฅๆ็ถ็ฑป็ๆๆๅฑๆงๅๆนๆณ
def bark(self):
print("ๆฑชๆฑชๅซ")
class XiaoTianQuan(Dog): # 3. ๅขๅ ๅ
ถ... |
3,947 | 5a3431b79b8f42b3042bb27d787d0d92891a7415 | # -*- coding:utf-8 -*-
'''
Created on 2016๏ฟฝ๏ฟฝ4๏ฟฝ๏ฟฝ8๏ฟฝ๏ฟฝ
@author: liping
'''
import sys
from PyQt4 import QtGui,QtCore
class QuitButton(QtGui.QWidget):
def __init__(self,parent = None):
QtGui.QWidget.__init__(self,parent)
self.setGeometry(300,300,250,150)
self.setWindowTitle('quitButto... |
3,948 | dff454cbde985a08b34377b80dd8e3b22f1cc13a | from django.http import response
from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from .models import User
from .serializers import UserSerializer,UserCreationSerialier,UserEditionSerializer
from rest_framework import status
from rest_framework.pe... |
3,949 | d8cfd9de95e1f47fc41a5389f5137b4af90dc0f1 | from datetime import datetime
import pytz
from pytz import timezone
##PDXtime = datetime.now()
##print(PDXtime.hour)
##
##NYCtime = PDXtime.hour + 3
##print(NYCtime)
##
##Londontime = PDXtime.hour + 8
##print(Londontime)
Londontz = timezone('Europe/London')
Londonlocaltime = datetime.now(Londontz)
print(Londo... |
3,950 | b9bc6a9dbb3dbe51fbae45078bd499fb97fa003f | # Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from c7n_azure.provider import resources
from c7n_azure.resources.arm import ArmResourceManager
from c7n.utils import type_schema
from c7n.filters.core import ValueFilter
@resources.register('mysql-flexibleserver')
class MySQLFlexibleServ... |
3,951 | 1049a7d2cdc54c489af6246ec014deb63a98f96d | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('levantamiento', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='FichaTecnica',
field... |
3,952 | 384588e1a767081191228db2afa4a489f967a220 | """
AlbumInfo-related frames for the Album view.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Iterator, Collection, Any
from ds_tools.caching.decorators import cached_property
from tk_gui.elements import Element, HorizontalSeparator, Multiline, Text, Input, Image, Spacer
fr... |
3,953 | e008f9b11a9b7480e9fb53391870809d6dea5497 | import numpy as np
from global_module.implementation_module import Autoencoder
from global_module.implementation_module import Reader
import tensorflow as tf
from global_module.settings_module import ParamsClass, Directory, Dictionary
import random
import sys
import time
class Test:
def __init__(self):
se... |
3,954 | 44bf409d627a6029ab4c4f1fff99f102b8d57279 | # cook your dish here
t=int(input())
while t:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
s=0
for i in range(n):
k=a[i]-i
if k>=0:
s+=k
print(s%1000000007)
t-=1
|
3,955 | 6db0adf25a7cc38c8965c07cc80bde0d82c75d56 | import os
from sqlalchemy import Column, ForeignKey, Integer, String, Float, Boolean, DateTime
from sqlalchemy import and_, or_
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine, func
from sqlalchemy.orm import sessionmaker, scoped_sess... |
3,956 | 26744d51dbce835d31d572a053294c9d280e1a8b | #SEE /etc/rc.local FOR BOOTUP COMMANDS
from Measure_and_File import *
from WebServer import *
from multiprocessing import *
web = WebServer()
board_boy = Measurer_and_Filer()
#try:
proc1 = Process( target=board_boy.measure_and_file, args=() )
proc1.start()
proc2 = Process( target=web.serve, args=() )
proc2.start()
#... |
3,957 | f3d61a9aa4205e91811f17c4e9520811445cc6a9 | import sys
import random
#coming into existence, all does not begin and end at this moment;
#not yet fully conscious, you pick up only snippets of your environment
for line in sys.stdin:
line = line.strip()
randLow = random.randint(0, 10)
randHigh = random.randint(11, 20)
print line[randLow:randHigh] |
3,958 | a5f3af6fc890f61eecb35bd157fc51bb65b4c586 | # Standard Library imports:
import argparse
import os
from pathlib import Path
from typing import Dict, List
# 3rd Party imports:
import keras.backend as K
from keras.layers import *
from keras.models import Model
import tensorflow as tf
from tensorflow.python.framework import graph_io, graph_util
from tensorflow.pyth... |
3,959 | 79390f3ae5dc4cc9105a672d4838a8b1ba53a248 | from flask import Flask, render_template, request, redirect
#from gevent.pywsgi import WSGIServer
import model as db
import sys
import time, calendar
import jsonify
def get_date(date):
date = date.split("/")
time = str(date[0])
day_str = calendar.day_name[calendar.weekday(int(date[3]), int(date[2]), int(da... |
3,960 | 9fa5f4b4aeb7fe42d313a0ec4e57ce15acbfcf46 | from keras.models import Sequential
from keras.layers import Convolution2D # for 2d images
from keras.layers import MaxPool2D
from keras.layers import Flatten
from keras.layers import Dense
import tensorflow as tf
from keras_preprocessing.image import ImageDataGenerator
cnn = Sequential()
rgb = 64
# step 1: convolu... |
3,961 | 201279c0cba2d52b6863204bfadb6291a0065f60 | from django.conf import settings
from django.contrib.sites.models import RequestSite
from django.contrib.sites.models import Site
from fish.labinterface.models import *
from registration import signals
from registration.forms import RegistrationForm
from registration.models import RegistrationProfile
from labinterfac... |
3,962 | ab4145ccc0b360dcca9b9aa6ebe919bdddac65a2 | from django.urls import path
from photo.api.views import api_photo_detail_view, api_photos_view
urlpatterns = [
path('<int:id>', api_photo_detail_view, name='user_detail'),
path('', api_photos_view, name='users')
] |
3,963 | 2194fb4f0b0618f1c8db39f659a4890457f45b1d | from django.conf.urls import patterns, url
urlpatterns = patterns(
'',
url(
r'^create_new/$',
'hx_lti_assignment.views.create_new_assignment',
name="create_new_assignment",
),
url(
r'^(?P<id>[0-9]+)/edit/',
'hx_lti_assignment.views.edit_assignment',
name=... |
3,964 | 721f23d2b6109194b8bca54b1cd04263e30cdf24 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 3 16:04:19 2018
@author: khanhle
"""
# Create first network with Keras
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Activation
from keras.utils import np_utils
from keras.layers.convolutional import Convolut... |
3,965 | b16e64edd0ff55a424ce3d4589321ee4576e930c | #
# PySNMP MIB module AN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:22:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
... |
3,966 | e90e4d2c777554999ab72d725d7e57bdfd508d3a | #!/usr/bin/env python
import rospy
from mark1.srv import WordCount, WordCountResponse
s= set('',)
def count_words(request):
s.update(set( request.words.split() ))
print s
return WordCountResponse( len( request.words.split()))
rospy.init_node('mark_service_server')
service = rospy.Service('Word_count', W... |
3,967 | 1d004ec0f4f5c50f49834f169812737d16f22b96 | w=int(input())
lst=[i+1 for i in range(100)]
for i in range(2,100):
lst.append(i*100)
lst.append(i*10000)
lst.append(10000)
print(297)
print(*lst)
|
3,968 | 5607d4fea315fa7bf87337453fbef90a93a66516 | import random
firstNames = ("Thomas", "Daniel", "James", "Aaron", "Tommy", "Terrell", "Jack", "Joseph", "Samuel", "Quinn", "Hunter", "Vince", "Young", "Ian", "Erving", "Leo")
lastNames = ("Smith", "Johnson", "Williams", "Kline","Brown", "Garcia", "Jones", "Miller", "Davis","Williams", "Alves", "Sobronsky", "Hall"... |
3,969 | 246ec0d6833c9292487cb4d381d2ae82b220677e | import sys
def show_data(data):
for line in data:
print(''.join(line))
print("")
def check_seat(data, i, j):
if data[i][j] == '#':
occupied = 1
found = True
elif data[i][j] == 'L':
occupied = 0
found = True
else:
occupied = 0
found = False
... |
3,970 | 78db25586f742b0a20bc3fad382b0d4f1a271841 | #!/usr/bin/python3
experiment_name = "nodes10"
wall = "wall2"
wall_image = "irati_110"
mr_dif_policy = True
spn_dif_policy = True
destination_ip = "2001:40b0:7500:286:84:88:81:57"
|
3,971 | e0c10dfa4074b0de4d78fc78a6f373074ef4dadd | letters = ['a', 'b', 'c']
def delete_head(letters):
del letters[0]
print letters
print delete_head(letters)
|
3,972 | e007e2d32fa799e7658813f36911616f7bf58b48 | from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
tf.__version__
import glob
import imageio
import matplotlib.pyplot as plt
import numpy as np
import os
import PIL
from tensorflow.keras import layers
import time
import pathlib
from IPython import display
###---... |
3,973 | c007dc2416d3f7c883c44dea5471927ea6f816d6 | # Uses python3
import sys
from operator import attrgetter
from collections import namedtuple
Segment = namedtuple('Segment', 'start end')
def optimal_points(segments):
segments = sorted(segments, key=attrgetter('end'), reverse=True)
points = []
#write your code here
while len(segments) > 0:
... |
3,974 | 395ff2e7c052b57548151fc71fad971c94ebceea | #@@---------------------------@@
# Author: Chamil Jayasundara
# Date: 5/18/17
# Description: Extract SFLOW data from slow logs
#@@---------------------------@@
import itertools
from collections import defaultdict
"""Flow Sample and Datagram Objects"""
class Container(object):
def __init__(self, id):
... |
3,975 | 6aa7114db66a76cfa9659f5537b1056f40f47bd2 | import requests
import json
ROOT_URL = "http://localhost:5000"
def get_all_countries():
response = requests.get("{}/countries".format(ROOT_URL))
return response.json()["countries"]
def get_country_probability(countryIds):
body = {"countryIds": countryIds}
response = requests.get("{}/countries/probability".format... |
3,976 | 325708d5e8b71bad4806b59f3f86a737c1baef8d | """game"""
def get_word_score(word_1, n_1):
"""string"""
# import string
# key = list(string.ascii_lowercase)
# value = []
# x=1
sum_1 = 0
# for i in range(0, 26):
# value.append(x)
# x+=1
# dictionary_ = dict(zip(key, value))
# print(dictionary_)
dictionary_ = {'... |
3,977 | 7d54d5fd855c7c03d2d4739e8ad4f9ab8772ca2b | def longest(s1, s2):
# your code
s=s1+s2
st="".join(sorted(set(s)))
return st
longest("xyaabbbccccdefww","xxxxyyyyabklmopq")
|
3,978 | e72962b644fab148741eb1c528d48ada45a43e51 | # Generated by Django 3.2.2 on 2021-05-07 08:01
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='teams',
fields=[
('id', models.AutoField(pr... |
3,979 | ed6eda4b6dbf3e94d8efb53004b19cd9c49e927e | import sqlite3
import sys
import threading
from time import sleep
sq = None
def get_queue(category, parser):
if sq == None:
return liteQueue(category, parser)
return sq
"""
SqLite Job Handler class for Links
"""
class liteQueue:
_create = "CREATE TABLE IF NOT EXISTS link ( 'url' TEXT,'cat... |
3,980 | fa925d0ef4f9df3fdf9a51c7fcc88933609bc9e3 | 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()
|
3,981 | 78a6202f501bc116e21e98a3e83c9e3f8d6402b4 | #!/usr/bin/env python
import requests
import re
def get_content(url):
paste_info = {
'site': 'pomf',
'url': url
}
m = re.match('^.*/([0-9a-zA-Z]+)\.([a-zA-Z0-9]+)$',url)
response = requests.get(url)
if response.status_code != 200:
return
paste_info['ext'] = m.group(2)
... |
3,982 | 1bb82a24faed6079ec161d95eff22aa122295c13 | # -*- coding: utf-8 -*-
"""
:copyright: (c) 2014-2016 by Mike Taylor
:license: MIT, see LICENSE for more details.
Micropub Tools
"""
import requests
from bs4 import BeautifulSoup, SoupStrainer
try: # Python v3
from urllib.parse import urlparse, urljoin
except ImportError:
from urlparse import urlparse, urlj... |
3,983 | 13e3337cf9e573b8906fe914a830a8e895af20ba | import re
class Markdown:
__formattedFile = []
__analyzing = []
def __processSingleLine(self, line):
if(self.__isHeading(line)):
self.__process("p")
self.__analyzing.append(re.sub("(#{1,6})", "", line).strip())
self.__process("h" + str(len(re.split("\s", line)[0])))
elif(self.__isH... |
3,984 | 9178d39a44cfb69e74b4d6cd29cbe56aea20f582 | #!/usr/bin/env python
#coding:gbk
"""
Author: pengtao --<pengtao@baidu.com>
Purpose:
1. ็ฎก็ๅไบคไบๅผ่ฐ็จhadoop Job็ๆกๆถ
History:
1. 2013/12/11 created
"""
import sys
import inspect
import cmd
import readline
#import argparse
#from optparse import (OptionParser, BadOptionError, AmbiguousOptionError)
from job i... |
3,985 | b16691429d83f6909a08b10cc0b310bb62cd550d | import json
from gamestate.gamestate_module import Gamestate
from time import time
from gamestate import action_getter as action_getter
def test_action_getter():
path = "./../Version_1.0/Tests/General/Action_1.json"
document = json.loads(open(path).read())
gamestate = Gamestate.from_document(document["gam... |
3,986 | 5c8628e41c0dd544ade330fdd37841beca6c0c91 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Triangle Project Code.
# Triangle analyzes the lengths of the sides of a triangle
# (represented by a, b and c) and returns the type of triangle.
#
# It returns:
# 'equilateral' if all sides are equal
# 'isosceles' if exactly 2 sides are equal
# 'scalene' ... |
3,987 | e9908e32204da8973f06d98430fc660c90b5e303 | #14681
#์ ์ ์ขํ๋ฅผ ์
๋ ฅ๋ฐ์ ๊ทธ ์ ์ด ์ด๋ ์ฌ๋ถ๋ฉด์ ์ํ๋์ง ์์๋ด๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. ๋จ, x์ขํ์ y์ขํ๋ ๋ชจ๋ ์์๋ ์์๋ผ๊ณ ๊ฐ์ ํ๋ค.
x = int(input())
y = int(input())
if(x>0 and y>0):
print("1")
elif(x>0 and y<0):
print("4")
elif(x<0 and y>0):
print("2")
else:
print("3")
|
3,988 | 25d4fa44cb17048301076391d5d67ae0b0812ac7 | # coding: utf-8
"""
SevOne API Documentation
Supported endpoints by the new RESTful API # noqa: E501
OpenAPI spec version: 2.1.18, Hash: db562e6
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
from swagger_client.models.d... |
3,989 | 59eb705d6d388de9afbcc0df3003f4d4f45f1fbd | import Tkinter
import random
secret = random.randint(1, 100)
### TKINTER ELEMENTS ###
window = Tkinter.Tk()
# greeting text
greeting = Tkinter.Label(window, text="Guess the secret number!")
greeting.pack()
# guess entry field
guess = Tkinter.Entry(window)
guess.pack()
# submit button
submit = Tkinter.Button(windo... |
3,990 | 8e9aec7d3653137a05f94e4041d28f3423122751 | from os.path import basename
from .FileInfo import FileInfo
class mrk_file(FileInfo):
"""
.mrk specific file container.
"""
def __init__(self, id_=None, file=None, parent=None):
super(mrk_file, self).__init__(id_, file, parent)
self._type = '.mrk'
#region class methods
def __get... |
3,991 | 5447bd3b08c22913ae50ee66ee81554d2357ef3e | import os
from typing import Union, Tuple, List
import pandas as pd
from flags import FLAGS
from helpers import load_from_pickle, decode_class, sort_results_by_metric
ROOT = FLAGS.ROOT
RESULTS_FOLDER = FLAGS.RESULTS_FOLDER
FULL_PATH_TO_CHECKPOINTS = os.path.join(ROOT, RESULTS_FOLDER, "checkpoints")
def eval_resul... |
3,992 | 31761b9469cc579c209e070fbe7b71943404a1ff | import requests
import json
def display_response(rsp):
try:
print("Printing a response.")
print("HTTP status code: ", rsp.status_code)
h = dict(rsp.headers)
print("Response headers: \n", json.dumps(h, indent=2, default=str))
try:
body = rsp.json()
p... |
3,993 | 35d99713df754052a006f76bb6f3cfe9cf875c0b | #!/usr/local/autopkg/python
"""
JamfScriptUploader processor for uploading items to Jamf Pro using AutoPkg
by G Pugh
"""
import os.path
import sys
from time import sleep
from autopkglib import ProcessorError # pylint: disable=import-error
# to use a base module in AutoPkg we need to add this path to the sys.pa... |
3,994 | 473c653da54ebdb7fe8a9eefc166cab167f43357 | """Config for a linear regression model evaluated on a diabetes dataset."""
from dbispipeline.evaluators import GridEvaluator
import dbispipeline.result_handlers as result_handlers
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from nlp4musa2020.dataloaders.alf200k import ALF200... |
3,995 | 1c1f1dab1ae2e8f18536784a5dec9de37c8a8582 | def test_{{ project_name }}():
assert True
|
3,996 | 2e66a31638eb4e619f14a29d5d3847482d207003 | from django.db import connection
from .models import Order
from .models import Package
from .models import DeliveryStatus
from .models import CalcParameters
class DataService:
def __init__(self):
pass
@staticmethod
def get_all_orders():
orders = Order.objects.order_by('-order_date')
... |
3,997 | 4acdde648b5ec32c078579e725e6ae035298f25a | # -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-01-15 17:27
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Person... |
3,998 | cbcbc0d01c32693ebbdbcf285efdc8e521c447ee | import pygame
from evolution import Darwin
from Sensor import Robot, obstacleArray
# Game Settings
pygame.init()
background_colour = (0, 0, 0)
(width, height) = (1000, 600)
target_location = (800, 300)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Omar's Simulation")
screen.fill(backgr... |
3,999 | fc5b9117ecf56401a888e2b6a5e244f9ab115e41 | # Copyright 2018 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.