index
int64
0
1,000k
blob_id
stringlengths
40
40
code
stringlengths
7
10.4M
12,400
cfdba341bb0f968101627d1ea53da4fab333473c
#from django.views.decorators.csrf import csrf_exempt from django.db import IntegrityError, transaction from django.shortcuts import render, render_to_response, RequestContext, redirect, get_object_or_404 from django.contrib.auth.decorators import login_required, permission_required from django.http import JsonResponse...
12,401
0856628754fa14d7744dae0628ea80c27994b89b
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jul 30 18:25:13 2021 @author: klaus """ from prettytable import PrettyTable import os from google.cloud import storage storage_client = storage.Client() BUCKET_NAME=os.getenv('DATA_BUCKET') BASE_PATH="/tmp/" RECIEVER_EMAIL="YOUREMAIL@xyz.xy" Contracts...
12,402
dda9de04af78c69a873ca9dd91c1dcb577ea9990
# Copyright (c) 2016-2023 by University of Kassel and Fraunhofer Institute for Energy Economics # and Energy System Technology (IEE), Kassel. All rights reserved. import pytest try: from julia.core import UnsupportedPythonError except ImportError: UnsupportedPythonError = Exception try: from julia import...
12,403
7abefbd89afe858eaadc427dfa0a81db60216aca
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Parameter class GroupBatchNorm(nn.Module): def __init__(self, num_features, num_groups=1, num_channels=0, dim=4, eps=1e-5, momentum=0.1, affine=True, mode=0, *args, **kwargs): """""" super(Grou...
12,404
65cc60d0acecd6ae9a063548cfa616fcc2a93e4d
# **Important: This notebook will only work with fastai-0.7.x. Do not try to run any fastai-1.x code from this path in the repository because it will load fastai-0.7.x** # # Random Forest Model interpretation # %load_ext autoreload # %autoreload 2 # + # %matplotlib inline from fastai.imports import * from fastai.st...
12,405
3feac9e2d42d6c9f5868bd8146b96157369193f7
# coding=utf-8 # # Copyright (C) 2013 Allis Tauri <allista@gmail.com> # # DegenPrimerGUI is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or # (at your option) any later versio...
12,406
77487abd7eb4e966dff682fd1308da323c569f82
from __future__ import annotations import itertools import ibis import ibis.expr.operations as ops def _reduction_format(translator, func_name, where, arg, *args): if where is not None: arg = ops.Where(where, arg, ibis.NA) return "{}({})".format( func_name, ", ".join(map(translator....
12,407
015c01cd3032a5669096626d21e166e44ebdfc9a
import codecademylib import pandas as pd ad_clicks = pd.read_csv('ad_clicks.csv') ad_clicks.head(10) ad_clicks.groupby('utm_source')\ .user_id.count()\ .reset_index() ad_clicks['is_click'] = ~ad_clicks\ .ad_click_timestamp.isnull() clicks_by_source = ad_clicks\ .groupby(['utm_source', ...
12,408
dc702462f7e9f15398bc0825d4513b27c12b50d2
""" Consider three situations: * delete at the beginning * delete at the middle * delete at the end """ from utils import ListNode, stringToListNode, prettyPrintLinkedList class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: # Two pass # lenList = 0 # h = head ...
12,409
608a582990dfb008ec9d05b669fc775f465053e1
from django.contrib import admin # Register your models here. from .models import * @admin.register(LunBo) class LunBoAdmin(admin.ModelAdmin): list_display = ('title',) @admin.register(Index) class IndexAdmin(admin.ModelAdmin): list_display = ('title',)
12,410
97535cab299032007ad40739ed6eef34df248177
import random import statistics import time from collections import defaultdict from functools import reduce from matplotlib import pyplot as pl from settings import TOTAL_ROWS, RAIL_ROAD_ENTRANCE_ID from utils import display_dictionary from utils import load_maps, getEdgesDict, GeoUtils class Environment: # po...
12,411
c36e2c61b5f5f00a032149338272cd889871aa0c
#!/usr/bin/env python # coding: utf-8 # # Coding a Single Perceptron # This file illustrates a single perceptron with two input variables that uses the sign function as its activation function. It is demonstrated that such a perceptron can represent every boolean function except for XOR() and XNOR(). # In[2]: ...
12,412
653446e1d5544c858a27dcbd5ae5d1be31d8235b
import copy from datetime import datetime, timedelta from django.utils import timezone from utils.api.tests import APITestCase from .models import ContestAnnouncement, ContestRuleType, Contest DEFAULT_CONTEST_DATA = {"title": "test title", "description": "test description", "start_time": tim...
12,413
876e642781f8a08620fda49be17319276b4fcb3f
from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User # from splitjson.widgets import SplitJSONWidget class LoginForm(forms.Form): username = forms.CharField(label='username') password = forms.CharField(widget=forms.PasswordInput) is_cr...
12,414
4e559086d6ebe20cd03a996db98e63a62e23d592
import os import numpy as np from skimage.morphology import dilation, ball from skimage.external import tifffile from scipy import ndimage import time def direct_field3D(a): b, ind = ndimage.distance_transform_edt(a, return_indices=True) c = np.array(np.unravel_index(np.arange(a.size), shape=a.shape)).reshap...
12,415
b760e9893113d60cdc0fae118f506114a6eed7fb
#!/usr/bin/env python3 """ Written by Francois Verges (@VergesFrancois) Created on: May 12, 2020 This script claims an AP within your Mist Organization of choice All the configuration details are coming from the 'config.json' file """ import argparse import time import json import requests def claim_ap(configs): ...
12,416
3ff9d81862efffba01ea7ae7211d03d53ad94b4d
import pygame, random, time, numpy as np from multiprocessing import Pipe import os class PacmanEnv(): def __init__(self, num_episodes=4, scale=5, move_left=.8, is_beneficial=.8, speed=5, update_freq=20, reward=200, punishment = 500, time_bw_epi=5, display=True, hangtime=2, deviate=1, ...
12,417
a3bcc610d94d2704057b75bd778d5737764803a3
import os import re import datetime from werkzeug.utils import secure_filename from flask import Flask, jsonify, request, abort, send_from_directory from flask_sqlalchemy import SQLAlchemy from flask_mysqldb import MySQL from flask_cors import CORS from flask_bcrypt import Bcrypt from flask_jwt_extended import ( JW...
12,418
242771917b53f281b783874e9ce44670ade0b592
# M.R. Sorell # Project Python password generator # letters : ask how many letters # numbers : ask how many numbers # symbols : ask how many symbols # generate a random password import random print("Welcome to the password generator") letters = int(input("How many letters do you want in your password: ")) integers...
12,419
bf57cd7e10e344144ec0d3b4f4d1e0f3642e1ee3
#!/usr/bin/python3 -B # Programming for passively reading the joint angles on the monopod from moteus_ctrlr.src.two_d_leg_class import Leg from ctrlrs.ik.sin_ik_hop_ctrlr import sinIkHopCtrlr import numpy as np import asyncio import math import moteus import time import argparse import sys async def main(): kn...
12,420
8e7b5e60e637438d85f44657b61a66f4641f20c1
import argparse from collections import namedtuple, defaultdict Line = namedtuple('Line', ['x1', 'y1', 'x2', 'y2']) parser = argparse.ArgumentParser() parser.add_argument('--include-diagonals', action='store_true') args = parser.parse_args() lines = [] with open('input') as f: for row in f: p1, p2 = row....
12,421
5769510870008b8b4363942eed7b95ae62d4d9a8
import pygame width, height = 800, 417 window = pygame.display.set_mode((width, height)) background = pygame.image.load('images/bg.png') pygame.display.set_caption('scrolling background') bgX = 0 bgX2 = background.get_width() class PLAYER(object): def __init__(self, x, y, vel): self.x =...
12,422
e3019c6b8fdf2dec179375c1c6dceef85a3cba26
#!/usr/bin/python #/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. # #* File Name : solve.py # #* Purpose : # #* Creation Date : 30-09-2011 # #* Last Modified : Sun 02 Oct 2011 07:08:07 PM EEST # #* Created By : Greg Liras <gregliras@gmail.com> # #_._._._._._._._._._._._._._._._._._._._._.*/ def rotations(prime): pr = s...
12,423
dd781ec8c13eae5a15225e5e295aa0e35e1ac2b1
__author__ = 'fernando' def about(): return "", 301, { "Location": "/sobre/VPCrvCkAAPE-I8ch" }
12,424
d135c13140f1d472dfe377418f0af1fcab093b6e
import pyttsx3 class encryption: def __init__(self, otext, keyword, number): self.otext = otext self.keyword = keyword self.number=number def caesar(self,otext,number): import string import collections upper= collections.deque(string.ascii_uppercas...
12,425
819191126dc15e8135320c1b11c5eac714e3979a
import re import requests import time class ImagesHelper: def __init__(self, queue, start_page=2100, end_page=2105): self.start_page = start_page self.end_page = end_page self.url_queue = queue def get_urls(self): for item in range(self.start_page, self.end_page): ...
12,426
ebd68e74f9254d8c5452b941b7b6d63fd4bfc0a4
from django.core.validators import RegexValidator from django.db import models WRONG_PHONE = "Phone number must be entered in the format: '+79999999999' or '89999999999'." class Company(models.Model): name = models.CharField(max_length=128, db_index=True) address = models.CharField(max_length=1024, default='...
12,427
d78956a5bb3233305e5021b1adef39686a9f8bd9
import ctypes import time from sdl2 import * from numpy import interp class Joystick(): def __init__(self): SDL_Init(SDL_INIT_JOYSTICK) self.axis = {1: 0.0, 4: 0.0} self.button = {5: False, 1: False, 0: False} def update(self): event = SDL_Event() while SDL_PollEvent(ctypes.byref(event)) != 0: if ev...
12,428
26e85e738d81123525cf0aa0740e13daf247ffb7
def duplicate_remover(word): """ >>> duplicate_remover("abbaca") 'ca' >>> duplicate_remover("azxxzy") 'ay' """ stack = [] for t in word: if len(stack) == 0: stack.append(t) elif t == stack[-1]: stack.pop() else: stack.append(t) ...
12,429
a65d53f5f95c66837759a62bafde9c0720e4fd17
# -*- coding: utf-8 -*- # # Chinese.Update Reversal Sort Fields # - A FlexTools Module - # # Finds the Chinese Reversal Index and uses the Hanzi field and # Pinyin Numbered fields to populate the Sort field. See the # documentation below for the Writing System codes. # # C D Farrow # May 2011 # # Pla...
12,430
aed0d738fab9c3a1d093aea4297273bcaadcb558
def main(): n = map(int, input().split()) n_sorted = sorted(n) if n_sorted[0] + n_sorted[1] == n_sorted[2]: print('Yes') else: print('No') if __name__ == "__main__": main()
12,431
aec3cd40d6fcba1a6cd80b3565a73c1eca84cc39
import numpy as np import sys def create_Tensor(f): counter = 0 # Tensor for Interlinks if(f): for i in range(nr): counter = counter + 1 for j in range(nn): f = i % nn s = j l = i / (nn*nl) if (counter % (nn * nl) == 0): counter = 0 else: pass th = counter / nn ti[f][s]...
12,432
c6da4538c037def6c830de0ddd0791c408e32607
import bal ch=1 while ch!=4: print("1.Check Balance\n2.Deposit \n3.Withdrwal\n4.Exit") ch=int(input("Enter your choice\n")) if(ch==1): print("Balance is",bal.bal) if(ch==2): amt=int(input("Enter amount for deposit")) bal.bal+=amt print("updated balance is:",bal.bal) if(ch==3): amt=int(input("...
12,433
646113195f6b9a128d38fdb65cd8a222d9771354
import time import numpy as np from schicluster import * from sklearn.cluster import KMeans, SpectralClustering from sklearn.metrics.cluster import adjusted_rand_score as ARI mm9dim = [197195432, 181748087, 159599783, 155630120, 152537259, 149517037, 152524553, 131738871, 124076172, 129993255, 121843856, 121...
12,434
d05902d29984c21e37d079553be4ce5276a3bdcf
from selenium import webdriver import time mails=["akhtamahendra@gmail.com","a.khtamahendra@gmail.com","ak.htamahendra@gmail.com","akh.tamahendra@gmail.com","akht.amahendra@gmail.com","akhta.mahendra@gmail.com","akhtam.ahendra@gmail.com","akhtama.hendra@gmail.com","akhtamah.endra@gmail.com","akhtamahe.ndra@gmail.co...
12,435
21593bab14cd42ad860f2e01b5d8f93ecb68320a
import os from django.test import TestCase from partner.util import load_choices HERE = os.path.abspath(os.path.dirname(__file__)) # Create your tests here. class TestChoiceLoader(TestCase): def test_choices_are_loaded(self): choices = load_choices(os.path.join(HERE, 'states.txt'), True) self.a...
12,436
26f5ec2d738c2262f91cce8ba0f0f62e28fa5ce2
from accounts.models import User from .models import Question, Answer, Tag import requests import json def get_questions(): """ Fetch Questions from eosio.stackexchange """ count = 1 for i in range(6): r = requests.get('https://api.stackexchange.com/2.2/questions?filter=withbody&site=...
12,437
9ec0eb5c7974388db836106e8848f96e32c902f1
from __future__ import unicode_literals from cities_light.models import City from django.contrib.contenttypes.models import ContentType from ...example_apps.autocomplete_test_case_app.models import Group, User from .case import * class AutocompleteGenericMock(autocomplete_light.AutocompleteGenericBase): choices...
12,438
799bc3c6e8e84d322887452077299de92c2442a3
#!/usr/bin/env python # -*- coding: utf-8 -*- from textteaser.parser import Parser from flask import Flask from flask import render_template from flask import send_from_directory from flask import request DEBUG = True THRESHOLD = 0.5 app = Flask(__name__) text = '' @app.route('/css/<path:path>') def sendCss(path):...
12,439
fac491b840dbd8560c8a764ffb01d15ce9a68e12
#импортирую библиотеки from moviepy import * from moviepy.editor import * from pygame import * #склеиваю видео c11 = VideoFileClip("ZlatanI.mp4") c11 c11 = c11.subclip(55,157) c11 = c11.margin(20) c12 = c11.fx(vfx.mirror_x) c13 = c11 c14 = c11.fx(vfx.mirror_x) Zlatan = clips_array([[c11,c12],[c13,c14]]) Z...
12,440
715f6398d4ab90effdf17dbc26cc3638026f6ab5
# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2019-09-24 20:38 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='LianJi...
12,441
ebacb34c6caba2bdd4f41cecf77dd732a7e77a67
'''CTS: Cluster Testing System: Main module Classes related to testing high-availability clusters... ''' __copyright__=''' Copyright (C) 2000, 2001 Alan Robertson <alanr@unix.sh> Licensed under the GNU GPL. ''' # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU ...
12,442
9802e47b10102d329ebfb007f714b8ab4586af9a
__author__ = 'Sajan Kumar' # These are the libraries you need for doing the source fitting analysis # Essentially you need root pyroot and Sherpa package import numpy as np from matplotlib import pyplot as plt from sherpa.fit import Fit from sherpa import models from sherpa.data import Data1D, Data2D from sherpa.stats...
12,443
2cf99803cc59f1dd38f8f43d7e72cf8620fc5e0b
# # The rules to travel: You can go one row down, and/or one colum right. # def gridTraveler(m, n, memo): key = f"{m},{n}" if key in memo: return memo[key] if m == 0 or n == 0: return 0 if m == 1 and n == 1: return 1 memo[key] = (gridTraveler(m - 1, n, memo) + gridTraveler(m, n - 1, memo)) r...
12,444
ee0e66c124d9ad718a9641e292c6ad8b80576eb9
# -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> import numpy as np from open import load_dicom_folder, dicom_datasets_to_numpy from icp import icp_wrap from skimage import measure from scipy.spatial import distance import matplotlib.pyplot as plt from scipy.interpolate import splprep, splev import copy from mpl_to...
12,445
ffb6c37229410ead6b9e91456f3d48c3f12bcc12
# -*- coding: utf-8 -*- """ Created on Fri Apr 8 14:56:45 2016 @author: user """ from __future__ import division from numpy.linalg import solve import numpy as np from matplotlib import pyplot as plot a = 0.12 b = 0.135 g = 1.85 cla = 40 mumax = 0.55 Kp = 4 mu = mumax*(1 + (cla/Kp))**-1 thetha = 0.2 S = np.matrix([...
12,446
2307621cf512695706c4ceada3fa680e3ce385e9
import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.ticker as tk from matplotlib import gridspec def field_norm(z_pts: np.ndarray, wire_locations: np.ndarray, p: np.ndarray) -> tuple: """ z_pts: an array consisting of points along the z-axis (0, 0, z) for magne...
12,447
30444f1a4133c17d010dbb9ea1aacf0bbac05438
# 通过用户输入数字计算阶乘 # 获取用户输入的数字 import time start = time.time() # num = int(input("请输入一个数字: ")) num = 10000 factorial = 1 # 查看数字是负数,0 或 正数 if num < 0: print("抱歉,负数没有阶乘") elif num == 0: print("0 的阶乘为 1") else: for i in range(1,num + 1): factorial = factorial*i print("%d 的阶乘为 %d" %(num,factorial)) end ...
12,448
d3dddae3eb2349fc039a717d3fa2305c43b5630a
'''tempo=int(input('Quantos anos seu carro tem? ')) if tempo<=3: print('Carro novo') else: print ('Carro velho') print ('Carro novo' if tempo<=3 else 'Carro velho')''' '''nome=str(input('Qual seu nome? ')) if nome=='Thiago': print('Que nome lindo você tem!') else: print('Queria que fosse Thiago XD') p...
12,449
40ef49b2c145dad7626c000a6822ff62bb25f406
from flask import Flask from flask import render_template from flask import redirect from flask import request from flask_wtf.csrf import CSRFProtect from flask_wtf.csrf import CSRFError import os app=Flask(__name__) @app.route('/login', methods=['GET', 'POST']) def login(): return render_template('login.html') ...
12,450
ec6d6cd27363cec2beeb0af6edd7f77cf636721b
# 霍夫变换 import cv2 import numpy as np def drawFindLines(img, lines): for i in lines: for rho, theta in i: a = np.cos(theta) b = np.sin(theta) # 变换到x-y坐标系 x0 = a * rho y0 = b * rho # 用点和斜率得到直线上的两个点 x1 = int(x0 + 1000 * (-b)) y1 = int(y0 + 1000 * (a)) x2 = int(x0 - 1000 * (-...
12,451
1f18d6083a8f94399e50b1786ed098d8060c0f71
from itertools import product from kmos.cli import main as cli_main from kmos.types import Action, Condition, Layer, Project, Site, Species # Project pt = Project() pt.set_meta( author='Michael Seibt', email='michael.seibt@tum.de', model_name='LGD_lateral', model_dimension=2 ) # Species pt.add_speci...
12,452
0b8c1463aa5effa450d7b08711cd16d0a44b5824
from selenium import webdriver from selenium.webdriver.chrome.options import Options import json chrome_options = Options() # chrome_options.add_argument('--headless') # chrome_options.add_argument('--disable-gpu') driver = webdriver.Chrome(chrome_options=chrome_options) driver.get("http://www.openedv.com/") input("ge...
12,453
0bfb6a1589509a90f955c3a1a2691cd9bd2715e3
from django.contrib import admin from .models import Funcionario class ListandoFuncionarios(admin.ModelAdmin): list_display = ('nome', 'user', 'empresa') admin.site.register(Funcionario, ListandoFuncionarios)
12,454
3e958900a8a04d13965418defeddd9d938d73998
import os while 1: text = input() try: print('basename = ' + os.path.basename(text)) except: print('unknown basename') pass try: print('dirname = ' + os.path.dirname(text)) except: print('unknown durname') pass try: print('splitext = ' + str(os.path.splitext(text))) except: print('unknown splite...
12,455
c26775426d34ebaa8ec5264d9b4d26263bb931ca
# Generated by Django 3.2.2 on 2021-06-16 19:12 from django.db import migrations, models import django_fsm class Migration(migrations.Migration): dependencies = [ ('main', '0007_rename_proxy_container_ip_containerinfo_proxy_container_address'), ] operations = [ migrations.AlterField( ...
12,456
141c47f9f9a12d70aa0bd918f28739c355b62b53
#!/usr/bin/env python import sys sys.path.insert(1,"/Users/edelman/Documents/programming/alignio-maf") sys.path.insert(1,"/Users/edelman/Documents/programming/bcbb/gff") from Bio import AlignIO from Bio.AlignIO import MafIO from BCBio import GFF #mafFile=sys.argv[1] #gffFile=sys.argv[2] #sequence=sys.argv[3] gff = "...
12,457
ea05f6c995aadc2384a7a23234f0a6eb9c7da631
import argparse class Parser: def __init__(self): self.result = [] def word(self, input): "Converts a MIPS 'word' command into binary machine code (as a string)." if len(input)!= 1: self.result.append("".join(map(str, input))) self.result.append(bin(int(in...
12,458
553dccb95df22fa23499923c9e0cf1b9e3d9737a
import matplotlib.pyplot as plt from matplotlib.pyplot import cm import numpy as np f = plt.figure() ax = f.add_subplot(111) ax.yaxis.set_ticks_position('both') ax.xaxis.set_ticks_position('both') ax.tick_params(which='both', direction='in', labelsize=14) V4 = (22*60+11)*1.0 V7 = V4/(np.array([15, 14, 15, 21])*60 +...
12,459
8f23895d5d44afe69b8b4bd80c78a3547d9751b2
import traceback import os import sys import arcpy from code_library.common import log from code_library.common import geospatial from code_library.common import network # need it for network_end_hucs log.init(arc_script=True,html=True) layer = arcpy.GetParameterAsText(0) method = arcpy.GetParameterAsT...
12,460
737fd7c52f40723516ab407386d5bcaa31de4840
import psycopg2 import yaml import os def connect(): config = {} yml_path = os.path.join(os.path.dirname(__file__), '../../config/db.yml') with open(yml_path, 'r') as file: config = yaml.load(file, Loader=yaml.FullLoader) return psycopg2.connect(dbname=config['database'], ...
12,461
270d09f67633d22cc6ed8e355f258f1954897979
import matplotlib.pyplot as plt def plot_matrix(M, save=False): plt.imshow(M, interpolation='nearest', aspect='auto', cmap='jet') plt.show() if save: plt.savefig(save)
12,462
0cb7e6c504eb6980fbe9ad71c39dc29fe9398ca1
class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] :type val: int :rtype: int """ length = len(nums) if length == 0: return 0 left = 0 right = length - 1 while left < right: i...
12,463
6cd846faf7b04a78097d17f3595c041d9959ffab
# -*- coding: utf-8 -*- from platinumegg.app.cabaret.views.adminhandler import AdminHandler from defines import Defines import settings from platinumegg.app.cabaret.util.api import BackendApi from platinumegg.app.cabaret.util.alert import AlertCode from platinumegg.app.cabaret.models.Memories import MemoriesMaster cla...
12,464
508347317fa73dd398067027657dec618e7acd30
from pandas_datareader import data import datetime import fix_yahoo_finance as yf yf.pdr_override() from bokeh.plotting import figure, show, output_file from bokeh.embed import components from bokeh.resources import CDN start=datetime.datetime(2015,11,1) end=datetime.datetime(2016,3,10) df=data.get_data_yahoo(tickers...
12,465
47389c1dc07c3e49968a3c2e58258a0642f93486
#coding=utf-8 import requests for i in xrange(1003): r= requests.get("http://freeapi.ipip.net/118.28.8.8") print r.text
12,466
c5cce2008acf99be7559809b3c199846c0009384
from conans import ConanFile, CMake, tools import os import shutil class FluidSynthConan(ConanFile): class CustomOption(object): def __init__(self, name, values=None, default=None, cmake_name=None, platforms=None, ...
12,467
da1bcdc2cd701a758b71e28b701e4d3e7a321ef5
import os import glob from glob import glob import pandas as pd from fuzzywuzzy import fuzz from fuzzywuzzy import process import enchant d = enchant.Dict("en_US") path="/Volumes/SkAnDH_Xb/final_year_pj/R2_/ads/" dirs_names=os.listdir("/Volumes/SkAnDH_Xb/final_year_pj/R2_/ads/r2_mp4/") for p in dirs_names: vs=os....
12,468
941ab6aa5d434199ab25b0c4aa2a9645d1651cc9
im=open('evil2.gfx','rb').read() for i in range(0,5): open('image' +str(i), 'wb').write(im[i::5])
12,469
e751324c7c073ec668f920678217d931cbd748d4
""" Tag: array, integer Given an integer n, return any array containing n unique integers such that they add up to 0. Example 1: Input: n = 5 Output: [-7,-1,1,3,4] Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4]. Example 2: Input: n = 3 Output: [-1,0,1] Example ...
12,470
02da22a179f72654a5f7208ef0dcf2ae4dc6308f
# -*- coding: utf-8 -*- """ Created on Mon May 19 21:20:06 2014 @author: Vlad """ import numpy as np import scipy.stats as st import uncertainties as un import pint as um import warnings DEBUG=False def ucreate(data,ierr=0.,conf=95.,unit=None): """ Creaza un obiect ufloat cu incertitudinea data de intervalul d...
12,471
48d3304efdaaea4cf98650b8b87c029d3d62026d
#!/usr/bin/python # Copyright (C) 2011 Ben Wing <ben@benwing.com> # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright notice, # this list of condition...
12,472
97490c9cd1108543f9ad3e0a0f3135697d111509
# Module for preparing training labels, # may also be run directly as a script # Author: Nick Wilkinson 2021 import argparse import numpy as np import pandas as pd import os from voxseg import utils def get_labels(data: pd.DataFrame, frame_length: float = 0.32, rate: int = 16000) -> pd.DataFrame: '''Function for ...
12,473
d8b836c796a311da7fb7f4ecafce0b60cfcf6e7e
#!/usr/bin/env python # -*- coding: utf-8 -*- from pwn import * # pip install pwntools context.arch = "amd64" key = randoms(8) def checksum(data): s = 0 for c in data: s ^= ord(c) return s def Send(data): p = p32(len(data) + 10) p += key p += data + "\x00" p += chr(checksum(key ...
12,474
d2d12c328a7a777d935e3ee3a88f6a22c890ab08
import cv2 image = cv2.imread('static/extraCardTemplates/ActionAttack.png') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # play with these numbers blur = cv2.GaussianBlur(gray, (5, 5), 0) thresh = cv2.adaptiveThreshold(blur, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 15, 30) # cv2.imwrite("suggestio...
12,475
afb8249e7f262c6270ae556ac2910a14267929d3
# -*- coding: utf-8 -*- """ Created on Wed Aug 26 12:16:20 2020 @author: chelsea """ def load_raw_data(input_folder, save_folder): import numpy as np from pathlib import Path import pickle import os from Raw_Data_Class import raw_data as RDC raw_data = RDC() ...
12,476
b2b2e1843657383b3e9baf3491a1707e7089d3b4
from __future__ import division from ..errors import UndefinedDistributionError from .base import UncertaintyBase from numpy import repeat, tile class UndefinedUncertainty(UncertaintyBase): """Undefined or unknown uncertainty""" id = 0 description = "Undefined or unknown uncertainty" @classmethod ...
12,477
aade96e2904344381b47ba20e7f7f1366f6db75e
""" given a string, s, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. exmaple: input: "ab-cd" output: "dc-ba" input: "a-bC-dEF-ghIj" output: "j-Ih-gfE-dCba" """ def reverse_only_chars(s): # strings are imm...
12,478
7fe5ec74f70ce3b4f6721df9e881af19718f8769
import os import curses curses.endwin() startDir = os.getcwd() os.system("clear") print(f"To return to the semi-graphical terminal windowing system, type: 'exit'") os.system("bash") os.chdir(startDir)
12,479
93d6481146afa1280c17a9131a44b57b9958d96e
from html.parser import HTMLParser import random import time from GetLocalHtml import getLocalWebHtml from GetProxyWebHtml import getProxyWebHtml #获得hidemyname代理前三页的高匿ip、端口、协议 def getHidemynameProxies(): proxyList=[] myParser=MyHidemynameParser() for hidemynamePage in range(0,3): #抓取1-3...
12,480
fefc8456fc6ee7af0bf1915a32441ed717d2b9f5
import os,sys import base64 class Directory(object): def startDir(self): if not os.path.isdir(os.path.expanduser('~') + "/.CowNewsReader"): if os.system("mkdir " + os.path.expanduser('~') + "/.CowNewsReader"): print "Error: Couldn't create directory" sys.exit(1) if not os.path.isdir(os.path.expandus...
12,481
5de4f225fd7a5254dd076ea2021ca1f0053c5ade
from django.http import Http404 from django.shortcuts import render, get_object_or_404, redirect from .models import Product from .forms import ProductCreateForm, RawProductForm # Create your views here. # def product_create_view(request): # if request.method == 'POST': # my_form = RawProductForm(request....
12,482
f2f251fda5d9222cc21d8ce34ca045d0af609394
#based on https://medium.com/bilesanmiahmad/how-to-upload-a-file-to-amazon-s3-in-python-68757a1867c6 #https://stackoverflow.com/questions/8637153/how-to-return-images-in-flask-response #https://stackoverflow.com/questions/18908426/increasing-client-max-body-size-in-nginx-conf-on-aws-elastic-beanstalk #https://medium.co...
12,483
604f7fa74876aa8cab6fcfe1aa8d481974381b56
#薪水和学历的关系图 import pandas as pd import numpy as np df = pd.DataFrame(pd.read_csv("../../data/data.csv",encoding='gbk')) ''' 去掉异常值数据 ''' df = df[df['education'] != '3个月'] df = df[df['education'] != '4个月'] df = df[df['education'] != '6个月'] df = df[df['education'] != '中专/中技'] df = df[df['lowSalary'] != '200/天'] df = df[d...
12,484
cabba2cde718fc81e2c3df92c45869f585b6c7a9
import scannerpy import scannertools as st import os from django.db.models import Q from query.models import Video, Frame, Face, Labeler, Tag, VideoTag from esper.prelude import Notifier import json from tqdm import tqdm # Faces were computed at this many FPS FACE_FPS = 2 def frames_to_detect_faces(microshot_boundar...
12,485
008bdb99b6415b4c3270cf94d5e15e1a0ccbd3a0
import os from cs50 import SQL from flask import Flask, flash, jsonify, redirect, render_template, request, session from flask_session import Session from tempfile import mkdtemp from werkzeug.exceptions import default_exceptions, HTTPException, InternalServerError from werkzeug.security import check_password_hash, ge...
12,486
271812b8726ba3ec4d0b262bf91946fe6c20c9c1
# -*- coding: utf-8 -*- """ Created on Mon Nov 6 18:42:31 2017 @author: Ryan Lott Game rules: Objective: Connect both keyboard sides with a single word All letters in the word must form a single chain """ import time import os from graph_func import...
12,487
0ca56fdc2734c15b965708c268c1af9d86e4a6f5
import re from django.contrib.auth.models import User from django.forms import ValidationError from nose.tools import eq_ from pyquery import PyQuery as pq from users.forms import (RegisterForm, EmailConfirmationForm, EmailChangeForm, PasswordChangeForm, PasswordConfirmationForm) from users.t...
12,488
d9d18d0802b699d81635236c227e8e356342abdf
import requests, bs4, time, csv #### setup variables f_writeout = 1 #binary flag to enable logging to local CSV file sb_url = 'https://buseta.wmata.com/m/index?q=1003237' #test url, ft totten station bus stop nb_url = 'https://buseta.wmata.com/m/index?q=2001159' #test url, twinbrook station bus stop #sb_url = 'https:/...
12,489
d87f02630744a787d0a0b53ba58359a57564db80
from django.contrib import admin from .models import School, Grade, Student, Mentor, Student_Group_Mentor_Assignment, Session_Schedule, Attendance, User, remark # Register your models here. class UserList(admin.ModelAdmin): list_display = ('email','username','is_active','created_on','role','is_staff','is_mentor')...
12,490
67e9c7f95207bf57e992731381853218815a07b4
import numpy as np import pandas as pd import pyterrier as pt import xgboost as xgb import time if not pt.started(): pt.init(mem=20000) dataset = pt.get_dataset("trec-deep-learning-docs") def msmarco_generate(): with pt.io.autoopen('msmarco-docs.tsv.gz', 'rt') as corpusfile: for l in corpusfile: ...
12,491
5c157bbff4bc4049751d537704482489b440b6c9
from numpy import * from os import listdir import operator #将32x32的二进制图像矩阵转换为1x1024的向量 def imgVector(filename): returnVect = zeros((1, 1024)) f = open(filename) for i in range(32): listStr = f.readline() for j in range(32): returnVect[0, 32*i+j] = int(listStr[j]) ...
12,492
82aefcd8bcf5fd8d7ba82ab6afd267c405b14cbc
import copy import random from presenter import SortPresenter SIZE = 10 PAUSE_SEC = 0.3 IS_DISPLAY = True def _swap(lst, i, t): v = lst[i] lst[i] = lst[t] lst[t] = v return lst def comb_sort(l, is_display=True): interval = int(SIZE // 1.3) counter = 0 is_swapped = True if is_displa...
12,493
c816ab40acf2fd355fac3f90ec573e5942b3a1da
from django.core.mail import EmailMultiAlternatives, BadHeaderError from django.conf import settings from django.db import transaction from django.http import HttpResponse from django.shortcuts import redirect from django.template import loader from django.utils.html import strip_tags from django.views.generic import T...
12,494
fdd8c4eefe663cb5052eb4bdb6fd41951b30cf99
import sys import pandas as pd filename = "survey_results_public.csv" if len(sys.argv) == 2: filename = sys.argv[1] country_name = 'Israel' chunks = [] dev_chunks=[] for chunk in pd.read_csv(filename, usecols=['Country','DevType'],chunksize=10000): part = chunk[chunk['Country'] == country_name] #d...
12,495
be2e25175a6324997c6fa62e9906dccd5fb6674d
# -*- coding: mbcs -*- # # Abaqus/CAE Release 2017 replay file # Internal Version: 2016_09_28-05.54.59 126836 # Run by WangDoo on Sun Aug 18 15:49:14 2019 # # from driverUtils import executeOnCaeGraphicsStartup # executeOnCaeGraphicsStartup() #: Executing "onCaeGraphicsStartup()" in the site directory ... from abaqus ...
12,496
6ace18bec836752e71475c542e0d95f728fe5e1d
from peewee import DoesNotExist from playhouse.shortcuts import model_to_dict from main.models.person import Person from ron.web import Controller from ron import request, response class API(Controller): # sets a base route for this controller base_route = '/api' @Controller.route('/', method='GET') ...
12,497
9f8ad9c4bdb0e7739014c42223ce4e629b4ed2be
#!/usr/bin/env python import argparse import ROOT import parametersweep as ps import glob import os import sys import numpy as np import subprocess as sp import utilities as ut import visualize ROOT.gROOT.SetBatch(ROOT.kTRUE) '''Performs the analysis of conductance-based model. Unlike the lifanalysis.py and qifanal...
12,498
8aa77fa63c1d0e6b8f24fe57c4ce18bc8e3f8c16
from util.get_tklogintoken import Teamkitlogintoken from util.get_logincode import qrcode from log.user_log import UserLog class envlogin(object): def __init__(self,driver): log = UserLog() logger = log.get_log() self.driver = driver Teamkitlogin = Teamkitlogintoken() Teamkit...
12,499
8e17bb1d9c5bfe08a049ecab0450bea6c5a7a2f0
''' Com base na tabela abaixo, escreva um programa que leia o código de um item e a quantidade deste item. A seguir, calcule e mostre o valor da conta a pagar. Entrada O arquivo de entrada contém dois valores inteiros correspondentes ao código e à quantidade de um item conforme tabela acima. Saída O arqu...