This file contains hidden or 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 tqdm import tqdm | |
| from time import sleep | |
| import psutil | |
| with tqdm(total=100, desc='cpu%', position=1) as cpubar, tqdm(total=100, desc='ram%', position=0) as rambar: | |
| while True: | |
| rambar.n=psutil.virtual_memory().percent | |
| cpubar.n=psutil.cpu_percent() | |
| rambar.refresh() | |
| cpubar.refresh() |
This file contains hidden or 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 keras import backend | |
| from keras.backend import numpy_backend | |
| import numpy as np | |
| import tensorflow as tf | |
| class NPTF(object): | |
| def __getattr__(self, name): | |
| if name in dir(numpy_backend) and name in dir(backend): |
This file contains hidden or 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
| var net = require("net"); | |
| process.on("uncaughtException", function(error) { | |
| console.error(error); | |
| }); | |
| if (process.argv.length != 5) { | |
| console.log("usage: %s <localport> <remotehost> <remoteport>", process.argv[1]); | |
| process.exit(); | |
| } |
This file contains hidden or 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 sys | |
| def print_loading_bar(complete, total): | |
| complete_percentage = round((complete/total * 100), 2) | |
| if complete_percentage % 1 == 0: | |
| loading_bar = (['='] * int(complete_percentage)) + (['>']) + (['-'] * (100 - 1 - int(complete_percentage))) | |
| sys.stdout.write("\r" + str(complete_percentage) + "%: "+ ''.join(loading_bar)) | |
| sys.stdout.flush() |
This file contains hidden or 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 classification_report(y_true, y_pred, labels): | |
| '''Similar to the one in sklearn.metrics, reports per classs recall, precision and F1 score''' | |
| y_true = numpy.asarray(y_true).ravel() | |
| y_pred = numpy.asarray(y_pred).ravel() | |
| corrects = Counter(yt for yt, yp in zip(y_true, y_pred) if yt == yp) | |
| y_true_counts = Counter(y_true) | |
| y_pred_counts = Counter(y_pred) | |
| report = ((lab, # label | |
| corrects[i] / max(1, y_true_counts[i]), # recall | |
| corrects[i] / max(1, y_pred_counts[i]), # precision |
This file contains hidden or 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
| sudo apt-get update | |
| sudo apt-get install libxcomposite-dev -y | |
| sudo apt-get install libxcursor1 -y | |
| sudo apt-get install libxi6 libgconf-2-4 -y | |
| sudo apt-get install libxtst6 -y | |
| sudo apt-get install libnss3-dev -y | |
| sudo apt-get install libcups -y | |
| sudo apt-get install libxss1 | |
| sudo apt-get install libxrandr2 |
This file contains hidden or 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
| /** | |
| Enables alphanumeric encoding and decoding of binary data for easy transportation over any medium | |
| Works using the GMP extension to avoid PHP's base_convert loss of preceision when working with large numbers e.g. a 256 bit key | |
| converts the binary to hex then to an arbitrary base, 62 is best in my experince | |
| */ | |
| class BinaryBaseChanger { | |
| const STORAGE_BASE = 16; | |
| public static function changeTo($binary_data, $base_to) { | |
| $hexadecimal = bin2hex($binary_data); |