Posts

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

Rename Algorithm to Procedure in LaTeX

Image
If you want to change the section name from Algorithm to Procedure, you just need to use the \floatname command while the code remains unchanged. The code for an algorithm: \begin{algorithm} \caption{Test}   \begin{algorithmic}[1]     \State Hello!   \end{algorithmic} \end{algorithm} Output: Now to change the label, add the following command before \begin{document} . \floatname{algorithm}{Procedure} The code remains the same. Output: This LaTeX tip relabels floats produced by the algorithm package from Algorithm to Procedure using the \floatname command, without changing the algorithm body itself. It is handy when a venue or style guide expects a particular caption label. The same \floatname approach works for renaming other float types too.

[Solved] 15 duplicate symbols for architecture x86_64

Image
Error: If you are getting build failures in Xcode for a C++ program with similar errors, then try this fix. 15 duplicate symbols for architecture x86_64 ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Solution: You can avoid declaring variables in the header and move them to implementation. Or you can declare all the variables in the header file as static.

[Solved] Enable iCloud Private Replay in Pi-hole

Image
Pi-hole is a network-wide ad-blocking DNS server. iCloud Private Replay is a secure internet relay service. While Pi-hole can protect you from unwanted tracking and advertisements, iCloud Private Relay provides you with privacy when you browse the web in Safari. When you join the Pi-hole network with a device with iCloud Private Relay enabled, Pi-hole returns NXDOMAIN response for mask.icloud.com and mask-h2.icloud.com as per Apple recommendation. To disable this feature in Pi-hole and allow the functioning of iCloud Private Relay, go to /etc/pihole/pihole-FTL.conf and set  BLOCK_ICLOUD_PR=false . References: https://pi-hole.net/ https://support.apple.com/en-us/HT212614 https://developer.apple.com/support/prepare-your-network-for-icloud-private-relay/ https://docs.pi-hole.net/ftldns/configfile/#icloud_private_relay

[How To] Calculate hash of a vector in C++

Image
This is a sample code to generate SHA256 in C++ using CryptoPP. For the first string in a vector: std::vector<std::string> stringVector{"abcde", "fghij", "klmno", "pqrst", "uvwxyz"}; byte digest[SHA256::DIGESTSIZE]; SHA256().CalculateDigest(digest, (const byte*)stringVector.data(), stringVector.size()); For an entire vector of string: std::vector<std::string> stringVector{"abcde", "fghij", "klmno", "pqrst", "uvwxyz"}; HexEncoder encoder(new FileSink(std::cout)); std::string digest; SHA256 hash; for(auto str: stringVector) {  hash.Update((const byte*)str.data(), str.size());  }  digest.resize(hash.DigestSize());  hash.Final((byte*)&digest[0]); std::cout << "Digest: "; StringSource(digest, true, new Redirector(encoder)); std::cout << std::endl; This sample computes a SHA-256 hash in C++ with the Crypto++ library, applied to data held in a vector of s...

Share folder from macOS to VirtualBox

Image
Follow these steps to share a folder from your host macOS to guest Kali Linux running inside VirtualBox. Step 1: From your macOS, Go to "System Preferences... >> Sharing" Step 2: Enable the File Sharing option and add a folder to share Step 3: Open VirtualBox >> Select Kali Linux (or any other image) Step 4: Click on "Settings >> Share Folder" Step 5: Click on Add new shared folder button and add the same folder you previously added in macOS from Step 2 Step 6: Log in to your Kali Linux image Step 7: Open Terminal and type the command "sudo adduser $USER vboxsf" Step 8: Reboot Kali Linux

[Solved] error: ‘getrusage’ was not declared in this scope

Image
Error: vb_perf.cpp: In function ‘int main(int, const char**)’: vb_perf.cpp:63:23: error: variable ‘main(int, const char**)::rusage rusage’ has initializer but incomplete type    63 |         struct rusage rusage = { };       |                       ^~~~~~ vb_perf.cpp:64:19: error: ‘RUSAGE_SELF’ was not declared in this scope    64 |         getrusage(RUSAGE_SELF, &rusage);       |                   ^~~~~~~~~~~ vb_perf.cpp:64:9: error: ‘getrusage’ was not declared in this scope; did you mean ‘rusage’?    64 |         getrusage(RUSAGE_SELF, &rusage);       |         ^~~~~~~~~       |         rusage Solution: Include this header to your source code: #include <...