Posts

Enabling Cloudflare Proxy for AWS Lambda

Image
Integrating Cloudflare with AWS Lambda can enhance security and performance. Here's a concise guide for technically proficient users to set up Cloudflare proxy for AWS Lambda. Step 1: Deploy Your Lambda Function Create and Deploy Lambda: Start by creating your Lambda function and deploying it to AWS. Step 2: Configure API Gateway Add API Gateway Trigger: Attach an API Gateway trigger to your Lambda function. This will manage HTTP requests to your function. Step 3: DNS Configuration Add CNAME Record: In your Cloudflare DNS settings, create a CNAME record. For instance, api.mydomain.com should point to your API Gateway URL, such as aaabbbccc.execute-api.ap-southeast-2.amazonaws.com. Step 4: SSL/TLS Encryption Enable Full Encryption Mode: Navigate to SSL/TLS settings on Cloudflare and select "Full" encryption mode. This ensures end-to-end encryption, necessary because Cloudflare requires SSL to communicate with AWS. Step 5: Proxy Configuration Ensure CNAME is Proxied: Verify...

Brother HL-L2445DW on Raspberry Pi (ARM) and CUPS

The official Brother HL-L2445DW drivers only support x86 architecture, so even if force installed on an ARM linux, such as the Raspberry Pi, it will not work. During installation, it will show an error message like this: bash linux-brprinter-installer-2.2.3-1 ... dpkg: warning: package architecture (i386) does not match system (armhf) The files are on the system but they will not work. Installing the ARM Raspberry Pi compatible Brother drivers The brlaser project is an open source driver for Brother laser printers. While it does not officially support the HL-L2445DW, there is a workaround. Step 1 - install brlaser  sudo apt-get install printer-driver-brlaser Step 2 - select a different but compatible driver In CUPS, select  Brother HL-L2300D, using brlaser v4 , which is fully compatible with the newer L2445DW.  Done, the printer is not fully operational, including double-sided printing

Convert animated WEBP to MP4

 Animated WebP, similar to animated GIF, is not the best video format to work with, but this is what the usual SVD (image or text to video) and ComfyUI will generate. Unfortunately, FFMPEG does not support WebP to MP4 conversion yet, so this simple frame-by-frame conversation had to be done. As it's generating a PNG for each frame, it's rather slow, so it's only suitable for short animations. The below simple python code converts the animated WebP into MP4, using the predefined FPS. Don't forget to  pip3 install pillow   moviepy import os import shutil import tempfile import argparse from moviepy.video.io.ImageSequenceClip import ImageSequenceClip import PIL.Image def analyse_image (path): im = PIL . Image . open(path) results = { 'size' : im . size, 'mode' : 'full' , } try : while True : if im . tile: tile = im . tile[ 0 ] update_region = t...

Octoprint as a systemd service - running it with high priority

Image
Octoprint provides remote access to your 3D printer, and as it's written in Python, you can run it on practically any operating system. If you are using a standard Raspberry PI image (for instance, because you run it on an Orange PI ), rather than the customised Octoprint image, you can manually install it and create a systemd service to run it: Add this to /etc/systemd/system/octoprint.service  [Unit] Description=Octoprint After=network.target [Service] ExecStart=/home/pi/octoprint/bin/octoprint serve WorkingDirectory=/home/pi/octoprint StandardOutput=inherit StandardError=inherit Restart=always User=pi CPUSchedulingPolicy=rr CPUSchedulingPriority=80 [Install] WantedBy=multi-user.target Then run sudo systemctl daemon-reload sudo systemctl enable octoprint This will start Octoprint on every reboot with a high priority (so unlikely to stutter during printing).

Fusion 360 - part list dimensions, counts, and total amounts (lengths)

Image
  A requirement that comes up often, especially in woodworking, is to be able to list out all materials used in bodies and components - dimensions, counts of each cut, and total lengths of materials used. There is a way to create a separate component from each body and manually add a description that will appear in a part list on a drawing, but it's unnecessarily labour intensive. Automated parts-list addon Fusion 360 provides a  Python API   that enables direct access to the objects in a design, so I created a simple Fusion 360 script that can be used as an addon or run directly to display to cuts required for the design and the total amount of length used by each material type. To run directly, download the script from GitHub , place it anywhere. Then in Fusion 360 click "View" > "Show Text Commands"; in the commands window on the bottom, change from "Txt" to "Py", and run the following command: import neu_dev; neu_dev.run_script(...

Triggering an Alexa routine from the command line or an Arduino compatible device (ESP32)

Image
By creating an auto-resetting virtual sensor on SmartThings.com, Alexa can execute a routine when the virtual sensor's state is triggered via a REST call to SmartThings.com Steps to follow Creating a virtual, auto-resetting sensor on SmartThings.com Register an account with SmartThings.com Go to My device handlers Create a new device handler  Switch to "From code" and paste in the auto-resetting sensor code from here. Go to My Locations and add a new location (e.g., "Living Room") Go to My Devices and add a new device Name, Label, Zigbee Id, Device Network Id = MyVirtualButton Type = Simulated Alexa Button (probably the last item in the dropdown) Location = Living Room (or whatever you created) Hub, Group = (e...

NumPy / Sklearn performance comparison - macOS, Ubuntu, Windows 10 - use Anaconda

Image
One of the advantages to use a Hackintosh is that you can try the same software on the same hardware across three operating systems: how does NumPy - and therefore Sklearn - perform across different operating systems and mathematics libraries? I created a simple Sklearn routine , which utilises a single thread for its calculations. Results Hardware Os Python Math library Comment Time (s) Macbook Air m1 MacOS Big Sur 3.9.1 CBLAS/LAPACK Anaconda install 22 Intel 9600k Ubuntu 20.04 3.8.5 OpenBLAS standard apt and pip install 27 Intel 9600k Ubuntu 20.04 3.9.0 OpenBLAS standard apt and pip install 27 Intel 9600k MacOS Catalina 3.8.5 MKL Hackintosh with Clover, Anaconda install 28 Intel 9600k Windows 10 3.8.5 MKL Anaconda install 28 Intel 9600k MacOS Big Sur 3.9.1 OpenBLAS Hac...