Skip to content

Instantly share code, notes, and snippets.

View codiflow's full-sized avatar
🥰
Being happy

Christian 🦄 codiflow

🥰
Being happy
View GitHub Profile
@fnky
fnky / ANSI.md
Last active September 23, 2024 13:13
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@freekrai
freekrai / demo.php
Last active September 2, 2024 14:11
PHP session-based rate limiter for APIs
<?php
date_default_timezone_set('America/Los_Angeles');
session_start();
include("ratelimiter.php");
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you.
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]);
$limit = 100; // number of connections to limit user to per $minutes
$minutes = 1; // number of $minutes to check for.