Skip to content

Instantly share code, notes, and snippets.

@axot
axot / retry.js
Last active September 1, 2021 01:41
poc for rendering iframe with ajax exponential backoff retry strategy
// <iframe id='iframe' frameborder='0' height='200' width='300'></iframe>
var frame = document.getElementById("iframe").contentWindow.document;
function retryTimeout(n, maximum_backoff) {
maximum_backoff = (typeof maximum_backoff !== 'undefined') ? maximum_backoff : 5000;
if (n < 0) n = 0;
if (maximum_backoff < 0) maximum_backoff = 5000;
var time = 2**(n-1)*100 + Math.floor(Math.random()*100);
@axot
axot / haproxy.md
Last active September 9, 2019 02:38
HAProxy rate limit across overall http requests.

Here are many examples to limit RPS for each client, at the same time, we also need a way to setup a global request limit.

There are two requirements for this purpose.

  1. instead track client ip, we need a global track.
  2. assume we want to setup 1k RPS as a global limit, it should alway allow first 1k requests and only cut off the excess parts.

Here is an example,

@axot
axot / genserial.py
Last active August 29, 2015 14:08
tkbctf4 "Simple Serial Code"
import random
import string
import md5
flag = md5.new()
flag.update("this_is_not_flag!!")
flag_md5 = flag.hexdigest()
print "flag_md5:", flag_md5
flag_md5 = [flag_md5[i:i+4] for i in range(0, len(flag_md5), 4)]
#!/bin/bash
export THEOS=`pwd`/theos
# clone theos.git
git clone git://github.com/DHowett/theos.git
# clone iphoneheaders.git
cd $THEOS
mv include include.bak
git clone git://github.com/rpetrich/iphoneheaders.git include