Skip to content

Instantly share code, notes, and snippets.

Avatar

Emma Sax emmahsax

View GitHub Profile
@emmahsax
emmahsax / bootstrap-navbar.md
Last active Jul 5, 2022
Example of a simple navigation with Bootstrap 5
View bootstrap-navbar.md

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 Jul 5, 2022
How to offer both PhotoSwipe v5 and Lightbox2 in a Jekyll project
View photoswipe-and-lightbox2.md

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 Sep 29, 2021
Example .travis.yml file to deploy to GitHub Pages
View github-pages-deploy-with-travis.md

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 Sep 14, 2021
Instructions to install an outdated Homebrew formula
View installing-old-brew-formulas.md

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 Jun 24, 2021
How to merge forks back in with upstream
View merging-forks-with-upstream.md

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 Dec 3, 2020
Turn any string into a string fit for URLs
View url-encode-a-string.md

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

&gt; url_encode('foo/bar')
@emmahsax
emmahsax / turn-seconds-into-human-readable-time.md
Last active Dec 3, 2020
Easily turn seconds into a human-readable time in Ruby
View turn-seconds-into-human-readable-time.md

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
emmahsax / switching-from-master-to-main.md
Last active Nov 24, 2020
A guide of how to switch from master to main branch in the terminal
View switching-from-master-to-main.md

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
emmahsax / git-aliases.md
Last active Jul 5, 2022
Personal git aliases
View git-aliases.md

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'