Skip to content

Instantly share code, notes, and snippets.

@lifeeth
lifeeth / selenium.sh
Created February 8, 2011 18:09
selenium init.d script for debian
#!/bin/bash
# /etc/init.d/selenium
# debian-compatible selenium-grid startup script.
# Based on jenkins startups
# Praneeth Bodduluri <lifeeth[at]gmail.com>
# update-rc.d -n -f selenium start 90 2 3 4 5 . stop 10 0 1 6 .
### BEGIN INIT INFO
# Provides: selenium-grid
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
import osmnodepbf
foo = osmnodepbf.Parser("some.osm.pbf")
tags = foo.return_tags(refresh=True) # To see what tags are available
railways_stations = foo.parse({"railway":"station"})
import os
import math
import csv
from openpyxl.reader.excel import load_workbook
files = os.listdir('files/')
for filename in files:
filename = filename.split(".")[0]
wb2 = load_workbook("files/"+filename+'.xlsx')
output_writer = csv.writer(open("csvfiles/"+filename+'.csv','wb'))
sheet = wb2.get_sheet_by_name(name = 'Sheet1')
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",
@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__))
@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 / 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'

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 / 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
@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