[Solved] Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?

If you get the following error when trying to run a Docker container: Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Then you can resolve it by running the following: systemctl start docker If this doesn’t work because of a root user issue, then you can do the following first: gpasswd -a $USER docker Additional issues? Issue 1 If you have tried the above, and get this error:...

March 4, 2023 · 1 min · 117 words · Andrew

[Solved] M1 docker preview and keycloak 'image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)' Issue

If you get the following error when trying to run a Docker container that was built on an M1 mac: M1 docker preview and keycloak 'image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)' Issue The solution Then you can do simply add the following argument to your docker build command. --platform linux/amd64 Where this goes docker build --platform linux/amd64 -t your_docker_item .

March 3, 2023 · 1 min · 65 words · Andrew

How to get the SHA512 sum of a string using Python

If you need to get the SHA512 sum of a string using Python, then you can do the following. Step 1 Firstly, we need to use the hashlib module: import hashlib Step 2 Now make sure that the input string is encoded correctly. your_input = "this is your input string".encode('utf-8') Step 3 Finally use the sha512 function of the hashlib module, and get the hexdigest() value from it: hashlib.sha512(your_input).hexdigest() Putting it all together import hashlib your_input = "this is your input string"....

March 2, 2023 · 1 min · 89 words · Andrew

How to get the SHA256 sum of a string using Python

If you need to get the SHA256 sum of a string using Python, then you can do the following. Step 1 Firstly, we need to use the hashlib module: import hashlib Step 2 Now make sure that the input string is encoded correctly. your_input = "this is your input string".encode('utf-8') Step 3 Finally use the sha256 function of the hashlib module, and get the hexdigest() value from it: hashlib.sha256(your_input).hexdigest() Putting it all together import hashlib your_input = "this is your input string"....

March 1, 2023 · 1 min · 89 words · Andrew

How to get the MD5 sum of a string using Python

If you need to get the MD5 sum of a string using Python, then you can do the following. Step 1 Firstly, we need to use the hashlib module: import hashlib Step 2 Now make sure that the input string is encoded correctly. your_input = "this is your input string".encode('utf-8') Step 3 Finally use the md5 function of the hashlib module, and get the hexdigest() value from it: hashlib.md5(your_input).hexdigest() Putting it all together import hashlib your_input = "this is your input string"....

February 28, 2023 · 1 min · 89 words · Andrew

[Solved] TypeError: Object of type datetime is not JSON serializable

If you get the following error: TypeError: Object of type datetime is not JSON serializable ..then you can solve it by using this trick: json.dumps(your_dict, indent=4, sort_keys=True, default=str)

February 27, 2023 · 1 min · 28 words · Andrew

How to Return a List of All AWS Lambda Function Names in CLI

If you would like to list all AWS Lambda Function Names in your CLI using the AWS CLI, then you can do this: Get a List of all Lambda Functions aws lambda list-functions However, note that this will return a potentially large JSON payload back to your CLI. So what if you only want a list of the function names themselves? You can couple the AWS command above, with the jq command as follows:...

February 24, 2023 · 1 min · 88 words · Andrew

How much faster is Python code?

The speed of Python code compared to other programming languages depends on a variety of factors, such as the specific task being performed, the libraries and frameworks used, the quality of the code implementation, and the hardware on which the code is executed. In general, Python is an interpreted language, which means that code is executed line-by-line by an interpreter, rather than being compiled into machine code beforehand. This can make Python code slower than compiled languages like C or C++ for some tasks....

February 23, 2023 · 2 min · 230 words · Andrew

How to Zip and Encode a Dictionary to String and Back in Python

If you have a Python dictionary, and want to encode it as a string and zip it to save space, perhaps for passing a dictionary through as an environment variable or similar, then you can do the following Zip then Encode / Decode then Unzip Functions import json, gzip, base64 from io import BytesIO def _zip_then_encode(data: dict) -> str: """Gzip and base64 encode a dictionary""" if type(data) != dict: raise TypeError("data must be a dictionary") compressed = BytesIO() with gzip....

February 22, 2023 · 1 min · 168 words · Andrew

What Categories of Websites are there?

There are many different categories of websites, but here are some of the most common: E-commerce websites: These websites sell products or services online. Examples include Amazon, eBay, and Etsy. News websites: These websites provide up-to-date news and information on a variety of topics. Examples include CNN, BBC, and The New York Times. Blogging websites: These websites are used for personal or business blogs. Examples include WordPress, Blogger, and Medium....

February 17, 2023 · 2 min · 233 words · Andrew