switching from wordpress to jekyll

I recently migrated this blog from WordPress to Jekyll due to several reasons. It came down to these three reasons: Cost Speed Security Cost. Jekyll generates static websites, meaning it can be hosted freely at Github. No more hosted VM’s. That’s a savings of $120 per year. Speed. Since Jekyll pages are static HTML pages, websites loads much faster. There are no more PHP, extra plugins or databases that slow down pages. Security. Since Jekyll pages are static files, they do not need a LAMP stack. So no more OS, PHP, plugins or MySQL databases to securely maintain. It’s a win win. The migration was quick and easy, but not it’s not entirely a 100% bug-free. I had to tweak Jekyll templates here and there to get it to look the way I wanted it. There are a ton of articles out there that covers the Jeklly to WordPress migration. I’m not going to cover the migration process here step by step. To quickly summarize, you’ll need to install a Jekyll exporter plugin in WordPress to export your posts. You can then import your posts into Jekyll and tweak Jekyll the way you want it. That’s it in a nutshell. ...

December 16, 2023 · 2 min · ulysses

php not able to run gcloud commands via shell_exec

I ran into an issue with PHP not able to run gcloud commands via shell_exec. It turned out to be a permission issue. I ended up granting the apache user access to /usr/share/httpd/.config directory which was missing. Google SDK needs write access to this directory. I ran the commands below and it worked after the changes. mkdir /usr/share/httpd/.config chown apache:root /usr/share/httpd/.config

December 15, 2023 · 1 min · ulysses

hiding passwords using openssl

How to hide main password on Linux using OpenSSL. Run this on a web server once. $ echo "SecretPassword" | openssl enc -aes-256-cbc -md sha512 -a -salt -pass pass:NotSoSecretPassword > secret.txt $ chmod 600 secret.txt On client machine, download the secret file. $ curl https://webserver/some/dir/secret.txt --output -s secret.txt To retrieve the secret password, run the code below. For added measure, delete secret.txt file afterwards. $ cat secret.txt | openssl enc -aes-256-cbc -md sha512 -a -d -salt -pass pass:NotSoSecretPassword $rm -f secret.txt In addition, you can rotate the NotSoSecretPassword to make it more secure.

October 31, 2023 · 1 min · ulysses

install latest terraform via homebrew

As of this writing, the latest Terraform version supported by Homebrew is version 1.5.7. It’s a bit outdated considering the latest Terraform version is 1.6.2. To force Homebrew to install the latest version of Terraform, run the following commands from your MacOS Terminal. But prior to that, check your version first. Check current version $ terraform --version Terraform v1.5.7 on darwin_amd64 Upgrade Terraform $ brew tap hashicorp/tap $ brew install hashicorp/tap/terraform Check version again ...

October 27, 2023 · 1 min · ulysses

youtube thumbnail

When uploading videos, Youtube gives you an option to upload your own thumbnails. If you want to use your own pics, you can format them to 1280×720 pixels and use it as a thumbnail. The script below will resize any image regardless of the original size to 1280×720 pixels using the convert utility of ImageMagick. The conversion may crop the edges of your image if it’s not 16:9 or 1.777 format. The script will also resize an image in portrait format. ...

October 26, 2023 · 1 min · ulysses

search second column for characters

How to search the second column for string starting with. Here are the contents of results.txt. John 10 Mario 12 Derek 15 Mark 20 Matt 25 Display only individuals that are older than 20 using awk. awk '$2 ~ /^20/' results.txt Result. Mark 20 Matt 25 You can easily adjust this to other columns.

October 24, 2023 · 1 min · ulysses

alternative to jq

If you don’t have JQ (JSON Parser) installed, you can use a combination of echo, grep and sed to pull out the data. # create new credentials new_access_keys_json=$(aws iam create-access-key --user-name $user --profile $profile) new_access_key_id=$(echo "$new_access_keys_json" | grep -o '"AccessKeyId": "[^"]*' | sed 's/"AccessKeyId": "//') new_access_secret_key=$(echo "$new_access_keys_json" | grep -o '"SecretAccessKey": "[^"]*' | sed 's/"SecretAccessKey": "//') In this example, we are creating new AWS IAM credentials. AccessKeyID and secretKey are extracted from JSON.

October 18, 2023 · 1 min · ulysses

lambda function list ec2 instances

This is a Lambda function code that list EC2 instances from multiple regions and write the output to a S3 bucket. Include name and IP address on the output. import boto3 import json import os from botocore.exceptions import NoCredentialsError # Set the AWS regions you want to query regions = ['us-east-1', 'us-west-2', 'eu-west-1'] # Set the S3 bucket and object key for storing the output s3_bucket = 'your-s3-bucket-name' s3_object_key = 'ec2-instances-list.txt' def lambda_handler(event, context): ec2_instances = [] for region in regions: try: # Create an EC2 client for the specified region ec2 = boto3.client('ec2', region_name=region) # Describe EC2 instances in the region response = ec2.describe_instances() for reservation in response['Reservations']: for instance in reservation['Instances']: # Extract instance information instance_name = "N/A" instance_ip = "N/A" for tag in instance.get('Tags', []): if tag['Key'] == 'Name': instance_name = tag['Value'] if instance.get('PublicIpAddress'): instance_ip = instance['PublicIpAddress'] ec2_instances.append(f"Region: {region}, Name: {instance_name}, IP: {instance_ip}") except NoCredentialsError: return "No AWS credentials found." # Store the EC2 instance information in an S3 object s3 = boto3.client('s3') s3.put_object(Bucket=s3_bucket, Key=s3_object_key, Body='\n'.join(ec2_instances), ContentType='text/plain') return { "statusCode": 200, "body": json.dumps("EC2 instance information has been saved to S3.") }

October 18, 2023 · 1 min · ulysses

bash split a string with delimiter

Here’s how to split a string that contains a delimeter. String server-boot;server-data Split the string and print on every line. data="server-boot;server-data" for i in $(echo $data | tr ";" "\n"); do echo $i done Result server-boot server-data Send output to a file file="output.txt" > $file data="server-boot;server-data" for i in $(echo $data | tr ";" "\n"); do echo $i >> $file done

September 18, 2023 · 1 min · ulysses

display asterisks when typing passwords in bash

Here’s how to display asterisks when typing passwords in Bash. #!/bin/bash unset password prompt="Enter Password:" while IFS= read -p "$prompt" -r -s -n 1 char do if [[ $char == $'\0' ]] then break fi prompt='*' password+="$char" done echo echo "Done. Password=$password"

September 18, 2023 · 1 min · ulysses