Skip to content

Instantly share code, notes, and snippets.

@lifeeth
lifeeth / aws_codedeploy_agent_install.sh
Last active January 20, 2022 01:02
AWS Codedeploy Agent install on Ubuntu 20.04 - Until a package is released for Ubuntu 20.04
#!/usr/bin/env bash
sudo snap install ruby --channel=2.5/stable --classic
sudo gem install bundler
sudo git clone https://github.com/aws/aws-codedeploy-agent.git /opt/codedeploy-agent
sudo chown -R root.root /opt/codedeploy-agent
sudo chmod 644 /opt/codedeploy-agent/conf/codedeployagent.yml
sudo chmod 755 /opt/codedeploy-agent/init.d/codedeploy-agent
sudo chmod 644 /opt/codedeploy-agent/init.d/codedeploy-agent.service
pushd /opt/codedeploy-agent
sudo bundle install --system
@lifeeth
lifeeth / acko-godigit-claims-settled-april-june-2019.csv
Last active October 29, 2019 12:43
acko godigit claims settled
Company Claims Claims settled Settlement Ratio Market Share
Acko 6439 4785 0.743 0.172
Go Digit 28715 19336 0.673 1.036
@lifeeth
lifeeth / AckoVsGoDigitDirect.csv
Created October 28, 2019 09:59
If all direct sales were website sales
Company Hits Direct Policies Conversion
Acko 5550000 79438 1.43%
Go Digit 1040000 721216 69.30%
@lifeeth
lifeeth / AckoVsGoDigitChannels.csv
Last active October 29, 2019 12:43
Acko vs Go Digit channels
Company Individual agents Agents(Bank) Agents(Non Bank) Broker Direct Other Total
Acko 0 356 0 72156 79438 1723 153673
Go Digit 177652 0 13758 101245 721216 0 1013871
@lifeeth
lifeeth / SFB-mclr.csv
Created October 21, 2019 10:11
Some Small Finance Bank MCLR before and after Scheduled
Small Finance Banks - 2019 Overnight 1 Month 3 Month 6 Month 1 Year 2 Year
Fincare - April 14.85 14.85 15.05 15.15 15.3 15.4
Fincare (Scheduled June 2019) - October 14.55 14.6 14.75 14.9 15 15.1
Jana - April 14.37 14.37 14.41 14.47 14.57 14.74
Jana (Scheduled Aug 2019) - October 13.43 13.45 13.49 13.56 13.68 13.91
North East - April 13.95 14.03 14.07 14.1 14.24 14.35
North East (Scheduled June 2019) - October 15.93 15.98 16 16.03 16.12 16.21

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.

@lifeeth
lifeeth / checker.sh
Created January 19, 2016 20:20
A check to see if GOLANG binary is built for GOARM=5
nm binary_to_check | grep --quiet _sfloat && echo 'ARMv5 Binary' || echo 'Not ARMv5 Binary'
@lifeeth
lifeeth / uwsgi.xml
Created February 11, 2012 06:04
uWSGI config XML
<uwsgi>
<uid>web2py</uid>
<gid>web2py</gid>
<pythonpath>/home/web2py/</pythonpath>
<app mountpoint="/">
<script>wsgihandler</script>
</app>
<mule>run_scheduler.py</mule>
<workers>4</workers>
<pidfile>/tmp/uwsgi-prod.pid</pidfile>
@lifeeth
lifeeth / run_scheduler.py
Created February 11, 2012 06:03
Scheduler process spawning for Web2py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
# Note the app name is hardcoded!
APPLICATION = 'eden'
if '__file__' in globals():
path = os.path.dirname(os.path.abspath(__file__))
possible_drives = [
r"\\.\PhysicalDrive1", # Windows
r"\\.\PhysicalDrive2",
r"\\.\PhysicalDrive3",
"/dev/mmcblk0", # Linux - MMC
"/dev/mmcblk1",
"/dev/mmcblk2",
"/dev/sdb", # Linux - Disk
"/dev/sdc",
"/dev/sdd",