Posts

Showing posts from 2022

error: package javax.xml.bind does not exist

Image
Try these fixes if you run into issues with javax.xml.bind, which was deprecated and later removed from Java. ---------------------------------------------------------------------- Solution 1 => Switch to Java 8 Please install the latest JDK 8 from oracle for your OS - https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html . If you have the latest Java (version 11/14) installed, you need to also install JDK 8 and use it to run the java code. Switch to JDK 8 on Linux / macOS: - Check current java version % java --version , if it is JDK 11/14 then install JDK 8 - Check all JDK versions installed % /usr/libexec/java_home -V - Edit bash profile % nano ~/.bash_profile export JAVA_HOME_8=$(/usr/libexec/java_home -v1.8) export JAVA_HOME_11=$(/usr/libexec/java_home -v11) export JAVA_HOME_14=$(/usr/libexec/java_home -v14)

[Fix] Free up disk space in macOS

Image
This hack worked for me when I was running low on disk space on my MacBook Pro, stopping me from upgrading to the latest version of Xcode and macOS. Run these quick and easy commands from the macOS terminal to clean system data over 100 GB . rm -rf Library/Logs rm -rf Library/Caches rm -rf System/Library/Caches rm -rf ~/Library/Logs rm -rf ~/Library/Caches

List Supported CPU Instructions Set [Solved]

Image
You may find these terminal commands useful if you are looking for ways to list all supported instructions set by the CPU on a macOS machine. For instance, you can check for Intel® Streaming SIMD Extensions 4 ( Intel® SSE4) or Intel® Software Guard Extensions (Intel® SGX) features for your device. % sysctl -n "machdep.cpu.brand_string" Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz % sysctl -a | grep machdep.cpu.features machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C % sysctl -a | grep machdep.cpu.leaf7_features machdep.cpu.leaf7_features: RDWRFSGS TSC_THREAD_OFFSET SGX BMI1 AVX2 SMEP BMI2 ERMS INVPCID FPU_CSDS MPX RDSEED ADX SMAP CLFSOPT IPT MDCLEAR TSXFA IBRS STIBP L1DF ACAPMSR SSBD % sysctl -a | grep AVX2 machdep.cpu.leaf7_feature...

Delete files from Git repo and history

Image
Follow these steps to delete single or multiple files from your Git repository and prune it from history. You should also add the file(s) to .gitignore (Step 5) to avoid committing the same files to your repo again in the future. git  clone <repo-path> git  rm  file1 file2 git  filter-repo --force --invert-paths --path file1 git  filter-repo --force --invert-paths --path file2 nano   .gitignore   git  add  . git  commit -m  "deleted file1 file2" git  remote add origin <repo-path> git  remote -v git  push origin --force --all git  push origin --force --tags

[How To] Install HElib on macOS

Image
HElib is an open-source (Apache License v2.0) software library that implements homomorphic encryption (HE). Currently, available schemes are the implementations of the Brakerski-Gentry-Vaikuntanathan (BGV) scheme and the Approximate Number scheme of Cheon-Kim-Kim-Song (CKKS), along with many optimizations to make homomorphic evaluation runs faster, focusing mostly on effective use of the Smart-Vercauteren ciphertext packing techniques and the Gentry-Halevi-Smart optimizations. To install HElib on macOS , follow these steps: brew update && brew upgrade && brew autoremove && brew cleanup cd Downloads/ git clone https://github.com/homenc/HElib.git Cloning into 'HElib'... remote: Enumerating objects: 14133, done. remote: Counting objects: 100% (292/292), done. remote: Compressing objects: 100% (211/211), done. remote: Total 14133 (delta 127), reused 172 (delta 54), pack-reused 13841 Receiving objects: 100% (14133/14133), 13.04 MiB | 5.81 MiB/s, done....

[How To] Run Jupyter Lab from a Remote server

Image
Step 1: Launch Jupyter Lab from the Remote server with the command $ jupyter-lab --no-browser --ip="0.0.0.0" [I 2022-11-24 15:03:36.648 ServerApp] jupyterlab | extension was successfully linked. [I 2022-11-24 15:03:36.711 ServerApp] nbclassic | extension was successfully linked. [I 2022-11-24 15:03:37.783 ServerApp] notebook_shim | extension was successfully linked. [I 2022-11-24 15:03:37.910 ServerApp] notebook_shim | extension was successfully loaded. [I 2022-11-24 15:03:37.917 LabApp] JupyterLab extension loaded from /home/pi/.local/lib/python3.9/site-packages/jupyterlab [I 2022-11-24 15:03:37.917 LabApp] JupyterLab application directory is /home/pi/.local/share/jupyter/lab [I 2022-11-24 15:03:37.941 ServerApp] jupyterlab | extension was successfully loaded. [I 2022-11-24 15:03:37.963 ServerApp] nbclassic | extension was successfully loaded. [I 2022-11-24 15:03:37.965 ServerApp] Serving notebooks from local directory: /home/pi/Documents Step 2: Open a browser window from y...

[How To] Install SEAL Python on a Raspberry Pi

Image
Follow this tutorial to install Microsoft SEAL 4.X for Python on a Raspberry Pi 3 device. You can follow the same commands to install it on any other Linux machine. I have copied the output for each command for your reference. $ uname -a Linux raspberrypi 5.15.76-v7+ #1597 SMP Fri Nov 4 12:13:17 GMT 2022 armv7l GNU/Linux $ sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove Reading package lists... Done Building dependency tree... Done Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. $ sudo apt-get install git build-essential cmake python3 python3-dev python3-pip Reading package lists... Done Building dependency tree... Done Reading state information... Done build-essential is already the newest version (12.9). git is already the newest version (1:2.30.2-1). python3 is already the newest version (3.9.2-3). python3-dev is already the newest version (3.9.2-3). python3-dev set to manually installed. cmake is alre...

Top 7 Free Cyber Security Newsletters

Image
The following is the list of the 7 free, most popular cyber security newsletters: The Hacker News SecurityWeek CSO SANS Newsletters WeLiveSecurity by ESET Cybersecurity Ventures Naked Security Following a few good newsletters is one of the easiest ways to keep up with security, where new vulnerabilities, breaches, and tools appear constantly. The roundup above mixes breaking news, vendor research, and practitioner commentary. Skimming one or two each week is usually enough to stay aware of major incidents and trends without being overwhelmed. Every source listed is free to subscribe to.

[Solved] Error: No such keg: /usr/local/Cellar/gcc

Image
If you are facing issues with Homebrew while installing or updating the GCC package (or any other module), follow this guide. The error occurred for me recently during my periodic homebrew updates on my MacBook Pro. devharsh@Devharshs-MacBook-Pro ~ % brew update && brew upgrade && brew cleanup                                                           Already up-to-date. Warning:  Skipping gcc: most recent version 12.1.0 not installed For some reason, I had a warning flashing up for GCC. So I tried to install the missing version. devharsh@Devharshs-MacBook-Pro ~ % brew install -f gcc@12 Error:  gcc 12.1.0_1 is already installed To install 12.1.0, first run:    brew unlink gcc Which unsurprisingly did not work, so I tried unlinking it.  devharsh@Devharshs-MacBook-Pro ~ % brew unlink gcc Error:  No su...

[How To] Upgrade to Python 3.9 in Google Colab

Image
Google Colaboratory , or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser and is especially well suited to machine learning, data analysis, and education. More technically, Colab is a hosted Jupyter notebook service that requires no setup to use while providing access free of charge to computing resources, including GPUs. By default, it starts the runtime with Python version 3.7. If you want to upgrade the version in your current notebook, then follow these steps in the given order: 1) !python --version Python 3.7.13 2) !sudo apt-get update -y Get:1 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic InRelease [15.9 kB] Hit:2 http://ppa.launchpad.net/cran/libgit2/ubuntu bionic InRelease Get:3 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ InRelease [3,626 B] Get:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic InRelease [15.9 kB] Hit:5 http://ppa.launchpad.net/graphics-d...

[How To] Install Pyfhel in macOS

Image
  Tested on Intel-based (x86_64) MacBook, not tested on M1/M2 (ARM) Apple Clang does not support  -fopenmp  and  -libseal , use GCC or CLANG % git clone --recursive https://github.com/ibarrond/Pyfhel 2.a) create  requirements.txt  file "setuptools<=60.9", "wheel", "cython>=3.0.0a9", "numpy>=1.20", "cmake>=3.15", "toml>=0.10" 2.b)  % pip3 install -r requirements.txt edit  pyproject.toml Line #111 [ Afhel ] extra_compile_args {Darwin = ["-std=c++17","-O3","-fopenmp"]}, extra_link_args {Darwin = ["-fopenmp","-dynamiclib"]}, Repeat the above for [ CYTHON EXTENSIONS ]

[Solved] Jupyter notebook raises Module Not Found Error

Image
I recently ran into issues on my MacBook with Jupyter notebooks, where it could not find any packages and was throwing "ModuleNotFoundError: No module named ****" for several libraries. I already had these packages installed but somehow Jupyter python kernel could not find it. I tried to install these packages in the notebook cells with the command !pip install **** but this did not help either. I also tried %brew reinstall jupyterlab and that did not work as well. Finally, I found a fix. Solution: Step-1: Install/upgrade jupyter packages: % pip3 install --upgrade jupyter notebook jupyterlab Step-2: Run jupyter with this command: % jupyter-lab

[Solved] ld: library not found for -lntl

Image
NTL: A Library for doing Number Theory NTL is a high-performance, portable C++ library providing data structures and algorithms for manipulating signed, arbitrary length integers and for vectors, matrices, and polynomials over the integers and over finite fields. You might face a linking error with NTL in macOS using the Apple Clang compiler: % make                                 Consolidate compiler generated dependencies of target degrees [ 25%] Linking CXX executable degrees ld: library not found for -lntl clang: error: linker command failed with exit code 1 (use -v to see invocation) Solution: % brew install NTL % export LIBRARY_PATH=/usr/local/lib % make This linker error means the build was told to link NTL, the C++ number theory library, but cannot find it. NTL provides arbitrary length integers and operations on polynomials and matrices over rings and finite fields. Installing NTL and poin...

[How To] Run MinimaxComp_degrees in macOS

Image
MinimaxComp_degrees This algorithm finds optimized degrees for comparison/max/ReLU algorithms using minimax composite polynomial on the RNS-CKKS scheme, which was proposed in https://ieeexplore.ieee.org/document/9517029 and https://eprint.iacr.org/2021/1215 . How to run on macOS using the Apple Clang compiler: 1. % brew install NTL 2. % export LIBRARY_PATH=/usr/local/lib 3. % git clone  https://github.com/eslee3209/MinimaxComp_degrees 4. % cd MinimaxComp_degrees 5. % cmake -S . -B build 6. % cd build 7. % make 8. % ./degrees Output: ------------------------------------ alpha: 20 epsilon: 0.2002716064453125e-4 mintime: 162 depth: 22 0.39825903512705770933e-4 7 13 15 15 59   This guide runs MinimaxComp_degrees on macOS, an algorithm that finds optimized polynomial degrees for comparison, max, and ReLU operations under the RNS-CKKS homomorphic encryption scheme, based on the referenced research. CKKS can only evaluate polynomials on encrypted data, so non-polyn...

[How To] Install CRC RevEng on macOS

Image
CRC RevEng CRC RevEng is a portable, arbitrary-precision CRC calculator and algorithm finder. It calculates CRCs using any 111 preset algorithms or a user-specified algorithm to any width. It calculates reversed CRCs to give the bit pattern that produces a desired forward CRC. CRC RevEng also reverse-engineers any CRC algorithm from good, correctly formatted message-CRC pairs and optional known parameters. It comprises powerful input interpretation options. Installation instructions for macOS: 1. Download reveng from SourceForge:  https://sourceforge.net/projects/reveng/files/ 2. Unzip the downloaded reveng zip file 3. % cd Downloads/reveng-3.0.3 4. % make gcc -O3 -Wall -ansi -fomit-frame-pointer -DPRESETS -DBMPTST -o bmptst bmpbit.c ( ./bmptst && touch bmptst ) || ( rm bmptst bmptst.exe && false ) reveng: configuration fault.   Update config.h with these definitions and recompile: #define BMP_BIT   64 #define BMP_SUB   32 rm: bmptst.exe: No suc...

Top 13 Free Email Newsletters

Image
The following is the list of the 13 free most popular newsletters: 1440 Below the Fold Benedict’s Newsletter Brain Pickings Morning Brew NextDraft NPR’s Life Kit NYTimes Morning Briefing The Elevator The GIST The Hustle The Lefsetz Letter The Moz Top Ten This is a curated list of free newsletters spanning general news, technology, and culture, for anyone who wants a quick daily or weekly digest in their inbox. A good newsletter saves time by summarizing what matters so you do not have to chase a dozen sites. Every option listed is free to subscribe to.

[Solved] frame.append method is deprecated and will be removed from pandas

Image
Code: all_results = all_results.append(current_result) Error: /var/folders/wh/tdg0ff9s1wl59234d5l27_gc0000gn/T/ipykernel_98654/2691205834.py:15: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. all_results = all_results.append(current_result) Fix: all_results = pd.concat([all_results, current_result]) This warning appears because DataFrame.append was deprecated and later removed from pandas, so code that built a frame by appending one row or frame at a time needs updating. The replacement is pandas.concat, which combines a list of frames in one call. Collecting the pieces in a list and concatenating once at the end is also faster than repeated appends.

[Solved] seaborn: decrease the size of the markers

Image
Code: ax = sns.swarmplot(y="time_taken", x="dtype", data=all_results, color=".25") Error: /usr/local/Cellar/jupyterlab/3.3.2/libexec/lib/python3.9/site-packages/seaborn/categorical.py:1296: UserWarning: 35.9% of the points cannot be placed; you may want to decrease the size of the markers or use stripplot. warnings.warn(msg, UserWarning) Fix: ax = sns.swarmplot(y="time_taken", x="dtype", data=all_results, color=".25", size=3.25 ) This seaborn warning appears when a swarm plot cannot place every point without overlap, so some are dropped. It is a sign the markers are too large for the amount of data. Reducing the marker size with the size parameter, or switching to a strip plot, lets all points show. Both are quick changes to the plotting call.

[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 ...