Skip to content

Instantly share code, notes, and snippets.

@Mitendra
Mitendra / haproxy_config.cfg
Created July 27, 2025 22:32
HAProxy config showing static ip, dns slots, healthcheck, healthcheck with different frequency
defaults
mode http
timeout connect 5s
timeout client 30s
timeout server 30s
# Backend 1: Static IPs without health check
backend backend1
balance roundrobin
server static1 10.0.0.1:80
@Mitendra
Mitendra / scaling_selenium_nginx.conf
Created December 13, 2018 00:08
Sample nginx config with embedded lua for enabling routing to multiple selenium hubs
worker_processes auto;
worker_rlimit_nofile 1024;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
http {
upstream seleniumhub {
server host1ip:4444; # replace this with actual upstream hub ip and port
server host2ip:4444; # replace this with actual upstream hub ip and port
@Mitendra
Mitendra / using_intend.rb
Last active June 7, 2018 20:50
implementation with intent
def sendEmail(checkoutDetails)
if isCheckoutCompleted(checkoutDetails)
# send an email saying checkout is complete
else
# send an email saying checkout errored out
end
end
def isCheckoutCompleted(checkoutDetails)
if(checkoutDetails.length == 1) # same as no of rows
@Mitendra
Mitendra / missing_intend.rb
Last active June 7, 2018 20:50
missing_intend
def sendEmail(numOfRows)
if(numOfRows == 1)
# send an email saying, checkout errored out
else
# send an email saying, checkout is complete
end
end
@Mitendra
Mitendra / simplified_redirects.rb
Last active June 7, 2018 20:21
simplified redirects
class URLHelper
def getBaseUrl(usage)
if(usage == "option1")
return "https://www.samplevip.midwest.mycompany.com/option1prefix/defaultSuffix/SpecificValue"
else
return "https://www.samplevip.midwest.mycompany.com/defaultprefix/defaultSuffix/SpecificValue"
end
end
end
@Mitendra
Mitendra / too_many_redirect.rb
Created June 7, 2018 20:14
An exaggerated example of too many redirects
class URLHelper
def initialize
@seperator = '/'
@domainSeperator = '.'
end
def getSchema()
"https"
end
@Mitendra
Mitendra / fault_injection_using_lua.lua
Created October 17, 2016 05:13
fault injection using lua
function has_value (tab, val)
for index, value in ipairs (tab) do
if value == val then
return true
end
end
return false
end
REDIS_HOST = "127.0.0.1"
REDIS_PORT = "6379"
@Mitendra
Mitendra / load_balancing.lua
Last active April 19, 2017 20:35
load balancing using lua
REDIS_HOST = "127.0.0.1"
REDIS_PORT = "6379"
DEFAULT_UPSTREAM_SERVER = "127.0.0.1"
local redis = require "resty.redis"
local red = redis:new()
red:set_timeout(1000) -- 1 second
local ok, err = red:connect(REDIS_HOST,REDIS_PORT)
if not ok then
ngx.var.target = DEFAULT_UPSTREAM_SERVER