Skip to content

Instantly share code, notes, and snippets.

@vichfs
vichfs / RestApiClient.php
Created January 15, 2025 13:06
Simple Rest API Client in PHP
<?php
class RestApiClient
{
private string $baseUrl;
private array $headers;
private int $timeout;
private bool $verifySSL;
private ?string $apiKey;
private array $allowedMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
@vichfs
vichfs / scrolltofocusedelm.js
Created October 3, 2024 10:46
JS Function to Scroll to Focused Element
function scrollToFocusedElement() {
const focusedElement = document.activeElement;
if (focusedElement) {
const rect = focusedElement.getBoundingClientRect();
const scrollTop = window.scrollY || document.documentElement.scrollTop;
const elementTop = rect.top + scrollTop;
window.scrollTo({
top: elementTop,
behavior: 'smooth'