Tuesday, February 22, 2022

[How To] Draw Vectors in Python

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

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:
    \State Hello!

Now to change the label, add the following command before \begin{document}.
The code remains the same.


Sunday, February 06, 2022

[Solved] 15 duplicate symbols for architecture x86_64


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)

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

Thursday, February 03, 2022

[Solved] Enable iCloud Private Replay in Pi-hole

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.


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

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()); 


std::cout << "Digest: ";
StringSource(digest, true, new Redirector(encoder));
std::cout << std::endl;