Archive for the ‘tips and tricks’ Category

Automating the Deployment and Scheduled Execution of an R script on a VPS using Laravel Forge

I love data, its in my blood, I love analysing, cleaning it and preparing it for others to use, still have to get to the last mile to displaying and visualizing it but that is a story for another day

2024 for me is the year of “automation”, for everything that I do. I have been polishing up my R skills over the holidays, as a way for moving into Python based data wrangling, however the challenges that I have faced is to do with getting my R scripts to run regularly – this has to be on a server connected to the internet since my laptop is not always on

I tried ShinyApps in the past, but this needed me to learn more things which I did not have bandwidth for.

So when Contabo my host wiped my dev VPS during the holidays, I had to re-build my sites, one of which was a documentation site built using PHP and markdown, which I wrote about Deploying a Tighten Jigsaw static site to a VPS using Laravel Forge I was deploying generated HTML to the VPS, then it hit me can’t I do the same with an R script

Setup and Configuration

  1. Install R on your server, here are steps to install R v4.x (I was able to get 4.3.2) https://medium.com/@hpgomide/how-to-update-your-r-3-x-to-the-r-4-x-in-your-linux-ubuntu-46e2209409c3
  2. Create a static site via Laravel Forge from the screenshot below
    • The domain does not really matter, use any custom sub-domain, even if it does not exist since we shall not be accessing this site anyway
    • Select Static HTML/Next.js/Nuxt.js
    • Select “website Isolation” where you specify a user name for the site, I tend to do this alot allowing me to do custom commands without using the global forge user
    • Create a new static site with Laravel Forge
  3. Install your site code repository, GitHub/Gitlab are natively supported, and uncheck the “Install Composer dependencies”, we do not need this for R
    • Install Repository
  4. The magic happens in the Deployments tab which is enabled once you have connected the code repository
    • Firstly “Enable Quick Deploy” so that whenever you push code to the selected branch in Step #2 above the code is deployed
    • Customize your R script to be executed, in my case it was a simple as in the image below. I would also recommend keeping it as simple as you can to reduce deployment headaches
    • R execution script
  5. You can also test a deployment by clicking the “Deploy Now” button at the top of the page which will re-run the last deployment

Laravel Forge is $12 per month for a single VPS, then costs $19 per month for unlimited servers

Copying files from Mac to Android- 2023 Edition

I just got a new phone, and I needed to copy some files over from my old phone SD card onto my new phone’s self storage. There did not seem an easy way so I decided to do it old the fashioned way

  1. Copy files to my Mac
  2. Copy files to my new phone – a Samsung S23

I had not done this for a couple of time, and Android File Transfer tool was not working for me. So I searched around for options to do this.

The approach that I used

  1. Enable USB debugging on your phone
  2. Install Android Debugging Bridge (ADB) that is part of the Android platform tools package using homebrew
    brew install android-platform-tools
  3. Search for devices using adb devices which returns something below
    daemon not running; starting now at tcp:5037
    daemon started successfully
    List of devices attached
    R5CW8168GDX unauthorized
  4. As you can see this is the first time the device has been seen by adb so needs to have its fingerprint stored, all you have to do is open your phone and accept the prompts.
  5. When the prompts have been accepted, you can see the device is now available
    List of devices attached
    R5CW8168GDX device
  6. Find the path where you want to copy the files:
    • Connect to the phone
      adb shell
    • Navigate to the path where you want to put the files mine was /storage/self/primary
    • Thus I have the
  7. Push files from the computer
    adb push <absolute_local_computer_path> <absolute_remote_phone_path>
  8. Pull the files when on the phone
    adb pull <absolute_remote_phone_path> <absolute_local_computer_path>

Voila and there you are …

Are there any GUI tools that you have used in 2023?

Deploying a Tighten Jigsaw static site to a VPS using Laravel Forge

I have ran into an interesting challenge for a documentation site that I am working on. The code repository is private on GitHub until it is ready to be made public, however needs to be be deployed publicly

Initially I started working with Jekyll deployment proved to be a challenge through GitHub pages and Netlify both of which required upgrades which the project could not justify

Thus I looked in the direction of Jigsaw by Tighten which I have wanted to try out in a long time. My reasoning being that since it was Laravel based, I would be able to deploy it leveraging my existing Laravel Forge subscription to a managed server, and voila all would be well.

I first struggled with getting Jigsaw to get configured to display the site – so I went back to the drawing board and came up with the following flow based

  1. Build a production static version of the site
  2. Deploy it to the gh-pages branch as per the instructions in https://jigsaw.tighten.com/docs/deploying-your-site/
  3. To automate this process I created a custom deploy action below
    deploy": "npm run prod; deploy_time=$(date \"+%A %d-%B, %Y %H:%M:%S\") && git add build_production && git commit -m \"Build for deploy on $deploy_time\" && git subtree push --prefix build_production origin gh-pages which combines all the commands to push to gh-pages
  4. Create an HTML site on my VPS using Laravel Forge
  5. Link the gh-pages branch as the app to the site
  6. Enable quick deploy so that any changes to the gh-pages branch automatically deploys the new site
  7. Do not forget to setup SSL on the site (using the method of your choice)

So once I make changes to my site, I run npm run deploy to push it into production …

Birthday Musings – High Noon

Snake in monkey shadow

I have made it, another trip around the sun, and I am a year older hopefully a little wiser, and it is a time to celebrate, but reflect and see look to what the future holds …

This year, this celebration is the high-noon of my life, I have lived through the morning – cold as the day starts with my birth, the teenage years as the 9am rays of the sun, and youthful exuberance that is 10am and 11am sunshine the best for getting your dose of Vitamin D to stay healthy. Now that it is high-noon, we at the equator with the sun overhead the shadow is a tiny spot a circle standing still, I looking at the past, present and peering into the future.

High-noon does not mean I am half-way my life, it just signals a turning point into what I am focusing on as I burst into the afternoon phase of my life, an opportunity to go for big hairy audacious goals with a long term thinking as time is my friend. The days of life are long so there is more to look forward to, work for and give to humanity

Thank you for all the love on this day…

Gakyali Mabaga

Geek Tools – My Mouse Journey

I have been a predominatly mouse user all my life, at the beginning there was no choice as all we had were desktops, even if I was able to learn to use vi on Unix/Linux terminals. However as laptops have become cheaper and more capable, they have become primary computing devices for many including myself, and however big the trackpads are they still feel unwieldly.

This is sharing my experiences trying out and finding mice that work for me

Sony 2 Button mouse aka your regular mouse

This is the basic mouse everyone starts with, USB wires, basic point and click device that just works

HP Wireless Mouse 250

This was my first foray into more than basic mice, a wireless mouse shaped to fit into my larger than average hands. I used this one for about 2-3 years and still works, the AA battery lasts 6 months or so

Apple Magic Mouse

When I moved to a Mac environment I had the HP Wireless mouse 250, however I had the opportunity to invest in the Apple mouse after all it was from the world’s best design company. It did not work for me, could not fit in my hands and my brain could not connect with its design

Apple Trackpad 2

This was a big jump basically an external trackpad, which was moved to the side where a mouse would be. I loved, and still love this trackpad however the pinch and move, double finger and other combinations of finger movements were too much for my brain which craved for a proper mouse

MX Master Series

The day I touched an MX Master 2S, I just had to have one. There was no going back, here was a mouse which fitted in my hand, had the controls my muscle memory would remember, plus the side scroll wheel that worked great for wide spreadsheets, and TweetDeck (I have 10 columns I follow). The battery life is amazing over 70 days such that I charge it when I feel guilty it is missing out on being charged

I have had the 2S and now 3, they are an indispensible part of my computing accessories and workflow

The ease of switching between laptops (just a button at the bottom) along with Flow (when I want to show off), plus USB-C charging as I work make this series of mice a must have.

There are lots of additional app-specific configuration options that can be made via the Logi Options app, but I am not yet there, the basics work fine for me

MX Vertical

This is a new addition to my workflow, 4 hours usage and inspiration for finally writing this post, and I love it… Seems like my wrist and shoulders are happy too. A strange shape but one which is so natural I am wondering why I never had one before. I will keep updating here how my experiences pan out over the next few weeks

MX Ergo

A new addition to my collection started as an experiment, but I have made it the primary mouse for my home workstation, a tad different from my previous mice experience. Being much heavier, it is more cumbersome to move around, so it is my fixed home workstation mouse.

Not having to move my hand is very interesting mentally and now I am familiar with the trackball even for DrawBattle games that kickoff our weekly team standup, the scroll which has up and down, with left and right tilt of the scroll bar giving a scrolling motion (what I need for the many columns in my XPro former Tweetdeck, and large Excel sheets)

This leaves the MX Vertical as the mouse I move around with in my laptop bag for mobile usage away from my home workstation.

Mouse Usage Hacks

The following hacks are what I use to improve my mouse usage over time

  1. Gimars Memory Foam Mouse Wrist Rest Support – https://smile.amazon.com/dp/B07KD7SCQG/ helps a lot with preventing carpal tunnel injury and means you can use your mouse for long periods without stress-related pains
  2. Increase the size of your cursor, mine is at maximum, so I never have to look for it anywhere on the screen

What is your mouse journey and experience, what else have you tried that seems to work?

Update – March 2024: Added the MX Ergo experience