Gregory Varghese
  • About Me
  • Labs
  • GitHub
  • My Work Setup
  • My Photography Blog
  • About Me
  • Labs
  • GitHub
  • My Work Setup
  • My Photography Blog
  • Categories
  • All
  • Solutions
  • Administration
  • Troubleshooting
  • Tips and Tricks
  • Development
24th March 2023
AI

A sonnet about Batman in the style of William Shakespeare

Batman dressed as William Shakespeare

Oh Batman, knight of darkness, hero bold
Fierce in battle, strong in heart and mind
Defender of the weak and young, behold
Thy righteous justice, keen and unconfined

With cape and cowl, thou roam’st the gloomy night
In search of evil, lurking in the shade
With batarangs and gadgets, swift and right
Thou fight’st with valor, never unafraid

Thou art the Dark Knight, feared by thy foes
But loved by Gotham, city of thy birth
Thy loyal allies, Robin and Batgirl knows
Thy strength of spirit, unmatched on this earth

Oh Batman, thy courage doth inspire
Thy legend shall never fade, nor expire.

  • Continue Reading
  • 0
  • 6
23rd March 2023
AIDevelopment

AI Experiments Featuring Monkeys

I was experimenting with AI writing and images and was experimenting. My initial testing was for serious subject matters, and it proved to be surprisingly well-written.

I decided to experiment to see how absurd things could get and was not disappointed. Here’s the first result.

A sonnet about monkeys in the style of William Shakespeare

AI-Generated Image of a Monkey Dressed as William Shakespeare

Oh primate of the jungle wild, with fur so soft and warm,
Your funny face is full of cheer, your spirit full of charm.
Your leaps and bounds are so delight, your antics such a sight,
Your antics bring joy and laughter, day and night.

Your antics full of curious play, never a dull moment today,
Your cries bring life to the trees, your presence is here to stay.
Your chatter fills the air with sound, as you swing from tree to tree,
Your kind is full of joy, of this much I guarantee.

Your life is full of family, and you are never lonely,
Your love and care for one another, is so pure and honestly.
Your life is filled with plenty of adventure, curiosity and more,
Your life is full of joy, and near the jungle floor.

Oh primate of the jungle wild, I sit and watch you play,
Your furry face and kind spirit, I shall never forget today.
Your life is full of joy and cheer, your presence warm and bright,
Your life is full of love and fun, and I am glad to be in your sight.

  • Continue Reading
  • 0
  • 3
6th January 2023
AdministrationSoftwareSolutionsTips and TricksToolsTroubleshootingUtilitiesWindowsWindows 10Windows 7Windows 8

How to Delete Folder with Special Character in Windows 10/11

I ran into an issue where a folder was created by some application with a special Unicode character that Windows Explorer doesn’t seem to play nicely with. I also was unable to tell what the character was since nothing would reveal it. The folder’s there, but you can’t rename or delete it. If I tried to remove or delete it, I’d get an error saying the folder doesn’t exist:

image from https://superuser.com/questions/1076803/cant-delete-folder-in-windows-10-that-contains-special-character

I have LockHunter installed but it wasn’t able to delete it for some reason. The easiest way I found to delete the folder was to use Git Bash and then use the appropriate commands to rename or delete the folder.

Browse to the folder where the offending folder is located. For example purposes, I’ll use c:\temp\folder1

cd c:/temp

Rename:

mv fol (hit tab to autocomplete) folder1

Delete:

del fol (hit tab to autocomplete)

If you don’t have Git Bash or are not a developer/power user, you can download the portable version from https://git-scm.com/download/win to use temporarily. Once you decompress the files to a folder, you’ll find git-bash.exe which you can double-click to run and use the above commands.

  • Continue Reading
  • 0
  • 35
14th November 2022
DevelopmentLaravelMacMAMPPHPProgramming

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

@vite('resources/js/app.js')

to my blade file, I’d get errors including:

This request has been blocked; the content must be served over HTTPS.

I found articles saying to add –https or –host to my package json command but then I got this error:

net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH

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:

import fs from 'fs';
const host = 'my-app.test';

Then add this to defineConfig section:

server: {
    host,
    hmr: { host },
    https: {
        key: fs.readFileSync(`/Applications/MAMP/Library/OpenSSL/certs/${host}.key`),
        cert: fs.readFileSync(`/Applications/MAMP/Library/OpenSSL/certs/${host}.crt`),
    },
},

You should now be able to run npm run dev and have no issues.

Sample full vite.config.js file for easy reference:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import fs from 'fs';
const host = 'my-app.text';

export default defineConfig({
    server: {
        host,
        hmr: { host },
        https: {
            key: fs.readFileSync(`/Applications/MAMP/Library/OpenSSL/certs/${host}.key`),
            cert: fs.readFileSync(`/Applications/MAMP/Library/OpenSSL/certs/${host}.crt`),
        },
    },
    plugins: [
        laravel([
            'resources/sass/app.scss',
            'resources/js/app.js',
        ]),
    ],
});
  • Continue Reading
  • 2
  • 60
1st August 2022
Uncategorized

Deploying Storybook via Gitlab Pipeline via SFTP

This is an update to my previous script to deploy Storybook to S3 via Gitlab Pipelines. We’re running a dev server on EC2 and I wanted to be able to deploy the project using SFTP. This assumes you already created a new user account on the FTP server.

Create an SSH key on your local machine and save it without a password using the following command:

sh-keygen -t ed25519 -C "GitLab SSH key"

You should have two new files in .ssh directory:

  • id_ed25519 — private key
  • id_ed25519.pub — public key

Add Key to Gitlab CI/CD Settings

Copy content of private key and go back to GitLab project. Navigate to Settings -> CI/CD -> Variables -> Expand -> Add Variable. GitLab’s variable is a key-value pair. Name key SSH_PRIVATE_KEY and paste private key in value field. Click Add Variable.

Add two more variables:

  • SSH_USER — name of the user on the remote server
  • SSH_HOST — IP address of remote server
  • FTPFOLDERPATH – The path where to upload files too on your server.

Copy the contents of public key and go back to remote server. Login as the same user which you have specified in SSH_USER GitLab’s variable.

Add SSH Key to Server

Navigate to /home/<username>/.ssh. If directory .ssh doesn’t exist, then create it. Paste the public key into authorized_keys file. If you don’t have authorized_keys file, create it.

Add .gitlab.ci.yml

Important Note: I ended up using node:16 for my script because my instance of Storybook was using Webpack 4 and the node:latest was using Node 18 which wasn’t compatible. If you’re using webpack 5, you should be able to use a later version. I’m also using node:16 instead of alpine or buster because I ran into issues adding the SSH keys. I’ll work on optimizing this later for performance but it works.

image: node:16

stages:
  - build
  - deploy

build:
  stage: build
  script:
    - npm install
    - npm run build-storybook
  artifacts:
    paths:
      - storybook-static
  only:
    - develop
    - main
deploy:
  stage: deploy
  artifacts:
    paths:
      - storybook-static
  before_script:
    - "command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )"
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - ls -la
  script:
    - echo "$SSH_USERNAME@$SSH_HOST"
    # clean up old storybook files
    - ssh -p22 $SSH_USERNAME@$SSH_HOST "rm -rf $FTPFOLDERPATH"
    # deploy artifacts
    - scp -P22 -r storybook-static/* $SSH_USERNAME@$SSH_HOST:$FTPFOLDERPATH
  only:
    - develop
    - main
  • Continue Reading
  • 0
  • 67
23rd October 2021
AdministrationDevelopmentGitlabPipelinesTips and TricksTools

How to deploy a React app to Amazon S3 using Gitlab CI/CD

I’ve been trying to build more CI/CD scripts using Gitlab to automate pipeline deployments for work. Here’s a useful one for building and deploying a React app to Amazon S3.

You’ll need to add a variable called S3_BUCKET_NAME to your repo or replace the variable with your bucket path.

stages:
   - build
   - deploy
build react-app:  
   #I'm using node:latest, but be sure to test or change to a version you know works. Sometimes node updates break the npm script. 
   image: node:latest
     
   stage: build  
   only:    
      - master  
   script:
      # Set PATH
      - export PATH=$PATH:/usr/bin/npm    
      # Install dependencies    
      - npm install    
      # Build App    
      - CI=false npm run build  
   artifacts:    
      paths:      
         # Build folder      
         - build/    
      expire_in: 1 hour
deploy master:
   image: python:latest
   stage: deploy
   only:
      - master
   script:
      - pip3 install awscli
      - aws s3 sync ./build s3://$S3_BUCKET_NAME --acl public-read
  • Continue Reading
  • 0
  • 87
4th January 2021
AdministrationBitbucketDevelopmentDigital OceanDropletJigsawLaravelLaravelPHPPHPPipelinesProgrammingSolutionsTips and TricksToolsTroubleshootingWeb Development

How to Setup CI/CD of Jigsaw Site to Digital Ocean Droplet Using Bitbucket Pipelines

I created a new personal resume site and decided I wanted to build a static site since it wouldn’t be frequently updated. I evaluated Nuxt, Gatsby, and a few others but settled on Jigsaw, a static site generator based on Laravel. I had never used it before and figured this would be a good learning experience while building something I needed. I was pleasantly surprised by how easy it is to use and setup, so kudos to the Tighten team for putting together such an elegant solution.

I wanted to get a CI/CD pipeline configured to handle the site’s deployment but couldn’t find any working tutorials, so I’m sharing my solution in case it helps others. I’m using Bitbucket for this since it’s a personal private repo, so I’m using Bitbucket Pipelines.

Instructions

After you enable pipelines for your project, you’ll need to configure a Pipelines Repository Variable in your project. Go to the settings tab in your repo, and then select Repository variables:

Add 3 variables:

  • USER_NAME – The SSH user name you want Bitbucket to use to connect to your server.
  • PRODUCTION_HOST – Your domain that Bitbucket should connect to
  • FOLDER – Folder Path where the site should be deployed to

Generate an SSH key (or use your own) and add it to your server under the SSH Keys tab in Pipelines:

I generated a new key and then added it to ~/.ssh/authorized_keys for the account.

Add this YAML snippet to your bitbucket-pipelines.yml in your root. This will use PHP 7.4, install rsync, node + npm, composer, and build the production version of the site to deploy to the specified folder.

The -aVP switch for rsync is to give me verbose progress feedback so I can see what’s happening. If you don’t need the detail, switch it to -a.

image: php:7.4-fpm
pipelines:
  branches:
    master:
      - step:
          name: Jigsaw Build
          script:
            - apt-get update && apt-get install -y unzip
            - apt-get install rsync openssh-client nodejs npm -y
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - composer install
            - npm install
            - npm run production
            - rsync -avP build_production/ $USER_NAME@$PRODUCTION_HOST:$FOLDER --exclude=bitbucket-pipelines.yml --chown=www-data:www-data

I received a few errors when rsync ran. In case you run into them as well, here’s the list and fixes. The first was:

rsync: failed to set times on "$FOLDER": Operation not permitted (1)

I added --no-t to resolve that and then got a new error:

rsync: failed to set permissions on "$FOLDER": Operation not permitted (1)

which was fixed with adding the switch --no-perms. My final rsync command became:

rsync -avP --no-t --no-perms build_production/ $USER_NAME@$PRODUCTION_HOST:$FOLDER --exclude=bitbucket-pipelines.yml --chown=www-data:www-data
  • Continue Reading
  • 0
  • 175
28th July 2020
Backblaze B2DevelopmentLaravelLaravelPHPPHPProgrammingWeb Development

How to use Backblaze B2 with Laravel

I am working on a Laravel project and decided to use a Backblaze bucket as it’s cheaper for storage when compared to AWS S3. I couldn’t find a tutorial on how to get it working from scratch and I tested a bunch of Laravel B2 libraries that didn’t end up working. The good news is that you don’t need a special B2 plugin and instead can use the S3 package recommended by the Laravel docs.

If you haven’t added the flysystem-aws-s3 package, add it to your project using composer:

composer require league/flysystem-aws-s3-v3

Login to your B2 account and create your bucket with your required settings. Once created, you’ll want to create a new application key with the permissions you need for your app. You should get a confirmation once it’s generated:

Open your .env file and locate the settings for AWS. You’ll need to add one key that’s not there by default:

AWS_ENDPOINT=

Match the settings in your .env from the application key to the values below.

AWS_ACCESS_KEY_ID=keyID
AWS_SECRET_ACCESS_KEY=applicationKey
AWS_DEFAULT_REGION=us-west-000
AWS_BUCKET=bucket-name
AWS_ENDPOINT=S3 Endpoint

Now you should be able to call the Laravel storage system like normal:

\Storage::disk('s3')->put('test.txt', 'test');
  • Continue Reading
  • 1
  • 189
4th May 2020
AdministrationCloudGitlabTips and Tricks

How to Setup a CI/CD Pipeline for Storybook.js using Gitlab

I just spent a few hours setting up a Gitlab pipeline to deploy a Storybook.js site. Of course the end result ended up being much simpler than I made it out to be. Like everything else on my blog, I’m sharing in case anyone else can use the information to save time.

Just put this in your gitlab-ci.yml and it’ll take care of caching the node modules and building your static version of Storybook to deploy.

image: node:latest

cache:
  paths:
    - node_modules/

stages:
 - build
 - deploy

build:
  stage: build
  script:
    - npm install
    - npm run build-storybook -- -o storybook-static
  artifacts:
    paths:
    - storybook-static
  only:
  - qa
  - develop
  - master

deploy:
  stage: deploy_to_aws
  # add your deploy code here
  • Continue Reading
  • 0
  • 206
8th April 2020
AdministrationApplicationsC#c#DevelopmentOpen SourceProgrammingSoftwareSolutionsTips and TricksToolsTroubleshootingUtilitiesWindowsWindows 10Windows 7Windows 8Windows ServerWindows Server 2008Windows Server 2012

How to Clear Archive & Read-only flags on Files in Windows in Bulk

I ran into an issue where I had to move files from one system to another and was running into issues because files had been set as read-only, had the archive flag set, or both. It was causing the system to skip files which wasn’t acceptable. Normally you could just use Windows to clear it in bulk, but that could potentially mess up file permissions. I needed a way to automatically just clear all flags but respect permissions.

I did some searching and didn’t find a utility that would do the job and most of the solutions I found required Powershell which wasn’t available on the system I was on. I ended up writing a quick console application in C# to do the trick. I’ve made it free and open sourced it in case anyone wants to use it.

If you need just the app, you can find the release build here with instructions. The app also prompts for input to make things a bit easier to use. There’s no install, no tracking or metrics, or anything else related to privacy concerns in this app. It’s a simple throwaway utility to get the job done and move on.

https://github.com/gregvarghese/clearflags/releases/tag/1.0.0

If you want to see the source code, that is available here:
https://github.com/gregvarghese/clearflags/

Please note that I did this in about 10 minutes for my own use so error handling is pretty much non-existent. I mention this because I did run into one issue where Windows was somehow seeing a folder with files in it as a file and it couldn’t be deleted or renamed and the utility couldn’t get past it until it was resolved. I didn’t spend much time debugging and just used my Mac to rename the folder and Windows was able to recognize it after the change, so the utility was able to continue processing.

  • Continue Reading
  • 0
  • 233
Load More Page 1 of 9
  • 1
  • 2
  • 3
  • …
  • 9
Older Posts

Tags


.NET (4) Administration (21) Applications (13) ASP.NET (8) ASP.NET MVC (2) C# (6) Caution (4) Debug (6) Development (18) Errors (9) ESET (3) Excel (2) Firefox (2) Fix (19) High CPU Usage (2) IIS (3) Javascript (5) jQuery (4) laravel (5) linux (6) Mac (13) MAMP (3) Memory (2) Microsoft (5) NTFS (2) Open Source (3) Outlook (2) Outlook 2011 (4) Photography (2) php (3) Programming (9) Reviews (2) Sitecore (2) Software (8) Solutions (36) SQL (4) SSL (2) Tips (27) Tools (6) Troubleshooting (24) Useful (18) Utilties (9) Windows (12) Windows 7 (4) Windows Server (2)

Categories


  • Administration 60
    • Caution 3
    • Cloud 7
      • Cloudflare 1
      • Digital Ocean 5
        • Droplet 5
      • Namecheap 1
    • Hardware 4
      • Drobo 3
    • IIS 2
    • Linux 8
      • Apache 1
      • SSH 7
        • Terminal 4
      • Ubuntu 16.04 1
    • Mac 9
      • Software 4
        • Alfred 1
        • MAMP 3
        • PHPStorm 1
      • Terminal 4
    • Review 1
    • Security 6
      • ESET 4
      • Firewall 1
    • SQL 3
      • 2008 1
      • DTSX 1
      • mySQL 1
    • Stupid Tales 2
    • Windows 43
      • Applications 16
      • Malware 2
      • NTFS 2
      • PowerShell 1
      • Reviews 1
      • Software 21
        • Excel 2
        • Outlook 1
        • Peerblock 1
        • Remote Desktop 1
          • RDC 1
        • SourceTree 1
        • Steam 1
        • Synergy 1
        • Visio 1
        • Visual Studio 2013 1
        • Word 1
        • Wordpress 2
          • Hack 2
      • Tips and Tricks 31
      • Tools 21
      • Utilities 19
      • Windows 10 2
      • Windows 7 9
      • Windows 8 4
      • Windows Server 3
        • Windows Server 2008 2
        • Windows Server 2012 2
  • Body Hacking 1
    • Diet 1
    • Soylent 1
  • Development 31
    • AI 2
    • Bitbucket 3
      • Pipelines 3
    • c# 2
    • CouchDB 1
    • Github 3
    • Gitlab 2
    • Open Source 4
    • ORM 1
      • Dapper 1
    • PHP 6
      • Laravel 6
        • Jigsaw 1
    • PHPStorm 1
    • Sitecore 2
    • SourceTree 1
    • Syncfusion 1
  • Mac 10
    • iCloud 1
    • Outlook 2011 2
    • Safari 1
  • Photography 3
    • Food 1
    • Rockstars 1
    • Uproar Festival 2012 1
    • Wolves 1
  • Products 3
    • Backblaze B2 1
    • Reviews 2
  • Programming 30
    • ASP.NET 7
      • MVC 1
    • AWS 1
      • Rekognition 1
    • C# 3
    • Javascript 2
    • jQuery 3
      • Fancybox 1
    • MonoTouch 1
    • PHP 6
      • Laravel 6
        • Tinker 1
    • Regex 1
    • Sitecore 2
    • SQL 1
    • SSL 2
    • VBA 2
      • Microsoft Word 1
    • Web Development 9
      • JavaScript 2
    • WinForms 2
  • Raspberry Pi 1
  • Recipe 1
  • Self Experimentation 1
  • Troubleshooting 44
    • Solutions 43
  • Uncategorized 10

Archives


  • March 2023 (2)
  • January 2023 (1)
  • November 2022 (1)
  • August 2022 (1)
  • October 2021 (1)
  • January 2021 (1)
  • July 2020 (1)
  • May 2020 (1)
  • April 2020 (1)
  • February 2020 (1)
  • September 2019 (1)
  • August 2019 (3)
  • July 2019 (1)
  • June 2019 (1)
  • May 2019 (4)
  • October 2018 (1)
  • July 2018 (1)
  • May 2018 (1)
  • April 2018 (2)
  • November 2017 (1)
  • October 2017 (1)
  • June 2017 (1)
  • May 2017 (1)
  • November 2016 (1)
  • October 2016 (2)
  • September 2016 (1)
  • June 2016 (2)
  • May 2016 (4)
  • February 2016 (1)
  • January 2016 (1)
  • October 2015 (1)
  • September 2015 (1)
  • July 2015 (1)
  • June 2015 (1)
  • May 2015 (3)
  • April 2015 (1)
  • March 2015 (1)
  • February 2015 (1)
  • July 2014 (1)
  • June 2014 (1)
  • May 2014 (1)
  • December 2013 (2)
  • September 2013 (1)
  • July 2013 (1)
  • May 2013 (2)
  • March 2013 (2)
  • February 2013 (1)
  • September 2012 (1)
  • August 2012 (4)
  • July 2012 (1)
  • March 2012 (1)
  • November 2011 (1)
  • September 2011 (4)
  • July 2011 (3)
  • June 2011 (3)
  • February 2011 (1)
  • August 2010 (1)
  • May 2010 (1)
  • October 2007 (1)

Continue Reading
Gregory Varghese

Top Posts & Pages


  • ReportCrash High CPU & How to Disable reportcrash in Mac OSX
  • How to Setup a CI/CD Pipeline for Storybook.js using Gitlab
  • Copy File Context to Clipboard via Command Line, Git Bash (Mingw64), or Terminal
  • How to execute SSH command with Bitbucket Pipelines
  • How to Import Multiple VCF contacts into iCloud
  • Using Laravel Vite with MAMP
  • How to use Backblaze B2 with Laravel
  • Maple Syrup Pie Recipe from Aux Anciens Canadiens Restaurant
  • How to deploy a React app to Amazon S3 using Gitlab CI/CD
  • How to Automate Sending Emails through Outlook interop using C#

Recent Posts


  • A sonnet about Batman in the style of William Shakespeare
  • AI Experiments Featuring Monkeys
  • How to Delete Folder with Special Character in Windows 10/11
  • Using Laravel Vite with MAMP
  • Deploying Storybook via Gitlab Pipeline via SFTP

Copyright © Gregory Varghese. 2023 • All rights reserved.

Onyx WordPress Theme by EckoThemes. Published with WordPress.