diff --git a/_posts/2023-08-06-HP-8560A-spectrum-analyzer-as-a-frequency-generator.md b/_posts/2023-08-06-HP-8560A-spectrum-analyzer-as-a-frequency-generator.md index 8fa0bef..f2d9c70 100644 --- a/_posts/2023-08-06-HP-8560A-spectrum-analyzer-as-a-frequency-generator.md +++ b/_posts/2023-08-06-HP-8560A-spectrum-analyzer-as-a-frequency-generator.md @@ -4,7 +4,7 @@ author: peter date: 2023-08-06 21:45:13 +0800 categories: [Electronics] # Blogging | Electronics | Programming | Mechanical tags: [electronics, rf, oscilloscope, spectrum analyzer, hack] # systems | embedded | rf | microwave | electronics | solidworks | automation -image: /assets/img/2023-08-06-HP-8560A-spectrum/IMG20230801205713.jpg +image: /assets/img/2023-08-06-HP-8560A-spectrum/preview.png --- I just bought a Hitachi VC-6025 oscilloscope from my Singapore trip for 85 SGD. It's a good deal, since there is not a lot of second-hand electronics auctions on Ebay Australia, and the shipping costs from overseas or even interstate make it not very economical. diff --git a/_posts/2023-08-09-Aliexpress-DC-block-characterization.md b/_posts/2023-08-09-Aliexpress-DC-block-characterization.md index a4c6ea5..73170e1 100644 --- a/_posts/2023-08-09-Aliexpress-DC-block-characterization.md +++ b/_posts/2023-08-09-Aliexpress-DC-block-characterization.md @@ -4,7 +4,7 @@ author: peter date: 2023-08-09 19:41:27 +0800 categories: [Electronics] # Blogging | Electronics | Programming | Mechanical tags: [rf, microwave, electronics] # systems | embedded | rf | microwave | electronics | solidworks | automation -image: /assets/img/2023-08-09-Aliexpress-DC-block/IMG20230809200758.jpg +image: /assets/img/2023-08-09-Aliexpress-DC-block/preview.png --- I recently purchased [this DC block](https://www.aliexpress.com/item/1005002575850555.html) from Aliexpress to protect our HP 8560A spectrum analyzer. I did some basic tests on the DC block and it looks good for the price. These N type DC blocks seem to be less common and twice as expensive than the SMA type, but I wanted to avoid using SMA hardware for my setup. diff --git a/_posts/2024-02-15-Altium-to-3d-GLTF.md b/_posts/2024-02-15-Altium-to-3d-GLTF.md index 4904ddb..cd1494a 100644 --- a/_posts/2024-02-15-Altium-to-3d-GLTF.md +++ b/_posts/2024-02-15-Altium-to-3d-GLTF.md @@ -4,7 +4,7 @@ author: peter date: 2024-02-15 16:41:46 +0800 categories: [Blogging, Electronics] # Blogging | Electronics | Programming | Mechanical tags: [electronics, solidworks] # systems | embedded | rf | microwave | electronics | solidworks | automation -image: /assets/img/2024-02-15-Altium-to-3d-GLTF/website.png +image: /assets/img/2024-02-15-Altium-to-3d-GLTF/preview.png --- As part of the [Neptunium flight computer](https://www.petertanner.dev/neptunium/), I wanted to create a proper webpage to showcase the flight computer. This will also be a landing page for people who want to use the wasm powered Neptunium Explorer, which will allow users to analyze flight data in the browser. At the center of this webpage I want to show an interactive 3d model of the flight computer diff --git a/_posts/2024-02-24-Inside-a-bus-USB-charger.md b/_posts/2024-02-24-Inside-a-bus-USB-charger.md index 9c03c83..08139cf 100644 --- a/_posts/2024-02-24-Inside-a-bus-USB-charger.md +++ b/_posts/2024-02-24-Inside-a-bus-USB-charger.md @@ -4,7 +4,7 @@ author: peter date: 2024-02-24 14:06:00 +0800 categories: [Electronics] # Blogging | Electronics | Programming | Mechanical tags: [electronics, bus] # systems | embedded | rf | microwave | electronics | solidworks | automation -image: /assets/img/2024-02-24-Inside-a-bus-USB-cha/usb-charger-bus-highres.jpg +image: /assets/img/2024-02-24-Inside-a-bus-USB-cha/preview.png --- Random post, on the bus I saw one of those wall-mounted USB chargers with the plastic cover already removed (I did not remove it). This is what the PCB inside of it looks like. diff --git a/assets/img/2023-08-06-HP-8560A-spectrum/preview.png b/assets/img/2023-08-06-HP-8560A-spectrum/preview.png new file mode 100644 index 0000000..cc86071 Binary files /dev/null and b/assets/img/2023-08-06-HP-8560A-spectrum/preview.png differ diff --git a/assets/img/2023-08-09-Aliexpress-DC-block/preview.png b/assets/img/2023-08-09-Aliexpress-DC-block/preview.png new file mode 100644 index 0000000..18a3401 Binary files /dev/null and b/assets/img/2023-08-09-Aliexpress-DC-block/preview.png differ diff --git a/assets/img/2024-02-15-Altium-to-3d-GLTF/preview.png b/assets/img/2024-02-15-Altium-to-3d-GLTF/preview.png new file mode 100644 index 0000000..48ce597 Binary files /dev/null and b/assets/img/2024-02-15-Altium-to-3d-GLTF/preview.png differ diff --git a/assets/img/2024-02-24-Inside-a-bus-USB-cha/preview.png b/assets/img/2024-02-24-Inside-a-bus-USB-cha/preview.png new file mode 100644 index 0000000..50a0a41 Binary files /dev/null and b/assets/img/2024-02-24-Inside-a-bus-USB-cha/preview.png differ diff --git a/generate-preview-images.sh b/generate-preview-images.sh new file mode 100755 index 0000000..08064f1 --- /dev/null +++ b/generate-preview-images.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Function to convert JPG/JPEG to PNG +convert_to_png() { + local file="$1" + local filename="${file%.*}" # Remove extension + local new_file="${filename}.png" + + echo "Converting $file to PNG..." + convert "$file" "$new_file" + echo "Converted $file to PNG: $new_file" + + # Update file variable to the new PNG file + file="$new_file" +} + +# Loop through all preview.jpg and preview.jpeg files in assets/img/ directories +for file in assets/img/*/{preview.jpg,preview.jpeg}; do + if [ -f "$file" ]; then + # Convert JPG/JPEG to PNG + convert_to_png "$file" + fi +done + + +# Loop through all preview.png files in assets/img/ directories +for file in assets/img/*/preview.png; do + if [ -f "$file" ]; then + # Get current dimensions + current_width=$(identify -format "%w" "$file") + current_height=$(identify -format "%h" "$file") + + # Calculate new dimensions, keeping aspect ratio + new_width=1200 + new_height=630 + if [ "$current_width" -gt "$new_width" ] || [ "$current_height" -gt "$new_height" ]; then + # Resize only if current dimensions exceed the new dimensions + convert "$file" -resize "${new_width}x${new_height}>" "$file" + echo "Resized $file" + # else + # echo "No need to resize $file" + fi + fi +done \ No newline at end of file diff --git a/post.sh b/post.sh index 258205f..7861b6f 100755 --- a/post.sh +++ b/post.sh @@ -7,18 +7,6 @@ sanitize_title() { echo "$sanitized_title" | tr ' ' '-' } -# Function to generate the front matter with the current date -generate_front_matter() { - current_date=$(date +'%Y-%m-%d %H:%M:%S %z') - echo "---" - echo "title: $1" - echo "author: peter" - echo "date: $current_date" - echo "categories: [Blogging] # Blogging | Electronics | Programming | Mechanical" - echo "tags: [getting started] # systems | embedded | rf | microwave | electronics | solidworks | automation" - echo "---" -} - # Prompt the user for a title read -e -p "Enter the title: " user_title @@ -30,6 +18,19 @@ current_date=$(date +'%Y-%m-%d') filename="${current_date}-${sanitized_title}" filepath="_posts/${filename}.md" +# Function to generate the front matter with the current date +generate_front_matter() { + current_date=$(date +'%Y-%m-%d %H:%M:%S %z') + echo "---" + echo "title: $1" + echo "author: peter" + echo "date: $current_date" + echo "categories: [Blogging] # Blogging | Electronics | Programming | Mechanical" + echo "tags: [getting started] # systems | embedded | rf | microwave | electronics | solidworks | automation" + echo "# image: assets/img/${filename:0:31}/preview.png" + echo "---" +} + # Check if the file already exists if [ -e "$filepath" ]; then echo "A file with the name '$filename' already exists in the '_posts' subdirectory." diff --git a/push.sh b/push.sh index 98f3e31..9611f28 100755 --- a/push.sh +++ b/push.sh @@ -15,6 +15,9 @@ new_posts="$(get_new_posts)" # Check if there are any new or modified files to commit if [ -n "$new_posts" ]; then + + ./generate-preview-images.sh + # Add all new and modified files echo "$commit_msg" git add $new_posts