explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!


Leave a comment

Active in your 40s: Healthy Products I Use

Most, if not all of my posts on this blog are tech or science related. Now with the widespread use of things like ChatGPT, CoPilot, etc., problem solvers like you and myself are probably using websites like this less and less and tools like the aforementioned, more and more. And I suppose the infrequency of my posts doesn’t help much either. That being said, I want to broaden the scope of this blog to include a few more topics I am passionate about: health and being active.

Disclosure

The motivation for such a change is not completely altruistic either. In doing so, I would like to generate a little passive income by using Amazon’s Affiliates program where by I can post a link here, having readers click said link and hopefully purchasing a product, I will receive a small commission. Also, I actually use these products nearly daily. I will likely not post any links to studies or other anecdotal evidences. These work for me, that’s it. If you have questions for me, leave a comment. Read this as my pseudo disclosure. Now on to the fun stuff.

Collagen Peptides

Collagen has been all the rage in the beauty world for decades. It promotes healthy growth of nails, hair, and skin. But I think it’s often overlooked in applications for athletes and active people. I’d like to share my personal experience with collagen peptides and why I believe they are essential for anyone, especially those involved in combat sports.

As someone who has been practicing combat sports since 2010, my body endures more damage than usual, particularly in my joints. My fingers, toes, knees, and shoulders often bear the brunt of this damage. In January 2020, I underwent surgery to repair my left meniscus and remove a foreign body from my knee, likely a small bone fragment from skateboarding in my 40s. The surgeon predicted I would be on crutches for one to two weeks, but I was off them in just a day and a half. I didn’t push through significant pain; I’m not immune to pain or exceptionally tough. I attribute my quick recovery to taking 20-40g of collagen peptides daily since 2017.

Before I started taking collagen peptides regularly, my recovery time from minor injuries like arm bars or shoulder/knee tweaks was at least a week. Since incorporating collagen peptides into my routine, my recovery time has reduced to just a few days.

I’ve tried various brands. BioOptimal is the one I like best for it’s lower price and I like the fact they source it from grass-fed, pasture-raised cattle (in Argentina I think). I go through a tub of this about every 3-4 weeks depending on my training schedule. I mix 3-4 scoops of this with a hefty scoop of Ryze Mushroom Coffee, a little Organic Maple Syrup, a dash of cocoa powder and occasionally a dash of turmeric. This is my morning body-brain concoction.

Ryze Mushroom Coffee

My brain loves caffeine, but my body doesn’t like caffeine, period. Yeah I can have the occasional soft drink and on very rare occasions, I may have a doctored up coffee from Dunkin Donuts. But anything more than the equivalent to 1.5 cups of coffee and I am in a world of hurt the next day. My sleep and urinary systems are out of whack. In finding coffee alternatives, I discovered Ryze Mushroom Coffee mixes after trying some others. The onset of alertness is a little different than coffee. It’s more subtle and seems to last longer for me. I also don’t get any sort of jitters. Not to mention the slew of health benefits associated with incorporating mushrooms into your diet. Lastly, this blend seems to taste way better than some of the other brands and blends I have tried.

Magnesium Glycinate

I don’t take too many supplements and vitamins, but Klaire Labs Magnesium Glycinate Complex is one of them. I take between 2-3 pills before bedtime. They also keep your digestive system pretty regular. There is plenty of research saying that magnesium is beneficial for sleep, digestion, cognitive abilities, recovery, etc.

fun legal stuff

The information provided on this blog is for general informational purposes only. All content, including text, graphics, images, and other material, is provided in good faith. However, I makes no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability, or completeness of any information on the site. By using this blog, you agree to hold me and affiliates harmless from any and all claims, liabilities, damages, losses, and expenses (including reasonable attorney’s fees) arising out of or in connection with your use of the information provided. This includes, but is not limited to, any errors or omissions in the content, or any actions taken based on the information provided. The content on this blog is not intended to be a substitute for professional advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding a medical condition or treatment. Some of the links on this blog may be affiliate links, meaning I may earn a commission if you click through and make a purchase. This comes at no additional cost to you. I reserves the right to update or change this disclaimer at any time without prior notice. Your continued use of the blog after any modifications to the disclaimer will constitute your acknowledgment of the modifications and your consent to abide and be bound by the modified disclaimer.


Leave a comment

a better Quick Git Merge/Rebase

Back in Feb, I posted a quick tip about expediting the process of pulling the latest from develop and merging into your current branch. https://jwopitz.wordpress.com/2023/02/24/quick-git-merge-rebase/

Usually I just do this from origin’s develop branch, so why should I have to type it every time? I shouldn’t. So I made a git alias to make this even easier:

git fmerge

I could also specify a different branch (it defaults to develop):

git fmerge another-branch

… or you can even specify another origin (though I have never done this)

git fmerge another-branch another-origin

Here is the alias you can add to your ~/.gitconfig file:

[alias]
        fmerge = "!f() { \
                branch=${1:-develop}; \
                shift; \
                remote=${1:-origin}; \
                git fetch $remote $branch:$branch && git merge $branch; \
        }; f"


1 Comment

Quick Git Merge/Rebase

Used to, in order to get the latest from the develop branch into your working branch (assuming you’re using something like GitFlow or the like) you’d normally do this:

# git working-branch
git checkout develop
git pull
git checkout working-branch 
git merge/rebase develop

I’ve learned you can shave this down to just:

# git working-branch
git fetch origin develop:develop 
git merge/rebase develop


Leave a comment

Adventures in teaching an 8yo Math

Recently my 8yo, who LOVES math, was asking me about something they’d discovered on a school video about Math. Apparently they had gone Youtube Spelunking and discovered the concept of Squares and Square Roots. In trying to supplement their understanding of the topic I discovered this brilliantly succinct explanation on Squares and the magic therein.

https://betterexplained.com/articles/surprising-patterns-in-the-square-numbers-1-4-9-16/


Leave a comment

Array Quick Trick

I was working on some coding challenges just to keep myself fresh. I encountered a fairly easy one, dealing w. factorials – link

Now there are various approaches to this, some more complex than others. I specifically wanted to try to use built in array APIs to get this done, specifically using reduce. At first you might think, “well if you’re gonna us an array, you’ll need to fill it with the values you want to factorial-ize“. And if you are using reduce, then you do indeed need a non-empty array.

let a = [];
for( let i = 0; i < factorial; i++ ){ a.push(i + 1); }
return a.reduce(( acc, crnt ) => acc * crnt
   , 1 )

I specifically wanted to avoid this approach, partly because I wanted to challenge myself, partly because I know there is a simpler way. Well there is.

return new Array( factorial ).fill( true ).reduce(( acc, crnt, idx ) => acc * ( idx + 1 )
, 1 )

Nothing here is groundbreaking, I just wanted to challenge myself in trying to accomplish this in one line or specifically trying to avoid using a for-loop to fill an array.


Leave a comment

SSH’ing to Amazon Linux instance

After creating a .pem file and following instructions per their documents – I was running into this:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for './.dev/ec2.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "./.dev/ec2.pem": bad permissions
Permission denied (publickey).

Googling the issue led me to this post https://99robots.com/how-to-fix-permission-error-ssh-amazon-ec2-instance/. You need to change the key’s permissions by chmod’ing the file like so:

chmod 400 ./.dev/ec2.pem 

However this still resulted in the Permission denied (publickey) error. Down in the comments, one user said that the user I was using (jwopitz) was not the what AWS is looking for. I was using

ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-public-dns-name

Instead it should be (assuming you haven’t changed any defaults on your instance’s configuration):

ssh -i /path/my-key-pair.pem ec2-user@my-instance-public-dns-name


Leave a comment

Quickly Sync Mac OS’s Time via Script

I’ve noticed lately that my computer’s time is off by over a minute, sometimes several.  This happens as after I have put my computer in standby by closing the lid.  The problem it causes is that with the time out of sync, I cannot use my auth tokens to log into my work’s VPN.  So instead of opening the Time & Date preferences, I use this one line command to quickly update.

Open Terminal and type:

sudo ntpdate -u time.apple.com

You can even create an alias in your .bash_profile to make it simpler:

alias synctime="sudo ntpdate -u time.apple.com"

 


Leave a comment

Permissions-Based UXs in Angular Using Directives

the problem

A UI may want to present some content in a read-only state, only allowing the user to interact with said content if they are permitted to do so.  I won’t argue the merits/demerits of this particular UX, only how to solve this requirement.

the solution

.directive( 'permissions', [
     'popupService',
     'sessionService',
     function( popupService, sessionService ){

          return {
              restrict: 'A',
              priority: -1,
              link: function( $scope, elem, attrs ){

                   elem.on( 'click', function( evt ){
                        if ( !sessionService.user.isPremium )
                        {
                             evt.preventDefault()
                             evt.stopImmediatePropagation()

                             $scope.$apply( function(){
                                  popupService.show( ... )
                             })
                        }
                   }
              }
          }
     }
])

You can see the original question/answer here – http://stackoverflow.com/a/38439845/1121919


Leave a comment

nvm/node: an easy way to use different versions for different projects

problem

I need to have different versions of node/npm for different projects.  I’d prefer to have each project “know” which version of node/npm it needs to use.


solution

prerequisites

Before we get started, there are a few prerequisites:

  • understand that this is a Mac solution.  While I’m sure a similar solution exists for Windows, I am neither knowledgeable enough nor inclined to write a compatible shell script for Windows at this time.
  • have/install nvm.  I installed mine with Brew.
  • have at least one version of node installed via nvm
  • have a basic understanding of terminal.
  • have a willingness to edit your .bash_profile.

gameplan

leveraging .nvmrc

Much like Ruby has a shortcut for setting the current version of Ruby to use, nvm has a similar feature.  When you enter the following command…

nvm use

… then nvm will look for a .nvmrc file and get the correct version number to use from there.  So first navigate to a project folder that uses node and create a new file called .nvmrc.  Inside just write 4.2.  If you’re a command-line geek then do the following:

cd <project folder>
touch .nvmrc # creates the file
echo \4.2 >> .nvmrc # appends the version to the file
cat .nvmrc # prints the file's contents

editing your .bash_profile

So the easiest way to make nvm read your .nvmrc file is to do a check when you change directories.  We need to make a function we can call when we cd into a directory:


#!/bin/sh
enter_directory(){
if [ "$PWD" != "$PREV_PWD" ]; then
PREV_PWD="$PWD";
if [ -e ".nvmrc" ]; then
nvm use;
fi
fi
}
export PROMPT_COMMAND="$PROMPT_COMMAND enter_directory;"

view raw

check.sh

hosted with ❤ by GitHub

All this is doing is

  • checking to see if the current directory matches the previous directory
  • if it doesn’t , then it stores the current directory to the previous’ variable
  • then it checks to see if a .nvmrc file exists
  • if so, then tell nvm to use it
  • lastly we tell the OS to call this command any time we do something in Terminal/Bash
Design a site like this with WordPress.com
Get started