Skip to content

Instantly share code, notes, and snippets.

View emmahsax's full-sized avatar

Emma Sax emmahsax

View GitHub Profile
@emmahsax
emmahsax / -pluralize.md
Last active January 11, 2024 20:01
Pluralizing English words according to all pluralizing rules!

Easily Pluralizing English Words in Go

This code makes it easy to pluralize words based off of English pluralizing rules.

$ go run main.go
2 balls
1 boy
3 foxes
2 babies
@emmahsax
emmahsax / totp.md
Last active August 10, 2023 18:49
A helpful file that shows how to generate TOTP rotating codes using Ruby

Generating TOTP tokens from a seeds file on your machine in Ruby

This file assumes you have a file (~/.totp.yml) on your machine where you store the SERVICEs, and their secret keys:

aws: rAndOmCharaCTeRsHerE
google: rAndOmCharaCTeRsHerE

Then, you can call like this:

@emmahsax
emmahsax / simple-k8s-pod.md
Last active March 12, 2024 17:47
A very simple Kubernetes pod

A simple Kubernetes pod

Apply this pod to a Kubernetes cluster:

kubectl apply -f simple_pod.yaml

This pod will be applied to the default namespace.

@emmahsax
emmahsax / bootstrap-navbar.md
Last active July 5, 2022 04:07
Example of a simple navigation with Bootstrap 5

Navbar with Bootstrap 5

Here's the html file. This file assumes that there's two SVG icons (an X and a menu bar) downloaded in the /assets/images/icons directory:

<header class="sticky-top">
  <nav class="navbar navbar-expand-md navbar-dark py-0 py-md-0">
    <div class="container-fluid">
      <!-- Left hand side of navbar -->
      <a class="navbar-brand mb-0" href="/" target="_self">
@emmahsax
emmahsax / photoswipe-and-lightbox2.md
Last active February 14, 2024 02:18
How to offer both PhotoSwipe v5 and Lightbox2 in a Jekyll project

Offering both PhotoSwipe v5 and Lightbox2 in a static site

This documents an example of how to offer both PhotoSwipe v5 and Lightbox2 in one project.

Notes

PhotoSwipe

PhotoSwipe helps to make the photo clickable, and then it'll zoom for the user and create a gallery, you can call the photo _include:

@emmahsax
emmahsax / github-pages-deploy-with-travis.md
Last active September 29, 2021 18:14
Example .travis.yml file to deploy to GitHub Pages

Example .travis.yml file to deploy to a GitHub Pages branch

os: linux
language: ruby
cache: bundler
install: bundle install

branches:
  only:
@emmahsax
emmahsax / installing-old-brew-formulas.md
Last active September 14, 2021 22:27
Instructions to install an outdated Homebrew formula

Installing Old Homebrew Formulas

Over the past several years, Homebrew has made it continually difficult to install an outdated formula. I'm not quite sure why, but it's been a struggle for developers for the past 7+ years.

However, there is a workaround (however it's not straight-forward). For this example, I'll use ruby-build:

  1. Note the version you currently have installed:
$ ruby-build --version
ruby-build 20210825
@emmahsax
emmahsax / merging-forks-with-upstream.md
Last active February 10, 2023 15:39
How to merge forks back in with upstream

Merging Forks with Upstream

Check to see if there's changes in upstream that you need to make in your fork

Look for a message like this. If it says that your default branch is behind the upstream's default branch (usually master), it means there are updates:

image

If there are updates, then merge your local fork with upstream

@emmahsax
emmahsax / url-encode-a-string.md
Created December 3, 2020 23:59
Turn any string into a string fit for URLs

URL Encode a string

If you ever have a string that doesn't play nice with URLs, that's probably because it has spaces, or slashes, or anything like that. So, with this easy method, we can turn that string into a URL-friendly string!

def url_encode(str)
  str.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| format('%%%<val>02X', val: m.unpack1('C')) }
end

> url_encode('foo/bar')
@emmahsax
emmahsax / turn-seconds-into-human-readable-time.md
Last active March 16, 2024 18:47
Easily turn seconds into a human-readable time in Ruby

Turn Seconds into Human-Readable Time with Ruby

If you have an integer which is an amount of seconds, you can easily turn it into the form

X days, Y hours, Z minutes, Q seconds

Here's a little method that will do all of that!