Skip to content

Instantly share code, notes, and snippets.

@SwiftedMind
SwiftedMind / route.tsx
Created November 11, 2023 17:29
Request Validation in Next.js
import { ZodError, z } from "zod";
interface RequestBody {
name: string;
}
const RequestBody = z.object({
name: z.string(),
});
@guillermodlpa
guillermodlpa / useKeepBrowserPathUpdated.ts
Created January 12, 2023 07:37
React hook guideline implementation to update the URL with a debounce in Next.js
function getBrowserPath(params) {
// your implementation here
}
const URL_UPDATE_DELAY = 750;
export default function useKeepBrowserPathUpdated(params) {
const path = getBrowserPath(params);
useEffect(() => {
@jvgrootveld
jvgrootveld / nextjs-firebase-admin-sdk-api-auth-middleware.ts
Last active July 18, 2023 13:37
API Auth middleware for NextJS with firebase admin SDK as this does not work with _middleware files
import { auth } from '../../firebase/firebase-admin'
import { NextApiRequest, NextApiResponse } from 'next'
type NextContextApiHandler = (req: NextApiRequestWithContext, res: NextApiResponse) => Promise<void>
export interface Context {
uid: string
}
export interface NextApiRequestWithContext extends NextApiRequest {
@JaysonChiang
JaysonChiang / api.ts
Last active February 28, 2024 00:18
Example of Axios with TypeScript
import axios, { AxiosError, AxiosResponse } from 'axios';
import token from './somewhere';
interface Todo {
id: string;
title: string;
}
interface User {
id: string;
@theodorosploumis
theodorosploumis / Nework_throttling_profiles.md
Last active May 11, 2024 04:18
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
@lisawolderiksen
lisawolderiksen / git-commit-template.md
Last active April 22, 2024 13:01
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

Laravel alternatives in NodeJS

These are alternative packages/frameworks in NodeJS that cover some of the primary features in Laravel. This is by no means a comprehensive list of Laravel features (or a comprehensive list of NodeJS alternatives).

Depending on your perspective, this list either shows how it's possible to switch from Laravel to NodeJS or shows why you'd want to stay with Laravel 😃


Full stack framework alternatives: Nest, Adonis

@Isopach
Isopach / steps.md
Created February 21, 2018 04:42
Install and run Vuls on Docker on Kali Linux
  1. apt-get update problems: Invalid signature -> run wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add

  2. Couldn't run hello-world:latest locally: change the /etc/default/docker file, specifially the following lines:

# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
@jaytaylor
jaytaylor / delete-from-v2-docker-registry.md
Last active May 10, 2024 16:28
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@fideloper
fideloper / start-container.sh
Last active August 31, 2021 10:59
Enable/Disable xDebug depending on env.
#!/usr/bin/env bash
###
# A CMD or ENTRYPOINT script for a Dockerfile to use to start a Nginx/PHP-FPM
#
# For more details, see 🐳 https://shippingdocker.com
##
if [ ! "production" == "$APP_ENV" ] && [ ! "prod" == "$APP_ENV" ]; then
# Enable xdebug