text string | size int64 | token_count int64 |
|---|---|---|
# sql_injection/bad_authentication.py
from django.conf import settings
from django.contrib.auth.backends import BaseBackend
from django.contrib.auth.hashers import check_password
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
class SettingsBackend(BaseBackend):
"... | 1,529 | 494 |
#!/usr/bin/python3
import time
from web3 import Web3, KeepAliveRPCProvider, IPCProvider
web3 = Web3(KeepAliveRPCProvider(host='127.0.0.1', port='8545'))
# Global Declarations
global true
global false
global hmq_account_0_a
global hmq_account_1_a
global hmq_account_2_a
global hmq_account_3_a
global hmq_accou... | 26,053 | 10,981 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This module contains the result sentences and intents for the English version
of the Say it again skill.
"""
# Result sentences
RESULT_SAY_SORRY = "Sorry, I don't remember what I said. I must have fallen asleep."
RESULT_TEXT_SORRY = "Sorry, I don't remember what you s... | 731 | 278 |
default_app_config = 'authentication.account.apps.AccountConfig'
| 65 | 18 |
#!/usr/bin/python
# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
#
# This utility generates the test data required for the tests contained in test_numpy_returns.py
#
# Also note that this utility requires Numpy which can be installed
# via the command:
# pip insta... | 1,065 | 375 |
# This program assists a technician in the process
# of checking a substance's temperature.
# Nmaed constant to represent the maximum
# temperature.
MAX_TEMP = 102.5
# Get the substance's temperature.
temperature = float(input("Enter the subtance's Celsius temperature: "))
# As long as necessary, instruct ... | 788 | 237 |
from __future__ import absolute_import
from __future__ import unicode_literals
from datetime import date
from django.test.testcases import TestCase
from custom.aaa.dbaccessors import EligibleCoupleQueryHelper
from custom.aaa.models import Child, Woman, WomanHistory
from six.moves import range
class TestEligibleCou... | 9,495 | 3,087 |
import pandas as pd
from dateutil import parser
from pm4pymdl.objects.mdl.exporter import exporter as mdl_exporter
from pm4pymdl.objects.ocel.exporter import exporter as ocel_exporter
from sapextractor.utils.dates import timestamp_column_from_dt_tm
from pandas.core.frame import DataFrame
from sapextractor.database_conn... | 31,473 | 11,143 |
import docx
from tempgen.parsers.parser import AbstractParser
class Parser(AbstractParser):
def paragraph_replace_text(self, paragraph, str, replace_str):
'''
https://github.com/python-openxml/python-docx/issues/30#issuecomment-881106471
'''
count = 0
search_pos = 0
... | 2,676 | 756 |
from django.db import models
from Apt.models import Apt
from Owner.models import Owner
from Renter.models import Renter
class Contract(models.Model):
owner = models.ForeignKey(Owner)
renter = models.ForeignKey(Renter)
apt = models.ForeignKey(Apt)
active = models.BooleanField(default=True)
start_d... | 523 | 168 |
# https://github.com/easy-tensorflow/easy-tensorflow/blob/master/1_TensorFlow_Basics/Tutorials/1_Graph_and_Session.ipynb
#%%
import tensorflow as tf
# tf.disable_eager_execution()
#%%
a = 2
b = 3
c = tf.add(a, b, name='Add')
print(c)
#%%
# to run the graph, put it in a session and run
sess = tf.Session()
print(s... | 466 | 200 |
from kafka import KafkaConsumer
from json import loads
# Define Amazon MSK Brokers
brokers=['<YOUR_MSK_BROKER_1>:9092', '<YOUR_MSK_BROKER_2>:9092']
# Define Kafka topic to be consumed from
kafka_topic='<YOUR_KAFKA_TOPIC>'
# A Kafka client that consumes records from a Kafka cluster
consumer = KafkaConsumer(
... | 639 | 219 |
'''
We are going to learn a latent space and a generative model for the MNIST dataset.
'''
import numpy as np
import torch
import torch.utils
import torch.utils.data
from torch.utils.tensorboard import SummaryWriter
import torchvision
import torch.nn.functional as F
from torchvision import datasets, transforms, utils... | 12,176 | 4,245 |
import unittest
from sqrt import lazy_sqrt, builtin_sqrt, newton_sqrt1
class SqrtTests(unittest.TestCase):
"""obligatory docstring, tests square root functions"""
def test_sqrt9(self):
self.assertEqual(newton_sqrt1(9), 3)
self.assertEqual(lazy_sqrt(9), 3)
def test_sqrt2(self):
... | 513 | 196 |
"""
Optuna example that optimizes a classifier configuration for IMDB movie review dataset.
This script is based on the example of allentune (https://github.com/allenai/allentune).
In this example, we optimize the validation accuracy of sentiment classification using AllenNLP.
Since it is too time-consuming to use the... | 5,202 | 1,833 |
# localimport-v1.7.3-blob-mcw99
import base64 as b, types as t, zlib as z; m=t.ModuleType('localimport');
m.__file__ = __file__; blob=b'\
eJydWUuP20YSvutXEMiBpIfmeOLDAkJo7GaRAMEGORiLPUQrEBTVkumhSKK75Uhj5L+nHv2iSNpyfBiTXY+uqq76qpoqy+qsP\
/SyLIv4t+a5rVT0vleiU1o0XfSDdM8dEf95PFVNm9f96V28KstPQqqm71D4Kf9H/jZeNaehlzqq++Fqn49t... | 4,145 | 2,918 |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def increasingBST(self, root: TreeNode) -> TreeNode:
head = TreeNode(None)
link = head
def dfs(subroot :... | 703 | 187 |
def lex(filename):
f = open(filename, "r")
src = f.read()
f.close()
lines = src.split("\n")
newlines = []
for line in lines:
if len(line) < 1 or line[0] == "#":
continue
newlines.append(line)
tokens = []
for line in newlines:
tokens.append(toke... | 2,715 | 870 |
from flask_bootstrap import Bootstrap
# from pipenv.vendor.dotenv import load_dotenv
from flask import Flask, render_template, request, jsonify, redirect, Response
import os
import thread
import json
import pprint
import pusher
import cv2
import sys
import numpy
import time
import serial
from time_convert import pretty... | 7,678 | 2,431 |
from django.contrib import admin
from .models import MappingData
# Register your models here.
admin.site.register(MappingData)
| 129 | 35 |
class Solution:
def rob(self, nums: List[int]) -> int:
# DP
# dp[i]: the max value until house i
dp = [0] * len(nums)
N = len(nums)
if N == 1: return nums[0]
if N == 2: return max(nums[0], nums[1])
dp[0] = nums[0]
dp[1] = max(nums[0], nums[1])
... | 417 | 182 |
import random
import interfaceUtils
# Add text to a sign
def setSignText(x, y, z, line1 = "", line2 = "", line3 = "", line4 = ""):
l1 = 'Text1:\'{"text":"'+line1+'"}\''
l2 = 'Text2:\'{"text":"'+line2+'"}\''
l3 = 'Text3:\'{"text":"'+line3+'"}\''
l4 = 'Text4:\'{"text":"'+line4+'"}\''
blockNBT = "{"+... | 3,381 | 1,202 |
import pygame
TITLE = 'Gravity'
BLOCK_SIZE = 32
SCREEN_WIDTH = 1024 # 32 * 32
SCREEN_HEIGHT = 576 # 32* 18
SCREEN = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
COLOR_KEY = (200,0,200)
MAX_FPS = 60
def split(frame, x, y, w, h):
img = pygame.Surface([w, h])
img.blit(frame, (0,0), (x... | 351 | 192 |
"""
MIT License
Copyright (c) 2021 Moon Seongmu
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, modify, merge, publish, ... | 1,852 | 637 |
# coding: utf-8
from math import sqrt
from scipy import interpolate
from scipy.spatial import Delaunay
import numpy as np
from numpy.linalg import norm
from naca_4digit_test import Naca_4_digit, Naca_5_digit
from joukowski_wing import joukowski_wing_complex, karman_trefftz_wing_complex
import matplotlib.pyplot as plt
i... | 36,033 | 15,566 |
from slot import *
class Leviathan(DragonBase):
ele = 'water'
att = 125
a = [('a', 0.6)]
class Siren(DragonBase):
ele = 'water'
att = 125
a = [('s', 0.9), ('a', 0.2)]
class Dragonyule_Jeanne(DragonBase):
ele = 'water'
att = 125
a = [('a', 0.30), ('cc', 0.15)]
DJ = Dragonyule_Jeann... | 868 | 413 |
from cmp.regex import Regex
from cmp.nfa_dfa import NFA
import pydot
from pprint import pprint
class GNFA:
def __init__(self, nfa :NFA):
self.nfa = nfa
self.states = nfa.states + 2
self.start = 0
self.finals = [nfa.states + 1]
self.transitions = { state: {} for state in rang... | 4,238 | 1,298 |
# Copyright 2013 Nebula Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | 4,203 | 1,297 |
class Queue(object):
def __init__(self):
self.items = []
def isEmpty(self):
return len(self.items) == 0
def enqueue(self, itemToAdd):
self.items.insert(0, itemToAdd)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items)
| 312 | 106 |
# -*- coding: utf-8 -*-
import argparse
import os
import pandas as pd
from sklearn.model_selection import train_test_split
# load data and tag lines with source characters' names
def load_data(args):
data = pd.read_csv(args.file_path)
data['id:data'] = data[args.id_colname]+':'+data[args.data_colname]
return dat... | 2,557 | 859 |
from tkinter import *
color = 'black'
def red():
global color
color = 'red'
def orange():
global color
color = 'orange'
def yellow():
global color
color = 'yellow'
def green():
global color
color = 'lime green'
def lime_green():
global color
color = 'green'
def ... | 2,445 | 923 |
from tensorflow.keras import backend as K
EPSILON = K.epsilon()
def accuracy(y_true, y_pred):
[tp, tn, fp, fn] = _analyse_data(y_true, y_pred)
return K.mean((tp + tn) / (tp + tn + fp + fn + EPSILON))
def specificity(y_true, y_pred):
[_, tn, fp, _] = _analyse_data(y_true, y_pred)
return K.mean(tn / ... | 1,080 | 473 |
import os
from prettyconf.loaders import EnvFile
from .base import BaseTestCase
class EnvFileTestCase(BaseTestCase):
def setUp(self):
super(EnvFileTestCase, self).setUp()
self.envfile = os.path.join(self.test_files_path, "envfile")
def test_basic_config_object(self):
config = EnvFile... | 2,598 | 895 |
from .test_views import * # NOQA
from .test_email import * # NOQA
| 68 | 27 |
#Imports
from bisection import *
#Constants
LowerLimit = 0.0
UpperLimit = 10.0
def f(x):
return (x)**2
Root = bisection(f,LowerLimit,UpperLimit)
print Root
| 163 | 67 |
#!/usr/bin/env python
from Tkinter import *
import tkMessageBox
import tkSimpleDialog
import struct
import sys, glob # for listing serial ports
import rospy
from roomba_control.srv import *
send_mode = None
def create_control_service_client(x):
global send_mode
try:
if send_mode == None:
... | 5,622 | 1,689 |
alpha_numbers = [
{
"alpha": "one",
"number": 1
},
{
"alpha": "two",
"number": 2
},
{
"alpha": "three",
"number": 3
},
{
"alpha": "four",
"number": 4
},
{
"alpha": "five",
"number": 5
},
{
... | 1,248 | 460 |
#!/usr/bin/env python
"""
Merge pdf files into a single file.
EXAMPLES
pdfmerge3 -o output.pdf
Merges all pdf files from the current folder in lexicographic order and put the result in output.pdf
pdfmerge3 -o output.pdf file1.pdf file2.pdf file3.pdf
Merges file1.pdf, file2.pdf, file3.pdf (in t... | 2,510 | 775 |
"""
Copyright (c) 2022 Huawei Technologies Co.,Ltd.
openGauss is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, W... | 2,685 | 1,025 |
import json
import acwingcli.actions as actions
import sys
import os
import acwingcli.commandline_writer as cmdwrite
# import acwingcli
import argparse
import subprocess
import acwingcli.update as update
import os
import websocket
import json
import threading
import psutil
import acwingcli.utils as utils
import ti... | 17,858 | 5,347 |
import cv2
import numpy as np
import json
import os
import re
import yolo.darknet.darknet as darknet
import haversine
import imutils as imu
from tracker.sort import *
#--------------------------------------------
'''
res_path - path to:
- calibration.npy
- perspective_matrix.npy
- mask.png
- sides.png... | 9,760 | 3,707 |
# Imports ott.csv, synonyms.csv, tree_otu_assoc.csv into the database
# Assumes database already set up. This happends either in initializedb.py
# if running pyramid app or setup_db.py for testing (both in
# this same directory)
import datetime as dt
import argparse
import psycopg2 as psy
import os
# other databa... | 1,975 | 617 |
# Standard Libraries
import logging
from datetime import date, timedelta
# Django Imports
from django.conf import settings
from django.db.models import Q
from django.test import Client, TestCase
from django.test.utils import override_settings
from django.urls import reverse
# Ghostwriter Libraries
from ghostwriter.fa... | 15,679 | 4,904 |
from gensim.models.ldamodel import LdaModel as ldamodel
from gensim import corpora
import pprint
from gensim.test.utils import datapath
import pyLDAvis
import pyLDAvis.gensim
from clean_data import clean as clean
def train_model(texts):
# turn our tokenized documents into a id <-> term dictionary
dictionary =... | 1,400 | 477 |
#!/usr/bin/env python
from selenium import selenium
import unittest, time, re
class Login_Unfollow_Follow_SendMessage_ReceiveMessage(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("test-browser-linux-master", 4444, "IE on Windows", "http://test.civicboom... | 3,480 | 1,130 |
"""Security related decorators"""
import logging
import urlparse
from decorator import decorator
try:
import webhelpers.html.secure_form as secure_form
except ImportError:
import webhelpers.pylonslib.secure_form as secure_form
from pylons.controllers.util import abort, redirect
from pylons.decorators.util imp... | 3,681 | 1,068 |
import os
import glob
seq_id = 'S001'
# cam_id = 'C001'
cam_id = '*'
pid = 'P001'
rid = 'R001'
aid = 'A007'
data_root = './data/NTU'
seq_path = '{seq_id}{cam_id}{pid}{rid}{aid}_rgb/img_00001.jpg'.format(**locals())
seq_path = os.path.join(data_root, seq_path)
print(seq_path)
def get_images(path):
files = glob... | 393 | 187 |
#
# Copyright 2020 IBM Corp. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | 6,876 | 1,860 |
import requests
from collections2 import Counter
import simplejson as json
import re
books = json.load(open("books2.json"))
color_stem = json.load(open("stemmizer_kolory.json"))
colors = json.load(open("kolory_nowe.json"))
def root_word(word, stem_dict):
if word in stem_dict:
return stem_dict[word]
... | 1,760 | 569 |
from django.contrib.contenttypes.models import ContentType
from django import forms
from . import models
class PauseForm(forms.ModelForm):
class Meta:
model = models.Pause
fields = ('reason',)
def clean(self):
cleaned_data = super(PauseForm, self).clean()
if not self.instanc... | 1,259 | 340 |
import discord
from discord.ext import commands
import facebook
from discord.ext.commands import Bot
Client = discord.Client()
bot = commands.Bot(command_prefix = "/") #Tells what the prefix before every command should be.
@bot.event
async def on_ready():
'''
Function to just tell us that the
bot is not active. Ev... | 2,047 | 667 |
# -*- coding: utf-8 -*-
# Author: XuMing <xuming624@qq.com>
# Brief:
import click
@click.command()
@click.option('--count', default=1, help="num")
@click.option('--rate', type=float, help='rate')
@click.option('--gender', type=click.Choice(['man', 'woman']), default='man', help='select sex')
@click.option('--center'... | 561 | 205 |
# -*- coding: utf-8 -*-
"""
Functions for fetching datasets from the internet
"""
from collections import namedtuple
import os.path as op
from .osf import _get_data_dir, _get_dataset_info
from .utils import _fetch_files
ANNOT = namedtuple('Surface', ('lh', 'rh'))
def fetch_fsaverage(version='fsaverage', data_dir=N... | 2,780 | 871 |
#
# Copyright (C) 2002-2008 greg Landrum and Rational Discovery LLC
#
""" unit tests for the model and descriptor packager """
import os
import random
import unittest
from xml.dom import minidom
from xml.etree import ElementTree as ET
from rdkit import Chem
from rdkit import RDConfig
from rdkit.Chem import Descripto... | 6,798 | 2,297 |
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#This software is distributed under the Creative Commons license (CC0) version 1.0. A copy of this license should have been distributed with this software.
#The license can also be read online: <https://creativecommons.org/publicdomain/zero/1.0/>. If this online license dif... | 9,545 | 2,998 |
def square_digits_sequence(n):
s = set()
while n not in s:
s.add(n)
n = sum(int(d)**2 for d in str(n))
return len(s)+1
| 147 | 61 |
#NPC definitions with AI overrides per NPC, as required.
from forge.blade.entity import NPC
from forge.blade.item import Item, RawMeat, Sword
from forge.blade.lib import AI
from forge.blade.lib.Enums import Material
from forge.blade.modules import DropTable, Skill
class Chicken(NPC.Passive):
def __init__(self, po... | 1,466 | 563 |
"""Перечисления"""
from enum import Enum, unique
from django.utils.translation import gettext_lazy as _
from etc.choices import ChoicesEnumMixin, get_choices
@unique
class Gender(ChoicesEnumMixin, Enum):
"""
Пол
"""
FEMALE = 1, _("Женский")
MALE = 2, _("Мужской")
@unique
class DisabilityGroup(C... | 1,638 | 706 |
'''
Two finite, strictly increasing, integer sequences are given.
Any common integer between the two sequences constitute an intersection point.
Take for example the following two sequences where intersection points are printed in bold:
First= 3 5 7 9 20 25 30 40 55 56 57 60 62
Second= 1 4 7 11 14 25 44 47 5... | 2,168 | 855 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
import collections.abc
import re
from dataclasses import fields
from enum import Enum, auto
from typing import (
Callable,
... | 40,724 | 11,715 |
# coding:utf8
import torch
from torch import nn, optim # nn 神经网络模块 optim优化函数模块
from torch.utils.data import DataLoader
from torch.autograd import Variable
from torchvision import transforms, datasets
from visdom import Visdom # 可视化处理模块
import time
import numpy as np
# 可视化app
viz = Visdom()
# 超参数
BATCH_SIZE = 40
LR ... | 4,911 | 2,112 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-26 17:23
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
... | 1,783 | 570 |
#Written by Thy H. Nguyen
import turtle
from math import pi
import random
def main():
wns = turtle.Screen()
def banh_xe(bichthuy):
bichthuy.shape("circle")
bichthuy.shapesize(0.1,0.1)
bichthuy.speed(10)
bichthuy.pensize(6)
def ve_hinh_tron(number,cao):
fo... | 3,737 | 1,712 |
# Generated by Django 3.1.7 on 2021-04-27 13:05
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('learning', '0024_tutoria... | 1,242 | 394 |
number = input()
def get_sums(type_numbers, number):
result = 0
if type_numbers == "even":
result = sum(list(map(int, filter(lambda x: int(x) % 2 == 0, number))))
elif type_numbers == "odd":
result = sum(list(map(int, filter(lambda x: int(x) % 2 == 1, number))))
return result
evens_... | 442 | 169 |
"""
Iterative versions of the tree traversals
TODO: Using a set defeats the purpose of iteration (reducing the space usage)
"""
class BinaryTree(object):
"""Object represents a binary tree"""
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def in_orde... | 1,955 | 594 |
#! usr/bin/python3.6
"""
Module initially auto generated using V5Automation files from CATIA V5 R28 on 2020-09-25 14:34:21.593357
.. warning::
The notes denoted "CAA V5 Visual Basic Help" are to be used as reference only.
They are there as a guide as to how the visual basic / catscript function... | 11,587 | 3,411 |
'''
Как известно, два наиболее распространённых формата записи даты — это европейский (сначала день, потом месяц, потом год) и американски (сначала месяц, потом день, потом год). Системный администратор поменял дату на одном из бэкапов и сейчас хочет вернуть дату обратно. Но он не проверил, в каком формате дата использ... | 1,257 | 512 |
from brainrender import settings
settings.INTERACTIVE = False
settings.OFFSCREEN = True
settings.DEFAULT_ATLAS = "allen_mouse_100um"
from vedo import settings as vsettings
vsettings.useDepthPeeling = False
vsettings.screenshotTransparentBackground = False # vedo for transparent bg
vsettings.useFXAA = True # This n... | 356 | 104 |
import _sk_fail; _sk_fail._("symbol")
| 38 | 16 |
import os
(basepath, _) = os.path.split(os.path.abspath(__file__))
warn_for_each_unoptimized_component = False
try:
from distutils.core import run_setup
# Run the setup script in the sandbox, so that it doesn't complain about unknown args when launched through nose
run_setup(basepath + "/compile.py")
... | 593 | 174 |
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
from .. import ... | 5,618 | 1,724 |
# -*- coding: utf-8 -*-
"""
vitals.models.users
~~~~~~~~~~~~~~~~~~~
:author: Dave Caraway
:copyright: © 2014-2015, Fog Mine LLC
:license: Proprietary, see LICENSE for more details.
"""
import base64
import os
from flask.ext.security import RoleMixin, UserMixin
from ..framework.sql import (
db... | 3,035 | 1,108 |
from transforms3d.taitbryan import quat2euler
import matplotlib.pyplot as plt
import numpy as np
from util import X, Xe
class Data(object):
"""
Data object for sim data
"""
def __init__(self):
self.x = []
self.J = []
self.K_mag = []
self.K_gps = []
self.K_accel... | 7,273 | 2,946 |
from django.conf import settings
from django.http import HttpResponseRedirect
def ssl_required(view_func):
def _wrapped_view_func(request, *args, **kwargs):
if (hasattr(settings, 'GUI_SSL_REDIRECT') and settings.GUI_SSL_REDIRECT
and request and not request.is_secure()):
request... | 580 | 170 |
import anvil.facebook.auth
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
import anvil.js
def set_theme(theme_map):
css = themed_css
for name, value in theme_map.items():
css = css.replace(f"%color:{name}%", value)
anvil.js.call_js("setThemeCss", css)
# This is t... | 1,874 | 737 |
#
# Copyright (c) SAS Institute Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | 1,098 | 334 |
from django.conf.urls import url, include
from django.views.decorators.csrf import csrf_exempt
from global_finprint.annotation.views.assignment import VideoAutoAssignView, ManageAssignmentView, ObservationListView, \
AssignmentListView, AssignmentListTbodyView, AssignmentModalBodyView, UnassignModalBodyView, Assig... | 2,582 | 897 |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from pytext.common.constants import Stage
from pytext.data import Data, RawBatcher, types
from pytext.data.sources.data_source import SafeFileWrapper
from pytext.data.sources.tsv import TSVDataSource
from pyt... | 3,512 | 1,116 |
import os
from itertools import chain
from hashlib import sha256
class DuplicatesRemover(object):
def __init__(self, search_path: str, file_type: str):
self.path = search_path
self.f_type = file_type
def find_duplicates(self):
file_paths = self.collect_file_paths()
files_size... | 1,765 | 577 |
def convert_iterable_to_absolute(nums_list):
result = list(map(lambda x: abs(x), nums_list))
return result
nums = map(lambda el: float(el), input().split())
print(convert_iterable_to_absolute(nums))
# def convert_iterable_to_absolute(nums_list):
# result = [abs(el) for el in nums_list]
# return resu... | 415 | 152 |
# -*- coding: utf-8 -*-
"""
Created on Mon May 14 12:20:07 2018
@author: 1172334950C
"""
class Question(object):
"""
This is used as the structure to format questions and retrieve those properties for our tests
number : string
Display element number within the Test Container
questi... | 2,686 | 841 |
from .env_viewer import EnvViewer
from .examine_env import examine_env
from .flexible_load import load_env
| 107 | 36 |
# coding=utf-8
"""
Tests for deepreg/model/network/util
"""
import pytest
import tensorflow as tf
import deepreg.model.network.util as util
from deepreg.model.backbone import global_net, local_net, u_net
def test_wrong_inputs():
"""
Function to test wrong input types passed to build backbone func
"""
... | 6,095 | 2,046 |
from . import util as test_util
init = test_util.import_importlib('importlib')
import sys
import unittest
import weakref
from test import support
try:
import threading
except ImportError:
threading = None
else:
from test import lock_tests
if threading is not None:
class ModuleLockAsRLockTests:
... | 4,841 | 1,478 |
#!/usr/bin/python3
'''
Abstract:
This is a code for test AI with given sed data.
Usage:
sed_test_AI_64_8.py [source] [id] [directory] [AI]
Editor and Practicer:
Jacob975
##################################
# Python3 #
# This code is made in python3 #
################################... | 9,053 | 2,904 |
from PyTib.common import open_file, write_file
import os
monlam = open_file('input/monlam1_total_corrected.txt').split('\n')
monlam_entries = [a.split(' | ')[0] for a in monlam]
monlam_entries = [a.rstrip('་') for a in monlam_entries]
monlam_dict = {a: True for a in monlam_entries}
non_monlam = {}
in_path = 'input/us... | 677 | 255 |
import typing
from starlette.responses import Response, HTMLResponse
from starlette.templating import _TemplateResponse
try:
import htmlmin
except ImportError:
htmlmin = None
def setup_html_minification(
response_classes=[HTMLResponse, _TemplateResponse], **minification_config
):
assert htmlmin is n... | 801 | 216 |
from lib.action import BaseAction
class SetStateAction(BaseAction):
def run(self, item, state):
self._put(item, state)
return {'status': 'ok'}
| 165 | 50 |
"""
Utility scripts for images
Author: Hieu Le
License: MIT
Copyright: 2018-2019
"""
import os
import numpy as np
from PIL import Image
from scipy import misc
#AT this point, I don't even know what is this file about. junk codes assembly.
def list_to_file(f,list):
file = open(f,"w")
for i in list:
file.... | 10,711 | 5,105 |
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{ openwisp2_secret_key }}'
# SECURITY WARNING: don't run with debug turned on in p... | 6,024 | 2,060 |
# Generated by Django 2.2.6 on 2019-10-24 22:23
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),
]
ope... | 1,056 | 302 |
#
# PySNMP MIB module TOKEN-RING-RMON-MIB (http://pysnmp.sf.net)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/TOKEN-RING-RMON-MIB
# Produced by pysmi-0.0.7 at Fri Feb 17 12:48:35 2017
# On host 5641388e757d platform Linux version 4.4.0-62-generic by user root
# Using Python version 2.7.13 (default, Dec 22 2016, 09:2... | 36,685 | 15,857 |
from django.db import models
from django.utils import timezone
"""
Model for client reviews
"""
class Review(models.Model):
job_title = models.CharField(max_length=200)
review_title = models.CharField(max_length=200)
description = models.TextField()
created_date = models.DateTimeField(auto_now_add=True... | 554 | 169 |
import json
from output.slack_output_data import SlackOutputData
from interface.driver.slack_driver import SlackDriver
from dataclasses import asdict
import requests
from util.logger import AppLog
_logger = AppLog(__name__)
class SlackDriverImpl(SlackDriver):
def __init__(self, url: str):
self.url = url
... | 517 | 159 |
"""Default configuration when no ENV variables are set."""
CLOUDFLARE_BYPASS_URL = "http://localhost:8191/v1"
TRACK_COIN = "dogecoin"
TRACK_ADDRESS = "DRSqEwcnJX3GZWH9Twtwk8D5ewqdJzi13k"
| 188 | 89 |
##############################################################################
#
# Copyright (c) 2009 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOF... | 1,841 | 580 |
import hashlib
import logging
import os
import requests
import time
from VirusTotalAVBot import VT_API
logger = logging.getLogger("VirusTotal Methods")
api_base_url = "https://www.virustotal.com/api/v3"
header = {'x-apikey': VT_API}
def vthash(filehash: str):
"""Returns the analysis data class for a file in Vir... | 5,407 | 1,721 |
# Generated by Django 3.1.5 on 2021-03-28 13:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("keyboard", "0003_algorithmmodelinst"),
]
operations = [
migrations.AddField(
model_name="algorithmmodelinst",
name="... | 621 | 199 |
from .mapper import ApiResponse, ApiResponseInterface
from .mapper.types import Timestamp, AnyType
__all__ = ['ProfileNoticeResponse']
class ProfileNoticeResponseInterface(ApiResponseInterface):
has_change_password_megaphone: bool
class ProfileNoticeResponse(ApiResponse, ProfileNoticeResponseInterface):
pa... | 323 | 87 |