How to Extract SSL Certificates from a PFX File on macOS
If you’ve ever been handed a .pfx file and told to “just upload the certificate,” you know the pain that’s coming.
PFX (PKCS#12) files bundle your private key, SSL certificate, and any intermediate certificates into one encrypted file. That’s great until you actually need to extract those pieces for something like an NGINX server, AWS load balancer, or third-party CDN that wants them all separately.
MacOS has OpenSSL built in, which is all you need. Here’s a simple shell script I use to generate the cert, private key, and chain in one shot and make them clipboard-ready for easy pasting.
Save the following as extract-ssl-from-pfx.sh:
Make it executable:
Then run it:
Follow the prompts. You’ll end up with three files and the contents ready to paste one by one wherever you need them.
Your private key is sensitive. Please don’t leave it lying around. Store it securely or delete it after use.
This script saves me time every time I deal with certificates. Hopefully, it does the same for you. If you have improvements or tweaks, I’d love to hear them.
Supercharge Your Laravel Development and Get AI to Understand Your Models
Hey there, Laravel enthusiasts! Today, I'm diving into a nifty trick that'll make getting AI to understand your Laravel model structures a breeze. We'll harness the power of bash scripting and AI to analyze our migrations quickly and efficiently. Let's get started!
As our Laravel projects grow, so does the complexity of our database structures. Migrations pile up, relationships intertwine, and before you know it, you're drowning in a sea of Schema::create and up functions. Wouldn't it be great to get a bird's-eye view of our models without manually sifting through dozens of files? What if you could get AI to understand your Laravel project without adding every file to the chat window?
Here's where our dynamic duo comes in a clever bash one-liner and your favorite AI chat tool (like ChatGPT or Claude). We'll use bash to extract the relevant parts of our migrations and then feed that information to an AI for analysis and insights.
Here's the one-liner code to copy and paste:
First, let's break down our bash sorcery to understand what's going on in an easier-to-read format:
Just add | pbcopy to have it copied directly to your clipboard on Mac:
This command does the following:
Please copy the entire output from your terminal and paste it into your AI chat of choice with your preferred prompt. I usually start with this prompt:
Generate a diagram
Here are some additional prompts you can optionally pair with the output to extract valuable insights and improvements:
There you have it, folks! With this simple bash one-liner and the power of AI, you can transform how you analyze and understand your Laravel database structures and output code. Give it a try on your next project, and watch your productivity soar!
Remember, tools like these are meant to augment your skills, not replace them. Always review AI suggestions critically and trust your developer instincts.
How to Move Files by Partial File Name to New Directory on Mac using a shell script
When it comes to photo editing, efficiency is key. Recently, I faced a challenge where a subject picked out 100 priority photos from a larger batch. Given the sheer number of images, manually sorting them wasn't practical. All pictures from my SLR were named in the DCIM_# format, so I noted the last five numbers of the selected files. To streamline the process, I wrote a shell script that automatically moves the chosen files to a new folder, allowing me to focus on the priority images first. I’m sharing this script to help others enhance their photo editing workflow.
Create the Shell Script:
Save the Script:
Make the Script Executable:
Run the Script:
Verify the Results:
By following these steps, you can efficiently manage and prioritize your photo editing tasks, saving valuable time and effort. This shell script can be customized and expanded to suit various file management needs, making it a versatile tool in your workflow.
How to enable MacFuse/PCloud Drive on Mac Sonoma 14.2.1
I recently upgraded to Mac Sonoma 14.2.1 and MacFuse stopped loading which affected my ability to load PCloud and NTFS drives. I spent a few days trying to troubleshoot everything and in the end it turned out I had to disable Mac System Integrity Protection to get everything to load. I'm sharing in case it helps anyone else.
To disable SIP on your Mac Sonoma for extensions like MacFuse and pCloud Drive:
Note: Disabling SIP poses security risks. Re-enable it once you've installed the necessary extensions. Only disable SIP when necessary and understand the potential risks involved.
Installing font awesome pro with bun
After recently switching to bun.sh, I was trying to install Font Awesome Pro. It uses a private registry but their docs have not been updated to support non-npm package managers and bun does not yet support .npmrc files.
You can configure a private registry using an organization scope. First, you must get your auth token from your paid Font Awesome account by going to your account page, scrolling down to the Tokens section, and copying the token.
Copy and paste this string, and replace YOUR_TOKEN_HERE with the token you copied above:
Open the terminal and enter these commands:
Paste in the config above with your token and then hit CTRL+X to quit, and Y to save when prompted. Now you should be able to run
Using Laravel Vite with MAMP
As seen in other posts, I use MAMP quite a bit for my web development environment. I know I can run docker, or any of the other platforms out there but they use more memory and resources that I'd prefer to devote to my dev tools.
I started a new Laravel project and wanted to use MAMP but Vite was throwing errors due to the SSL not matching out of the box.
When adding
to my blade file, I'd get errors including:
I found articles saying to add --https or --host to my package json command but then I got this error:
Load MAMP Pro, add your host and generate your SSL certificates. For this example, we'll use set the host name to my-app.test, and assume you're storing the SSL keys in the default location.
Open vite.config.js and add the following 2 lines:
Then add this to defineConfig section:
You should now be able to run npm run dev and have no issues.
Sample full vite.config.js file for easy reference:
How to Get Laravel Debugging to work with PHPStorm and MAMP Pro 5
This has been one of the more aggravating things I've had to deal with in setting up software for development. I've followed the official documentation from JetBrains, over 30 other blog tutorials, and literally failed in getting any of them to work.
I figured out an easy way to make the setup work so I'm sharing it in case someone else finds it useful and for self-reference since I'll probably forget how to do this again in 6 months when I start a new project.
Happy debugging!
Self-signed SSL certificates not working with MAMP and Chrome
I use MAMP Pro for most of my PHP development and Chrome has annoyingly been blocking the self-signed SSL certificates MAMP generates, saying the certificate is not valid and "Your connection is not private":
Thankfully, I found an easy solve to fix this. These steps assume you've created a host in MAMP. You'll need to go to the SSL tab of the host you are trying to fix and
Go back to Chrome, and reload the page and the certificate should work now:
How to get website average latency in BASH
This is tested on Mac only. Add these two functions to your .bashrc and do a shellupdate in terminal to load the latest, or just grab my dotfiles from my github: https://github.com/gregvarghese/dotfiles
Usage example: