NB

Husband, Father, and Solver of Problems.

    TIL my 100vw needs a max-width

    Mon Jan 25 2021

    TL;DR; If you want an element to be full screen and it's inside of a parent element that is full screen, use width:100% instead of width:100vw to avoid the scrollbar sized white space

    I'm not sure how I haven't come across this,or if I have, I don't remember. I was working on a layout and had a position: absolute; div, and I wanted it to be the width of the screen. I reached into my tool box of css and grabbed my trusty width:100vh;, but after I applied the style, I noticed an odd white bar on the right hand side of the screen.

    This is actually "a feature, not a bug", and it has everything to do with the scroll bar on the right side of the screen. Since the scrollbar is covering up the right 5px of the screen, when you tell the browser that you want your block to be the width of the screen, it thinks it's stealing those 5px away from your design and in response gives you an extra 5px that you can scroll to.

    A couple options I see are to apply a global rule to the body such as:

    max-width: 100%;
    overflow: hidden;
    

    Although this will leave you with some other problems down the road when items inside your 100vw block seem a little too close to the right side of the screen.

    A better option would be to set the max width of the block to 100% or even better, just use width:100%

    Wordpress Safari Date Field Polyfill

    Tue Jan 19 2021

    TL; DR; This is a plugin that includes the date-input-polyfill package to provide a picker for browsers that do not support date inputs such as Safari 13.1.

    Working on a site that uses Elementor, I noticed that their date picker element doesn't work on Safari 13.1 and decided to see if there were any polyfills out there for the date input field. I came across the date-input-polyfill package which seemed to fit the bill and bundled it into a simple plugin you can download here.

    UPDATE: After going through the process of testing this out further, I noticed a "Native HTML5" option in the Elementor date field. Elementor has already solved this problem for me haha 🤦‍♂️.

    But in case I ever run into a situation where I need to make a HTML5 date picker cross-browser ready, I have the plugin for the job.

    Dangerous "As" – Typescript

    Thu Dec 17 2020

    TL;DR

    Do This:

    const car: Car = someObj
    

    Not This:

    const car: Car = someObj as Car
    

    Or This:

    const car: Car = <Car>someObj
    

    I'm still pretty new to Typescript,

    and until today I thought that I should type my objects this way:

    const car = {
      color: "RED",
      drivetrain: "AWD",
    } as Car
    
    interface Car {
      color: string
      drivetrain: "AWD" | "2WD" | "4WD"
    }
    

    It wasn't until I was seeing undefined property errors that I decided to take a look at what the "as" keyword is actually doing here. Up until this point, I thought that what I was doing was typing const car to the interface Car. What the as keyword actually does, is forces whatever object I'm defining into that type.

    What makes this dangerous, is that when you typecast an object like this, the compiler will not warn you of missing properties and will give you a false sense of security because you're not seeing compilation errors. For example, this will still compile even though we didn't include a color property:

    const car = {
      drivetrain: "AWD",
    } as Car
    
    interface Car {
      color: string
      drivetrain: "AWD" | "2WD" | "4WD"
    }
    

    With this in mind here's the code above written in a type-safe way:

    const car: Car = {
      color: "RED",
      drivetrain: "AWD",
    }
    
    interface Car {
      color: string
      drivetrain: "AWD" | "2WD" | "4WD"
    }
    
    How to find available IP addresses when DHCP isn't working (Guide for Macs)

    Wed Dec 16 2020

    I needed to set my laptop to a static ip because the router's DHCP service wasn't issuing me one regardless of how many times I renewed it. I found this Stack Exchange Article that featured a really handy terminal command:

    ifconfig | grep broadcast && arp -a
    

    This produces a list of all devices (and their IPs) that respond to the broadcast. My network was pretty small, and the IPs are in order so you can find a gap that doesn't seem to have a device and try it out.

    Vegan Szechuan Celery Squash

    Sat Sep 12 2020

    A delicious alternative to the Szechuan Eggplant I love to order that answers the question: "What do I do with all of this celery?"

    Ingredients:

    • 1 Tbsp Sesame Oil
    • 1 Tbsp Walnut Oil
    • 1 Tbsp Coconut Oil
    • 1/2 Tsp Red Pepper Flakes
    • 2 Tbsp Fresh Grated Ginger (Divided)
    • 4 Cloves Garlic (Divided)
    • 2 Tbsp Corn Starch
    • 6 Stalks of Celery 4 stalks diced, 2 stalks sliced diagonally
    • 2 Large Carrots
    • 1/8 cup Dark Soy Sauce
    • 1/8 cup Light Soy Sauce
    • 2 TBSP Maple Syrup
    • 1/2 cup frozen peas

    Phase 1 Preparation

    • Heat sesame oil over high heat until shimmering.
    • Add two peeled and crushed cloves of garlic, 1 Tbsp grated ginger and stir and cook until garlic is blackened.
    • Add walnut oil and diced celery, sliced squash, and sliced carrots to pan to stir fry.

    Prepare Sauce

    • With a whisk or immersion blender add red pepper flakes, 2 cloves of minced garlic, light and dark soy sauce, maple syrup, coconut oil, and corn starch. Mix thoroughly.

    Combine

    • When the squash is soft from stir frying for approx. 8-10 minutes, add the sauce mixture and sliced celery to the pan. Stir until all veggies are thoroughly coated with sauce.
    View more posts