This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set "VIRTUAL_ENV=%CD%\temp" | |
set "PATH=%VIRTUAL_ENV%\Scripts;%PATH%" | |
set "PROMPT=(VIRTUAL) $P$G%" | |
python -m venv temp | |
pip install -r requirements.txt | |
python main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import xmltodict | |
import json | |
import off | |
FINDINGS_FILE = r'qualys\qualys_hosts.xml' | |
SEVERITIES = ['Low', 'Low', 'Medium', 'Medium', 'High'] | |
CONFIDENCES = { 'Potential': 'Medium', 'Confirmed': 'High' } | |
OFF_FILE = r'offl.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_file(filename, chunk_size=1024*1024, delimiter='\n'): | |
with open(filename, 'r', encoding="utf8") as f: | |
carry_forward = '' | |
chunk = 'INITIALIZED' | |
while len(chunk) > 0: | |
chunk = f.read(chunk_size) | |
augmented_chunk = carry_forward + chunk | |
lines = augmented_chunk.split(delimiter) | |
carry_forward = lines.pop() | |
yield from lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime, re | |
from google.cloud import storage | |
from functools import lru_cache | |
try: | |
import ujson as json | |
except ImportError: | |
import json | |
def select_dictionary_values(dictionary, values): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Threaded Google Cloud Storage Blob reader. | |
Reads a set of blobs parallel to speed up reading. Blobs are | |
read line by line, the usecase this was written for was jsonl | |
files, but any record-per-line format where you don't care | |
about the order of the lines should not have issues. | |
Limited performance testing reading a set of eight blobs, | |
4x 19Mb, 4x 5.4Mb in four threads ran in 20.1% of the time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
B+Tree Code Adapted From: | |
https://gist.github.com/savarin/69acd246302567395f65ad6b97ee503d | |
No explicit license when accessed on 2nd March 2020. | |
Other code: | |
(C) 2021 Justin Joyce. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bar_chars = (' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█') | |
def _draw_histogram(bins): | |
mx = max([v for k,v in bins.items()]) | |
bar_height = (mx / 7) | |
if mx == 0: | |
return ' ' * len(bins) | |
histogram = '' | |
for k,v in bins.items(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt # type:ignore | |
from mabel.data.formats import dictset | |
import numpy as np # type:ignore | |
def bollinger_bands(series, length=20, sigmas=2): | |
index = 0 | |
window = series[0:length] | |
num_vals = len(window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Grammar: | |
======== | |
Expression --> AndTerm { OR AndTerm}+ | |
AndTerm --> Condition { AND Condition}+ | |
Condition --> Terminal (>,<,>=,<=,==) Terminal | (Expression) | |
Terminal --> Number or String or Variable | |
Usage: | |
====== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function colorGradient(colors, fadeFraction) { | |
if (fadeFraction >= 1) { | |
return colors[colors.length - 1] | |
} else if (fadeFraction <= 0) { | |
return colors[0] | |
} | |
let fade = fadeFraction * (colors.length - 1); | |
let interval = Math.trunc(fade); | |
fade = fade - interval |
OlderNewer