index int64 0 1,000k | blob_id stringlengths 40 40 | code stringlengths 7 10.4M |
|---|---|---|
4,100 | 3653c6fce33467600a3eea72578ed995606bfc03 | import string
#takes file as input, outputs a dictionary of keys from the file
#file should be in format (apiName, key/id)
#dictionary key = apiName, value = key/id
def getKeys(f):
keys = {}
f = open(f, 'r')
for line in f:
apiInfo = line.split(',')
keys[apiInfo[0]] = apiInfo[1].strip(string... |
4,101 | d5f1601d11eb54e6c3dafab0137ec8f2358bb568 | import json
import boto3
import os
from helper import getEC2Regions, sendDataToSNS, OPTOUT_TAG, SNS_NOTIFICATION_IIAS_EC2
def getEC2FilteredRegionalInstanceInfo(region):
ec2RegionalClient = boto3.client('ec2', region_name = region)
paginator = ec2RegionalClient.get_paginator('describe_instances')
page_ite... |
4,102 | 420c3944de0a5436a9824604fd6caf27706eb99c | def print_duplicates(arr):
uniques = set()
for elem in arr:
if elem in uniques:
print(elem, end=' ')
else:
uniques.add(elem)
|
4,103 | bc843abecfc076c9413498f9ebba0da0857ad3cc | from eth_account.account import Account
from nucypher.characters.lawful import Alice, Bob, Ursula
from nucypher.network.middleware import RestMiddleware
from nucypher.data_sources import DataSource
from umbral.keys import UmbralPublicKey
import sys
import os
import binascii
import shutil
import maya
import datetime
te... |
4,104 | 2fb8bce3a64787dbaf5a3bb3da53f70005048467 |
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# In[2]:
import os
GFE_PATH = "C:\Haely\MS2017\sem2\EE 259\Project\grammatical_facial_expression"
def load_a_affirm_data(gfe_path=GFE_PATH):
csv_patha = os.path.join(gfe_path, "a_affirmative_datapoints.csv")
... |
4,105 | c0bd060990d00ab50c9f2d3060b7f975ff16e1ab | import sys, time
from machine import Pin
print('LOAD: blinker.py')
def blink_connected_to_wifi(pin=23):
_blink_pattern(pin, [[3, 0.5, 0.5], [4, 0.2, 0.2]])
def blink_not_connected_to_wifi(pin=23):
_blink_pattern(pin, [[2, 0.2, 0.2], [1, 0.5, 0.5], [2, 0.2, 0.2], [1, 0.5, 0.5]])
# pin - the pin, connected ... |
4,106 | f3a1a926feabcabc870f0a41ae239939c331d09d | from pathlib import Path
file = Path(__file__).parent / 'input.txt'
Y = 2000000
MAX_X = 4000000
MIN_X = 0
MAX_Y = 4000000
MIN_Y = 0
# file = Path(__file__).parent / 'test_input.txt'
# Y = 10
# MAX_X = 20
# MIN_X = 0
# MAX_Y = 20
# MIN_Y = 0
text = file.read_text().splitlines()
class Beacon():
def __init__(self, ... |
4,107 | 17b8fec5583f2544bd02a2409528082fa1dc2a1e | import numpy as np
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
a = np.array(a)
b = np.array(b)
print(np.dot(a, b)) |
4,108 | 67e6d39ef291e4bb30c0b6bab7b71d97c86b0ef1 | from nltk.stem.porter import PorterStemmer
from nltk.stem.snowball import SnowballStemmer
p_stemmer = PorterStemmer()
s_stemmer = SnowballStemmer(language="english")
print(s_stemmer.stem("writing"))
|
4,109 | 7261c5f9ac87c8337383daec312372b345ab7652 | #!/usr/bin/env python
"""
This example shows how to create an unstructured grid.
"""
import vtk
import numpy as np
import pickle as pkl
colors_list = pkl.load(open('permuted_colors.pkl','rb'))
meta = pkl.load(open('v_atlas/meta_information.pkl','rb'))
def main():
colors = vtk.vtkNamedColors()
Data=np.load(... |
4,110 | 510d411d79d5df8658703241f161b3e2a9ec5932 | #!/usr/bin/env python2.7
'''
lib script to encapsulate the camera info
'''
from xml.dom import minidom, Node
# what % of the file system remains before deleting files
# amount that we will cleanup relative to the filesystem total
CAMERA_XML_FILE = "/tmp/cameras.xml"
def cameras_get_info():
'''
cameras_ge... |
4,111 | 70b8efa844395592131382d1d1e2c39150804f99 | from setuptools import Command
class decl_cmd1(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
pass
class decl_cmd2(Command):
user_options = []
def initialize_options(self):
pass
def final... |
4,112 | a470aad80e47b244811e4d9aed4a630ba36a8daf | """helloworld URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
https://docs.djangoproject.com/zh-hans/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add ... |
4,113 | c120db53e1ea5a5b865b891cf602a13113fb1e41 | import urllib.request
import io
import cv2
import numpy as np
img_url = 'http://192.168.0.2:7079/hi'
while True:
data = urllib.request.urlopen(img_url)
raw_data = data.read()
nparr = np.frombuffer(raw_data, np.byte)
image_raw = cv2.imdecode(nparr, cv2.IMREAD_ANYCOLOR)
cv2.imshow("test", image_raw)... |
4,114 | 86c4193ec0fee8a0c06858913ec8153fcf0df6d9 | #!/usr/bin/python
import pyglet
from pyglet.gl import *
win = pyglet.window.Window()
@win.event
def on_draw():
# Clear buffers
glClear(GL_COLOR_BUFFER_BIT)
# Draw outlines only
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
# Draw some stuff
glBegin(GL_TRIANGLES)
glVertex3i(0, 0, 0)
glVertex3i(300, 0, 0)
glVe... |
4,115 | c2260278c8dfb353f55ee9ea3495049b08169447 | from django.contrib.auth import get_user_model
from django.db import models
from django.db.models.signals import post_save
from apps.common.constants import NOTIFICATION_TYPE_CHOICES, INFO
from apps.core.models import BaseModel
from apps.core.utils.helpers import get_upload_path
from apps.core.utils.push_notification ... |
4,116 | c07454dfb9dabb89c86f63063231ae9cf915aa38 | from django.db.models import Model, CharField, IntegerField, ManyToManyField, ForeignKey, PROTECT
from django.core.validators import MaxValueValidator, MinValueValidator
from polymorphic.models import PolymorphicModel
from model_utils import Choices
class Tendencia(Model):
valor = CharField(max_length=16, unique=... |
4,117 | e3b39c6655fc14efec3b3f95b08bc7b2c036cbdc | import matplotlib.pyplot as plt
import pandas as pd
from collections import Counter
import numpy as np
import imdb
import csv
import networkx as nx
from networkx import *
def split_data(data):
df = pd.read_csv(data)
ranks = df.groupby('userId')['timestamp'].rank(method='first')
counts = df['userId'].map(df.... |
4,118 | cf97c87400649dd15e5d006707f9adfbd0c91b2c | from django.shortcuts import render
from .forms import TeacherForm,Teacher
from django.http import HttpResponse
def add_teacher(request):
if request.method=="POST":
form=TeacherForm(request.POST)
if form.is_valid():
form.save()
return redirect("list_teachers")
else:
return HttpResponse("in... |
4,119 | 94559d9fd296acd468c33d6b0541b974575b8852 | # -*- coding: utf-8 -*-
"""
Automatically create and parse commands
based on a YAML configuration file.
NOTE: we can't have a logger here,
before knowing the level of debug.
"""
import os
import sys
import argparse
from controller import __version__, PROJECTRC, PROJECTRC_ALTERNATIVE
from controller.conf_utilities im... |
4,120 | 127ca34d3fae3af4506258388a28c539ccc7c33b | /Users/linhly/anaconda/lib/python3.6/reprlib.py |
4,121 | f15f96658130ac9bba748a518371ad80d9772fbc | import pickle
from pathlib import Path
from rich.console import Console
from fourierdb import FourierDocument, FourierCollection, FourierDB
console = Console()
doc = FourierDocument({"bar": "eggs", "xyz": "spam"})
doc2 = FourierDocument({"a": "foo", "b": "bar"})
doc3 = FourierDocument({"abc": "xyz"})
doc4 = FourierDo... |
4,122 | 7d3f4e0a5031f9ce618c568b440c7425489060a1 | import sys
class Obj:
def __init__(self, name):
self.name = name
self.down = []
def add_child(self, obj):
self.down.append(obj)
def prnt(self, prev):
if not self.down:
print(prev + '=' + self.name)
else:
for d in self.down:
... |
4,123 | 6437cb90ebaed7cf59df780062ebccf77fcef084 | from ethereum.abi import (
decode_abi,
normalize_name as normalize_abi_method_name,
method_id as get_abi_method_id)
from ethereum.utils import encode_int, zpad, decode_hex
import json
import time
from web3 import Web3, HTTPProvider, TestRPCProvider
from solc import compile_source
from web3.contract import ... |
4,124 | b53294330a908f8a50d8fbb50b9c88e2bc6135a1 | print("gggg")
print("gggg")
print("gggg")
|
4,125 | f4c3b6ee6389b31c6a280bf7cfe920a2791c1299 | import logging
from tqdm import tqdm
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
def create_tables(db_engine):
"""RUN SQL STATEMENTS TO CREATE TABLES"""
with db_engine.connect() as conn:
create_table_stmts = []
create_drugs_table = """
DROP TABLE IF EXISTS dr... |
4,126 | d638194a37dc503b7dfb5410abf264be67c3a4f0 | import pyttsx
engine = pyttsx.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate-55)
engine.say('Hello , whats your name ?');
engine.say('I am mr. robot. What news would you like to listen to today ?');
#engine.say('Sally sells seashells by the seashore.')
#engine.say('Sally sells seashells by the... |
4,127 | 471d4cc95d6cb8d02f1c96e940c2a2235affbc52 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 19 17:24:25 2015
@author: Damien
"""
import numpy as np
from operator import itemgetter
import itertools
def writeOBJ(vertlist,trilist,filename):
print "number of triangles: " + str(len(trilist))
print "number of vertices: " + str(len(vertlist))
OBJ = open(f... |
4,128 | e748420dfdb77fa8661111a92fc48b79f64bff10 | #!/usr/bin/env python
# encoding: utf-8
"""
PreScaledTriggers.py
Created by Bryn Mathias on 2011-11-02.
Copyright (c) 2011 Imperial College. All rights reserved.
"""
import sys
import os
from plottingUtils import *
# HLT_HT600_v1Pre_1_HLT_HT300_v9Pre_210
def main():
c1 = Print("HLT_HT550_HLT_HT250.pdf")
c1.open(... |
4,129 | 426b711571d3b5c4f8c7b0bad3a613951902e60b | def calc_fib(n):
fib_lis = dict()
for i in range(n+1):
if (i <= 1):
fib_lis[i] = i
else:
fib_lis[i] = fib_lis[i-2] + fib_lis[i-1]
return fib_lis[n]
n = int(input())
print(calc_fib(n))
|
4,130 | 40b9114e4348bab5d76d68a937b3abe95a90c230 | import os
# didnt endup using this
import time
# from django.contrib.gis.utils import LayerMapping
from django.contrib.gis.geos import fromstr
# from models import Harbord
import csv
from pygeocoder import Geocoder
# from django.contrib.gis.geos import (Point, fromstr, fromfile,
# GEOSGeometry, Multi... |
4,131 | f92a1398a27541557ec5bbf752d44ce40d1df94a | # -*- coding: utf-8 -*-
#imports
from math import sqrt, pi, exp
from csv import reader
from random import seed,randrange
"""
Helper functions
"""
#calculate probability
def probability(x,avg,standev):
exponent = exp(-((x-avg)**2 / (2 * standev**2)))
return (1/(sqrt(2*pi) *standev)) * exponent
#mean
def avg(... |
4,132 | 42f656898481768ea0bf1ca0b6afbe06de9dd597 | import numpy as np
from math import *
from visual import *
from visual.graph import *
def energy2(n):
return ((n*h/L)**2)/(8*m)*convert
def factorial(n):
out=1
for x in range(n):
out=out*(x+1)
return out
def bosonconfigs(numelvl,numpart):
x=numpart
n=numelvl
out=choose(x+n-1,x)
... |
4,133 | 3c3d45f0844496b8d623286b36a4935a154f410a | # coding: utf-8
import datetime
import json
import requests
import os
import re
import sys
from todoist.api import TodoistAPI
#SLACK_CHANNEL = os.environ['SLACK_CHANNEL']
#SLACK_POSTURL = os.environ['SLACK_POSTURL']
TDIAPI = TodoistAPI(os.environ['TODOISTAPITOKEN'], cache=False)
TDIAPI.sync()
name = os.environ['TODOI... |
4,134 | cd2062055e30fc37a5f00f4bce6ffd9ea5eda860 | /Applications/anaconda2/lib/python2.7/warnings.py |
4,135 | 675dc9467dd6db9c2a429941af56d78d6c0e1c08 | """
Copyright (C) 2005 - 2016 Splunk Inc. All Rights Reserved.
"""
import logging
import sys
if sys.platform == "win32":
import os, msvcrt
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
import splunk.adm... |
4,136 | 83c109bc5aab6739a3a32116fae4f0c011d6118e | import torch
from torch.nn import functional as F
from sklearn.metrics import f1_score, accuracy_score
@torch.no_grad()
def validate(data, model):
model.evaluate()
out = model(data.x, data.train_index)
return model.loss(out[data.val_mask == 1], data.y[data.val_mask == 1])
@torch.no_grad()
def validate_... |
4,137 | a3216aa41cd28b91653b99017e21a03e43372e9b | # -*- encoding: utf-8 -*-
#----------------------------------------------------------------------------
#
# Copyright (C) 2014 .
# Coded by: Borni DHIFI (dhifi.borni@gmail.com)
#
#----------------------------------------------------------------------------
import models
import wizard
import parser
# vim:expa... |
4,138 | de6a6c2dc7bea255e5674663616c962c1d1625e0 | class Solution:
# @param arrive : list of integers
# @param depart : list of integers
# @param K : integer
# @return a boolean
def hotel(self, arrive, depart, K):
self.count = 0
self.temp = 0
for i in range(len(arrive)):
for j in range(i, len(depart)):
... |
4,139 | 2d5e147b081283047cd044746d73d91ee2e59052 | from datetime import datetime
import xarray
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.dates import date2num
import numpy as np
from matplotlib.gridspec import GridSpec
def test_plot_area_avg(target_nc_folder="", source_nc_path=""):
# target_nc_folder = "/HOME/huziy/skynet3_rech1/Netbea... |
4,140 | a868ecb6ea6a5c7a186ddd8fa4fb76d96efeb21d | import numpy as np
'''
1. Create 0-D array, 1-D array, 2-D array, 3-D array with following value
0-D: [2]
1-D: [3, 4, 5, 6, 7]
2-D: [[8, 1, 3], [2, 3, 4], [6, 2, 5]]
3-D: [[[1, 2, 4], [3, 3, 2], [1, 9, 1]], [[6, 8, 7], [9, 1, 0], [8, 2, 3]], [[5, 4, 1], [5, 7, 2], [3, 5, 9]]]
print them
'''
D0 = np.... |
4,141 | a7123fa221555b15162dbab0d93a86965190b805 | # BotSetup.py
from websockets.exceptions import InvalidStatusCode
from dokbot.DokBotCog import DokBotCog
from events.EventCog import EventCog
from dotenv import load_dotenv
from datetime import datetime
from .DokBot import DokBot
import utils.Logger as Log
import logging
import os
import sys
import traceback
import di... |
4,142 | f3664f5f69207c3f2dcec96c90cd220003da0904 | import json
import paho.mqtt.client as mqtt
from datetime import datetime
import ssl
from collections import OrderedDict
import time
from tkinter import *
import numpy as np
MQTT_IP = 'emq'
MQTT_PORT = 8883
username = "spread_ICAM"
password = "spread_ICAM"
deviceType = "spread_ICAM"
version = "v1"
def on_connect(cli... |
4,143 | 30e8e269cf6500ab804566a85c9b96b3ef9bda36 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 Cesar Sinchiguano <cesarsinchiguano@hotmail.es>
#
# Distributed under terms of the BSD license.
"""
"""
import numpy as np
from open3d import *
def main():
print("Load a ply point cloud, print it, and render it")
pcd = read_... |
4,144 | 07fdf6605d970d2491116ad82a1119499b561d1f | M, N = map(int, input().split())
def is_prime(num):
if num <= 1:
return False
i = 2
while i * i <= num:
if num % i == 0:
return False
i += 1
return True
if __name__=="__main__":
for i in range(M, N+1):
if is_prime(i):
print(i)
|
4,145 | c70db0fc9d98657e318ecab7eb8af60cc2b19a2c | from fixate.reporting.csv import register_csv, unregister_csv |
4,146 | ae83a0e1ebf1190ab55459563bc7b86d240de89a | #! /usr/bin/python2
# Copyright 2007 John Kasunich and Jeff Epler
#
# modified by Rudy du Preez to fit with the kinematics component pumakins.c
# Note: DH parameters in pumakins halfile should bet set to
# A2=400, A3=50, D3=100, D4=400, D6=95
#
# z |
# ... |
4,147 | 1c7635917e398c30e4a232f76b2c02a51e165a63 | def fib(limit):
a, b = 0, 1
yield a
yield b
while b < limit:
a, b = b, a + b
yield b
print sum(x for x in fib(4000000) if not x % 2) # 4613732
|
4,148 | 45e8bdacad4ed293f7267d96abc9cbe8c8e192ae | from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', admin.site.urls),
path('upload/', include('links.urls')),
]
|
4,149 | d0dbf5a13b8e718ed426a254546ba13da12b2c3e |
#Program written and maintained by Matthew Meyerink
#File responsible for defining the game based on user input
from cpu_game import CPU_Game
from warning_color import Warning
class User_Game(CPU_Game):
#Get the user phrase to start the game
def get_user_phrase(self):
correct_form = False
w... |
4,150 | fd877f5952c1fc0b2115d0950a066501ee7545f8 | # coding: utf-8
from openerp import SUPERUSER_ID
from openerp.osv import osv, fields
from openerp.addons.ud.ud import _TIPOS_BOLSA
TIPOS_BOLSA = dict(_TIPOS_BOLSA)
def get_banco(cls, cr, browse_record, usuario_id, context=None):
dados_bancarios_model = cls.pool.get("ud.dados.bancarios")
args = [("banco_id", ... |
4,151 | 9d2fdf47b5c4b56cc0177a9c0a86b1ed57c88d49 | from flask import Flask,Blueprint
from .views import login
from flask_session import Session
import redis
app = Flask(__name__,template_folder='templates',static_url_path='static')
app.debug = True
print('app.root_path===',app.root_path)
print('app.static_url_path===',app.static_url_path)
app.secret_key('uaremyhero... |
4,152 | e480136aca96e45cc8a7ca34c1a9d09b96a5a4da | import cv2 as cv
import numpy as np
import pytesseract as tes
text = get_text_from_image("resizedReceipt.jpg")
print(text)
def get_text_from_image(imageName):
img = preprocess(imageName)
result = tes.image_to_string(img)
return result
def preprocess(image_name):
image = cv.imread(image_name)
g... |
4,153 | 83d0a32ef2d365d17caa9d311c367ed5828559ac | n, m = map(int, input().split())
li = list(map(int, input().split()))
max = 0
for i in range(0, n):
for j in range(i+1, n):
for k in range(j+1, n):
tmp = li[i] + li[j] + li[k]
if(tmp <= m and max < tmp):
max = tmp
print(max) |
4,154 | 07f8fd305e2311c0e37a785da0a826b8ea4e78ba | from project import db
from project.models import User, Recipe, Association, Ingre, Recipe_ingre
user=User.query.filter_by(username="xiaofan").first()
recipe=Recipe.query.filter_by(recipename="Jerry").first()
recipes = Recipe.query.filter(Recipe.users.any(username="xiaofan")).all()
if recipe not in recipes:
us... |
4,155 | 079610f2aaebec8c6e46ccf21a9d5728df1be8de | #!/usr/bin/env python
def findSubset(s0, s, t):
mys0 = s0.copy()
mys = s.copy()
if t == 0 and mys0:
return mys0
elif t == 0: # and mys0 == set()
return True
else:
if len(mys) > 0:
p = mys.pop()
mys1 = mys0.copy()
mys1.add(p)
... |
4,156 | 500d6f473f07b35bf2d075d3061ac2e54eab702a | import numpy as np
import cv2
FRAME_WIDTH = 320
FRAME_HEIGHT = 240
cv2.namedWindow('Measure Angle with centerline')
# WebCam Initialize
vidCapture = cv2.VideoCapture(1)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('webcam_record.avi', fourcc, 20.0, (640, 480))
while True:
# ke... |
4,157 | 3a8164299fa51b7d781f2b80d77cfba05b5f6915 | import os
from pathlib import Path
DEFAULT_ROOT_PATH = Path(os.path.expanduser(os.getenv("PLOTTER_ROOT", "~/.plotter/mainnet"))).resolve()
|
4,158 | ec44e12624fbee3148cfa4f886e86ba437e920ec | """
This file contains the general data storage classes used throughout Logician.
"""
import csv
import json
import os
from collections import OrderedDict
VALID_CHANNEL_COUNTS = [4]
class Acquisition:
"""
The acqusition object contains data from all of the acquired channels.
Parameters
----------
... |
4,159 | 1d4a51cfbd5df9ac9074c816a140309e04fff021 | ###############################################################################
# Copyright (c), Forschungszentrum Jülich GmbH, IAS-1/PGI-1, Germany. #
# All rights reserved. #
# This file is part of the AiiDA-FLEUR package. #
... |
4,160 | d5dae7ab6eb34c82ae795730ecae666c4f81f10a | from db_connector import insert_item_details, insert_user_details
from Item_details import ItemDetails
def mechant_service(user_id):
print('================================')
print('Merchant Page')
print('================================')
heading='=============================================\nenter ... |
4,161 | 9e98c6b59433369bca3d4f7ae261f7e7ab3aae6b | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import datetime
archivo = open("salida2.csv", "a+")
startTime = datetime.now()
def mergeSort(alist):
print("Splitting ",alist)
if len(alist)>1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]
merge... |
4,162 | 21aee78e8cbb1ca150bca880e79dc0d84326e2d4 | print("RUNNING ON CPU")
from library import config, utils, broker_funcs, portfolio
import numpy as np
import pandas as pd
# import matplotlib.pyplot as plt
from fbm.fbmlib import fbm
import time
import pickle
assert config.changePrice == True
print(config.config)
t0 = time.localtime()
t0str = time.strftime("%H:%M:%S... |
4,163 | 0719448e7eb8d48e636be1332c904beebf27e02d | # 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 ... |
4,164 | 9d27b8844ab4070bb53afd89620177b89013956e | from pickle import dump, load
def save(parameters):
# Функция сохранения прогресса в файл
with open('saves/save.zs', 'wb') as game_save:
dump(parameters, game_save)
game_save.close()
def load_settings():
# Функция загрузки сохранения при выборе опции продолжения игры
try:... |
4,165 | c153c7a3a11a09ed645540632daec42e8905432a | #!/bin/env python3
"""
A tool for painting and saving Game Boy tiles.
Usage: `python3 gb-tile-painter.py`
Please see: README.md.
"""
from sys import argv, exit
# If we got an argument and it is --help or -h
if len(argv) == 2 and (argv[1] == "--help" or argv[1] == "-h"):
print(__doc__) # Print the docstring
... |
4,166 | f653e906d3026de4bb1e705162f4321bb75e8705 | import tensorflow as tf
import blood_model
import os
import numpy as np
FLAGS = tf.app.flags.FLAGS
RUN = 'new_test_hm'
tf.app.flags.DEFINE_string('checkpoint_dir', RUN+'/checkpoints',
"""Directory where to write event logs and checkpoint.""")
tf.app.flags.DEFINE_string('summaries_dir', RUN+... |
4,167 | f153da7e4537f807f6c9d9d268a00443933d8315 | #!/usr/bin/env python
# coding: utf-8
# # Cabecera
# In[1]:
# -*- coding: utf-8 -*-
# ------------- Cantidad de segundos que has vivido -------------
# # Definición de variables
# In[2]:
# Definición de variables
anios = 30
dias_por_anio = 365
horas_por_dia = 24
segundos_por_hora = 60
# # Operación
# In[3]... |
4,168 | cc019c732003ed72db80a7893096a0bef0f12e47 | """
Iterations over :term:`hosts<host>`, :term:`roles<role>`,
:term:`components<component>` and config files.
"""
from contextlib import contextmanager
from fabric.api import env, settings, abort
from os.path import join
from pkg_resources import iter_entry_points
from warnings import warn
from fabric.network import s... |
4,169 | efeb069a7e2aab7262a557236c693752d2973523 | import sys
import time
from abc import ABC, abstractmethod
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QApplication
import inupdater.resource
from inupdater.splash import SplashScreen
class UserInterface(ABC):
"""Interface for GUI element"""
def __init__(self) -> None:
self.stat... |
4,170 | 81535b43437f9bcb18973ceaa5c3340ad9bd4f0f | from django.forms import ModelForm
from django import forms
from models import *
from django.forms.widgets import *
class CommentForm(ModelForm):
# tags = TagField(widget=TagAutocomplete())
class Meta:
model=Comment
# fields = ('title', 'description', 'tags', 'enable_comments', 'owner')#, 'first_card' )
# w... |
4,171 | 377143635939cf113e4188b5c4f55cec068a17b1 | #!/usr/bin/env python
# coding:utf-8
import time
from SocketServer import (TCPServer as TCP,
StreamRequestHandler as SRH)
HOST = '127.0.0.1'
PORT = 8888
BUFSIZE = 1024
ADDR = (HOST, PORT)
class MyRequestHandler(SRH):
def handle(self):
print '...connected from :', self.client_addr... |
4,172 | 7ed84706ace2cbf523021887df1e13d113f9ce4c | import os.path
import numpy as np
import matplotlib.pyplot as plt
import util
import collections
def learn_distributions(file_lists_by_category):
"""
Estimate the parameters p_d, and q_d from the training set
Input
-----
file_lists_by_category: A two-element list. The first element is a list of
... |
4,173 | d67a2eca4e2fde443b99f5133c2657cdf4ac00de | #!/usr/bin/python3
"Places module"
from flask import jsonify, request, Response, abort
from api.v1.views import app_views
from models import storage
from models.place import Place
@app_views.route('cities/<city_id>/places', strict_slashes=False,
methods=['GET'])
def get_all_places(city_id):
''' g... |
4,174 | f4ab6df8efc334fa338ade7deecd36d8cd859e96 | # Title: K번째 수
# Link: https://www.acmicpc.net/problem/11004
import sys
sys.setrecursionlimit(10 ** 6)
def read_list_int():
return list(map(int, sys.stdin.readline().strip().split(' ')))
def read_single_int():
return int(sys.stdin.readline().strip())
def selection_sort(nums, k):
sor... |
4,175 | 8743be809953f59bd14431e509042c4c51d9fab4 | import torch
from torchvision import datasets, transforms
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
from PIL import Image
import requests
from io import BytesIO
from net import Net
class predict_guitar():
def __init__(self):
"""Model is lo... |
4,176 | 6f8ce77dd45f555ca092482715b6ccaa33414fd8 | # --------------------------------------------------------------------------------------------------
# Property of UAH
# IDS module for ladder logic monitoring
# This codes is Written by Rishabh Das
# Date:- 18th June 2018
# -----------------------------------------------------------------------------------------------... |
4,177 | 1df1081308ead28c023774a8671df8a0671a1bba | from Song import Song
class FroggyWoogie(Song):
def __init__(self):
super(FroggyWoogie, self).__init__()
self.file = 'Music/5-Sleepy_Koala_-_Froggy_Woogie.mp3'
self.plan = [[0.0, 32, 'W', 16.271],[16.271, 16, 'S', 8.135],[24.406, 44, 'S', 22.373], [46.779, 16, '... |
4,178 | 7eeba06e78bd1e7139b1706574c4d040465d4566 | import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4, 5], [1, 2, 3, 4, 5],
'go-', label='line 1', linewidth=2)
plt.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25],
'rs--', label='line 2', linewidth=4)
plt.axis([0, 6, 0, 26])
plt.legend(loc="upper right")
plt.show()
|
4,179 | 32e904a39d03d3166369420b49db0b9b118110a3 | import hashlib
import json
import logging
import os
import urllib.parse
import uuid
from datetime import datetime
import pytz
from celery import states as celery_states
from django.conf import settings
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.base_user import BaseUserManager
... |
4,180 | 1b4c9841fd10d065983974e93fe5dcbe048c1281 | #! /usr/bin/env python3
#
# This file is part of Toboggan, https://github.com/TheoryInPractice/Toboggan/,
# and is Copyright (C) North Carolina State University, 2017. It is licensed
# under the three-clause BSD license; see LICENSE.
#
# -*- coding: utf-8 -*-
# python libs
import sys
import itertools
# local imports
fr... |
4,181 | 419aee3045a0d532afa0fc314df9cdef7aab5219 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 13:13:53 2018
@author: zhang
"""
'''
Warp Commands use during diffusion-weighted images preprocessing
================================================================
dwidenoise & mrdegibbs from MRTrix3.0; eddy-openmp from FSL
------------------------------------------... |
4,182 | 8855747f58b48bedc362930662e147b1fc4ebd63 | """
MAIN IDEA --> Keep 2 pointers. i points to current 0 element and j searches for first non zero element which comes after i.
As soon as we get a j, we swap i and j. So index i now becomes non zero. Now move i to next index i.e i+1 and now check if i
is zero or non zero. If i is still zero, then again search for 1st... |
4,183 | f0168a737b9215520ce600470f9b27837dafb593 | from django.apps import AppConfig
class TermserviceConfig(AppConfig):
name = 'termservice'
|
4,184 | b3f0aae91c885d0e15ff3e456b5cab43fca65b67 | from . import *
from ..utils.constants import NUM_SEARCH_RESULT
def get_course_by_id(course_id):
return Course.query.filter_by(id=course_id).first()
def get_course_by_subject_and_course_num(subject_code, course_num):
return Course.query.filter_by(subject_code=subject_code, course_num=course_num).first()
d... |
4,185 | 379ab72f5cc74cf6ed4319fff76437ce84aaca23 | import os
import sys
import random
import string
trainingData = open('./Data.txt').readlines()
# Used for storing the Markov states
table = {}
# Stores all the words
words = []
# The size of the tuple that represents the Markov State
ChainLength = 2
# Length of hte output chain
Size = int(sys.argv[1])
if(len(sys.... |
4,186 | 00a1b5f20f15994a659eda56201ba7c45d49a4db | import os
import json
from .utils import *
def _unique_predict(solve_list):
valid_solve_list = filter(lambda x: x[0] is not None, solve_list)
valid_solve_list = sorted(valid_solve_list, key=lambda x: x[0])
unique_solve_list = list()
current_no = -1
for e in valid_solve_list:
if current_no ... |
4,187 | 82c10076ba73723b696e3e33280296c2a24f20b9 | from django.apps import AppConfig
class PrimaryuserConfig(AppConfig):
name = 'PrimaryUser'
|
4,188 | 133bd0b2affc3d29390edeab51299d294dafb709 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 2 18:52:27 2021
@author: burak
"""
import veriler
import gorsel
import numpy as np
from sklearn.neighbors import KNeighborsClassifier
neighbors = np.arange(1,13)
train_accuracy = np.empty(len(neighbors))
test_accuracy = np.empty(len(neighbors))
... |
4,189 | 6285d1665bacbff746f44f42ce65981f937fff64 | # Generated by Django 3.2.3 on 2021-05-29 16:37
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),
('logi... |
4,190 | 6bf1a0fbf65895eac9baa71bc5e04e861f0a3ed5 | from gpiozero import Motor
class Car:
def __init__(self, speed: float = 1):
self.speed = speed
self.forward_right_motor = Motor(forward=12, backward=16)
self.backward_right_motor = Motor(forward=21, backward=20)
self.forward_left_motor = Motor(forward=23, backward=18)
sel... |
4,191 | 31801f62942337b0cdf0e022dc75a9e125be54e3 | from django.db import models
from django.conf import settings
from django.utils.text import slugify
from six import python_2_unicode_compatible
from ckeditor_uploader.fields import RichTextUploadingField
from ckeditor.fields import RichTextField
# Create your models here.
class topic(models.Model):
name = models.Ch... |
4,192 | c14d76493cd3dacc55c993f588dec555b7a4a13c | # %% import libs
import os
import argparse
import logging as logger
import mxnet as mx
import tqdm
from mxnet import autograd
from mxnet import gluon
from gluoncv.utils import makedirs
import datasets as gan_datasets
from utils import vis, get_cpus, TrainingHistory
import models
mx.random.seed(5)
logger.basicConfig(l... |
4,193 | b2b47b394eadebda5c51e89abd27832f9dbd4c8c | from gymnasium.spaces import Box, Discrete
import numpy as np
from typing import Optional, TYPE_CHECKING, Union
from ray.rllib.env.base_env import BaseEnv
from ray.rllib.models.action_dist import ActionDistribution
from ray.rllib.models.modelv2 import ModelV2
from ray.rllib.models.tf.tf_action_dist import Categorical,... |
4,194 | ae82ecadb61fd87afbc83926b9dc9d5f7e8c35a0 | # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-07-31 18:38
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('product', '0007_auto_20170731_1812'),
]
operations... |
4,195 | a7be2f43c6ec8d1576ed194a75762a36089cb052 | num_str = "1"
num_str1 = "\u00b2"
num_str2 = "一千零一"
# 判断字符串是否只包含数字
# 1.三种方法都不能判断小数
# 2.isdigit 和 isnumeric 比 isdecimal 强大一些,后者只能判断正常数字,前两者可以判断带有数字的符号,如平方
# isnumeric 还可以判断中文数字
print(num_str)
print(num_str1)
print(num_str.isdecimal())
print(num_str1.isdecimal())
print(num_str.isdigit())
print(num_str1.isdigit())
print(n... |
4,196 | 34aa08b9a5a89d3fca129271a9e812e2382ca88e | 207. Course Schedule
Some courses may have prerequisites, for example to take course 0 you have to first take course 1,
which is expressed as a pair: [0,1]
Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses?
For example:
2, [[1,0]]
There are a total of... |
4,197 | 109a0ba0952bd5923ecbefa41556de7aa9f9eea8 | # Copyright (c) 2012 - Samuel Loretan <tynril at gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modi... |
4,198 | 7a5106456d0fdd905829c5aa1f4a69b027f3a04c | from pymongo import MongoClient
import Config
DB = Config.DB
COLLECTION = Config.COLLECTION
def connectMongo():
uri = "mongodb://localhost"
client = MongoClient(uri)
return client[DB]
def connectMongoCollection(collection = COLLECTION):
uri = "mongodb://localhost"
client = MongoClient(uri)
db = client[DB]
re... |
4,199 | 601089c2555e6fc75803087ee1d8af7f8180f651 | from collections import defaultdict
def solution(clothes):
answer = 1
hash_map = defaultdict(lambda: 0)
for value, key in clothes:
hash_map[key] += 1
for v in hash_map.values():
answer *= v + 1
return answer - 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.