Skip to content

Instantly share code, notes, and snippets.

@redhat127
redhat127 / pagination.jsx
Created July 10, 2025 07:26
inertiajs with laravel and react - pagination
import { Link } from "@inertiajs/react";
function buildPageUrls(current, last, links) {
const delta = 3;
const range = [];
const left = Math.max(2, current - delta);
const right = Math.min(last - 1, current + delta);
let l = 1; // track last added page number, start from 1 because first page added below
range.push({ page: 1, url: links.first });
@redhat127
redhat127 / app.css
Last active April 6, 2025 19:23
roo.tsx
@import "tailwindcss";
@redhat127
redhat127 / main.py
Created April 2, 2025 19:25
install the first two packages: (requests, bs4)
import requests
from bs4 import BeautifulSoup
def get_latest_news():
url = "https://www.amnesty.org/en/"
headers = {"User-Agent": "Mozilla/5.0"} # Helps to avoid being blocked
response = requests.get(url, headers=headers)
if response.status_code != 200:
print(f"Failed to fetch page. Status code: {response.status_code}")
@redhat127
redhat127 / login.blade.php
Created March 16, 2025 08:54
is this the best way to login with only email input?
<x-layout title="home">
<div class="space-y-4">
<h1 class="font-bold text-4xl">login</h1>
<form action="{{ route('login') }}" method="POST" class="space-y-4" novalidate>
@csrf
@session('success')
<div class="bg-green-100 border-green-600 border text-green-900 text-center p-2 rounded">
{{ $value }}
</div>
@endsession