Skip to content

Instantly share code, notes, and snippets.

View zachshallbetter's full-sized avatar

Zach Shallbetter zachshallbetter

View GitHub Profile
@zachshallbetter
zachshallbetter / global_gitignore.md
Created November 6, 2023 21:06
Github Global .gitignore

On macOS, as with other Unix-like operating systems, global gitignore settings are defined in a global .gitignore file, which Git checks in addition to the project's .gitignore. This is used to ignore files and directories that are specific to your local environment, such as OS-specific files or IDE-specific files, which should not be committed to shared repositories.

Here’s the step-by-step process to set up a global .gitignore file on macOS:

  1. Open the Terminal: You can do this by using Spotlight (Cmd + Space), then typing "Terminal" and hitting Enter.

  2. Choose a location for your global .gitignore: Commonly, this would be in your home directory for easy access.

  3. Create or edit your global .gitignore file:

    • You can use any text editor to create or edit this file. For example, using nano would be nano ~/.gitignore_global.
# Protecting Routes in Next.js with App Router
This Gist provides code examples and explanations for protecting routes in a Next.js application using the App Router feature in Next.js 13.4. It covers the latest features, including Middleware, exportMode, unstable_cache, and more. This guide is intended for senior developers with a good understanding of Next.js and React.
## Article Source
The code and explanations in this Gist are based on the Medium article [Protecting Routes in Next.js with App Router](https://medium.com/@zachshallbetter/protecting-routes-in-next-js-with-app-router-53c3409c0655) by Zach Shallbetter. For detailed context and explanations, please refer to the original article.
## Code Examples
@zachshallbetter
zachshallbetter / README.md
Created September 29, 2023 22:42
Next.js Route Testing

Testing Routes in Next.js with Jest and node-mocks-http

This Gist provides a code example for testing routes in a Next.js application using the Jest testing framework and the node-mocks-http library. Testing your routes is crucial to ensure they work as expected and handle various scenarios gracefully.

Prerequisites

Before you start testing routes, make sure you have the following dependencies installed:

@zachshallbetter
zachshallbetter / README.md
Created September 29, 2023 21:33
Middleware Examples

Next.js Middleware Examples

This Gist contains a collection of Next.js Middleware examples that demonstrate various use cases and scenarios for enhancing your Next.js applications. Middleware in Next.js allows you to intercept, modify, and control the flow of requests and responses, making it a powerful tool for building robust web applications.

Middleware Examples

  1. Authentication Middleware (authenticationMiddleware.ts):
    • Checks if the user is authenticated based on a session cookie.
    • Redirects unauthenticated users to the login page.
  • Ensures users have the necessary role to access protected routes.
@zachshallbetter
zachshallbetter / readme.md
Created June 2, 2023 02:18
Structured directory overview shell script

show_structure.sh

This is a shell script that provides a structured overview of your directory, excluding directories listed in .gitignore and any file or directory starting with a dot. The structure is printed up to three levels deep (-L 3).

Dependencies

This script uses the tree and rg (ripgrep) commands. If these are not installed on your system, you can install them with the following commands:

On Ubuntu/Debian:

@zachshallbetter
zachshallbetter / index.html
Created April 17, 2023 23:34
No Follow, No Index
<meta name="robots" content="noindex,nofollow">
@zachshallbetter
zachshallbetter / App.js
Last active March 21, 2023 21:52
JSX Carousel
import React from 'react';
import Carousel from "./Carousel";
const images = [
{ src: "https://images.pexels.com/photos/3635300/pexels-photo-3635300.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1", alt: "Image 1" },
{ src: "https://images.pexels.com/photos/315938/pexels-photo-315938.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1", alt: "Image 2" },
{ src: "https://images.pexels.com/photos/388417/pexels-photo-388417.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1", alt: "Image 3" },
];
function App() {
@zachshallbetter
zachshallbetter / README.md
Created January 24, 2023 21:46 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@zachshallbetter
zachshallbetter / php.info
Created January 24, 2023 20:00
PHP Information file
<?php phpinfo(); ?>
@zachshallbetter
zachshallbetter / SettingsSync
Created August 24, 2019 21:31
Visual Studio Code Settings
SettingsSync