Skip to content

Instantly share code, notes, and snippets.


Emma Sax emmahsax

View GitHub Profile
emmahsax /
Last active Jul 5, 2022
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 /
Last active Jul 5, 2022
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.



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 /
Last active Sep 29, 2021
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

emmahsax /
Last active Sep 14, 2021
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 /
Last active Jun 24, 2021
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:


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

emmahsax /
Created Dec 3, 2020
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')) }

&gt; url_encode('foo/bar')
emmahsax /
Last active Dec 3, 2020
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!

emmahsax /
Last active Nov 24, 2020
A guide of how to switch from master to main branch in the terminal

Switching from master Branch to main Branch

From the terminal, run this:

git checkout master
git branch -m master main
git fetch
git branch --unset-upstream
git branch -u origin/main
emmahsax /
Last active Jul 5, 2022
Personal git aliases

Personal Git Aliases

A list of git aliases I use on my machines to make working with GitHub and GitLab a little bit faster.

For more information, see my Ruby command-line gem: emmahsax/git_helper.

alias gadd='git add -A'
alias gaddp='git add -p'
alias gcam='git commit -am'