Skip to content

Instantly share code, notes, and snippets.

View jazibsawar's full-sized avatar

Jazib Sawar jazibsawar

  • Tartu, Estonia
View GitHub Profile
@jazibsawar
jazibsawar / leaky-bucket-rate-limiter.ts
Last active February 18, 2025 22:33
Implementation of leaky bucket rate limiter in TS
/*
The algorithm is simple:
Assume a bucket that can hold a limited amount of water (requests). Over time, water leaks out at a fixed rate,
creating space for new water. A new request (water) is only accepted if there is enough free space in the bucket;
otherwise, it is denied.
*/
class LeakyBucketRateLimiter {
private bucketCapacity: number;
private currentBucketSize: number;
private bucketLeakRate: number;
@jazibsawar
jazibsawar / staticgen-archive.json
Created July 9, 2020 15:42
STATICGEN.COM DATA ARCHIVE
[]
@jazibsawar
jazibsawar / delete_custom_post_type.php
Created October 2, 2017 12:28
WordPress $wpdb: Delete all posts of a custom post type with its associated meta data (taxonomies, post meta) using SQL query & $wpdb
<?php
function delete_custom_posts($post_type = 'post'){
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare("
DELETE posts,pt,pm
FROM wp_posts posts
LEFT JOIN wp_term_relationships pt ON pt.object_id = posts.ID
LEFT JOIN wp_postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s