Skip to content

Instantly share code, notes, and snippets.

View z4nr34l's full-sized avatar
💻
QmVlcC1ib29wLCBib29wLWJlZXA=

Mateusz Janota z4nr34l

💻
QmVlcC1ib29wLCBib29wLWJlZXA=
View GitHub Profile
@z4nr34l
z4nr34l / grid-layout.tsx
Created December 30, 2025 18:02
React + tailwind responsive grid layout
import { cn } from "@workspace/ui/lib/utils";
import type { ReactNode } from "react";
type GridConfig = {
cols: number;
rows: number;
};
type GridLayoutProps = {
mobile: GridConfig;
@z4nr34l
z4nr34l / update-dependencies.yml
Created December 12, 2025 12:36
Just put this file in your next.js repository inside .github/workflows/ and get PRs with latest version of Next every 8h (if there was newer)
name: Update Dependencies
on:
schedule:
# Runs every 8 hours (at 00:00, 08:00, and 16:00 UTC)
- cron: "0 */8 * * *"
workflow_dispatch: # Allows manual trigger
permissions:
contents: write
@z4nr34l
z4nr34l / responsive.tsx
Created September 9, 2025 19:22
React Tailwind css responsive display helper component
import { cn } from "@/lib/utils";
interface ResponsiveProps {
children: React.ReactNode;
className?: string;
}
interface BreakpointProps extends ResponsiveProps {
show?: "sm" | "md" | "lg" | "xl" | "2xl";
hide?: "sm" | "md" | "lg" | "xl" | "2xl";
@z4nr34l
z4nr34l / smart-sort.ts
Created May 2, 2025 10:01
TypeScript smart sorting primitive
/**
* Smart sorting utility that detects data types and applies appropriate sorting methods
* - Strings are compared case-insensitively
* - Dates are compared as Date objects
* - Numbers are compared numerically
* - Booleans are compared as booleans (false first, true second)
*/
/**
* Detects the data type of a value
@z4nr34l
z4nr34l / updater.sh
Last active February 27, 2025 10:10
Updater script for usage in cron to update any project on remote machine. Just add it as * * * * * /opt/projects/project/updater.sh
#!/bin/bash
# Project settings
PROJECT_DIR="/opt/projects" # CHANGE PATH
# Function to log messages with date and time
log_message() {
echo "[$(date +"%Y-%m-%d %H:%M:%S")] $1"
}
@z4nr34l
z4nr34l / middleware_rfc.md
Last active October 11, 2024 12:20
RFC: Next.js Dynamic Middleware

RFC: Next.js Dynamic Middleware

Summary

This RFC proposes a new approach to implementing middleware in Next.js, moving away from a single middleware.ts file to a more dynamic, route-specific implementation similar to the current handling of dynamic segments, pages, and layouts.

Motivation

The current middleware implementation in Next.js, while powerful, lacks the flexibility and modularity offered by other Next.js features like dynamic routing. This proposal aims to bring middleware in line with these other features, allowing for more granular control and easier management of middleware across a complex application.

@z4nr34l
z4nr34l / middleware.ts
Last active August 6, 2024 11:37
next-easy-middlewares multipath middleware chain
import { createMiddleware } from '@rescale/nemo';
import { internalMiddleware } from '@/app/(platform)/(personal)/_middleware';
const middlewares = {
'/(home|settings){/:path}?': internalMiddleware,
};
export const middleware = createMiddleware(
middlewares as never,
);
@z4nr34l
z4nr34l / updater.sh
Created May 31, 2024 08:14
Auto project update on dedicated server, just put it in cron :D
#!/bin/bash
# Project settings
PROJECT_DIR="<PROJECT DIR>"
# Function to log messages with date and time
log_message() {
echo "[$(date +"%Y-%m-%d %H:%M:%S")] $1"
}
@z4nr34l
z4nr34l / route.ts
Last active May 28, 2024 08:18
@rescale/cron example usage
import type { NextRequest, NextResponse } from 'next/server';
import { CronJob, type ErrorResponse } from '@rescale/cron';
// [...]
interface CombinedResponse {
updateSubscriptions: UpdateSubscriptionResponse[];
sendNewsletter: SendNewsletterResponse[];
}
@z4nr34l
z4nr34l / README.md
Created May 20, 2024 07:19
Tinybird github + vercel integration for nextjs projects.

As there is no officially supported integration that really works I've prepared a simple CI/CD pipelines to cover vercel's preview and production environments.

Instruction

1. Create 3 Tinybird workspaces:

  • <name>_dev,
  • <name>_stage,
  • <name>