index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
985,100 | b225cbd3108a064b59bad406c1a86f5daecda4ea | #! /usr/bin/env python
import sqlite3
from sqlite3 import OperationalError
conn = sqlite3.connect('test.users.sqlite3')
cur = conn.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS users ( \
id INTEGER PRIMARY KEY AUTOINCREMENT, \
is_verified INTEGER,\
creation_time VARCHAR(256) NOT NULL... |
985,101 | 6907f32865c5a151b0627eaf57e7f659b7ba43d4 | # author: Ziming Guo
# time: 2020/2/9
'''
练习2:
["无忌","赵敏","周芷若"] [101,102,103] ————> {"无忌":101,"赵敏":102,"周芷若":103}
'''
list01 = ["无忌", "赵敏", "周芷若"]
list02 = [101, 102, 103]
dict01 = {list01[i]: list02[i] for i in range(0, len(list01))}
print(dict01)
|
985,102 | a127882af53889d1fed1fb2ecbd787e9d3e50a5e | # -*- coding: utf-8 -*- #
# Copyright 2017 Google LLC. 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... |
985,103 | e61ecc4c1ce28cc3f33407e3e0b5c54a19fb6199 | #!/usr/bin/python3
# decrypt.py
# A simple RSA decryption program
#import sys
#import math
#import cmath
from lettervalue import *
scanned_file = open('code.txt').read().split()
# read in file and strip lead/trail whitespace
e = 48925 # public key
n = 88579 # public key
p = 283 #... |
985,104 | 39e8538eb56e9c50ef4688a93bbc8e9956ac4933 |
# coding: utf-8
# Setup
# ====
# In[1]:
import pandas as pd
import seaborn as sns
get_ipython().magic('pylab inline')
# Import Years and IPC Classes Data
# ===
# In[2]:
# data_directory = '../data/'
# In[3]:
# IPC_patent_attributes = pd.read_csv('../Data/pid_issdate_ipc.csv')
# IPC_patent_attributes.ISSDATE ... |
985,105 | e3fae11371f73ba9892aea6978ddb415951708e9 | import pandas as pd
from data_handlers.dhWebcritech import dhWebcritech, get_geofilter_Webcritech
from util.df_matcher import df_matcher_unique
def areanameGetter(REFERENCE_AREA, area_type="Country", country_filter=""):
'''
Function useful to get names of areas to consider in the analysis. This includes
-... |
985,106 | 4277beb78fa38dd606dbae82eaa55e48f3f96ee2 | #-----------------------------------------------------------------------------
# Copyright (c) 2013-2020, PyInstaller Development Team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# The full license is in the file COPYING.txt, ... |
985,107 | 4dd0a2aa6c607831953ad8f19fed7ac2b2a40a8c | """
Access Splitwise via API
"""
from flask import Flask, render_template, redirect, session, url_for, request
from flask import Flask, session, request
from splitwise import Splitwise
from splitwise.expense import Expense
from splitwise.user import ExpenseUser
from typing import List
from typing import Dict
import sy... |
985,108 | f144c3f8b679693ef49b131f878870c07abd92bd | # # -*- coding: utf-8 -*-
# from bagogold.bagogold.models.cri_cra import CRI_CRA
# from decimal import Decimal
# from django.core.management.base import BaseCommand
# import datetime
# import mechanize
#
#
#
# class Command(BaseCommand):
# help = 'Busca os CRI e CRA atualmente válidos'
#
# def handle(self, ... |
985,109 | eea30d27f9654918944f100212dffdb43b88f2e9 | import random
def generarHorarios():
n = random.randint(3, 10)
print(str(n))
for i in range(n):
inicio = random.randint(1, 18)
fin = random.randint(inicio+1, 19)
print(str(inicio),end='')
print(" ",end='')
print(str(fin),end='')
print("\n",end='')
... |
985,110 | 9ef619e0557590b9db31cda36a1aed6b9a76a61f | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 4 11:16:44 2018
@author: edmond
"""
import gym
env = gym.make('CartPole-v0')
print(env.action_space)
#> Discrete(2)
print(env.observation_space)
print(env.observation_space.high)
print(env.observation_space.low)
from gym import spaces
space = sp... |
985,111 | 9e95e5a056cef2e32010f294ad6475c2d8a74232 | from unittest import TestCase
from auto_tagger import main
class TestAutoTagger(TestCase):
def test_main_can_run(self):
main()
assert True
|
985,112 | e44d0c064d0e2ab4fe84b69e329414491241bd2c | from __future__ import print_function
import os
import json
from google.cloud import vision
image_uri = 'https://drive.google.com/file/d/1B7WmDp4R96G_gQEYje32wAe3ZRcqHIK0/view?usp=sharing'
path = os.path.abspath(os.environ["GOOGLE_APPLICATION_CREDENTIALS"])
client = vision.ImageAnnotatorClient.from_service_account_... |
985,113 | 6a09161bbe82187a96540826cc066d02c69bb80b | from django.conf.urls import url
from django.contrib import admin
admin.autodiscover()
from . import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^InvaildAccess', views.InvaildAccess, name='InvaildAccess'),
url(r'^$', views.index, name='index'),
url(r'^subIndex', views.subIndex, name... |
985,114 | 27a59417dc7d45a67ccc7ea148755ca791a2c5f2 | from django.contrib import admin
from models import Edificio, Propietario, Departamento
admin.site.register(Edificio)
admin.site.register(Propietario)
admin.site.register(Departamento)
|
985,115 | 788df4808cc50a50f37c08072bcca47d3be0af53 | from tornado import web
from tornado import gen
from lib.database.auth import deny
import json
import time
class JSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
elif isinstance(obj, bytes):
return obj.decode('utf8')
... |
985,116 | be70dd4d7fea00915e9ad2b47178db30e4858acf | #!/usr/bin/env python
# This final piece of skeleton code will be centred around
# to follow a colour and stop upon sight of another one.
from __future__ import division
import cv2
import cv
import numpy as np
import rospy
import sys
import yaml
from os.path import expanduser
from geometry_msgs.msg import Twist, Vect... |
985,117 | 9bf88464e0cfa0e1ab0aefecd72c933e049561dd | inp = open('Prob08.in.txt', 'r')
t = int(inp.readline())
for _ in range(t):
a, b, c = map(float, inp.readline().split())
arr = [a, b, c]
ans = []
for x in arr:
if x >= 180:
y = round(x-180.0, 2)
use = ""
if y < 100:
use += '0'
... |
985,118 | 4a1f63868d0c3ac3c8ecd2dbca291ad4ccfa165e | from .attribute_dict import AttributeDict
|
985,119 | 030888d991e351f4ed8b17f7b21ecc28b1a193fa | try:
a
except x:
b
try:
a
except x:
b
except:
c
try:
d
except:
e
try:
f
except y:
g
except z, w:
h
try:
a
except x:
b
except y, z:
c
except:
d
try:
a
except x[y], z[w]:
b
|
985,120 | 89e0c459bd5957ffe1bab5cf9ea69939c3ee055e | inp_put = []
while True:
b = raw_input()
inp_put.append(b)
a=''.join(inp_put)
#a.swapcase()
if b == 'exit':
break
c=a.swapcase()
print c
|
985,121 | e7f214316df70a01e0b1c1a24a51c896e84a9577 | #!/usr/bin/python3
# Copyright(c) 2019 - Mikeias Fernandes <bio@mikeias.net>
# gff2html.py - a script for visualization of gff features
#################################################
import sys
from Bio import SeqIO
#################################################
usage = "gff2html.py genome.fasta proteins.fa... |
985,122 | 1c701eabb01f803c52a1d4b6f784e6da53aedd19 | class student:
def __init__(self, m1, m2):
self. m1 = m1
self.m2 = m2
def sum(self, a=None, b=None, c=None):
s = 0
if a!=None and b!=None and c!=None:
c=a+b+c
elif a!=None and b!=None:
c=a+b
else:
c=a
return c
s1 = s... |
985,123 | 02bed81962feb4e4f848bfbd975dc0f40976645c | """The mighty TePADiM -- extremely a work in progress.
To do:
Tweak line generation function so the user can set some of the
variables!
Exception handling. We should probably start doing that now...
Q to Quit when creating new list instead of choosing source file
More candles!
"""
import time
from random import ran... |
985,124 | 4fdda3d3a864d9c8f9f1f7053c2e78196b977508 | import numpy as np
import scipy.special
import scipy.integrate
import matplotlib.pyplot as plt
import seaborn as sns
rc = {'lines.linewidth': 2, 'axes.labelsize': 18, 'axes.titlesize': 18}
sns.set(rc=rc)
#ex3_3a
# Specify parameter
alpha = 1
beta = 0.2
delta = 0.3
gamma = 0.8
# Set the time step
delta_t = 0.001
# M... |
985,125 | 0082b1a3f2417a2d0d6213900439afc79a060a8c | from firebase_admin import credentials
from firebase_admin import firestore
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
import firebase_admin
import logging
import os
import sys
import time
import yaml
def parse_wifi_map(map_path):
with open(map_path, 'r') as f:
... |
985,126 | 781f508bfbb4915aeb41843be0950a14411d9e3d | import page_loader
def test_url_to_file_name():
url = 'http://test.com/style.css'
expected = 'test-com-style.css'
assert expected == page_loader.url.to_file_name(url)
def test_url_to_file_name_with_ext():
url = 'http://test.com/test.php'
expected = 'test-com-test.html'
assert expected == pag... |
985,127 | c32fb47dce52b1e7e99ceb61f2697db71fd761a7 | #So My assumption forn this assignment is :
# I am getting some speeches in wav form
#Now I wil convert it into text form and
# will pass it to any chatbot model where question answer trained model wil be there
# So respond of that "Chatbot" model will convert through TTS
from os import listdir, path
import matplot... |
985,128 | 71cc43bf49ec6802d805d6441932dbbf6d395770 | from is_prime import is_prime
from functools import wraps
def sieve_of_eratosthens(a):
'''
Return tre sieve of Eratosthens before 'a'
a - int
'''
is_comp = [False] * (a+1)
is_comp[0] = True
is_comp[1] = True
for i, n in enumerate(is_comp):
if n:
pass
else:
... |
985,129 | b2d25adb1059abb9a187564c8e790305a45f65a2 | """
Author: Andrew Schutt
Contact: schutta@uni.edu
Last Modified: 10/31/09
File: timer.py
Comments: times both the list based radixSort and linked list.
"""
import time
from pa05 import linkedRadixSort
from pa04 import radixSort
def radixTimer(alist):
liststart = time.time()
radixSort(alist)
total = t... |
985,130 | b2e483a9362487c695ef4b72d21786a5f11f8385 | import re
import sys
import copy
# See http://clang.llvm.org/docs/IntroductionToTheClangAST.html
from clang.cindex import Index, CursorKind, TranslationUnit
def auto_load():
""" Find libclang and load it """
if sys.startswith('linux'):
pass
class Object(object):
def __setattr__(self, name, value):
self.... |
985,131 | d2d6d9f840ee2f8d05f8dd1390dab4e6b5593752 | # -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-11-08 09:52
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('info', '0004_auto_20181108_1706'),
]
operations = [
migrations.AlterField(
... |
985,132 | ecf9f63b29400ed565491d346855e732ed41eac1 | from __future__ import print_function
from numpy.random import normal
from numpy.linalg import svd
from math import sqrt
import torch
import torch.nn as nn
from torch.nn import functional as F
import torch.nn.init
from torch.nn import Parameter
import numpy as np
from common import conv as dp_conv
from common import fl... |
985,133 | a1dd2396d8466ed38cae72f5f9192f0150db5e4f | """ Module containing classes that implement the CrawlerUrlData
class in different ways """
# Right now there is just one implementation - the caching URL data
# implementation using helper methods from urlhelper.
import crawlerbase
import hashlib
import zlib
import os
import re
import httplib
import time
from eiii_... |
985,134 | ece525770a47346badad584d5480a1edef2de37f | import logging
import threading
from seleniumwire.server import MitmProxy
log = logging.getLogger(__name__)
def create(addr='127.0.0.1', port=0, options=None):
"""Create a new proxy backend.
Args:
addr: The address the proxy server will listen on. Default 127.0.0.1.
port: The port the proxy... |
985,135 | 7716aca53a1dfc30c3f59abe26644135697400dd | # coding: utf-8
import numpy as np
from csv import *
from xlwt import *
from xlrd import *
from genetic import *
from pandas import *
c_count=8
student_groupnum=5
profnum=9
course_prof=[]
classdetailfile=open('courseinfo.csv','r',encoding='gbk')
classdetail=DictReader(classdetailfile)
courseid={}
for ... |
985,136 | 9eb122361c12a3bf5712241d0449bc062291a1d6 | '''
MIT License
Copyright (c) 2018 Sebastien Dubois, Sebastien Levy, Felix Crevier
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 ... |
985,137 | 682c9159a9d9dbd0d16f02fd855a59b3a666c893 | def predict_lang(word):
if len(word) > 0:
try:
si_count = 0
en_count = 0
other_count = 0
for char in word:
ord_val = ord(char)
if (65 <= ord_val <= 90) or (97 <= ord_val <= 122):
en_count += 1
... |
985,138 | 134adbf41a77396e77c4a0ffdf31cb6394096a14 | from .accuracy import AccuracyMetric
from .average import AverageMetric
from .moving_average import MovingAverageMetric
from .statistics import Statistics
from .kendall_tau import compute_kendall_tau |
985,139 | a4a482478946ec4580c5bc2e1f2faa3139a363e6 | import torch
from torch.utils.data import Dataset, DataLoader
from PIL import Image
import numpy as np
import torch.nn as nn
from torchvision.models import vgg16
import torch.optim as optim
from torchvision import transforms
from glob import glob
import os
class TripletDataset(Dataset):
def __init__(self, transfo... |
985,140 | 6770ce60e1e650472338c1727a788a2eea5aabc2 | """The Genie++ Clustering Algorithm
Copyright (C) 2018-2020 Marek Gagolewski (https://www.gagolewski.com)
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 t... |
985,141 | af7e9c4ca72c60c5a8c1f7751be9122b2b891430 | import argparse
import boto3
import os
from itertools import islice
def grouper(iterable, n):
"""Yield n-length chunks of the iterable"""
it = iter(iterable)
while True:
chunk = tuple(islice(it, n))
if not chunk:
return
yield chunk
def generate_tiles():
# NOTE thi... |
985,142 | d90999b54428088ca94a6873ceea7fbf18950ac4 | def validate_stack_sequences(pushed: 'list[int]', popped: 'list[int]') -> bool:
l_ = len(pushed)
if l_ < 3:
return True
for i in range(0, l_-2):
first = pushed.index(popped[i])
for j in range(i+1, l_-1):
second = pushed.index(popped[j])
if second >= first:
... |
985,143 | dce9f2940240392adaca83b0b5165d9cf6a7c3b4 | x=[1,2,3,4,5]
y=[1,2,3,4,5,-2]
s=0
c=1
for i in x:
s=s+i
for x in y:
if x>0:
c=c*x
print(c/s)
|
985,144 | b8cc9e3fa05b57a3364ea7ecd2e231f05268c684 | #def reader()
#def converter()
#def writer()
print('File in / File out - Divide by space')
file_in, file_out = input('> ').split()
file = open(file_in, 'r')
file_export = open(file_out, 'w')
string = ''
aminoacid = ''
dic_P = {
'ATA':'I', 'ATC':'I', 'ATT':'I', 'ATG':'M',
'ACA':'T', 'ACC':'T', 'ACG... |
985,145 | d54287d6dd6a8e60975dac972bd2f813f95072dc | import scrapy
class ForumItem(scrapy.Item):
"""
Represents a subforum
"""
link = scrapy.Field()
name = scrapy.Field()
class TopicItem(scrapy.Item):
"""
Represents a forum thread
"""
id = scrapy.Field()
thread_link = scrapy.Field()
forum_link = scrapy.Field()
name = sc... |
985,146 | 24819352fb9360dec7e7debfb8893a3033d3287d | import pygame
import math
ancho = 600
alto = 480
contador=0
lista=[]
anguloo=15
def rotacion(pto,angulo):
ang=math.radians(angulo)
x= pto[0]*math.cos(ang) + pto[1]*math.sin(ang)
y=-pto[0]*math.sin(ang) + pto[1]*math.cos(ang)
xint=int(x)
yint=int(y)
return [xint,yint]
def APant(c,pto):
x=c[... |
985,147 | e86af5ff8a81dde0899c4d38f3261dc773ce7f50 | import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('193.30.96.57', username='hidden', password='hidden', port=22, allow_agent=False, look_for_keys=False)
shell = client.invoke_shell()
_, stdout, stderr = client.exec_command(' system clock set time-z... |
985,148 | dfe07c9a91123792712af42ff8ce6ca8917a179f |
#!/usr/bin/env python
"""
Reads the header from a GE a-Si Angio Detector
Authors: Henning O. Sorensen & Erik Knudsen
Center for Fundamental Research: Metal Structures in Four Dimensions
Risoe National Laboratory
Frederiksborgvej 399
DK-4000 Roskilde
email:erik.... |
985,149 | 6fbf603752a7c74a32d6cb91e1eb7c1a4b513942 | import json
import csv
import pandas as pd
import scraper
import process
BASE_URL = "http://www.ilga.gov"
LEG_URL = BASE_URL + "/legislation/"
senate_url = BASE_URL + "/senate/"
house_url = BASE_URL + "/house/"
def data_to_csv(data, filename, header):
with open(filename, 'w', newline='') as file:
writer ... |
985,150 | a79ae345d030e677c943e263dd3626eefb36eb23 | USERNAME = 'jeager'
PASSWORD = 'Telkom123'
SERVER='35.240.228.215'
PORT='5672'
QUEUE='environment_sensor'
ROUTING_KEY='environment_sensor' |
985,151 | 71a746913f19d897160dc009b86466c7d3828743 | import config
from access import access
from devices import devices
from actions import actions
from zenossapi import zenossapi
from xbmc import xbmc
from openstack import openstack
__all__ = ['actions', 'access','config','devices','zenossapi','xbmc','openstack']
|
985,152 | b28651473f153a8f7682784910984120bedaffd4 | # -*- coding: iso-8859-15
'''
Created on 02/05/2013
@author: Jesus Maria Gonzalez Nava
'''
from Scanner import *
import sys
if __name__ == '__main__':
credential = int(sys.argv[1])
print('Valor de credential: ' + str(credential))
if credential == 1:
objMineria = MineriaDatos()
... |
985,153 | 4b52462f005d6f553c78d145f6e77940a0cdaf5e | # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
# 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. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICEN... |
985,154 | f5f3d7f42ba37480f11e2b7761bb963c496cc8e4 | from rest_framework import serializers
from .models import CurrencyPair
from Currency.serializers import CurrencySerializer
class CurrencyPairSerializer(serializers.ModelSerializer):
class Meta:
model=CurrencyPair
fields=('id','from_id','to_id', 'deleted_at')
def to_representation(self, instan... |
985,155 | 4d1b20d95eefb21c3eaab9497efc2880877cd516 | #encoidng:utf-8
from werkzeug.security import check_password_hash,generate_password_hash
# class Person(object):
# name = ''
# age = ''
# def __init__(self,name):
# self.name = name
#
# def eat(self):
# print(self.name+'eat')
#
# p = Person('donghao')
# p1 = Person('donghao')
#
# p.weigh... |
985,156 | b05e6f7e7379eaa4a07d43eec65e29c65f466000 | import cv2
import numpy as np
from pycocotools.coco import COCO
from skimage import io
from matplotlib import pyplot as plt
import os
from transformer import Transformer, AugmentSelection
from config import config, TransformationParams
from data_pred import *
ANNO_FILE = 'E:/dataset/coco2017/annotations/pers... |
985,157 | e8c037521e35b4a43c751df1136d544e05e770e1 | # Generated by Django 2.2.7 on 2019-12-02 14:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('posts', '0002_auto_20191201_1214'),
]
operations = [
migrations.AlterField(
model_name='comment... |
985,158 | a64b9c1a523fc9383b57983b654fc841abb8af7a | from multiprocessing import Process, Value, Array, Lock
from BitCoinNode import BitCoinNode
from Transaction import Transaction, TransactionOutput, TransactionInput
import utils, binascii, constants
from typing import List, Tuple, Dict
def generateTransaction(sendList: List[Tuple[str, int, str, str, str]], recvList: L... |
985,159 | 737ab841cdf9e449694ebdbd2d827bd11930605a | """
REST API Documentation for the NRS TFRS Credit Trading Application
The Transportation Fuels Reporting System is being designed to streamline compliance reporting for transportation fuel suppliers in accordance with the Renewable & Low Carbon Fuel Requirements Regulation.
OpenAPI spec version: v1
... |
985,160 | 8fa634d95ade9a52de24286f53dcb17a0c44c651 | import luigi
from mars_gym.simulation.training import SupervisedModelTraining
if __name__ == '__main__':
# job = SupervisedModelTraining(
# project="config.conf1_rnn",
# recommender_module_class="model.RNNAttModel",
# recommender_extra_params={
# "n_factors": 100,
# "hidden_size": 100,
# ... |
985,161 | 75ef8fced9a9b0c22b9e31dcbcb3a269cc24ead9 | import os, sys, Queue, mutex, MySQLdb, datetime, Image, itertools, urllib2, threading
from time import sleep
display_name = 'localhost:%d.0' % 11
os.environ['DISPLAY'] = display_name
WEB_HOST = "beta.flowgram.com"
bookmarklet = """var s= document.createElement('script');
s.type = "text/javascript";
s.src =... |
985,162 | 5c45e8c1dd24242d633b607977c79fd3a12c6f07 | from __future__ import unicode_literals, division, absolute_import
import logging
from datetime import datetime, timedelta
import threading
from sqlalchemy import Column, Integer, Unicode
from flask import request, render_template, flash, Blueprint, redirect, url_for
from flexget.ui.webui import register_plugin, db_s... |
985,163 | c0eb0f70d5138a985f02978fecbf01dd2c380398 | from constants import STATUS
import random
class Player:
def __init__(self):
self.adadachi = None
self.inventory = {
"games": ["hide-n-seek", "tag", "go fish", "red rover"],
"foods": ["banana cream pie", "carrot sticks", "mashed potatoes", "mac 'n cheese", "tater tots", "cho... |
985,164 | fea0350cb6aec320a7cd8ebc5e7662b44870f4ca | #!/usr/bin/env python3
"""
This is one of the labs scripts
"""
import operator
import re
error = {}
error_csv_path = 'errors.csv'
error_pattern = r"ERROR ([\w ']+)"
syslog_path = 'syslog.log'
user = {}
user_csv_path = 'users.csv'
user_pattern = r"\(([\.\w]+)\)"
with open(syslog_path) as fp:
line = fp.readline()... |
985,165 | f37b485ba68a1fc1ae993d4d380890771c5bde6d | import os
from pdfClass import PDFObj
from excelRead import extract_excel
from excelWrite import write_excel
import re
import warnings
warnings.simplefilter("ignore") #To surpress PDF-read 'superfluous whitespace' warning
def main(var):
end_dict, float_dict, excel_file_path = do_extract(var)
if any(float_dic... |
985,166 | f82477e831756d71ffccbffd9c9cb2c3cd5d64ac | import sys, datetime
from subprocess import call
es_endpoint = raw_input("Elasticsearch Endpoint: ") or sys.exit('ERROR: Elasticsearch endpoint is required')
es_index = raw_input("Elastichsearch Index [all] ") or ""
backup_name = raw_input("Backup Name: ") or sys.exit('ERROR: Elasticsearch cluster name is required')
s... |
985,167 | 2043af9196189f826df44fd1b9b649347c36248c | import re
from django.templatetags.static import static
from markdown.extensions import Extension
from markdown.postprocessors import Postprocessor
assetRE = re.compile(r'{% static (\'|"|")(.*?)(\1) %}')
class DjangoStaticAssetsProcessor(Postprocessor):
def replacement(self, match):
path = match.g... |
985,168 | f4f7f4f495af658f4133c1a8475d03b55ddaff4f | class Solution:
def search(self, nums, target):
"""
判断这个数在数组中的位置
二分查找,当数组为空的时候,修改18 20/22
少去一个判断
时间复杂度大于 Olog(n)
:type nums: List[int]
:type target: int
:rtype: int
"""
flag = -1 # 判断是否排序了
for i in range(len(nums) - 1): # 判断旋... |
985,169 | 8d76216a0a2831afad52fa753acc58ae5d41656b | import pickle
import numpy as np
import pandas as pd
import sys
sys.path.insert(1, '../src/MyAIGuide/data')
from fitbitDataGatheredFromWebExport import fitbitDataGatheredFromWebExport
from movesDataGatheredFromWebExport import movesDataGatheredFromWebExport
from googleFitGatheredFromWebExport import googleFitGatheredF... |
985,170 | 827f65d603def2fad1969acba40480795a4f1f19 | #!/usr/bin/env python3
# util.py - utility functions
import math
from .types import Point
MACHINE_EPS = 1e-9
def dist(a: Point, b: Point):
"""Return the squared distance between two points"""
return (a.x - b.x) ** 2 + (a.y - b.y) ** 2
def ceil(x):
"""Return the ceiling of x as a float, but fudge it b... |
985,171 | 019f88f123cb1fae59ff545b7c9764e2886aa3d1 | from __future__ import print_function, unicode_literals
from binascii import hexlify
from twisted.trial import unittest
from twisted.internet import protocol, reactor, defer
from twisted.internet.endpoints import clientFromString, connectProtocol
from .common import ServerBase
from .. import transit_server
class Accum... |
985,172 | d69ebc047ad2854fbcb2dea748e7c08e0db0ef04 | #this file will test if we can split string properly, without taking any optional argument, and the input string will be already sorted and only contain one word because we didn't add sort function or rotate function in this version
import kwic
document1 = "a";
document2 = "a\nb";
assert(kwic.kwic(document1) == [(["... |
985,173 | 6174a767381a843e04ea705e4c8a2f27b1728e0f | #code=utf-8
from PIL import Image
im = Image.open('C:\\Users\\30\\Desktop\\emoji.jpg')
print im.format,im.size,im.mode
print dir(im)
|
985,174 | 26344f2661e5646f133ff638145dd27f802c0e14 | import ROOT
import yaml
import sys
import multiprocessing
import bz2
import pickle
from modules.NuclideGenerator import NuclideGenerator
from modules.NuclidesPlotter import NuclidesPlotter
from modules.DecaySimulator import DecaySimulator
from modules.Nuclide import NuclidePopulation
from modules.DecaySimulator import ... |
985,175 | b6231e40c109eb4a5f8c3c6f6832ead14d070a63 | class Room(object):
def __init__(self, name, description):
self.name = name
self.description = description
self.paths = {}
def go(self, direction):
return self.paths.get(direction, None)
def add_paths(self, paths):
self.paths.update(paths)
central_corridor = Room("Central Corridor",
"""
... |
985,176 | 98076d50d174c5605f84d3541abffb0bc951d669 | #Credit Pizza Pizza ClassroomJr.com
#Scrapped idea. Using REGEX for multiple delimiter splitting. Would not join correctly at the end without splitting punctuation.
#import re
#split_mad_story = re.split("\s|\.|,|!|", mad_story)
print("Pizza was invented by a ____(adjective)____ ____(nationality)____ chef named ____... |
985,177 | b43e8a4a44f5e3eb229ef3616057debed510ffb1 | ''''
Created on September 2, 2016
API Testing for createUser
@author Vipin Gupta
'''
import unittest
import requests
import urllib2
import dictrecursive
import xmltodict
import HTMLTestRunner
import xml.etree.ElementTree as ET
from xml.sax.saxutils import unescape
class TestCreateUserRest (unitte... |
985,178 | 1b81fb5bec1f1d9481aee7a1d19618ac278ac3ca | from PIL import Image, ImageFilter, ImageOps
import numpy as np
import re
import os
from paths_to_data import *
"""
File containing all functions relative to image processing
"""
def add_noise(image, type="s&p"):
"""
Function to add noise (gaussian or salt and pepper) to image
"""
# Get the width and... |
985,179 | 37aab0391efc16f55f8748cbbb02ef3c87e98eae | __version__ = '0.3'
from .extras import *
from .exceptions import *
from .ddpclient import DDPClient
|
985,180 | d2d92e069513f04c353e0b267fb0877b220efc98 | '''Write a Python function to calculate the sum of three given numbers, if the
values are equal then return thrice their sum.'''
def sum_thrice(a, b, c): #sum_thrice function with argument a,b,c
sum = a + b + c #add a,b,c and store in sum
if a == b == c: #if a,b,c are same value then find thrice... |
985,181 | c3529c8a3421e917ea5c06d16b808718a3df518d | import numpy as np
from xx.preprocession import processing_word, get_stop_words
# from xx.chat_analysis import build_word_vector
from gensim.models.word2vec import Word2Vec
from sklearn.externals import joblib
from sklearn.metrics import f1_score,recall_score,precision_score,accuracy_score
# 获得句子中所有词汇的向量,然后取平均值
def bu... |
985,182 | f4390cd6afb09cfe65bbcdb41391da1e34836bc3 | """Describe table row formats for CTAMLDataDumper output files.
These row classes below define the structure of the tables in
the output PyTables .h5 files.
"""
from tables import (
IsDescription,
UInt32Col,
UInt16Col,
UInt8Col,
Float32Col,
StringCol,
Int32Col,
)
class EventTableRow(IsD... |
985,183 | a999bd7922e50657d4b9b00c23203917826cafdb | """
This type stub file was generated by pyright.
"""
from ...utils.validation import _deprecate_positional_args
@_deprecate_positional_args
def plot_partial_dependence(estimator, X, features, *, feature_names=..., target=..., response_method=..., n_cols=..., grid_resolution=..., percentiles=..., method=..., n_jobs=.... |
985,184 | 890fd3b5525d78b3bddbc5f55ff21303da111d0b | a = '12345'
print(a[:-3]) |
985,185 | df8102b9310b37c3260c31a3062ef195408ff46a | from rest_framework.serializers import ModelSerializer
from blog.models import BlogPost
class BlogPostSerializer(ModelSerializer):
class Meta:
model = BlogPost
fields = '__all__'
|
985,186 | 5347d6af72acc782450464c2315fac4c1720e830 | import math
def prime(num):
if num ==1 :
return "Not prime"
elif num == 2:
return "Prime"
else:
n = int(math.sqrt(num))
for i in range(2,n+1):
if num%i ==0:
return "Not prime"
return "Prime"
T = int(input())
for i in range(T)... |
985,187 | a573ec6d36c09a7dda9d39141d1d7fa62ceab09c | def count_digits(n):
""" function to find the number of digits """
count = 0
n=abs(n)
while n!=0:
count += 1
n = n // 10
return count
n=-111112
a=count_digits(n)
print("number of digits " + str(n) + ": " + str(a))
|
985,188 | 41dd15a0df9f9c87325493be9968904094f57e58 | data = [int(x) for x in input().split()]
def recurse(data, index):
# return (value, index after last)
print("recurse ", index)
child_num = data[index]
metadata_num = data[index + 1]
print("cn {} mn {}".format(child_num, metadata_num))
index += 2
result = 0
for _ in range(child_num):... |
985,189 | 6fcc54485f1827057134943e2fd93adafad99625 | """VALIDATORS"""
|
985,190 | fc3acc4ba079760f8eb4b5402ac0a8ec3ccbc650 | # Scraper.py
# Date created: 5/10/14
# trevor.prater@gmail.com (Trevor Prater)
# jun.huang.cs@gmail.com (Jun Huang)
import os
import re
import sys
import pytumblr
import json
from datetime import datetime, timedelta
from PIL import Image
class Scraper:
#Constructors
def cleanupImageFolder(self):
os.system('rm... |
985,191 | ebf7ab952b178433b0cfd6f398ec84f2e88d535d | from app import app,db
from app.models import User, Post
@app.shell_context_processor
def make_shell_context():
return {'db':db,'User':User,'Post':Post}
if __name__=='__main__':
app.run(debug=True)
|
985,192 | c2a165edcb7495533a9cab8c0e0e0df2595e9fe0 | import glob
import os
import re
import string
import numpy as np
import pandas as pd
import xarray as xr
import mkgu
import mkgu.assemblies
from mkgu.knownfile import KnownFile as kf
def align_debug():
v2_base_path = "/braintree/data2/active/users/jjpr/mkgu_packaging/crcns/v2-1"
nc_files = sorted(glob.glob(o... |
985,193 | bb7f57b73401572d5ca60121f8fe3e05f5b3f1d0 | # -*- coding: utf-8 -*-
import urllib2
import sys
from bs4 import BeautifulSoup
req = urllib2.Request("http://www.aizhan.com/siteall/www.ip138.com/")
f = urllib2.urlopen(req)
#content = f.read().decode('UTF-8').encode('GBK') //网页抓取内容,显示中文正常
content = f.read()
soup = BeautifulSoup(content,"html.parser",fromEnc... |
985,194 | a4f28cbd2ef80bd1d968a7974d93b718ebf2d9c0 | # spiral.py
# COMP9444, CSE, UNSW
import torch
from torch import typename
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
class PolarNet(torch.nn.Module):
def __init__(self, num_hid):
super(PolarNet, self).__init__()
# INSERT CODE HERE
self.hidden = to... |
985,195 | 3636cff2cd2e149936c50343ebe60e7df7e6a367 | # -*- coding:utf-8 -*-
import tarfile
import os
"""
压缩某个目录下所有文件
"""
def compress_file(tarfilename, dirname):
#tarfilename是压缩包名字,dirname是要打包的目录
if os.path.isfile(dirname):
with tarfile.open(tarfilename, 'w') as tar:
tar.add(dirname)
else:
with tarfile.open(tarfilename, 'w') as... |
985,196 | 68bf27d7dd75452b371fe93e855c5886e13ddbfe | import sys, math
my_file = open(sys.argv[1], 'r')
my_prs = {}
for line in open("train-answer.txt", "r"):
my_list = line.split()
my_prs[my_list[0]] = my_list[1]
#memo λ1 =0.95, λunk =1-λ1, V=1000000, W=0,H=0
V = 1000000
word_count = 0 #W=0
H = 0
unknown = 0
for line in my_file:
P = 1
words = line.split... |
985,197 | 5c2f5d846b6fee28cb4ddb2b14582fea692f43fe | def helper(string):
result = ""
i = 0
while string[i] == " ":
i += 1
for j in range(i, len(string)):
result += string[j]
return result
def reverse(string):
result = ""
for i in range(0, len(string)):
result = string[i] + result
return result
def ... |
985,198 | f87076bd24548734d43bd01822635b02ece5a23f | import base64
import calendar
import datetime as dt
import random
import string
from datetime import datetime, timedelta
import pytz
from django.contrib.messages import constants
def increment_months(sourcedate, months):
month = sourcedate.month - 1 + months
year = sourcedate.year + month // 12
month = ... |
985,199 | 15930973730f2adfef44425a909b0186f6349d3a | #credit card verification via Luhn algorithm
#first we verify visa cards with mod 10 algorithm
#function that verifies visa cards
def visa(card_num):
#first, starting with the first num, double the odd digits abd sum them up
i=0
sum1=0
while i<len(card_num):
k=card_num[i]
g=k*2
if g>9:
new_g=g-9
new_l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.