Skip to content

Instantly share code, notes, and snippets.

View AndreyNazarchuk's full-sized avatar
🎯
Focusing

andynazay153 AndreyNazarchuk

🎯
Focusing
View GitHub Profile
@freekrai
freekrai / demo.php
Last active April 13, 2024 20:48
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.
@jbeales
jbeales / usps-abbreviations.php
Last active February 4, 2020 01:30
The official USPS abbreviations used in City & Street names, as a PHP array.
<?php
// based on: http://pe.usps.gov/text/pub28/28apc_002.htm
$usps_abbreviations = [
'ALLEY' => 'ALY',
'ANNEX' => 'ANX',
'ARCADE' => 'ARC',
'AVENUE' => 'AVE',
'BAYOO' => 'BYU',
'BEACH' => 'BCH',
{
"name": "fish.pufferfish.raw",
"id": 206,
"icon": "fish_raw_puffer_fish",
"use_animation": "eat",
"use_duration": 32,
"max_damage": 0,
"stacked_by_data": true,
"food": {
@gerard-kanters
gerard-kanters / inactivity.js
Last active March 6, 2024 18:49
Inactivity timeout javascript
<script type="text/javascript">
function idleTimer() {
var t;
//window.onload = resetTimer;
window.onmousemove = resetTimer; // catches mouse movements
window.onmousedown = resetTimer; // catches mouse movements
window.onclick = resetTimer; // catches mouse clicks
window.onscroll = resetTimer; // catches scrolling
window.onkeypress = resetTimer; //catches keyboard actions
@iso2022jp
iso2022jp / base94.c
Created November 11, 2012 09:05
base94 encoder/decoder
#include "base94.h"
void base94_encode(const unsigned char *plain, unsigned char *code) {
// high * 2^64 | low
unsigned long long value
= ((unsigned long long)plain[1] << 56) | ((unsigned long long)plain[2] << 48)
| ((unsigned long long)plain[3] << 40) | ((unsigned long long)plain[4] << 32)