Skip to content

Instantly share code, notes, and snippets.

@ChisholmKyle
ChisholmKyle / mkdir_p.c
Last active December 5, 2022 09:13
Simple recursive mkdir in C
/* recursive mkdir based on
http://nion.modprobe.de/blog/archives/357-Recursive-directory-creation.html
*/
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#define PATH_MAX_STRING_SIZE 256
@ChisholmKyle
ChisholmKyle / redislimiter.js
Created February 11, 2016 08:05
General purpose rate limiters using Redis and ioredis in node.js
var Ioredis = require('ioredis');
var redis = new Ioredis();
// Rolling window rate limiter
//
// key is a unique identifier for the process or function call being limited
// exp is the expiry in milliseconds
// maxnum is the number of function calls allowed before expiry
var redis_limiter_rolling = function(key, maxnum, exp, next) {
redis.multi([