Posts

[How To] Run HELR (Homomorphic Encryption Logistic Regression) in macOS

Image
HELR is a software project for performing a logistic regression training on encrypted data (Secure Logistic Regression based on Homomorphic Encryption: Design and Evaluation ( https://medinform.jmir.org/2018/2/e19/ )). Step 1: brew install GMP Step 2: brew install NTL Step 3: git clone  https://github.com/K-miran/HELR.git Step 4: cd HELR

[How To] Print with staples in macOS

Image
Step 1/3: If you have opened a PDF from Google Chrome, go to the Print dialogue box and click on the link "Print using system dialog.." Step 2/3: Click on the dropdown menu that says "Media & Quality" and change it to "Finishing Options" Step 3/3: Click on Staple dropdown options and select the number of staples and the orientation where you want the pages to be stapled.

[Solved] Install matplotlib / basemap in macOS

Image
I have been trying to import the basemap module in my python script using " from mpl_toolkits.basemap import Basemap " but with no luck! I ran into issues while installing basemap with pip. Excerpt from the error:    Installing build dependencies ... error    error :  subprocess-exited-with-error       ×   pip subprocess to install build dependencies  did not run successfully.    │  exit code:  1    ╰─>   [552 lines of output]         Ignoring numpy: markers 'python_version >= "3.10"' don't match your environment         Ignoring numpy: markers 'python_version == "2.6" or (python_version >= "3.2" and python_version <= "3.3")' don't match your environment         Ignoring cython: markers 'python_version == "3.2"' don't match your environment ... ...             note: This error ...

[How To] Run Bidirectional LSTM in Python

Image
 This is a sample program to run bidirectional LSTM in Python using Tensorflow. The complete code repository is available at  https://github.com/devharsh/LSTM-Demo . Code: #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 1 13:34:00 2022. @author: devharsh """ import matplotlib.pyplot as plt from pandas import read_csv from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder from tensorflow import keras from tensorflow.keras import layers inputs = keras.Input(shape=(None,), dtype="float64") xem = layers.Embedding(101, 128)(inputs) xl1 = layers.Bidirectional(layers.LSTM(64, return_sequences=True))(xem) xl2 = layers.Bidirectional(layers.LSTM(64))(xl1) outputs = layers.Dense(1, activation="sigmoid")(xl2) model = keras.Model(inputs, outputs) model.summary()

[Solved] Fix upgrade errors in Kali Linux

Image
If you face errors from powershell-empire while upgrading Kali Linux, upgrade the pip packages for Flask and aiohttp with root privileges. Error - 1: Traceback (most recent call last):   File "/usr/share/powershell-empire/empire.py", line 11, in <module>     import empire.server.server as server   File "/usr/share/powershell-empire/empire/server/server.py", line 23, in <module>     import flask   File "/usr/lib/python3/dist-packages/flask/__init__.py", line 19, in <module>     from . import json   File "/usr/lib/python3/dist-packages/flask/json/__init__.py", line 15, in <module>     from itsdangerous import json as _json ImportError: cannot import name 'json' from 'itsdangerous' (/usr/lib/python3/dist-packages/itsdangerous/__init__.py) dpkg: error processing package powershell-empire (--configure):  installed powershell-empire package post-installation script subprocess returned error exit status...

[How To] Remove conda from macOS

Image
Follow these steps from a Terminal window to remove conda in macOS: conda install anaconda-clean anaconda-clean --yes rm -rf /Users/devharsh/.anaconda_backup/ (Replace "devharsh" with user directory) rm -rf ~/anaconda3 rm -rf ~/anaconda2 rm -rf ~/.condarc ~/.conda ~/.continuum sudo rm ~/.zshrc brew reinstall python /usr/local/opt/python@3.9/bin/python3.9 -m pip install --upgrade pip pip3 list These steps fully remove a conda or Anaconda installation from macOS, first using anaconda-clean to clear configuration and then deleting the install directories and shell hooks. A clean removal is the safest way to recover from a broken environment or to switch package managers, since leftover paths in the shell profile often cause confusing errors afterward.

[How To] Draw Vectors in Python

Image
import numpy as np import matplotlib.pyplot as plt x_pos = np.linspace(0,5,10) y_pos = np.linspace(0,10,10) x_dir = y_dir = np.zeros((10,10)) plt.quiver(x_pos, y_pos, x_dir, y_dir, scale=1)