Skip to content

Instantly share code, notes, and snippets.


Rajeev Singh callicoder

View GitHub Profile
tasdikrahman / haproxy-allow-whitelisted-IPs.cfg
Created May 5, 2019
HAproxy config (/etc/haproxy/haproxy.cfg) for kingsly to allow only whitelisted IP's for a backend.
View haproxy-allow-whitelisted-IPs.cfg
frontend kingsly-frontend
acl ALLOW_SRC src -f /etc/haproxy/include/allow-ips.lst
http-request deny if !ALLOW_SRC
default_backend kingsly
ArsalRaza /
Last active Jan 11, 2022
Extract Audio from Video, Mute Video, Crop Video from start, Crop Video from end Android MediaMuxer - JAVA
import android.annotation.SuppressLint;
import android.util.Log;
import java.nio.ByteBuffer;

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

javierarques / sticky.js
Last active Mar 5, 2021
Sticky Sideabr With Vanilla Javascript. Detects scroll and set fixed the element. Live example:
View sticky.js
// Sticky Nav Component
var Sticky = (function() {
'use strict';
var CSS_CLASS_ACTIVE = 'is-fixed';
var Sticky = {
element: null,
position: 0,
addEvents: function() {
harlow /
Last active Jan 16, 2022
Job queues in Golang
sayan801 / Extract Audio from Video Using MediaMuxer
Created Oct 7, 2014
Extract Audio from Video Using MediaMuxer
View Extract Audio from Video Using MediaMuxer
private boolean cloneMediaUsingMuxer(String srcMedia, String dstMediaPath,
int expectedTrackCount, int degrees) throws IOException {
// Set up MediaExtractor to read from the source.
//AssetFileDescriptor srcFd = mResources.openRawResourceFd(srcMedia);
MediaExtractor extractor = new MediaExtractor();
int trackCount = extractor.getTrackCount();
//assertEquals("wrong number of tracks", expectedTrackCount, trackCount);
// Set up MediaMuxer for the destination.
MediaMuxer muxer;
zziuni / stuns
Created Sep 18, 2012
STUN server list
View stuns
# source :
# A list of available STUN server.