index
int64
0
1,000k
blob_id
stringlengths
40
40
code
stringlengths
7
10.4M
10,100
3161ee98445156af569967ccf26987c18df29669
r"""The ``fourier`` module provides the core functionality of MPoL via :class:`mpol.fourier.FourierCube`.""" from __future__ import annotations from typing import Any import numpy as np import torch import torch.fft # to avoid conflicts with old torch.fft *function* import torchkbnufft from numpy import complexfloa...
10,101
dc8030ce2a8c415209ecc19ca9926055c46a12b8
# longest_palindrome2.py class Solution: def longestPalindrome(self, s): map_dict = dict() for i in s: if i in map_dict.keys(): map_dict[i] += 1 else: map_dict[i] = 1 result = 0 mark = 0 for j in map_dict.keys(): ...
10,102
6528abc78922a64f4353a2d7541e4a0938d601de
"""Test antisymmetric_projection.""" import numpy as np from toqito.perms import antisymmetric_projection def test_antisymmetric_projection_d_2_p_1(): """Dimension is 2 and p is equal to 1.""" res = antisymmetric_projection(2, 1).todense() expected_res = np.array([[1, 0], [0, 1]]) bool_mat = np.iscl...
10,103
1fe5f2f76999c7484acfae831e2a66337f041601
# Credit: http://realiseyourdreams.wordpress.com/latex-scripts/ #Script to clean up a directory tree! import os,subprocess #browse the directory for dirname, dirnames, filenames in os.walk('.'): for filename in filenames: #Check every file for: filepath = os.path.join(dirname, filename) #hidden file if filena...
10,104
17575318372e09039c8d94ed803192e24859cb05
import subprocess import shlex import time import os import signal PROCESS = [] while True: ANSWER = input('ะ’ั‹ะฑะตั€ะธั‚ะต ะดะตะนัั‚ะฒะธะต: q - ะฒั‹ั…ะพะด, s - ะทะฐะฟัƒัั‚ะธั‚ัŒ ัะตั€ะฒะตั€ ะธ ะบะปะธะตะฝั‚ั‹, x - ะทะฐะบั€ั‹ั‚ัŒ ะฒัะต ะพะบะฝะฐ: ') if ANSWER == 'q': break elif ANSWER == 's': PROCESS.append(subprocess.Popen('gnome-terminal ...
10,105
133acc36f9c3b54ed808a209054f5efcddbb04ae
# Generated by Django 2.2.7 on 2020-02-03 13:54 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('fillintheblanks', '0001_initial'), ] operations = [ migrations.AddField( model_name='fillquestion', name='answer_ord...
10,106
d90d6cd69a792ba03697df51cb5224467c74deeb
from rest_framework import serializers from .models import * from django.contrib.auth import authenticate from django.contrib.auth.models import Group from rest_framework.response import Response import json from django.db import models class LoginSerializer(serializers.ModelSerializer): email = serializers.CharFie...
10,107
5e901074031de4e02fa68fa42c3ff780e14d8110
import os import spotipy from spotipy.oauth2 import SpotifyOAuth import pyautogui import cv2 from datetime import datetime from utils import * class SpotifyControls: """ This class execute Spotify API commands based on the hand pose predicted from HandPoses. The gesture controller uses a specific...
10,108
ce051e802eb45ba3bd5fcf4a1389eb9baf6a0408
from inv.models import Item from dogma.models import TypeAttributes from dogma.const import * def getCPUandPGandSlot(itemsIter): """Adds extra information to the given list of items. Returns: A list of tuples in the form (item, cpu, pg, classes). - cpu and pg are the unbonused values of the CPU and PG a...
10,109
36e6f0b965827ee85ff79c8d591e8307e8b1a590
import psycopg2 #open databse connection db = psycopg2.connect(database = "postgres") ###################------------3g------------#################### #####Question 3g##### What percent of students transfer into one of the ABC majors? cursor3g1 = db.cursor() #find total num of student ended in ABC cursor3g1.exec...
10,110
6b9ca358d4a42aac3fb7f208435efecc22dab6c7
""" This class is the most granular section of the Pabuito Grade Tool. It takes a subcategory from the xml and generates all GUI components for grading. It includes all class attributes required to retrieve and load grading attributes [comments, values, etc] """ import maya.cmds as cmds # import maya.utils import ...
10,111
d9aa30b8557d9797b9275b5d3dfe2cb31d4755c8
#!/usr/bin/env python import numpy as np import sys import os import argparse as ARG import pylab as plt sys.path.insert(0, os.path.abspath( os.path.join(os.path.dirname(__file__), '..'))) sys.path.insert(0, os.path.abspath( os.path.join(os.path.dirname(__file__), '.'))) import fqlag from sim_psd import ...
10,112
33c49773b2ebb081ed2436e398eaaf389720c24c
# -*- coding: utf-8 -*- """ Created on Mon Feb 25 12:04:20 2019 @author: Usuario """ from matplotlib import pyplot as plt import argparse import cv2 import numpy as np ap = argparse.ArgumentParser() ap.add_argument("-i","--image",required=True,help="Set the Path of image") args = vars(ap.parse_args()) image = cv2.i...
10,113
d802b6d08fc7e5b47705374aa305ee6f0b23690b
# -*- coding:UTF-8 -*- import cx_Oracle import datetime import os # ่ฎพ็ฝฎๅญ—็ฌฆ้›†ไธŽoracleไธ€่‡ด๏ผŒไธ็„ถinsertไธญๆ–‡ไนฑ็  os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.ZHS16GBK' print('====beging...') # ่Žทๅ–้œ€่ฆๅˆคๆ–ญ็š„ๆ•ฐๆฎไฟกๆฏ startTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M') print('===========================',startTime,'=======================...
10,114
a7114a9f1c7342e155cde04dc0f5d1461fd08f87
''' Given a string s, return the longest palindromic substring in s. ------- RESULTS ------- Time Complexity: Space Complexity: '''
10,115
15f11fae7dbededb6aaf3292c8e211a9b86c605d
from django.contrib import admin from .models import Article # Register your models here. @admin.register(Article) class ArticleModel(admin.ModelAdmin): list_filter = ('subject', 'date_of_publish', 'state') list_display = ('subject', 'date_of_publish', 'state') date_hierarchy = ('date_of_publish')
10,116
a6852f294fd536d7b020db33fab561a12829837f
from django.contrib.auth.hashers import BasePasswordHasher from collections import OrderedDict class PlainTextPassword(BasePasswordHasher): algorithm = "plain" def salt(self): return '' def encode(self, password, salt): assert salt == '' return password def verify(self, passwo...
10,117
abe111117ab67c2fbc0cba8d867937fb54b9b7da
""" @author: Viet Nguyen <nhviet1009@gmail.com> """ import torch import torch.nn as nn class WordAttNet(nn.Module): def __init__(self, hidden_size, word_dict_len, embed_size): super(WordAttNet, self).__init__() self.lookup = nn.Embedding(num_embeddings=word_dict_len, embedding_dim=embed_size) ...
10,118
6523c652c98874716aa973e39d767e0915aa46fd
''' ้—ฎ้ข˜๏ผšๅฆ‚ๆžœไธๅŒ็š„็ˆถ็ฑปๅ‡บ็Žฐไบ†็›ธๅŒๅ็งฐ็š„ๅฑžๆ€งๆˆ–่€…ๆ–นๆณ• ๅญ็ฑปไผš็ปงๆ‰ฟ่ฐ็š„ๅฑžๆ€งๆˆ–่€…ๆ–นๆณ•๏ผŸ python3ไธญ้ƒฝๆ˜ฏๆ–ฐๅผ็ฑป๏ผšๅนฟๅบฆไผ˜ๅ…ˆ๏ผŒไปŽ็ˆถ็ฑปไธญๆŸฅ่ฏขๅฏนๅบ”็š„ๆ–นๆณ•๏ผŒๆŸฅ่ฏขๅˆฐ็ฌฌไธ€ไธชๆปก่ถณ็š„ๆ–นๆณ•ไน‹ๅŽๅฐฑ็›ดๆŽฅ่ฟ”ๅ›ž object | A(object) | A_1(A) --> A_2(A) | Test(A_1, A_2) python2ไธญ็š„็ปๅ…ธ็ฑป๏ผšๆทฑๅบฆไผ˜ๅ…ˆ A ...
10,119
3345787c7d7a7a72f1db2490cc585d39ca74240e
__author__ = 'ericdennison' from hhscp import app from hhscp.events import * from hhscp.users import User, Users, ADMIN, USERSFILE from flask import render_template from flask import request, session from flask import redirect import inspect import sys import datetime import tempfile @app.route('/calendar') def site...
10,120
1d14118d1ee7f2888ed7ee68be4a27ff7488faab
import random from socket import * port = 2500 BUFFER = 1024 server = "localhost" sock = socket(AF_INET, SOCK_DGRAM) sock.connect((server, port)) for i in range(10): delay = 0.1 data = 'Hello message' while True: sock.send(data.encode()) print("Waiting up to {} secondes for a reply".form...
10,121
3eee7008c7db28f7c6fcc4500683b34f808aa2d7
# -*- coding: utf-8 -*- # // --- Directions # // Check to see if two provided strings are anagrams of eachother. # // One string is an anagram of another if it uses the same characters # // in the same quantity. Only consider characters, not spaces # // or punctuation. Consider capital letters to be the same as lower ...
10,122
c33697970dfb1d99d9b071460c235dbf2b612e62
from DateTime import DateTime from Products.ATContentTypes.interfaces import IATEvent as IATEvent_ATCT from Products.ATContentTypes.tests.utils import EmailValidator from Products.ATContentTypes.tests.utils import EmptyValidator from Products.ATContentTypes.tests.utils import NotRequiredTidyHTMLValidator from Products....
10,123
c00873814c110f571396973e99ffc953b2e21788
dict = {'naam': }
10,124
59e446d26c5becfe8e7d4486e204d85a0b807dab
__author__ = 'Gina Pappagallo (gmp5vb)' def greetings(msg): print(str(msg))
10,125
4cc15ca62803def398ce31181c0a73184d8b28f6
""" :Copyright: 2014-2023 Jochen Kupperschmidt :License: Revised BSD (see `LICENSE` file for details) """ import pytest from byceps.services.tourney import ( tourney_match_comment_service, tourney_match_service, ) def test_hide_comment(api_client, api_client_authz_header, admin_user, comment): comment_b...
10,126
d26f1a7e426c5a280e66638bc239ce4b69f7b71b
import sys import numpy as np import random import os import math def usage(): print("Usage \n") print("python3 packet_generator.py <num_packets> <payload_length> <radix> <stages> <output_file_name> \n") print("output_file_name is optional will default to test.mem in the current working directory") def packet_gen...
10,127
2cf767ba9dea293fb5df7725d9f89ab17e0d6a8a
## https://leetcode.com/problems/max-increase-to-keep-city-skyline/description/ class Solution: def findMaxInCol(self,grid,m,n): ret = [0]*n for j in range(n): i=1 temp = grid[0][j] while i<m: if grid[i][j] > temp: temp = g...
10,128
eea67d437a504d06bd909c4b52a8d59d770620a1
#!/bin/python import platform os_info = platform.platform() print os_info if os_info.find('Linux') >= 0 or os_info.find('Darwin') >= 0: # Linux or Mac build env = Environment() env.Append(CPPFLAGS = '-Wall -O3') env.Append(CPPPATH = ['src',]) elif os_info.find('Windows') >= 0: env = Environment(MSVC_U...
10,129
e8842838829bb9d68f660c0635d1dbac14a3f1c4
import csv from selenium.webdriver.support.ui import Select def selectdepaturereturn(self, d="none", r="none", prom_cod="none"): find_element_text = "Departure_option_xpath" session_name = "Booking" Departure_date_selected = Select(self.get_path(session_name, find_element_text)) Departure_date = self.g...
10,130
68d93144b338174773b709a3ccca8294593122cc
#โ˜†๐’๐’Ž๐’‚๐’‹๐’Š๐’๐’‚๐’Šโ˜†# import sys import math from math import ceil, floor import itertools from functools import lru_cache from collections import deque sys.setrecursionlimit(10000000) input=lambda : sys.stdin.readline().rstrip() '''''โœ‚''''''''''''''''''''''''''''''''''''''''''''''''''''''''' def is_prime(n): n = a...
10,131
8f2ea021c34f154961db57b8d28ab14f6a7e3beb
from datetime import datetime, timedelta, timezone import time_machine from translator.tools import date_tools # --------------------------------------------------------------------------------unit test for parse_datetime_from_unix function-----------------------------------------------------------------------------...
10,132
3a8149808aadc48420f9050a93a167347b073a80
def main(): N, K = (int(i) for i in input().split()) if (N+1)//2 >= K: print("YES") else: print("NO") if __name__ == '__main__': main()
10,133
ae1dc185a11658df7838a799c1318b7167c5051b
#Short and handy script to login and after "x" seconds logout from Stackoverflow import requests import config import re import datetime import time ### DEFINING VARIABLES ### headers = { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 1...
10,134
0d8c6dec7b375a385c4df501e05eab2e5f685288
# coding: utf-8 # # Awele TME 1 # ##DE BEZENAC DE TOLDI # # In[9]: # - - - - - - - - - - - # IAMSI - 2016 # joueur d'Awele # - - - - - # REM: ce programme a ete ecrit en Python 3.4 # # En salle machine : utiliser la commande "python3" # - - - - - - - - - - - # - - - - - - - - - - - - - - - INFORMATIONS BINOME #...
10,135
0be99279635d8b5185fb29b2dd272f51d2d6c8f0
import apps.configs.configuration as conf from apps.configs.vars import Vars from apps.models.tarea_programada import TareaProgramada,StatusTarea from apps.models.receptor_estado import ReceptorDeEstado from apps.utils.system_util import path_join import json from apps.models.exception import AppException from apps.uti...
10,136
9eecfc950df298c1de1c1c596f981051b2eb4f89
import random #-----Entradas----# MENSAJE_SALUDAR = ''' Bienvenido a este programa, !!!jueguemos!!''' MENSAJE_SEGUNDO_NIVEL = 'Felicidades pasaste el primer nivel ahora ve por el รบltimo!!' MENSAJE_CALIENTE = 'Estas caliente' MENSAJE_FRIO = 'Estas Frio' PREGUNTAR_NUMERO = ''' En este juego deb...
10,137
f1d36444e6a1c54ff572586fa59566a52384819e
#!/usr/bin/python #import os import json import sys #import time from datetime import datetime as dt from datetime import date, timedelta import pdb import smtplib #from time import strftime #from types import * import ConfigParser import operator from email.mime.multipart import MIMEMultipart from email.mime.text imp...
10,138
1b4bd28e41f14829f6cb760541c9114becf4863f
with open("D:\DanielVIB\Maize\MoreDataSets\PearsonNetworks\ConsolidateCut\ProcessesRecallNoBP.txt", "r") as fileSAC,\ open("D:\DanielVIB\Maize\MoreDataSets\PearsonNetworks\ConsolidateCut\ProcessesRecallKrem.txt", "r") as fileKrem,\ open("D:\DanielVIB\Maize\MoreDataSets\PearsonNetworks\ConsolidateCut\Proc...
10,139
4ebee1de80f17cbfef5a335124fd85c762adf5cf
from postprocess import dynamic_audio_normalize from _shutil import * f = get_files()[0] dynamic_audio_normalize(f)
10,140
20c22db1d9ac8c1f01fe5e64609396c07518bc08
from copy import deepcopy from django.contrib.auth.hashers import make_password from django.core.mail import send_mail from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect from django.contrib.auth import login, update_session_auth_hash from django.contrib.auth.forms i...
10,141
f8cf01e2f554205b8a1a9b085c98b46d791ca3b3
"""backport module""" import os import shutil import re class Backport: """A simple class for transforming Python source files. """ DEFAULT_PATH = "." PYTHON_EXTENSION = "py" BACKUP_EXTENSION = "orig" REPLACEMENTS = {} IGNORE = (__file__,) def __init__(self, path=DEFAULT_PATH, file...
10,142
6b27564c0870f6ef341dcc425d6af2ed6fc726f3
# Copyright (c) 2021 by Cisco Systems, Inc. # All rights reserved. expected_output = { 'evi': { 1: { 'bd_id': { 11: { 'eth_tag': { 0: { 'remote_count': 4, 'local_count': 5, ...
10,143
bbaeb7b13e50e14fe29dab5846310e43b6f73e83
''' Individual stages of the pipeline implemented as functions from input files to output files. The run_stage function knows everything about submitting jobs and, given the state parameter, has full access to the state of the pipeline, such as config, options, DRMAA and the logger. ''' from utils import safe_make_di...
10,144
ce43bb3c2172dd0f286807a751827a4c3ab85816
# We run a preorder depth first search on the root of a binary tree. # # At each node in this traversal, we output D dashes (where D is the depth of t # his node), then we output the value of this node. (If the depth of a node is D, # the depth of its immediate child is D+1. The depth of the root node is 0.) # # ...
10,145
b07556b6800e79679cc3d40276a098aa90b0bff4
import unittest from deep_tasks import * class TestFindFuncs(unittest.TestCase): def setUp(self): self.diki = { 'A': { 'C': [2, 5], 'D': { 'I': 'heyo!', 'J': 6, 'F': 'In [A][D]' }, ...
10,146
d4814dc755ff0f3a8e82427659a7e4dfeaa84bcd
import math import operator from scipy import stats from utils import getTweets w1 = 0.3 w2 = 0.3 w3 = 0.3 def kullback_leibler(distr_a,distr_b): return stats.entropy(distr_a,distr_b) def logistic_increasing_func(x): return 1 / (1 + math.exp(x)) def coverage_score(tweet): return 0 def significance_sco...
10,147
e70493981b140fc0b59b99b30f0d67c37ba967ea
from RSAAlgorithm import autoGen as genKeyPair class Keyring: def __init__(self): self.name = "Me" self.publicKey, self.privateKey = genKeyPair(10)#10 bits of entropy is ridiculously weak: for testing purposes only. self.keys = [{self.name : self.publicKey}] def addKeyValuePair(self, k...
10,148
24b99b72d627ec6231516524c44767c60a4a5b5f
from functools import reduce with open('input') as rawinput: groups = rawinput.read().split('\n\n') def count_individual_answers(individual): def reducer(accumulator, letter): accumulator[letter] = accumulator.get(letter, 0) + 1 return accumulator return reduce(reducer, individual, {}) ...
10,149
edcbc5c642684eb83cf45a131a74c91de4404a58
# -*- coding: utf-8 -*- import scrapy from scrapy.http import HtmlResponse from bookparser.items import BookparserItem class Book24Spider(scrapy.Spider): name = 'book24' allowed_domains = ['book24.ru'] def __init__(self, book): self.start_urls = [f'https://book24.ru/search/?q={book}'] def pa...
10,150
ada2dff08d5221ed885ab97eabbd8d2972cf3396
class Error(Exception): pass def foo(): for i in reversed(range(10)): if i == 5: raise Error yield i i = 0 try: for (i, val) in enumerate(foo()): print i except Error: print "caught exception at i = %d" % i raise
10,151
297816b3f675d550d8abbe2ab4c2cee40c52b880
#!/usr/bin/python3 # # jip, 20.12.2017, falling into marasmus... :-) # import sys import tkinter from tkinter import Button from tkinter import TOP, BOTTOM, LEFT import time from random import randint #from Line import Line from Point import Point from Snowflake import Snowflake def quit(): root.destroy() s...
10,152
2619d6f9cab0cbe231a6a7d3bb56e7bc6d489089
# inpld project - python script # - AIM: poll the value of a sensor and send as OSC to sclang e.g. '/gsr 52' import OSC from OSC import OSCClient, OSCMessage from threading import Timer import Adafruit_BBIO.ADC as ADC import random # for faking random ADC values inPin = "P9_40" # connect sensor to this pin sendAddres...
10,153
9afe405dfceec2abf6c1dea58fc92c447c33ca51
# coding = utf-8 # python 3.7.3 # created by wuyang on 2020/3/24 from .base import BaseNet from .fcn import FCN, FCNHead from .pspnet import PSPNet from .deeplabv3 import DeepLabV3 models = { "fcn": FCN, "pspnet": PSPNet, "deeplabv3": DeepLabV3, } def get_segmentation_model(name, **kwargs): return m...
10,154
75a9863bd19775c603021dfb41e9f3f7b158f097
import caw.widget class Spacer(caw.widget.Widget): def __init__(self, width=5, **kwargs): super(Spacer, self).__init__(**kwargs) self.width_hint = width
10,155
06643d2c93f551e8e046711b1116a076c7446f43
s="hello python this is python language" '''expected out put is hello:1 python:2 this:1 is:1 language:1 ''' x=s.split() d={} for i in x: if d.get(i): d[i]=d.get(i)+1 else: d[i]=1 print d
10,156
2cf66dbf96281e08a034ff4a43da177679efa423
# -*- coding: utf-8 -*- # Generated by Django 1.10.6 on 2017-05-09 21:18 from __future__ import unicode_literals import django.core.validators from django.db import migrations, models from django.utils.timezone import now class Migration(migrations.Migration): dependencies = [ ('csn', '0001_initial'), ...
10,157
8ca1e7fc49881ff859d35111f58754db0cd6881a
"""Django templates for hiccup main page."""
10,158
740cb544c7e62fd40d5cebde9371cd34007dab0e
def main(): #Escribe tu cรณdigo debajo de esta lรญnea import math x= int(input("Escribe un numero: ")) y= math.sqrt(x) z= round(y) u= z+1 print(str(u)) pass if __name__=='__main__': main()
10,159
13f2f8d8d0538b4f6cec0ef123eab769fb01f7d8
<<<<<<< HEAD import json import re import os hotelname = input("่ฏท่พ“ๅ…ฅ้…’ๅบ—ๅ๏ผš") while not re.match(r'\w+', hotelname): hotelname = input("่ฏท่พ“ๅ…ฅๆญฃ็กฎ็š„้…’ๅบ—ๅ๏ผš") json_filename='hotel_info.json' f=open(json_filename,'r') hotel_info=json.load(f) for x in hotel_info: y=x['hotel_name'] print(x) print(y) if y.find(hote...
10,160
c0425fe2c2d713a8a97164d6127560d9d0154a2a
import os os.system('clear') import json import importlib import argparse import gevent import time import requests import smtplib from smtplib import SMTPException from gevent.threadpool import ThreadPool from gevent.queue import Queue from gevent import monkey monkey.patch_all(thread=False) os.environ['TERM'] = 'dum...
10,161
0e013ca31c3b969c8dac3638ec56d4d12492aa8e
import tensorflow as tf from absl.testing import parameterized from meta_model import utils def assert_specs_equal(actual, expected): assert tuple(actual._shape) == tuple(expected._shape) assert actual._dtype == expected._dtype assert type(actual) == type(expected) if isinstance(actual, tf.RaggedTens...
10,162
5ad63a3149707961bb9ac76e162e4159330da6d1
""" ํ†ฑ๋‹ˆ๋ฐ”ํ€ด https://www.acmicpc.net/problem/14891 """ def moveClock(g) : temp = gears[g][-1] for i in range(8) : gears[g][i], temp = temp, gears[g][i] def moveNonClock(g) : temp = gears[g][0] for i in range(7,-1,-1) : gears[g][i], temp = temp, gears[g][i] def moveGear(gear, direction, be...
10,163
c918ca69685b0aff413be3d2e83a2e5221eebf10
import urllib.request, urllib.error, urllib.parse, json from flask import Flask, render_template, request, request import logging import random app = Flask(__name__) def safe_get(url): try: return urllib.request.urlopen(url) except urllib.error.HTTPError as e: print("The server coul...
10,164
e00d82974c960d0322653a884a68e33197651a45
import time, math, os from selenium import webdriver import pyperclip from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait options = webdriver.ChromeOptions() options.binary_location = "/Applications/Google C...
10,165
630c533a9c42d6a55747b8f874aee3daee3e96ef
import binascii string = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736" nums = binascii.unhexlify(string) #Convert hex to binary-data strings = (''.join(chr(num ^ key) for num in nums) for key in range(256)) test = max(strings, key=lambda s: sum((26-i) * s.count(c) for i, c in enumerate('etaoins...
10,166
5a170bfc6c894c0547755403b7b3028fa73bb949
import random import sqlite3 class DataBase: def __init__(self): self.ids = 0 self.conn = sqlite3.connect('card.s3db') self.cur = self.conn.cursor() def create_table(self) -> None: self.cur.execute('''CREATE TABLE IF NOT EXISTS card ( id INTEGER...
10,167
e57eb8cbf84b2f54c47c5fda7f86ce41383bccd9
from time import sleep from .automodule import AutoModule from .siad import Siad, Result class AutoUnlock(AutoModule): def __init__(self, configuration_dictionary: dict, siad: Siad): self.password = configuration_dictionary.get("wallet-password", None) self.siad = siad if self.password is ...
10,168
fc86adc251a10c55c6e20c3e9e355fcfac8427c5
def chang_first_value(list_to_change): """Changes a list inside the function""" list_to_change[0]='something different' some_nums=[2,6,4,2,22,54,12,8,-1] print(some_nums) chang_first_value(some_nums) print(some_nums)
10,169
8c2286d0911f5970eccd29122030f9f285c0cab3
from django.test import TestCase from django.test import Client # Create your tests here. class NoteTest(TestCase): def test_get_note(self): c = Client() response = c.get('/edit/40/6/1/') self.assertEqual(response.status_code, 200) def test_save_note(self): c = Client() ...
10,170
a58062de2c7ce4e6ea7bb2e2156aae1c607fe6c3
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes ...
10,171
e7d6f6c6090d5dfa8a08b2349182403f61f92e9a
# -*- coding: utf-8 -*- from qcloudsdkcore.request import Request class CdbTdsqlExpandInstanceRequest(Request): def __init__(self): super(CdbTdsqlExpandInstanceRequest, self).__init__( 'tdsql', 'qcloudcliV1', 'CdbTdsqlExpandInstance', 'tdsql.api.qcloud.com') def get_cdbInstanceUuid(self)...
10,172
e2a8293b9d136ed9f85c25562c1d78fd9705f29c
import json import numpy as np import pandas as pd from sklearn import tree from sklearn.neighbors import KNeighborsClassifier # In[2]: #reading json with open("./train.json") as f: data = json.load(f) df = pd.io.json.json_normalize(data) df.columns = df.columns.map(lambda x: x.split(".")[-1]) df = df.values in...
10,173
3e66d928167468e45ae6c6962af56cbc8326a339
import requests import time from config import URL from config import LOCATION from bs4 import BeautifulSoup raw_html = requests.get(URL).text data = BeautifulSoup(raw_html, 'html.parser') tl = (data.select('h2')[1]) tl = (tl.encode_contents()) tl = tl.rstrip(' <span id="displayDate"></span>') if (data.select('td')[...
10,174
c32ddc2de616c74e1108251f8266f0c5d526b249
import module_fibonacci module_fibonacci.fib(7)
10,175
d9ff288d468ff914c4b8e1467f191a61562857f0
from ginn.core import * from ginn import utils from ginn import models
10,176
947f82ace44df37ef71984b76b8ab86d5da43fa0
import PySimpleGUI as sg import tkinter as tk #### 00 get input files from user sg.change_look_and_feel('Topanga') ### my GUI colourful setting layout1 = [ [sg.Text('Number of input files: '), sg.Input()], [sg.OK(), sg.Cancel()] ] ######Display first window to ask how many input files window = sg.Window('Pro...
10,177
4c47361a8d08f89954100c486b39b4da3cddfbfc
from misc import * start = time.time() def gcdpower(a,b): while(a != b and b != 0 and a!=0): if(a >= 2*b): a %= 2*b if(a > b): a,b = b,a if(2*a >= b): a,b = a,2*a-b a,b = max(a,b),min(a,b) return min(a,b) n = 2000 matrix = [[10,1],[1,0]] mod...
10,178
b6b2545ebf075eda66b4e453addac6491a20eba0
import os basedir = os.path.abspath(os.path.dirname(__file__)) DEBUG = False TESTING = False CSRF_ENABLED = True SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL'] SECRET_KEY = 'thisisdfjdshkddfjchanged' CSRF_SESSION_KEY = 'ad190242b1dd440584ab5324688526dshb'
10,179
ed1c5e019342cd783c2ba7709b9c337018b69242
from models.gate import Gate class Light(Gate): def place_gate(self): z = self.coord[0] x = self.coord[1] self.editor.set_block(x+0, 50, z+0, "gray_wool") self.editor.set_block(x+1, 50, z+0, "gray_wool") self.editor.set_block(x+2, 50, z+0, "gray_wool") self.editor.s...
10,180
f6cf82b43aef951d7e44919d0833e6f36de2cdf9
# def calc(*numbers): # sum=0 # for n in numbers: # sum = sum + n*n # return sum # print(calc(1,2)) # from conf import conf # # conf={'s':1} # def sum(a,b): # s=a+b # return s # if __name__=='__main__': # print(sum(1,2)) # # print(conf['s']) # def person(name,age,**...
10,181
5ef6253279c1788d925e7a5dc59c22edb6e18b5f
#Salary Prediction based on number of years of experience from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split import numpy as np import matplotlib.pyplot as plt import pandas as pd # import the dataset dataset = pd.read_csv('Salary-Data.csv') x = dataset.iloc[:, :-1]....
10,182
e38a779ff0f67f76039dd5050614675f4adaf99d
#!/usr/bin/env python # coding: utf-8 # # Langchain Quickstart # # In this quickstart you will create a simple LLM Chain and learn how to log it and get feedback on an LLM response. # # [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/truera/trulens/...
10,183
f4c518e62f0d6797ccef75ce11f2c68082bfd603
import os import sys from flask import Flask # This is just here for the sake of examples testing # to make sure that the imports work # (you don't actually need it in your code) sys.path.insert(1, ".") from flask_discord_interactions import (DiscordInteractions, # noqa: E402 ...
10,184
02385fbaeaa49c0f51622334d9d1eda8d5c56db1
nomeVendedor = input() salario = float(input()) vendas = float(input()) total = salario + vendas * 0.15 print("TOTAL = R$ " + "{:.2f}".format(total))
10,185
fef91fa7ff4f007c889d4a838a67137c06aa7690
""" This code was implemented by Vojtech Kubac as a part of his Master Thesis that will be defended on February 2020. At the Faculty of Mathematics and Physics of Charles University in Prague. """ """ This code solves FSI2 and FSI3 Bencmarks from "S. Turek and J. Hron, โ€œProposal for numerical benchmarking of fluid...
10,186
3016046c947b119acdea2272d4aba7c8be79e9dc
# -*- coding:utf-8 -*- import sys from . import resnet, inception_v3, dense_net from .error import ModelError from lib import storage _recognizer_cache = {} _rec_config = { 'AJ#insole': { # ้ž‹ๅžซ 'model_type': 'resnet', 'model_config': { 'num_epochs': 25, 'fixed_param': Fal...
10,187
276b62d567fd7e03cbbe2a18554232f62d0aaed8
from django.shortcuts import render from django.http import HttpResponse from django.template import loader from django.template.loader import get_template from django.core.mail import EmailMessage from django.shortcuts import redirect from django.contrib import messages # Create your views here. def portfolio(reques...
10,188
161e1d78da717ba10b76a695f9a37d5058397079
#๋™์ผํ•œ ๋ฌผ๊ฑด์„ A๋งค์žฅ์—์„œ๋Š” 20%, B๋งค์žฅ์—์„œ๋Š” 10% ํ• ์ธ ํ›„ 11% ํ• ์ธ(์ค‘๋ณตํ• ์ธ)ํ•œ๋‹ค. ๋ฌผ๊ฑด์ด 10,000์›์ผ ๋•Œ ์–ด๋˜ ์‡ผํ•‘๋ชฐ์—์„œ ์‹ธ๊ฒŒ ์‚ด ์ˆ˜ ์žˆ์„๊นŒ? item_price = int(input("๋ฌผํ’ˆ์˜ ๊ฐ€๊ฒฉ : ")) #๋งˆ์ผ“ A์—์„œ์˜ ํ• ์ธ์œจ๊ณผ ๋ฌผํ’ˆ ๊ฐ€๊ฒฉ sale_percent_M_A = float(input("A ๋งˆ์ผ“ ํ• ์ธ์œจ : ")) /100 market_a = item_price*(1-sale_percent_M_A) print("A ๋งค์žฅ์—์„œ์˜ ํ• ์ธ๋œ ๋ฌผํ’ˆ ๊ฐ€๊ฒฉ์€", market_a, "์› ์ด๋‹ค") #๋งˆ์ผ“ B์—์„œ์˜ ํ• ์ธ์œจ๊ณผ ๋ฌผํ’ˆ ๊ฐ€๊ฒฉ sale_pe...
10,189
4e5277c1808f61695559a3e0042dff509c9bd569
MEDIA_ROOT_URL = '/' MEDIA_ROOT = '/var/www/django/Coffee-in-the-Cloud/server/'
10,190
8f76a676839c3e42b51728756098115abe7bcf56
# Generated by Django 2.0.3 on 2018-05-15 15:21 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('feedbap', '0006_product'), ] operations = [ migrations.CreateModel( name='Order', f...
10,191
f2162b7a1cd9c62ec0c2ab3456716d603ed6ecac
import logging import sys import optuna from sklearn import datasets from sklearn.linear_model import SGDClassifier from sklearn.model_selection import train_test_split def objective(trial): iris = datasets.load_iris() classes = list(set(iris.target)) train_x, valid_x, train_y, valid_y = train_test_split...
10,192
4f8fd40fd2cc91265881b0f4ba83ee5db076c1c6
import uuid from functools import wraps from flask import request from flask import Response from flask_restful import Resource def generate_members(element_name, url, total_num): members = [] i = 0 while i < total_num: dic = dict() dic["@odata.id"] = url + element_name + str(i + 1) ...
10,193
6dde96565f9d7ab34a32fbc93b157301280cf4d7
from ROOT import TH1F, TH2F import math class Particle(object): def __init__(self, pdg_code, momentum, status): self.pdg = pdg_code self.momentum = momentum self.status = status self.mass = 0 if abs(self.pdg) == 11: self.mass = 0.5109989461 / 10...
10,194
dfe461bb6043067be580b06aee510a88c74d9b59
from typing import Dict, Optional from hidet.ir.expr import Var from hidet.ir.type import ScalarType _primitive_variables: Dict[str, Var] = {} def attach_pool(var): if '_primitive_variables' not in var.__dict__: var.__dict__['_primitive_variables'] = _primitive_variables return var def thread_idx(...
10,195
69b0cc21404fefeb812e2bc636d4076cd15b4cb2
import time from django_rq.decorators import job import django_rq import rq import logging logging.basicConfig() logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) @job def printsomething(the_thing): time.sleep(2) print("Look at me I'm printing something!...{}".format(the_thing)) 1 / 0 ...
10,196
d9827d47f018afe2c6d35da2ca35b3b2f4b3de81
"""The class Movie is defined and it contains the details of a movie""" import webbrowser class Movie(): """This class is for stores movie related information with its attributes. title: string to store title of a movie. storyline: string to store storyline of movie. poster_image_url: string to s...
10,197
489eb996af35fcfb70558fb3b95f6543551c4300
# pylint: disable=C0103 # pylint: disable=C0301 # pylint: disable=C0321 '''๊ธฐ๋ณธ๊ตฌ์กฐ for ๋ณ€์ˆ˜ in ๋ฆฌ์ŠคํŠธ(๋˜๋Š” ํŠœํ”Œ, ๋ฌธ์ž์—ด): <์ˆ˜ํ–‰ํ•  ๋ฌธ์žฅ1> <์ˆ˜ํ–‰ํ•  ๋ฌธ์žฅ2> <์ˆ˜ํ–‰ํ•  ๋ฌธ์žฅ3> ๋ฆฌ์ŠคํŠธ๋‚˜ ํŠœํ”Œ, ๋ฌธ์ž์—ด์˜ ์ฒซ ๋ฒˆ์งธ ์š”์†Œ๋ถ€ํ„ฐ ๋งˆ์ง€๋ง‰ ์š”์†Œ๊นŒ์ง€ ์ฐจ๋ก€๋กœ ๋ณ€์ˆ˜์— ๋Œ€์ž…๋˜์–ด <์ˆ˜ํ–‰ํ•  ๋ฌธ์žฅ1> <์ˆ˜ํ–‰ํ•  ๋ฌธ์žฅ2> ๋“ฑ์ด ์ˆ˜ํ–‰๋œ๋‹ค ''' # ์ „ํ˜•์ ์ธ For๋ฌธ test_list = ['one', 'two', 'three'] for i in test_list: print(i) #๋ณ€์ˆ˜(i)์— ๋ฆฌ...
10,198
b6dc82ad3b278b49dd28ba9b5de8df31ddfd2562
import sys import glob # sys.path.append('generated') # sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0]) from thrift import Thrift from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol from thrift.protocol import TMultiplexedProtocol from ...
10,199
abee5d28776cf5fad4daf2b700f68cda3dfd21f3
import datetime import io import os import sys import uuid from urllib.parse import unquote_plus from PIL import Image from . import storage client = storage.storage.get_instance() # Disk-based solution #def resize_image(image_path, resized_path, w, h): # with Image.open(image_path) as image: # image.thumbn...