Format an APFS (MAC) hard disk on Windows

  1. Launch a new Command Prompt (cmd)
  2. Type the command diskpart
  3. type list disk and note the number of the APFS formatted disk
  4. type select disk X where X is the number noted in step 3
  5. type clean. Now the drive doesn’t have partitions anymore, it’s just an unallocated space.
  6. Type create partition primary
  7. To format type format quick fs=ntfs
  8. Type assign letter=X

Google Keystore

keytool -genkey -v -keystore MY-RELEASE-KEY.keystore -alias MY_ALIAS_NAME -keyalg RSA -keysize 2048 -validity 10000 -storetype jks

keytool -v -list -keystore MAAS-RELEASE-KEY.keystore

keytool -export -rfc -keystore upload-keystore.jks -alias upload -file upload_certificate.pem

Calculate Hamming, Manhattan and Minkowski Distance

# calculate hamming distance
from math import sqrt


def hamming_distance(x, y):
    return sum(abs(a1 - a2) for a1, a2 in zip(x, y)) / len(x)


# define data
rowA = [0, 1, 0, 1, 0, 1]
rowB = [0, 1, 0, 0, 1, 0]
# calculate distance
result = hamming_distance(rowA, rowB)
print(result)


# calculate manhattan distance
def manhattan_distance(x, y):
    return sum(abs(a1-a2) for a1, a2 in zip(x, y))


# define data
rowA = [10, 30, 45, 10, 5]
rowB = [12, 24, 18, 8, 7]
# calculate distance
result = manhattan_distance(rowA, rowB)
print(result)


# calculate minkowski distance
def minkowski_distance(x, y, z):
    return sum(abs(a1-a2)**z for a1, a2 in zip(x, y))**(1/z)


# define data
rowA = [20, 40, 25, 30, 5]
rowB = [12, 10, 18, 10, 7]
# calculate distance (z=1)
result = minkowski_distance(rowA, rowB, 1)
print(result)
# calculate distance (z=2)
result = minkowski_distance(rowA, rowB, 2)
print(result)

Convert Let’s Encrypt SSL certificates from pem to crt/key

openssl rsa -in <path_to_privkey.pem> -pubout > key.pub

openssl rsa -outform der -in privkey.pem -out privkey.key 

openssl x509 -outform der -in fullchain.pem -out fullchain.crt 

openssl x509 -outform der -in cert.pem -out cert.crt

openssl x509 -in cert.pem -outform pem -outform der -out cert.cer