Skip to content

Instantly share code, notes, and snippets.

View ppsreejith's full-sized avatar
🗒️
Learning

Sreejith Pp ppsreejith

🗒️
Learning
View GitHub Profile
#!/bin/sh
PROXY_IP=144.16.192.247
PROXY_PORT=8080
LAN_IP=`nvram get lan_ipaddr`
LAN_NET=$LAN_IP/`nvram get lan_netmask`
iptables -t nat -A PREROUTING -i br0 -s $LAN_NET -d ! $LAN_IP -p tcp --dport 80 -j DNAT --to $PROXY_IP:$PROXY_PORT
iptables -t nat -A PREROUTING -i br0 -s $LAN_NET -d ! $LAN_IP -p tcp --dport 443 -j DNAT --to $PROXY_IP:$PROXY_PORT
iptables -t nat -A POSTROUTING -o br0 -s $PROXY_IP -p tcp -d $LAN_NET -j SNAT --to $PROXY_IP
iptables -A FORWARD -i vlan1 -o br0 -s $LAN_NET -d $PROXY_IP -p tcp --dport $PROXY_PORT -j ACCEPT
@ppsreejith
ppsreejith / gist:9bb5be30cfdfadbbd851
Created November 8, 2014 10:33
Ssh configuration through tor
## Inside the firewall ( use proxy)
Host *
#ProxyCommand /usr/bin/corkscrew 192.168.1.102 8080 %h %p
#ProxyCommand putty -load phoneproxy %h %p
#ProxyCommand nc -X connect -x 192.168.1.102:8080 %h %p
CheckHostIP no
Compression yes
Protocol 2
ProxyCommand connect -4 -S 192.168.1.150:9050 $(tor-resolve %h 192.168.1.150:9050) %p
@ppsreejith
ppsreejith / dist_calc.py
Created January 6, 2016 09:22
Calculating distance for csv file
import googlemaps
import csv
gmaps = googlemaps.Client('YOUR_API_KEY_HERE')
with open('NAME_OF_FILE.csv') as info:
read = csv.reader(info)
ans = []
for row in read:
ans.append(row[0] + ", Hong Kong")

Keybase proof

I hereby claim:

  • I am ppsreejith on github.
  • I am ppsreejith (https://keybase.io/ppsreejith) on keybase.
  • I have a public key whose fingerprint is 4CC9 7B47 29F5 EABE 0C6B 73AC A8F0 1505 C9DD 49BA

To claim this, I am signing this object:

@ppsreejith
ppsreejith / simple_server.py
Last active February 27, 2017 06:18
A simple python http server
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = 8080
class myHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
@ppsreejith
ppsreejith / reducer_template
Created March 9, 2017 14:06
A template for object function based reducers.
import Immutable from 'immutable';
import _ from 'lodash';
const initialState = Immutable.Map({
data: 5
})
const reducers = {
FILTER_EDIT: (state, {data}) => state.merge({data}),
FILTER_INC: (state) => state.updateIn(['data'], val => val+1),
@ppsreejith
ppsreejith / nginx.conf
Last active November 27, 2017 13:30
nginx conf for s3 proxy
worker_processes auto;
pid /run/nginx.pid;
daemon off;
events {
worker_connections 1024;
}
http {
sendfile on;
@ppsreejith
ppsreejith / spending_calc.py
Created November 24, 2018 16:07
Spending calculator
#Everything is monthly
G_INITIAL_AMOUNT = 0.0
G_INVESTMENT = 1200.0
G_INTEREST_RATE = 1.07 ** (1.0/12.0)
G_INFLATION_RATE = 1.0228 ** (1.0/12.0)
G_CURRENT_SPENDING = 1000.0
def compound(principal, investment, rate, time):
"Compound interest calculator"
["background",
"tench",
"goldfish",
"great white shark",
"tiger shark",
"hammerhead",
"electric ray",
"stingray",
"cock",
"hen",
@ppsreejith
ppsreejith / spend-calculator.py
Created September 10, 2019 08:08
To calculate spending and burn rate over a large period of time
G_CONSTANT_AMOUNT = 400000.0 # Minimum bank balance kept or liquid cash
G_INITIAL_INVESTMENT = 150000.0 # Existing investments
G_MONTHLY_INVESTMENT = 70000.0 # How much you plan to invest monthly
G_RETURN_RATE = 1.11 ** (1.0/12.0) # compound annual return rate on investment (maybe last 5 years?)
G_INFLATION_RATE = 1.08 ** (1.0/12.0) # compound annual inflation rate (maybe last 10 years?)
G_CURRENT_SPENDING = 80000.0 # Current (and planned future) monthly spending
G_LEEWAY_MONTHS = 3.0 # Number of months you need to keep spare (maybe to look for a new job etc)
def compound(principal, investment, rate, time):
"Compound interest calculator"