index
int64
0
1,000k
blob_id
stringlengths
40
40
code
stringlengths
7
10.4M
11,700
32b5b5b89c1f9bf6097e589a3b89c2202241dc28
''' LISTS IN PYTHON ''' # 1. To Create Lists in Python Numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Names = ['Alex', 'Bob', 'Nancy'] ## List can have elements with different data type list_1 = [1997, 1998, 'Alex', 'Bob', True, False, 3.45, 5.6] ## List-of-List list_2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # ...
11,701
c6f65c594b417f8f6671680c62551d8d4936c9b4
#/usr/bin/env python import hashlib import socket import struct import json import time import sys import os # check if ip is within CIDR def addressInNetwork(ip, net): ipaddr = int(''.join([ '%02x' % int(x) for x in ip.split('.') ]), 16) netstr, bits = net.split('/') netaddr = int(''.join([ '%02x' % int(x) ...
11,702
78617876fed15979032ab7e18c24b045e347c027
from django.conf.urls import url from task.views import index,registerNotification,success urlpatterns=[ url("^$",index,name='index'), url("^register$",registerNotification,name='registerNotification'), url("^success$",success,name='success'), ] import task.jobs
11,703
c15060b2fe273d896d2ad29e1558491430cf7aa0
#!/usr/bin/env python3 from datetime import datetime, timedelta class Image: """Defines information about an image""" def __init__(self, json): """ Initializes the Image class with information for an image :param json: String. Raw JSON """ self.height = json["height"]...
11,704
8098a606d0fc2e0a0051a53e1e5462b91b64a9d8
#!/usr/bin/python # -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait import pymysql db = py...
11,705
d4c6a0858e66e54a5a0349ef82367a19bd49a391
# -*- coding: utf-8 -*- """ Created on Tue Apr 30 13:03:47 2019 @author: Yoshi """ import matplotlib.pyplot as plt import numpy as np import pdb import analysis_config as cf import analysis_backend as bk import dispersions as disp import lmfit as lmf from scipy.optimize import curve_fit def get_max_f...
11,706
44fda58daa020ec3a77612c00432b63187ae08e1
f_lado = list(map(float, input().split())) f_lado.sort() f_lado.reverse() if(f_lado[0] >= f_lado[1]+f_lado[2]): print("NAO FORMA TRIANGULO") else: if(f_lado[0]**2 == f_lado[1]**2 + f_lado[2]**2): print("TRIANGULO RETANGULO") if(f_lado[0]**2 > f_lado[1]**2 + f_lado[2]**2): print("TRIANGULO OBTUSANGULO") if(f_lad...
11,707
32b1427edaf87dfc00905f2518d87336e0371470
from flask import render_template, json, request from core.controllers.cipher import Cipher class CipherRoute: def __init__(self): self.main_page_legend = \ 'Cesar cipher site. Please choose rotation and case: ' \ 'encrypt or decrypt <br>' \ 'After that enter text in t...
11,708
8e775d2913fb036a82abb57a936d4c2853d590d6
import random def gen_random_A(length, majNum): a = [] for j in range(0, length): a.append(random.randint(0, majNum)) return a def partition_even_odd(a): i = 0 j = len(a)-1 while i <= j: if a[i] % 2 == 1 and a[j] % 2 == 0: a[j], a[i] = a[i], a[j] i += 1 ...
11,709
b41c688f050a120caf8a95021165e36bbee55b14
# coding: utf8 from __future__ import unicode_literals # Source: https://github.com/stopwords-iso/stopwords-et STOP_WORDS = set( """ aga ei et ja jah kas kui kõik ma me mida midagi mind minu mis mu mul mulle nad nii oled olen oli oma on pole sa seda see selle siin siis ta ...
11,710
a947246be7fbb10392014db0f395cacc1301c526
from __future__ import print_function import httplib2 import os import json from apiclient import errors from apiclient import discovery from oauth2client import client from oauth2client import tools from oauth2client.file import Storage import MySQLdb import re conn = MySQLdb.connect(user='root', password='luyuan', ...
11,711
7ac34b5670b3974e45d78a570fb9d17b4b04a194
from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.decorators import user_passes_test from apps.users.models import BaseUser def student_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None): """ Decorator for views that checks that the user is student, re...
11,712
e6e334b6eede49980cf1f44b2bfb10e470e8207b
""" For installing package. """ import re from setuptools import setup # Descriptions SHORT_DESCRIPTION = "Useful tools for machine learning mastery." with open('README.md') as f: LONG_DESCRIPTION = f.read() # version with open('./src/__init__.py') as f: VERSION = next( re.finditer( r'\n_...
11,713
4f6e0591971772eaae54841076d34b1d895632f7
import json from django.http import HttpResponseRedirect from django.template.response import TemplateResponse from django.contrib.auth.models import User from api.models import Category, Account, Topic from legislation import sunlightapi as sun from utils.custom_decorators import beta_blocker, login_required def ba...
11,714
09eda8181e1dfab8a3997de254723d0b13b2bdc8
#!/usr/bin/python # -*- coding: utf-8 -*- import logging import cPickle as pickle import psycopg2 import numpy as np np.random.seed(19870712) # for reproducibility path = "/home/terence/pycharm_use/IPIR_De_identification/1_data/" get_conn = psycopg2.connect(dbname='IPIR_De_identification',user='postgres', host='local...
11,715
c5390c7d612685d454f157ca7dc7e636bd7fa3d9
from mpl_toolkits import mplot3d from matplotlib.ticker import MaxNLocator import matplotlib.pyplot as plt import matplotlib.colors import matplotlib.animation as animation import numpy as np import pandas as pd import sys from tools.my_setup import * frame_delay_ms=10 # frame_delay_ms=25 # frame_delay_ms=50 # turn...
11,716
b9acea13ba6bbf15d39c5711be3ebbe56598222b
from cs50 import get_string # Get user input and use in print s = get_string("What is your name? ") print("Hello, " + s)
11,717
d0ce40be3ddeece19c9dfc2262327a13afb1072f
from django.shortcuts import render,redirect from pharmacy.models import Medicine,Order from django.contrib import messages from patient.models import Bill from .models import PlasmaProfile,DonorRequest def searchMedicine(request): if request.user.type!="Donor": storage = messages.get_messages(request) ...
11,718
99234952493f97dc3caa1c6cf9232e1e92e13b3d
from os.path import join from os import getcwd from settings import APP_DIR def app_path(*appends): return join(APP_DIR, *appends) def brick_path(*appends): return app_path("bricks", *appends)
11,719
e25c824282b2c856c97d42e946655429df9a8977
import sys assert sys.version_info >= (3, 5) # make sure we have Python 3.5+ from pyspark.sql import SparkSession, functions, types spark = SparkSession.builder.appName('colour prediction').getOrCreate() spark.sparkContext.setLogLevel('WARN') assert spark.version >= '2.4' # make sure we have Spark 2.4+ from pyspark.m...
11,720
e02e1fcca972d114d56ca1daefd017f33af0d88c
from flask_restful import Resource from flask import Flask, request, send_from_directory import os class GetBundles(Resource): def get(self): file_name=request.args.get('file') clientId=request.args.get('clientId') file_name1 = os.path.join(os.path.realpath(os.path...
11,721
665650a7b0ecdc6ef26df2b49e34ada7fe662f02
# Django from django.urls import path # Views from .views import ContactView urlpatterns = [ path( route="message/send/", view=ContactView.as_view(), name="send_message", ), ]
11,722
e1f1452b910495792af98d2a131f5c6e6547b5b0
from django.shortcuts import render # Create your views here. def default_map(request): return render(request, 'default.html', {}) def default_map2(request): return render(request, 'mapa2.html', {}) def search(request): print("REQUEST", request) return render(request, 'mapa3.html', {})
11,723
718d5303ce13ffec5a6d6cd1fab149149fbb37e1
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='Author', fields=[ ('id', models.AutoField(verbo...
11,724
21719097ea011687485f991a8726851d21eeb7b1
from typing import List class Solution: def fourSum(self, nums: List[int], target: int) -> List[List[int]]: if not nums: return [] nums.sort() answer = [] i = 0 while i < len(nums) - 3: if i > 0 and nums[i] == nums[i - 1]: i = i + 1 ...
11,725
612e48421094f47183a638281187c9514f847827
import sys import numpy as np import matplotlib.pyplot as plt import cleverhans from cleverhans.attacks_tf import fgsm from cleverhans.utils_tf import batch_eval from models import ResidualBlockProperties, ParsevalResNet, ResNet from data_utils import Cifar10Loader, Dataset import visualization from visualization im...
11,726
e52d157ce7386ad77e044412aae682353ad4b695
# client for the remote controlled bot
11,727
3375c68a2a729deac32011f2c8a256e77ed712fc
import pygame, sys from intro import intro from utils import * from sprites import * from pygame.locals import * from random import randint intro() DISPLAYSURF = pygame.display.set_mode((800, 593)) pygame.display.set_caption("Kill the Baby!") background = load_image("KTBbackground2.png") BASIN = pygame.Rect((20, 391),...
11,728
3ae662881f3ffdea5c79bdccf1fe7b51eb2ad7b7
from tensorflow.keras.models import load_model import threading import numpy as np import cv2 as cv import pickle import time import os CAMERA_PORT = 0 IMG_SIZE = 48 MODEL_DIR = './models/26-08-2020_22-33-45' DATA_DIR = 'data' CASCADE_CLASSIFIER_PATH = 'res/haarcascade_frontalface_default.xml' ROI_BOX_COLOR = (255, 0...
11,729
b99e9dea430f0a0efca4d36d81279cfa88a9c4bf
from django.contrib import admin from django.urls import path from .views import vendas, novaVenda, listVendas, updateVenda urlpatterns = [ path('', vendas, name='vendas'), path('nova-venda/', novaVenda, name='nova_venda'), path('lista-vendas/', listVendas, name='all_vendas'), path('update/<int:id>', u...
11,730
90518a75795708830fca0192f1e3b3c07c8f447d
# coding: utf-8 # In[4]: import pandas_datareader.data as web import datetime start = datetime.datetime(2013, 1, 1) end = datetime.datetime(2016, 1, 27) df = web.DataReader("GOOGL", 'yahoo', start, end) dates =[] for x in range(len(df)): newdate = str(df.index[x]) newdate = newdate[0:10] dates.appe...
11,731
de8b33c46ea3aabc58586f09326df14036d725dd
#! /usr/bin/python from math import sqrt def prime(n) : if n < 2 : return False for i in range(2,int(sqrt(n))+1) : if n % i == 0 : return False return True aa = 0 bb = 0 cc = 0 for a in range(-999,1000,2) : for b in range(-999,1000,2) : c = 0 for n in range(0,1000) : if prime(n*n+a*n+b) == T...
11,732
e9e69a0db6c549be2dcdb167c58b61fa592bc036
from typing import * class Solution: def canPartition(self, nums: List[int]) -> bool: s = sum(nums) if s % 2 == 1: return False dp = [[-1 for __ in range(s//2+1)] for _ in range(len(nums))] def partition_recursive(dp, nums, idx, curr_s): if...
11,733
d913e1a77c32da657f037a657439afc116fcdd08
from django.apps import AppConfig class AbstractbaseclassesConfig(AppConfig): name = 'abstractbaseclasses'
11,734
36dcb5a8997fdd2b9c58a744929258e1aed9a50e
import json import urllib.request tuling_key='8c918d2e025d4dc1ada1313094dc8e9d' api_url = "http://openapi.tuling123.com/openapi/api/v2" def get_message(message,userid): req = { "perception": { "inputText": { "text": message }, "selfInfo": { "lo...
11,735
ca4b53cd94a4cba91e6d30be3e6c88fed607391e
from django.db import models class Pet(models.Model): name = models.CharField(max_length=50) age = models.IntegerField() available = models.BooleanField(default = True) image = models.ImageField() price = models.DecimalField()
11,736
b7e07ff745be4fd543bc06ea8c1b0973f4063b74
from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( ...
11,737
0bc5dc46ce4dbd06520d3c081e042afde693ef99
############# E17 Decode a web page ############ #updated 12.08 from bs4 import BeautifulSoup import requests def decode(url): # requests the website r = requests.get(url) # store the text from the website as a variable to make it easier to read r_html = r.text # run the text through BeautifulSoup ...
11,738
08d4b3081eb88d3ae61ed322cb8508f691b5f750
#!/usr/bin/env python """Utils module for NSX SDK""" import requests import json import sys class HTTPClient(object): """HTTPClient have the following properties: Attributes: base_url: A string representing the base url. login: A string representing login. password: A string represe...
11,739
c15d12ed6f4a865a05dcabb01febdfac499fd819
import json from datetime import datetime from django.http import HttpResponse, HttpResponseRedirect, Http404 from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status from usermgmt.models import Notification, FriendRequest from usermgmt.serializers impor...
11,740
3f51bd09569a8db0111938b971a91bcd2fbddac1
# This class is required in terms to apply specific colors to specific word class SimpleGroupedColorFunc(object): def __init__(self, color_to_words, default_color): self.word_to_color = {word: color for (color, words) in color_to_words.items() ...
11,741
d06d7aaaceed220c7ea76f56f142e49b97d855d1
''' AI Implemented Using A Recurrent Neural Network ''' from ai.models.base_model import BaseModel class RecNNet(BaseModel): def __init__(self, is_white=False): self.is_white = is_white def _trained(self): return True def _train(self): return True def _predict_move(self, b...
11,742
ee28711ba8b18f614ceaabadbc3d29bf8d0fe646
######### VBF samples['VBF_HToInvisible_M110'] = ['/VBF_HToInvisible_M110_13TeV_powheg_pythia8/RunIISpring16MiniAODv2-PUSpring16RAWAODSIM_reHLT_80X_mcRun2_asymptotic_v14-v1/MINIAODSIM',['addQCDPDFWeights=True','isSignalSample=True','addGenParticles=True','crossSection=4.434e+00','triggerName=HLT2']] samples['VBF_HT...
11,743
9dd1487222680274bc94246e300c4361aee5bbf5
__author__ = 'Lee' import Semiring, XSemiring, MatrixRing def initial_matrix(cnf, words): X = XSemiring.XSemiringFactory.constructor(cnf) n = len(words) + 1 f = lambda i,j: X.lift(set([])) if i != j + 1 else X.lift({(cnf.term_of(words[j]),)}) return MatrixRing.Matrix.lift([f(i,j) for i in range(n) for...
11,744
f63e6adc7d0f9c0893b87253c6616be6819dfce4
n = int(input()) m = {len(s): s for s in input().split()} x = input() for v in range(len(x), -1, -1): if v in m: print(m[v]) break
11,745
a2f3115da8e6e0097de73bd31e2813c58e0a9110
from microkubes.gateway import Registrator, KongGatewayRegistrator from unittest import mock import pook def test_get_url(): r = Registrator(gw_admin_url='http://kong:8001') assert r._get_url('/apis') == 'http://kong:8001/apis' assert r._get_url('////apis') == 'http://kong:8001/apis' # normalize asse...
11,746
886e413ced639490470a0f7b1e13dc04fe178164
def get_grid(filename): grid = [] with open(filename) as f: for line in f: new_line = [] for charac in line: if charac == "#": new_line += ["#"] elif charac == ".": new_line += ["."] elif char...
11,747
bf70c52c6c52d0d9ddc97731ed78b9a8eb536d9c
s = set("Hacker") # print(s.intersection("Rank")) # print(s.intersection(set(['R', 'a', 'n', 'k']))) print(s.intersection(enumerate(['R', 'a', 'n', 'k']))) # print(s.intersection({"Rank":1})) # print(s & set("Rank")) # eng = int(input()) # english = input() # fren = int(input()) # french = input() # e = set(engli...
11,748
79779f435112061d90409d34fc52337716e08c2f
#!/usr/bin/env python2 from __future__ import division import signal from gi.repository import Gtk, GObject from settings import Settings from googlemusic import GoogleMusic from threads import DownloadThread, SearchThread class Jenna(object): def __init__(self): GObject.threads_init() self.set...
11,749
b562028706fb79f75201bccf9b435d9f1a366b26
from django import forms from django.contrib.auth.forms import UserCreationForm from .models import User,UserInfo class UserForm(UserCreationForm): class Meta: model=UserInfo fields=['username','first_name','last_name','age','gender','contact','email','password1','password2']
11,750
3a2f3ec527bcd4cf7520edd57cdb295552f4e5f1
# encoding:utf-8 import urllib2 ''' # 判断有没有重定向 response = urllib2.urlopen("http://www.baidu.cn") print response.geturl() == "http://www.baidu.cn" ''' class RedirectHandler(urllib2.HTTPRedirectHandler): def http_error_302(self, req, fp, code, msg, headers): # 302重定向 # 重定向以后的url res = urllib2.HT...
11,751
2134a90751f7b58fee81bb1e5f09134571bfb216
# coding=utf-8 # import logging from security_data.models.security_attribute import SecurityAttribute from sqlalchemy.orm import sessionmaker from security_data.utils.error_handling import (SecurityAttributeAlreadyExistError, SecurityAttributeNotExistError) class SecurityAttributeServices: def ...
11,752
715225571cfe011d4e9a29b5b71e9129e6bf35d3
#6-8 dog = { 'name': 'pugmaw', 'owner': 'ahri' } cat = { 'name': 'neeko', 'owner': 'khazix' } hamster = { 'name': 'bard', 'owner': 'lucian' } #6-9 pets = [] pets.append(dog) pets.append(cat) pets.append(hamster) # for pet in pets: # print(pet) favorite_places = { 'sam': 'japan', ...
11,753
d35991d492f5ae4ef412aa1b6292ceb9d33dcd81
from ._GuidanceStatus import *
11,754
ed9cea65cee6e6294c94f4722ad81726e819a6e5
# -*- coding: gbk -*- import os import os.path import common import sys import info # this function generater directory for each file and drag the files into their directory def createFile(dir): fileList = os.listdir(dir) for filename in fileList: dotPos = filename.find(".") subdir = os.path.join(dir,filename[:d...
11,755
2aa31dd8411c016c7ddd8ab4ca46cc89d4372de6
import pygame pygame.init() x = 400 y = 300 velocidade = 10 fundo = pygame.image.load("fundo teste.png") pers = pygame.image.load("pers.png") janela = pygame.display.set_mode((800,600)) pygame.display.set_caption("Criando jogo com Python") janela_aberta = True while janela_aberta : pygame.time.delay(50) for...
11,756
45e4003d1b1564851d9f914b66bea578429473bc
#!python #-*- encoding: utf-8 -*- ''' A script to test RE for unicode (GBK) ''' import re import sys reload(sys) sys.setdefaultencoding('utf-8') gbkstring = ''' <h3>拍拍贷统计信息</h3> <p>历史统计</p> <p>正常还清:62 次,逾期还清(1-15):0 次,逾期还清(>15):0 次 </p> <p> ...
11,757
4039b2b981e68c6857b2ea2c3d2ab5763408da6f
import numpy as np essay = np.array([["pass", "not pass", "not pass", "not pass", "pass"], ["not pass", "not pass", "not pass", "not pass", "not pass"], ["pass", "not pass", "pass", "not pass", "not pass"]]) u = len([y for str in essay for y in str if y == 'pass']) print(u)
11,758
0416cd33c0714be554764f5b2f739aa82838e266
import os import re import shutil from rdflib import RDFS import s5_enrichment_extractor as extractor import utils ''' E2: ENRICH ONTOLOGY WITH PROPERTY RANGES Input: s5-ontology and freebase-s3-type Output: e2-rdfs_range (triples to add RANGE to Properties in the ontology, obtained by scanning TYPE for type.propert...
11,759
96fa812a7f3a24672371530d7984a43c5a8914f0
import logging from pathlib import Path from typing import List from pandas import DataFrame from tabulate import tabulate _log = logging.getLogger(__name__) def fmt_to_table(scenarios: List[dict], tablefmt: str) -> str: return tabulate(scenarios, headers="keys", floatfmt...
11,760
5ce56f3144aeb6bc29ae3ac9ed1a85ccb3b2f921
"""Find nearest (most similar) word """ from scipy.spatial.distance import cdist import numpy import sys from load_vectors import WordVectors def search(wv, word): if word not in wv.labidxmap: print word, 'not in vocabulary' cd = cdist(wv.vecs[wv.labidxmap[word]][numpy.newaxis, :], wv.vecs, 'cosine') ...
11,761
934b91cdb75871e61e86669c10053e12a22d153a
import os f=open("commands.txt", "r") if f.mode == 'r': contents =f.read() print(contents)
11,762
d7102d3d45e1ef46a3b5f3eefa45e16b1bce9a02
import findSimilarity def main(): # text_1 = 'Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace.' # text_2 = ...
11,763
458beb59d87fee30a1175b44664dd938f333ccb4
import copy import math import time # a = get_int() def get_int(): return int(input()) # a = get_string() def get_string(): return input() # a_list = get_int_list() def get_int_list(): return [int(x) for x in input().split()] # a_list = get_string_list(): def get_string_list(): return input().split() ...
11,764
c0aa418b50fbb66e33c2ad109cd461c1d47056c8
import math def snt(n): if(n < 2): return False for i in range(2, int(n//2)+1): if(n%i == 0): return False break return True n = int(input()) s = input() a = s.split() tmp = [] for i in a: if(snt(int(i))): tmp.append(int(i)) ok = [False for i in ...
11,765
95f3fb59c7607e0982b283eeabf6d54e62912f41
from flask import Flask, redirect, render_template, request, escape from flask_mysqldb import MySQL app = Flask(__name__) app.config['MYSQL_HOST'] = "localhost" app.config["MYSQL_USER"] = "root" app.config["MYSQL_PASSWORD"] = "" app.config["MYSQL_DB"] = "TODO" app.config["MYSQL_CURSORCLASS"] = "DictCursor" mysql = MyS...
11,766
38f6f3a514a43133174777ef32a7f43af0f620a6
########################### # 6.0002 Problem Set 1a: Space Cows # Name: # Collaborators: # Time: from ps1_partition import get_partitions import time #================================ # Part A: Transporting Space Cows #================================ # Problem 1 def load_cows(filename): """ Read the conten...
11,767
bdd642672b327375bf25949c03034d638b65be4c
from django.contrib import admin from .models import Track, Artist, Genre class TrackAdmin(admin.ModelAdmin): list_display = ['title', 'album', 'track_number', 'artist_names', 'genre_names', ] def artist_names(self, obj): names = [artist.artist_name for artist in obj.artists.all()] return ", ".join(names) de...
11,768
828af5c777c38d3a368d04bd116365ee4a862405
# There exist two zeroes: +0 (or just 0) and -0. # Write a function that returns true if the input number is -0 and false otherwise (True and False for Python). # In JavaScript/TypeScript, the input will be a number. In Python and Java, the input will be a float. def is_negative_zero(n): return True if str(n) ==...
11,769
1a18d41e6b235b6ddea3e1d09ca5f6fbe32af7eb
from django.shortcuts import render, redirect from . import models from . import forms from django.contrib.auth.decorators import login_required # Create your views here. @login_required(login_url="/userAuth/login/") def pesanan(request): pesanan_user = models.Pesanan.objects.filter(user=request.user, aktif=True).or...
11,770
6f7719614e149d16c553ad2d374ece78f0fdab8e
__author__ = 'Qiao Jin' import json pmid2ctxid = {} pmid2ctx = json.load(open('pmid2ctx.json')) evidence = json.load(open('evidence.json')) indexed_evidence = [] indexed_contexts = [] for entry in evidence: pmid = entry['pmid'] if pmid not in pmid2ctx: continue if pmid not in pmid2ctxid: pmid2ctxid[pmid] = l...
11,771
4b0298ab510e7dfe5c8c09988566ebda27a840c8
# Use the new CASA5 QAC smaller bench data to run the M100 combination # Takes about 18-20' to run. Fills about 3.3GB but needs quite a bit more scratch space to run. # # curl http://admit.astro.umd.edu/~teuben/QAC/qac_bench5.tar.gz | tar zxf - # # some figures have been made to adjust the box so we can better comp...
11,772
41f3659261d02c46bb54a81f733ecca45580098c
import gym import numpy as np import matplotlib.pyplot as plt N_ROWS, N_COLS, N_WIN = 3, 3, 3 class TicTacToe(gym.Env): def __init__(self, n_rows=N_ROWS, n_cols=N_COLS, n_win=N_WIN, clone=None): if clone is not None: self.n_rows, self.n_cols, self.n_win = clone.n_rows, clone.n_cols, clone.n_w...
11,773
8a7925d46221f9bb702f1a4f5c6d4b3e83c60958
from django.conf.urls import url from core import views urlpatterns = [ url(r'reg/', views.RegisterView.as_view()), url(r'login/', views.LoginView.as_view()), url(r'logout/', views.LogoutView.as_view()), ]
11,774
dde910b9dcb2e30e2d07aa11c26711e1716158c6
from mongoengine import Document, fields, connect from utils import get_timestamp, now_yyyymmddhhmmss class ControlTypeEnum: queue = 'queue' func = 'func' class ControlValidEnum: invalid = 0 # 无效 valid = 1 # 有效 class ControlRmCurrentEnum: no = 'no' # 不删除 read2rm = 'read2rm' # 准备删除 ...
11,775
c1f3c76aef540d469cb269db21da241cc8b5585c
# Create your views here. from django.shortcuts import render from forms import Register_Form from models import Register from django.utils.translation import ugettext def home(request): form2 = Register_Form() reg_list = Register.objects.all() msg = ugettext('message from views to be translated') ret...
11,776
4d96e930577ef435205b2308294b3e3d902e5032
MAXDATA = 1200 globalIDX = 0 radio.set_transmit_power(7) radio.set_group(88) input.temperature() #prepare sensor sensordata = bytearray(MAXDATA) #SENSOR DATA - 8 bit per reading for i in range(sensordata.length): sensordata[i]=0 tstamps = bytearray(MAXDATA*4) # TIMESTAMPS - 32 bit per reading for i in range(tst...
11,777
98dfdc63b43c936320c07def19212d9d55a4fcf5
import os reader = [] scs = [] b = [] def SortByLow(): scs.sort(key=int) for k in scs: for i in reader: if i.find(k) != -1: b.append(i) def SortByHight(): scs.sort(key=int) scs.reverse() for k in scs: for i in reader: if i.find(k) != -1: ...
11,778
9ad2761252972bd1a1f7d73a7fbddf2c3f723c79
import FWCore.ParameterSet.Config as cms process = cms.Process("TEST2D") process.maxEvents.input = 3 process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring('file:testSlimmingTest1D.root') ) process.testABE = cms.EDAnalyzer("ThinningTestAnalyzer", parentTag = cms.InputTag('thinningThingPro...
11,779
8c1ec7187e6d3b972b8a509cc9b76b2195a4776b
import numpy as np import matplotlib.pyplot as plt def plot_graph(values, marker, label): xx = [x[0] for x in values] val = [x[1] for x in values] plt.plot(xx, val, marker, label=label) f = np.loadtxt("sol/error-35.txt") plot_graph(f, "m-", "35") f = np.loadtxt("sol/error-131.txt") plot_graph(f, "r-", "131"...
11,780
d8d1a456805db8c885b96980d15e270324dfc1e5
from django.shortcuts import render # Create your views here. from django.http import HttpResponse def mealSchedulePageView(request) : if request.s return HttpResponse('This will be the meal schedule page view')
11,781
323c17ba1273e915141c478af7fc6fcf33cb21b0
from django.db import models # Create your models here. class GoodItem(models.Model): """A model of a rock band.""" name = models.CharField(max_length=200)
11,782
7430e509f9c43b0dc2deedb6c6c56bb0f64eddd0
from email.encoders import encode_base64 from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.utils import formatdate, make_msgid from flask_ezmail.utils import sanitize_address, sanitize_subject, force_text,\ sanitize_addresses, mes...
11,783
c199fca0f78124f760aaa2669e706b0d484bae24
# pylint: disable=not-callable, no-member, invalid-name, line-too-long, wildcard-import, unused-wildcard-import, missing-docstring import pytest import torch from e3nn_little import o3 from e3nn_little.nn import (WeightedTensorProduct, GroupedWeightedTensorProduct, Identity, ...
11,784
2a86d39169d7e0cc50843eb546ed2c6e754de09f
import json import time ## dictionary for order ## ordercheck = "yes"; Drinks = { "Coke" : 4.50, "Diet coke" : 4.50, "Sprite" : 4.50, "Asahi" : 12.75, "None" : 0.0, } Mains = { "Margherita" : 14.00, "Napoletana" : 16.50, "Supreme" : 21.00, "Meat lovers" : 19.75, "Haw...
11,785
2ec5933ddcf112d3a163d5f48e1134375812b964
from DocInspector.DocStats import DocStats def collectGeneralStats(stats: DocStats, service): """ Collects a bunch of general stats about the document At present this includes the creation date, self link and title :param stats: The object to store the stats in :param service: The service to use ...
11,786
49a8c6afc5e5db6c641c0152f2d28fe3e5a52ca6
import time class Clock(): def __init__(self, hour, minute, second): self.hour = hour self.minute = minute self.second = second def __str__(self): return 'The time is {}:{}:{}'.format(self.hour,self.minute,self.second) #Main h = int(input("Enter hour: ")) whil...
11,787
d04c1ab68858dd510a879f47b4b998cdfded3791
import discord, aiohttp from discord.ext import commands from urllib.parse import quote import asyncio class StackSearch(commands.Cog): def __init__(self, client): self.client = client self.url = ( "https://api.stackexchange.com/search/advanced?site=stackoverflow.com&q=" ) ...
11,788
9acabdbf36bce3c61af6e1cd4e4eef543c2f40a0
a=int(input("enter 1st value")) b=int(input("enter 2nd value")) c=int(input("enter 3rd value")) def sum(a,b,c): sum=a+b+c if a==b or b==c or a==c: sum=0 return sum print("the sum is: ",sum(a,b,c))
11,789
b125be4cc2be6ec5358ab45fabae288fe41509b0
str1="Partrol" str2="Car" print(str1+str2)
11,790
ae682fcd8e20cadaffdf2a715b684c710fb61c9d
import tkinter as tk texte1 = "kd oqnbgzhm ehbghdq ztqz tm bncd ozq rtarshstshnm zkogzadshptd: bgzptd kdssqd drs qdlokzbdd ozq tmd ztsqd. tshkhrdq kz eqdptdmbd cdr kdssqdr ontq cdbncdq kd ldrrzfd." texte2 = "gx qosvlnkd wkvlkxo xiu vscx qno yd fsu cx qniix cx unkggx kdvsddyx xu vsdukxdu g'kdckvx. gxi gxuuoxi cy fsu...
11,791
aec63c3ebe3e1f1a93dd88af86c34231642343a0
# Generated by Django 2.0.1 on 2018-01-03 14:22 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('graphqlendpoint', '0015_auto_20180103_1041'), ] operations = [ migrations.RemoveField( model_na...
11,792
6524091fd45dd2fd2d96e979c3c3a55aa7c5e4fd
# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-04-11 12:33 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('cms_test', '0010_auto_20180411_1215'), ] operations = [ migrations.CreateMo...
11,793
4571417fe48b0f3e1dcaa6b884dbc6c08f166bbf
from kivy.app import App from kivy.uix.label import Label from kivy.clock import Clock from kivy.uix.textinput import TextInput from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy.uix.checkbox import CheckBox from kivy.uix.slider import Slider import time import json import requests im...
11,794
b9c12f4b31361e4fc45febce76da50a5544d442c
""" Objects and Classes - Lab Check your code: https://judge.softuni.bg/Contests/Practice/Index/1733#0 SUPyF2 Objects/Classes-Lab - 01. Comment Problem: Create a class with name "Comment". The __init__ method should accept 3 parameters • username • content • likes (optional, 0 by default) Use the exact nam...
11,795
1ae0f0e4ca02e3ac56376f3e86cb151c7b453874
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations def add_hero(apps, schema_editor): Hero = apps.get_model("heroes", "Hero") # Make the default "does not have hero" hero Hero.objects.get_or_create(steam_id=0) def remove_hero(apps, schema_editor): """ ...
11,796
cea1f1566f7f4424970ea0677c74a098be779aca
"""Identify place fields""" import numpy as np import matplotlib.pyplot as plt import itertools as it import random from scipy.ndimage.filters import gaussian_filter1d from scipy.signal import argrelextrema from scipy.optimize import curve_fit from scipy.stats import mode, percentileofscore from pycircstat...
11,797
8a0b4a0ccb703163c2bcf255a9c79e4702445158
"""TLE N = int(input()) sequence = list(input().split()) ans = [] for i in range(N): a_i = sequence[i] ans.append(a_i) ans = ans[::-1] print(" ".join(ans)) """ from collections import deque n = int(input()) sequence = deque(map(int,input().split())) ans = deque() if n % 2 == 1: for i in range(n): ...
11,798
60385f21272751711e4beaaa9d106ae13a4d76cd
from django.shortcuts import render from django.http import HttpResponse,Http404 import datetime from mytest.forms import Mail from django.views.decorators.csrf import csrf_exempt from django.core.mail import send_mail from django import template register=template.Library() def hello(request): return HttpResponse("...
11,799
4d06cf7586652071d4ca21d874b32a0a232a3c3f
''' @author: shylent ''' from itertools import count, islice from random import randint from tftp.util import CANCELLED, iterlast, timedCaller from twisted.internet.defer import inlineCallbacks from twisted.internet.task import Clock from twisted.trial import unittest class TimedCaller(unittest.TestCase): @stati...