This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface ISwitchCameraArgs { | |
deviceId?: string | |
} | |
export interface IStartCameraArgs { | |
constraints?: MediaStreamConstraints; | |
retryCount?: number; | |
} | |
export interface ICameraDevice extends MediaDeviceInfo { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"logo": "https://www.car-logos.org/wp-content/uploads/2011/09/abarth1.png", | |
"brandName": "Abarth", | |
"models":[ | |
{ | |
"model": "204 A Roadster", | |
"startYear": 1949, | |
"endYear": 1950, | |
"nameTags": "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list | |
# A list of available STUN server. | |
stun.l.google.com:19302 | |
stun1.l.google.com:19302 | |
stun2.l.google.com:19302 | |
stun3.l.google.com:19302 | |
stun4.l.google.com:19302 | |
stun01.sipphone.com | |
stun.ekiga.net |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//initialize the function once the page loads | |
window.onload = function() { | |
activateTimer(); | |
} | |
//show the popup if the user is idle for more than 15 seconds | |
// the user is considered idle if he doesn't actively interact | |
//with the page by either moving his cursor or pressing any button on the keyboard | |
const activateTimer = ()=> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def removeQuotesFromValue(value): | |
value = value.replace("'", '"') | |
# value = value.replace('"', "") | |
return value | |
def splitLineIntoParts(line): | |
line = line.lstrip() | |
line = line.rstrip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPaginatedItems(items, page, pageSize) { | |
var pg = page || 1, | |
pgSize = pageSize || 100, | |
offset = (pg - 1) * pgSize, | |
pagedItems = _.drop(items, offset).slice(0, pgSize); | |
return { | |
page: pg, | |
pageSize: pgSize, | |
total: items.length, | |
total_pages: Math.ceil(items.length / pgSize), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<style type="text/css"> | |
.action-btn-group{ | |
margin: 4px; margin-left: 40vw; padding: 10px; cursor: grab; font-size: 1.4em; | |
} | |
</style> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
//perform the action here | |
} | |
catch(err) { | |
//do something when an error occurs e.g console.log(); | |
} |