index
int64
0
1,000k
blob_id
stringlengths
40
40
code
stringlengths
7
10.4M
993,400
088c3bd4457e4b2265c0d150090a5ac5b79c0957
#!/usr/bin/python # coding=utf-8 import base64 from Crypto import Random from Crypto.Hash import SHA from Crypto.Signature import PKCS1_v1_5 as Signature_pkcs1_v1_5 from Crypto.PublicKey import RSA from typing import Dict, Any def key_generation(): # 伪随机数生成器 random_generator = Random.new().read # 生成2048...
993,401
fe660e25ea2f605a0e68d324437727bf6a20b65d
def add(a, b): return a + b add(2, 2) 2**100 + 2**101
993,402
6bd13f4360cf18dd38fa591631e93e469eefd9f9
# -*- coding: utf-8 -*- # Generated by Django 1.11.10 on 2019-10-18 12:29 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('live', '0004_auto_20191018_1058'), ] operations = [ migrations.AddField( ...
993,403
7fdffc9500bbc00e8a101f253f2c863caa2537a4
# # Copyright (c) 2020, Hyve Design Solutions Corporation. # 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 the above copyright # notice, th...
993,404
1035246cd9facbc2f7172899158a981e9dafce93
from pyglet.media import Player, ManagedSoundPlayer import pyglet def play_background_music(): try: player = Player() player.eos_action = Player.EOS_LOOP player.volume = 0.9 player.queue(pyglet.resource.media('data/music/music.ogg')) player.play() except Exception: ...
993,405
2bb451a804c24b2d08a5443148057b02ad7cf76e
from google.appengine.ext import ndb class CrashReportGroup(ndb.Model): created_at = ndb.DateTimeProperty(auto_now_add=True) latest_crash_date = ndb.DateTimeProperty() package_name = ndb.StringProperty() @classmethod def get_group(cls, package_name): return cl...
993,406
13be9bf8df123ee1ba2179af6fd5df6c0ed319c8
class Solution(object): def findTheDifference(self, s, t): r = 0 for c in s: r += ord(c) for c in t: r -= ord(c) return chr(abs(r))
993,407
e144d96a39b47566e3267af887182d0881bf93ee
#------------- SAMPLE THREADED SERVER --------------- # Similar threading code can be found here: # Python Network Programming Cookbook -- Chapter - 2 # Python Software Foundation: http://docs.python.org/2/library/socketserver.html import socket import threading import SocketServer import time import random import ...
993,408
010ef5befba3fed29deb531db312f233eb22f4cc
import sys import numpy as np def inputs(func=lambda x: x, sep=None, maxsplit=-1): return map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit)) def input_row(n : int, type=np.int, *args, **kwargs): return np.fromiter(inputs(type, *args, **kwargs), dtype=type) def input_2d(nrows : int, ncols : int, typ...
993,409
b8f73e92c6da8dcb15419d1224db99fcfaa47821
import pyfx import numpy as np import ffmpeg def video_dimensions(filename): """ Get dimensions of frames in a video file. """ probe = ffmpeg.probe(filename) video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None) width ...
993,410
db5b6c6efd36f75afae76bb166ed5015f5983b0b
# Set of function to solve the PDE for a result until we meet the tolerance at all points from function import func def solve(nodes, tol): # initialize madDel as greater than the tolerance madDel = tol + 1 iterator = 0 while (madDel > tol) and iterator < 10000: newValues = [] iterator ...
993,411
4bf735fd7c0058b0b34374a61ecc2a6a2cc9b93b
import requests Base = "http://127.0.0.1:5000/" moc_data = [{"name":"potato", "discount":0.7, "id":1}, {"name":"tomato", "discount":0.1, "id":2}, {"name":"ququmba", "discount":0.2, "id":3}] for i in range(len(moc_data)): response = requests.put(Base + "mall/" + str(i), moc_data[i]) pr...
993,412
2bd636fd41a0ddbfaf98d624d2add2503003062e
def isprime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i*i <= n: if n % i == 0 or n % (i+2) == 0: return False i += 6 return True def gen_primes(n): prime_list = [] num = 2 while num < n: is_prime = True for index, prime in enumera...
993,413
3b6c745062ab6e21c18d1024fdcb20ccca7606b7
#!/usr/bin/env python # coding: utf-8 import numpy as np import os, sys, time, copy, yaml from .utils import * # Controller base class UAV_pid(): def __init__(self, *args, **kwargs): # PID Controller Vehicle Parameters if 'debug' in kwargs: self.flag_debug = kwargs['debug'] el...
993,414
a48a3dd9ce903f76356eeb95fa4352cb3a2df6e6
# -*- coding:utf-8 -*- import json from celery import signature from flask import jsonify # Content-Type: application/json Content-Type: text/html; charset=utf-8 # celeryApp = Celery(broker=Config.CELERY_BROKER_URL) # celeryApp.conf.update(app.config) # celeryApp.autodiscover_tasks(['yiqidai','yunzhangfan...
993,415
3431a60513173f82f3ece16302cc8a42fd080d0e
from statistics import mean import numpy as np import matplotlib.pyplot as plt xs = np.array([1,2,3,4,5,6], dtype = np.float64) ys = np.array([5,4,6,5,6,7], dtype = np.float64) # xs=np.array([12,13,14,15,16,17,18,19,20,21,22,23]) # ys=np.array([202031,208153,188749,165747,150677,142722,136637,143456,135291,118952,1039...
993,416
8fc07007d86e86a6b7baa5350ca7c39ad8820089
from __future__ import division,print_function import sys sys.dont_write_bytecode = True from lib import * import numpy as np _ = 0 Coc2tunings = { # vl l nom h vh xh # Scale Factors 'Flex' : [5.07, 4.05, 3.04, 2.03, 1.01, _], 'Pmat' : [7.80, 6.24, 4.68, 3.12, 1.56, _], 'Pre...
993,417
4f00364b83b301418a280b7883755f92d3891825
import argparse import socket import topohiding from topohiding.helperfunctions import FakeHPKCR, HPKCR, find_generator import struct import base64 import os import time # Test Commands: # python3.6 cli.py -k 5 -v 1 -p 60002 -b 2 -i foo1 -n 127.0.0.1:60001 # python3.6 cli.py -k 5 -v 1 -p 60001 -b 2 -i foo0 -n 127.0.0...
993,418
2e03b82406df019e27998f4c4c3f61ac65f0e151
# grabs 3 dictionaries containing shopping lists and merges them into one shopping list # original dictionaries, modified to have 'apples' in 2 dictionaries # to test an additional case (duplicate values) roommate1Shopping = {'fruit': 'apples', 'meat': 'chicken', 'vegetables': 'potatoes', 'drinks': ['beer','wine','vod...
993,419
5c4bb7b95d715d25a952f98aef84f02393e71468
import cv2 import numpy as np def main(): # 이미지 원본 img_src = "C:/Users/wsChoe/customDataset/labelImg/data/original_img/1.jpg" img_source = cv2.imread(img_src) # 이미지 축소 img_result = cv2.resize(img_source, None, fx=0.15, fy=0.15, interpolation = cv2.INTER_AREA) cv2.imshow("x0.5 INTER_AREA", i...
993,420
91f40e99627fb98a48f727dc30aa2b1e287d820c
import argparse import numpy as np from pathlib import Path import matplotlib.pyplot as plt from test_mask import test_topk def run_experiment(data_path, masking_features): """ Compares concrete dropout to randomly picking k features. """ random_roc = [] dropout_roc = [] k_values = [5, 10, 15...
993,421
a6884076ce65f766d69dceab0b187ff48b7d193d
# 装饰器的本质就是闭包 # 装饰器的作用,在不修改原函数的前提下,实现函数功能的拓展。 def login(index): #传入被装饰的函数 def foo(): usernamae ='python' password = '123' u = input('请输入用户名') p = input('请输入密码') if usernamae== u and password == p: index() #执行传入进来的被装饰函数 else: print("用户名或密码错误") ...
993,422
292c761f620fef0db5b9d86a31b0054ae6576365
class Solution: def canJump(self, nums: List[int]) -> bool: n, pos = len(nums), 0 for i in range(n): if i <= pos: pos = max(pos, i + nums[i]) if pos >= n - 1: return True return False
993,423
ab8ab86d54edac6ea03ac9737b6754f16a55b32c
import networkx as nx import numpy as np import re def make_graph(lines): lines = [line[:-1] for line in lines] g = nx.DiGraph() for line in lines: source,targets = line.split(' contain ') source = source.replace(' bags','') if 'no other bags' not in targets: for starge...
993,424
911f458f1e66c83abadb684ae919737697191097
""" """ from django.conf.urls import include, url import ckeditor import rec_file urlpatterns = [ url(r'^ckeditor_upload_image/?$',ckeditor.upload_image), url(r'^upload/?$',rec_file.general) ]
993,425
6c1278d0fcadc4b3c8cfde312b136c0b1f15716f
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 1 12:54:31 2018 @author: ajay yadav """ import random # for gentrating random things may be random letter or number import string # for genrating the string vowels ='aeiou' # for vowels consonants = 'bcdfghjklmnpqrstvwxy' # for consonants lette...
993,426
4e1fdb37bf9a19d239beface68e20dedee205f35
""" Решение системы x^2+y^2=1 y=tan(x) """ """ Графически локализуем корни Получаем x_1 = [0.6 , 0.7] y_1 = [0.7, 0.8] Искать будем только один корень в этом интервале, так как в виду специфики уравнений, если (x*, y*) является корнем, то (-x*,-y*) также является корнем """ """ Выберем следующее выр...
993,427
ed9be598d20ad7ef324962bbb1f547204008808c
import requests res = requests.get('https://torina.top') print(res.txt)
993,428
1afe5509342ddb50639daebb9efe5f535f54d042
import elasticsearch from elasticsearch import helpers import collections class ElasticService: @staticmethod def create_index_with_data(data, index: str, request_body: dict): es = elasticsearch.Elasticsearch() # Ignore 404 error when index doesn't exist. es.indices.delete(index=index...
993,429
63b7eb90392f121e0f85962e3a5c0175c93ea9da
import numpy as np from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split # 数据归一化预处理 class StandardScaler: def __init__(self): self.mean_ = None self.scaler_ = None def fit(self, X): """根据传进来的训练数据集X,获取数据的均值以及方差""" assert X.ndim == 2 ...
993,430
c171c893e0b55a163a52d4689a07ca66fe7471b9
l_num_alpha=["ZERO","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"] l_num_int =[0,1,2,3,4,5,6,7,8,9] while 1==1 : num_alpha=str(input("영문 숫자명을 입력하시요 ")).upper() if num_alpha.upper() == 'Q': print("프로그램을 종료합니다. 안녕~^^ ") break else: for i in range...
993,431
36b4f1df4632d1a19145e8d46a603d81ccd2c884
# Raspberry Pi Pico - I2C LCD # Datei: buch-rpi-pico-kap6-i2c-lcd.py # Bibliothek from machine import I2C, Pin from lcd_api import LcdApi from pico_i2c_lcd import I2cLcd import utime # Variablen/Objekte I2C_ADDR = 0x3F I2C_NUM_ROWS = 2 I2C_NUM_COLS = 16 sda=machine.Pin(8) scl=machine.Pin(9) i2...
993,432
48230167eab0fc5f43cae9b6ac5bad38ed650a80
import numpy as np from sklearn.base import BaseEstimator, ClusterMixin from sklearn.metrics.pairwise import pairwise_kernels from sklearn.utils import check_random_state from sklearn import metrics import os, glob from sklearn.decomposition import TruncatedSVD from sklearn.feature_extraction.text import T...
993,433
587936592b2de26a97be21ae06024583e8958101
# 1. print("Output of 1st program is: ") import pandas as pd d=pd.DataFrame([5,2,4,8]) print(d) print(d[0]) # 2. print("\n\nOutput of 2nd Program is: ") d=pd.DataFrame({'a':[5,2,4,8]}) print(d) # 3. print("\n\nOutput of 3rd Program is: ") print(d['a'][1]) # 4. print("\n\nOutput of 4th Program is: ") d=pd.DataFra...
993,434
1bd34ce0f0ec2d0dc94e2b3c1dd4c7ae4e0927df
import numpy as np def fit(X_train, Y_train) : result = {} class_values = set(Y_train) for current_class in class_values : result[current_class] = {} result["total_data"] = len(Y_train) current_class_rows = (Y_train==current_class) X_train_current = X_train[current_class_row...
993,435
e4a6fb40f325c69cf63e7c1e3bf8b6fbf46c6ac4
# Generated by Django 2.2.4 on 2021-08-24 10:30 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('objects', '0003_auto_20210823_1430'), ('dispatching', '0001_initial'), ] operations = [ migrations....
993,436
c4f62970a60a784fe1852a8231d0b58f5136a34f
print "Hello, world, I am not becoming a Git Ninja"
993,437
dfdc3495e93a3ff16d18535b2e0b5b9e45ea8482
# OK # https://www.machinelearningplus.com/nlp/text-summarization-approaches-nlp-example/ # sudo pip3 install gensim # pip3 show gensim | grep Version # sudo pip3 install -U gensim # sudo python3 -m pip install -U gensim # sudo pip install gensim --user # sudo pip3 install --upgrade gensim # python3 -m pip install g...
993,438
a3b19f02a72320a0f15e090ec5b63f9cc225beaa
# Write a Python function to create the HTML string with tags around the word(s). # Sample function and result : # add_tags('i', 'Python') -> '<i>Python</i>' # add_tags('b', 'Python Tutorial') -> '<b>Python Tutorial </b>' def add_tags(tag, message): return "<{tag}>{message}</{tag}>".format(tag=tag, message=messag...
993,439
d73472a15cb29dcc0202043d2bcf4b31a6a13e56
import simplejson as json from flask_wtf import Form from wtforms import StringField, IntegerField, SelectField from wtforms.widgets import TextInput, FileInput, HiddenInput from wtforms.validators import Required, Optional, NumberRange, Length, Regexp import logging log = logging.getLogger(__name__) # If present, ...
993,440
26b6508f078ffdae3e558b4192d032f8247ae2d1
class Solution(object): def generateMatrix(self, n): """ :type n: int :rtype: List[List[int]] """ if n == 0: return [] up, left = 0, 0 down, right = n - 1, n - 1 res = [[0 for i in range(n)] for j in range(n)] direct,count ...
993,441
f522229fb9b4265414fb64100f7b509f1d06c0ea
#!/usr/bin/python # Days of Year # Author: Thomas Perl import datetime today = datetime.datetime.now() day_of_year = int(today.strftime('%j')) print day_of_year
993,442
9744527ba91b6277206419a2d9e124ae628b8611
from multiprocessing import Queue class BufferManager: def __init__(self): self.percept_buffer = Queue() self.action_buffer = Queue() def read_percept(self): return self.percept_buffer.get(True) if not self.percept_buffer.empty() else None def write_percept(self, perce...
993,443
08ef47ea1c063b7e30c1c158d7ceb9bd06ee00e9
''' Author: Aaron Aikman Date of Creation: 11/21/2017 Installation: Put in scripts folder Enter 'rehash' in the mel command line Put the Shelf Button script into a python button Shelf Button: import AAikman_AddAttrToSel as aaAddAttrs reload(aaAddAttrs) aaAddAttrs.main() Marking Menu Script: python("import AAikman_A...
993,444
cf6b400f0873ba8e41dd3adda3ac3b677fa4744e
import os import sys import numpy as np import pandas as pd from matplotlib import pyplot as plt import seaborn as sns from datetime import datetime # === Day 2 tree1_loc = os.path.join(os.getcwd(), 'hft_group_project/datasets/day2', '25.csv') tree1_data = pd.read_csv(tree1_loc) tree2_loc = os.path.join(os.getcwd(), ...
993,445
10ba373c3cef3bf516c0ecb8425522596719845a
from django import forms from django.conf import settings from django.http import HttpResponse, HttpResponseRedirect, Http404 from homepage.models import * from manager import models as mmod from . import templater from datetime import datetime def process_request(request): '''Sends an employee to the form for up...
993,446
98d9b1ac46a2438e60a4e030c8fd8350563d24b0
from scapy.all import * from threading import Thread import time import sys def generate_packets(dst_addr): #ARP(op=2, pdst=dest_IP, psrc=spoof_IP, hwsrc=hwsrc) pkt = ARP(op=1, pdst=dst_addr) return pkt def flood_packet(dst_addr, timeout=100): print(dst_addr) start_time = time.time() while tim...
993,447
71aa5a06ea4edc6fed87c12a48a09e0c4f7d326b
def sumAll(n): res = 0 i = 0 while i<=n: res += i i += 1 return res
993,448
507d1d55b646bfed9194f1bdb301a025897004d9
#!/bin/python #Filename=using_file.py poem='''\ Programming is fun When the work is done if you wanna make your work also fun: use Python! and funk ''' #peng=file('test.txt','w') # if file no exist and it will creat new file f=file('poem.txt','a') # open for wrinting f.write(poem) # wrint text to file. at end ,add f....
993,449
b6a82100dcf8f622a2bcc23c3990043a7730d9af
from django import forms from .models import * from django.core.exceptions import ValidationError from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User from django.contrib.auth import get_user_model from django.forms import modelformset_factory class CustomUserCreationF...
993,450
c4b8028af65097671723489df5274aa40bcc33a9
#!/usr/bin/env python3 # seekf.py - seek and modify file import sys if (len(sys.argv) < 4): sys.stderr.write("Usage: seekf.py filename color shade\n") exit(1) # your code here... ############################################### # # $ seekf.py colors yellow 6.6 # # $ readf.py colors # blue 4.4 # i...
993,451
ee47cdf94ba6a9169ce8107b52e14c955237cc07
from django.shortcuts import render from django.contrib.auth.models import User def main(request): return render(request, 'main.html', {})
993,452
e0ce356b3dabb392f44420594564a0d1e657fb95
############################# # # # Alexander Chick # # # # copyright 2015 # # # ############################# """ This program creates 50 * 50 = 2500 test interaction objects in the "zE0001R1" table in Parse. Data m...
993,453
19f5243ff43c20beed65a4c11871c6f7d8500185
from flask import Flask, request, render_template import requests import json app = Flask(__name__) app.debug = True @app.route('/') def hello_world(): return 'Hello World!' @app.route('/search_form') def search_form(): return render_template("search_form.html") @app.route('/search_info') def view_search_info...
993,454
dfddd7f26d630601cab680f54089ce7a36ec4484
# stuff for managing the "tmp" temporary directory import os import shutil def reset(): if os.path.exists('tmp'): shutil.rmtree('tmp') os.makedirs('tmp')
993,455
cc3d34596a5a32e60fa32b406d82b7b406d37833
from typing import Optional, List, Tuple, IO import numpy as np import pickle class TradingPopulation: def __init__(self, input_shape: Tuple[int, int], starting_balance: float, num_individuals: int, mutation_chance_genome=.1, mutation_magnitude=.15, crossover_chance_genome=.5): ...
993,456
8a2db74aa39746e27fca5a8c0ccd7166b9a59135
from django import forms from users_profiles.models import UserProfile from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User class UserProfileForm(forms.ModelForm): class Meta: model = UserProfile fields = ('receive_news', 'picture') #todo how ...
993,457
f7ba58797dab809843107b81c4cfbb9a117508b8
# coding: utf-8 from __future__ import absolute_import # import models into model package from .ane import ANE from .ane_flow_coefficient import ANEFlowCoefficient from .error import Error from .error_meta import ErrorMeta from .flow_spec import FlowSpec from .path_query_response import PathQueryResponse from .query_d...
993,458
be4cf1a3d70e3e692b2daaa186ce64e21cf69f1f
#!/usr/bin/env python import os value=os.system("ipython notebook --pylab inline") if value>0: value=os.system("ipython notebook --pylab inline --port 9999")
993,459
56a03e302f1f9d27551000325decd497ec22cea9
def cigar_party(cigars, is_weekend): if (cigars >= 40 and cigars <= 60) and not is_weekend: return True if (cigars >= 40 and cigars <= 60) and is_weekend: return True if (cigars > 60) and is_weekend: return True if (cigars < 40 or cigars > 60) and is_weekend: return Fals...
993,460
2098f551db4a95ab1f90a16c9bd5bcee1ee19b13
import optparse import os,sys import json import commands import ROOT import pickle from plotter import Plot CHANNELS = [-11*11,-13*13,-11*13] #CHANNELS = [-11*13] JETMULTCATEGS = [2,3,4] SLICEBINS = [(20,320),(20,60),(60,120),(120,320)] SLICEVAR = 'jetpt' SYSTVARS = ['','jesup','jesdn','jerup'...
993,461
62f6afaa756ce364ca6fb8edc02181602fa8e376
# https://adventofcode.com/2018/day/4 import re from datetime import date, time, timedelta SLEEP = -1 AWAKE = -2 def read_input(fn): line_re = re.compile(r'^\[(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\]\s+(.+)$') action_re = re.compile(r'Guard #(\d+) begins shift') with open(fn) as file: for year, month, d...
993,462
2b242afc1610e58df35a42891782fac58101dd48
# -*- coding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "Lic...
993,463
ac7dc1541bff22447d029a3195f23a1322383412
import requests res = requests.get("http://www.baidu.com") print(res.cookies) for key, value in res.cookies.items(): print(key + "=" + value)
993,464
73de781bacf3b0c15b9bc498f966e25458b73739
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 17 21:47:48 2019 @author: jaredgridley The purpose of this program is to make a framed box based on the input specifications. """ import math character = input("Enter frame character ==> ") print(character) height = int(input("Height of box ==> "...
993,465
293323a5af0e84f98e3dfa76495cedf0a2485dc5
HEADLESS = False # Changeable Constants SEARCH_TERM = 'PS4' MIN_PRICE = 1700 MAX_PRICE = 3000 MAX_NB_RESULTS = 50 # Rather Constant Constants DIRECTORY = 'results' CURRENCY = '€' BASE_URL = "https://www.amazon.nl/" FILTERS = { 'min': MIN_PRICE, 'max': MAX_PRICE }
993,466
e24616b10433b22a779f7f1913ccb6afd1edbd4f
""" Utils """ import logging def getLoggingLevel(verbosity): """Verbosity level to logging level.""" logLevels = {0: logging.WARNING, 1: logging.INFO} if verbosity > 1: return logging.DEBUG else: return logLevels.get(verbosity, logging.ERROR)
993,467
65808f0747867f43f808777454222cc95d5e7511
import datetime import urllib import random from django.contrib import auth from django.contrib.auth.signals import user_logged_in from django.core.exceptions import ImproperlyConfigured from django.db import models from django.db.models.manager import EmptyManager from django.contrib.contenttypes.models import Content...
993,468
47c85a58692be95e356e455c7c2ea469ecc7d222
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration """ Derive from the offline class and override InDetFlags """ __author__ = "J. Masik" __version__= "$Revision: 1.2 $" __doc__ = "ConfiguredNewTrackingTrigCuts" from AthenaCommon.Include import include _sharedcuts = False if _sharedcuts: ...
993,469
f904aa1a24126e7cd5b1fbd931d7d1dda5762298
#/**********************************************************************/ #/* CSC 280 Programming Project 2 Part 1 */ #/* */ #/* modifier: Dri Torres ...
993,470
0ad5bb8dce5ec9f2e66b5a86eaf37bb525084521
import os import subprocess from pyngrok import ngrok try: from google.colab import drive colab_env = True except ImportError: colab_env = False EXTENSIONS = ["ms-python.python", "ms-toolsai.jupyter"] class ColabCode: def __init__(self, workspace, port=10000, password=None, authtoken=None, mount_d...
993,471
0857288303119f87eb6ae98c34e9db0435151f58
from uuid import UUID from pvm.activities.activity import Activity from pvm.transition import Transition class Cycle(Activity): """自循环活动节点 """ def __init__(self, name: str, id: UUID = None): super(Cycle, self).__init__(name, id) self._reserved_transition = Transition() self._rese...
993,472
e9e03c0f9e0d193e84555bfd7da9c1f1e8231687
''' Created on 11 Mar 2019 @author: olma ''' import math class Line(): ''' classdocs ''' def __init__(self, coor1, coor2): ''' Constructor ''' self.coor1 = coor1 self.coor2 = coor2 def distance(self): # distance = radical din (x2-x1) la patrat...
993,473
798efccd8ecc2e728f637da3a475e89511f88b15
## This function rotates a list k amount of times without generating a new array. ## e.g [1,2,3,4,5], k = 2 --> [3,4,5,1,2] def rotateList(nums, k): # pop(0) deletes the first object in nums while k > 0: temp = nums.pop(0) nums.append(temp) k -= 1 return nums if __name__ == "__...
993,474
e88690b92280679a4fd4e908a35504ab10189294
global_data = { 'host': 'api.github.com', 'user': 'amitdad36', 'password': 'amit036198823', } tc1 = { 'method': 'post', 'url': '/gists', 'body': template_api['create_gist'] }
993,475
121203b2cb9f75b37685143847b564c34e0af8b2
def foo(x): return x**2 print foo(8.0)
993,476
96531ce3bc3611d0063b8c7ef53f5bde09052a1c
import os import shap import torch import numpy as np import simple_influence from scipy.stats import pearsonr, spearmanr from sklearn.datasets import make_classification from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, normalize from eli5.permutation_importance imp...
993,477
a3345bbd63cab053cb7ae34e2a2d8ef77c261444
import socket import sys from gui import ClientGUI # Create a new client socket and connect to the server def create_connection(server_address): client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect((server_address)) return client # create components, star...
993,478
12229bd529d9b4773f911c88f0846ca7338de451
import sys sys.stdin = open('21_input.txt') dr = [-1, 1, 0, 0] dc = [0, 0, -1, 1] def dfs(sr, sc): global arr, visited, N, L, count S = [(sr, sc)] visited[sr][sc] = 1 num = 1 cnt = 1 while S: r, c = S.pop() for i in range(4): nr = r + dr[i] nc = c + dc[i...
993,479
c6c80390c5c245e105004c12d621411309525015
#!/usr/bin/env python3 #------------------------------------------------------------------------------- # O(n) solution class Solution(object): def addDigits(self, num): """ :type num: int :rtype: int """ return self.addDigits(sum(int(i) for i in str(num))) if num>=10 else ...
993,480
1c4845a52823c04fefa6aa15b2d13ff4ea66c940
string = input("Mata in en textsträng: ").lower().replace(" ", "") print(f"{len(string)}") if string == string[::-1]: print("Textsträngen är en palindrom") else: print("Textsträngen är inte en palindrom")
993,481
d2ef86a0137816a2569ad2bdbd3b75c65817ae62
# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-03-07 12:17 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('cms', '0006_auto_20160305_2005'), ] operations = [ migrations.CreateModel( ...
993,482
1cf3d27d0b454b25874058bff88f978dea00e29d
#!/local/anaconda/bin/python # IMPORTANT: leave the above line as is. import logging import sys import numpy as np lines = 0 avgs = None for line in sys.stdin: line = line.strip() k, v = line.split(', ') coef = np.fromstring(v, sep=" ",dtype='double') if avgs is None: avgs = np.zeros(coef.siz...
993,483
4f162792fdb26dc061a5c48a21933586afd76f67
from pwn import * BLOCKSIZE = 16 def xor(a,b): return bytes([x^y for x,y in zip(a,b)]) class Block: def __init__(self, data = b''): self.data = data def double(self): assert(len(self.data) == BLOCKSIZE) x = int.from_bytes(self.data, 'big') n = BLOCKSIZE * 8 ...
993,484
3ef0e3e1797aa0603712d2b6df408c6d6be9cc0b
import argparse import copy import logging import os import sys import time from pathlib import Path from typing import Callable, Iterable, List, Union import pytorch_lightning as pl import wandb from hydra import compose, initialize, initialize_config_dir from hydra.utils import instantiate, to_absolute_path from ome...
993,485
8c236a9ed17f524841c80bed7decca8d2f4249e5
""" GrantRevokeMenu class module. """ from functools import partial from typing import List, Callable, Tuple from http.client import HTTPException from dms2021client.data.rest import AuthService from dms2021client.presentation.orderedmenu import OrderedMenu from dms2021client.data.rest.exc import NotFoundError, Unautho...
993,486
becb8c2b9f90a8ba5fd7429ff745d527b363c06f
# -*- coding: utf8 -*- import sys from time import sleep from snapconnect import snap SERIAL_TYPE = snap.SERIAL_TYPE_RS232 class BridgeVersionClient(object): def __init__(self, path, nodeAddress, message): print 'init conn2' self.path=path self.nodeAddress=nodeAddress self.messag...
993,487
a024d48d3b125cb2cf78c7f11bab50a41c1a64ab
class Solution: def bitwiseComplement(self, N: int) -> int: if N==0: return 1 cur=1 rep=0 while N>0: if N&1==1: cur*=2 N>>=1 else: rep+=cur cur*=2 N>>=1 return ...
993,488
b304e1f8654aade278502eec132151546e453969
from __future__ import print_function import os import torch import torch.nn as nn import torch.nn.parallel import torch.utils.data from torch.autograd import Variable import torch.nn.functional as F from collections import OrderedDict import numpy as np import sys BASE_DIR = os.path.dirname(os.path.abspath(__file__))...
993,489
548cd6a03527b5fc77fbd595c8c2794fde6c3a96
class Solution(object): def numTrees(self, n): """ :type n: int :rtype: int """ count = [0] * (n+1) count[0],count[1] = 1,1 self.do(n,count) return count[n] def do(self,n,count): if count[n] > 0: return count[n] res = 0 ...
993,490
e64050d660e41bb7b148bb9b5eb6b347f9c688e9
x = 10; y = 20; x_list = [x]*10 y_list = [y]*10 allnumbers = x_list+y_list print(allnumbers)
993,491
39bede9dcb859084491e30f90bf64f30225d0000
from urllib import request url = 'https://query1.finance.yahoo.com/v7/finance/download/TSLA?period1=1521654485&period2=1524332885&interval=1d&events=history&crumb=o5Eu4tetf/L' def download_stock_data(csv_url): response = request.urlopen(csv_url) csv = response.read() csv_str = str(csv) lines = csv_s...
993,492
fe39bbf58c6467eaadbf3ec2f11f5ecd78498d69
''' Author: Artur Assis Alves Date : 07/04/2020 Title : Question 9 ''' import sys #Functions: def is_palindrome (word): ''' Returns True if the string 'word' is a palindrome. Returns False otherwise. Input : word -> string Output: True/False -> bool '...
993,493
8f27989245bdd7d0582b02e1ef2788cf19d13c85
# https://www.hackerrank.com/challenges/apple-and-orange/problem import math import os import random import re import sys def countApplesAndOranges(s, t, a, b, apples, oranges): # s, t : location of Sam's house start & end # a : location of apple tree # b : location of orange tree # apples: array (vec...
993,494
bdbb1abd3d2f6ced4c18c87f5b1be227be3d5a8f
"""Convert :term:`BAM` format to :term:`BED` formats""" from biokit.converters.convbase import ConvBase __all__ = ["Bam2Bed"] class Bam2Bed(ConvBase): """Convert sorted :term:`BAM` file into :term:`BED` file :: samtools depth -aa INPUT > OUTPUT """ def __init__(self, infile, outfile, *arg...
993,495
149ab6b0b6cae924992b32e6d93399ed66e9455b
from __future__ import absolute_import from django.shortcuts import render from django.http import HttpResponse,JsonResponse from django.views.decorators.csrf import csrf_exempt from Backoffice.models import Session_utilisateur, Commercial, Magasinvdsa, Admin import json import Dashboard from Dashboard import views ...
993,496
c70000071ebb05e92516a7f948e10c4f9d08964e
#!/usr/bin/env python import argparse from sqs_s3_logger.environment import Environment from sqs_s3_logger.lambda_function_builder import build_package, ROLE_NAME, ROLE_POLICY def get_environment(args): f_name = args.function if args.function is not None else\ '{}-to-{}'.format(args.queue, args.bucket) ...
993,497
92d121e956e69ce3cea995773f6f4208f734dd56
# -*- coding: utf-8 -*- import time import tornado.web import tornado.gen import tornado.httpclient import url from util import dtools, security, httputils from handler.site_base import SiteBaseHandler class OrderHandler(SiteBaseHandler): @tornado.gen.coroutine def post(self, siteid): parse_args = ...
993,498
74a370248526ad8c934836925fad344ddd72c216
import os, math, numpy as np import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN, KMeans from sklearn.decomposition import PCA from sklearn import preprocessing from bathyml.common.training import getParameterizedModel from mpl_toolkits.mplot3d import Axes3D def read_csv_data( fileName: str, nBands: int...
993,499
d1c0eab6bd5890577fa6bcd4219c0d32a0e182a1
"""Name-en-US: Animate on Spline Description-en-US: Creates an Align To Spline tag with keys at the start/end of animation. Written for CINEMA 4D R14.025 LICENSE: Copyright (C) 2012 by Donovan Keith (www.donovankeith.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software a...