Skip to content

Instantly share code, notes, and snippets.

View emmahsax's full-sized avatar

Emma Sax emmahsax

View GitHub Profile
@emmahsax
emmahsax / jekyll-feed-with-multiple-environments.md
Last active November 11, 2020 19:01
Jekyll Feed with multiple environments

Jekyll Feed with Multiple Environments

What this will do is generate a two different feeds:

  • A feed.xml for your local development, which will contain the values you specify for your development environment in your _config.yml.
  • A feed.xml for your live site, which will have the values set in your _config.yml for your production environment.

This is necessary because without different values for title, description, etc, many feed readers will view the two feeds as the same, even if the post content is different This makes it difficult to test if your feed is working and updating locally.

You could add additional environments as well, such as development, test, staging, and production.

@emmahsax
emmahsax / blog-post-pagination-with-jekyll-paginate-v2.md
Last active December 8, 2021 21:30
Blog post pagination with jekyll-paginate-v2

Blog Post Pagination with jekyll-paginate-v2

This uses the pagination provided here. See the pagination in action at https://emmasax.com/blog/.

Let's start with the basics. Here's what the Jekyll _config.yml should look like:

title: An Awesome Blog
description: My blog, which is awesome
url: https://an-awesome-blog.com
@emmahsax
emmahsax / opening-external-links-in-new-tabs.md
Last active December 10, 2020 15:04
Opening external links in new tabs with Javascript
@emmahsax
emmahsax / turn-utc-dates-to-local-timezone.md
Last active July 5, 2022 04:11
Turn UTC dates to local Timezone with Javascript

Turn UTC Dates to Local Timezone with Javascript

Here's the snippet of HTML that can be used to call this file:

<script src="/js/turn-utc-dates-to-local-timezone.js" type="text/javascript"></script>

And here's the JS file turn-utc-dates-to-local-timezone.js:

@emmahsax
emmahsax / circleci-config-to-ignore-branch.md
Last active June 15, 2023 11:41
CircleCI configuration to completely ignore a specific branch

CircleCI Configuration to Ignore a Branch

This file live in the .circleci/ directory of your project, named config.yml:

version: 2.1
jobs:
  skip:
    working_directory: ~/PROJECT_DIRECTORY # If we leave this out, the build will break with missing required arguments
 docker: [ image: circleci/ruby:2.6.5 ] # This doesn't really matter, but just choose any docker image
@emmahsax
emmahsax / fixing-git-history.md
Last active November 11, 2020 19:11
A few files I've used in the past to fix Git history

Fixing Git History

There are two files that I tend to use to fix up some screwed up git history. None of these files should be used on huge repositories where a lot of people have forks and clones. Running any of these files completely rewrites history and will change the git SHA of all of the later commits.

I've used this first file when I've accidentally committed a bunch of past commits with the wrong email (think work vs. personal emails). To use it:

  1. Make a backup branch: git branch default_branch_backup
  2. Make sure you're back on the default branch: git checkout default_branch
  3. Run the script: email_switch.sh
  4. Wait patiently...
@emmahsax
emmahsax / static-site-urls-and-links.md
Last active February 18, 2023 18:30
Linking to images, resources, CSS, and JS within Jekyll
@emmahsax
emmahsax / git-aliases.md
Last active August 13, 2023 22:10
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'
@emmahsax
emmahsax / switching-from-master-to-main.md
Last active November 24, 2020 21:37
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
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!