Skip to content

Instantly share code, notes, and snippets.

@wes-goulet
wes-goulet / insta-fetcher.mjs
Created May 11, 2022 23:09
Node script to fetch instagram posts for a given user and save the files to a folder
#!/usr/bin/env node
// @ts-check
import fetch from "node-fetch";
import fs from "fs";
import { IgApiClient } from "instagram-private-api";
/**
* @typedef InstaPost
* @prop {string} thumbnailUrl
window.onscroll = function () {
/** @type {HTMLElement | null} */
const header = document.querySelector('header');
if (header !== null) {
if (window.scrollY < 5) {
header.classList.remove('scrolled');
} else {
header.classList.add('scrolled');
}
}
@wes-goulet
wes-goulet / type-guard-example.js
Created October 10, 2020 18:31
Type Guard in jsdoc comment
/** @typedef {{swim: () => void}} Fish */
/** @typedef {{fly: () => void}} Bird */
/**
* @param {Fish | Bird} pet
* @returns {pet is Fish}
*/
function isFish(pet) {
return "swim" in pet;
}
@wes-goulet
wes-goulet / launch.json
Created April 18, 2020 21:47
Example VSCode Debug Config for debugging rollup and jest tests
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Rollup",
"program": "${workspaceFolder}/node_modules/.bin/rollup",
"args": ["-c"],
"internalConsoleOptions": "openOnSessionStart"
@wes-goulet
wes-goulet / .zshrc
Last active January 6, 2024 19:49
My up-to-date .zshrc file, leveraging Oh My Zsh
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/wes/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@wes-goulet
wes-goulet / css-tips.md
Last active December 28, 2022 07:42
bullet list of css tips

Margin

  • default margin on the top and bottom of text elements (headings, paragraphs, lists), is equal to the font-size.
    • (for h1 it's actually a little bit smaller, but it's close enough)
  • Whenever two margins touch each other, they will collapse into one single margin instead of two of them which push against one another
  • To center something horizontally on the screen use auto margin, like section { margin: 0 auto; }

Selectors

  • Select multiple elements with comma
    • h1, h3, p { margin-top: 0; }
  • Last selector wins, so p font-size would be 20px in this example:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug index.ts",
npx gzip-size-cli dist/esm/wc-menu-button.min.js
### create linode - https://www.linode.com/docs/getting-started/#create-a-linode
# use random password and save in lastpass
# update packages
yum update
# set hostname
hostnamectl set-hostname example_hostname
# set timezone
@wes-goulet
wes-goulet / gpg-git-setup.sh
Last active September 26, 2022 23:32
Commands to import and setup your gpg key for git commit signing
# install gpg
brew install gnupg
# copy my-gpg-key.asc from other workstation or lastpass or somewhere
# and then import it
gpg --import ~/Downloads/my-gpg-key.asc
# make sure it's there and get the key id (the part that comes after "rsa4096/")
gpg --list-secret-keys --keyid-format LONG