Skip to content

Instantly share code, notes, and snippets.

View ppsreejith's full-sized avatar
🗒️
Learning

Sreejith Pp ppsreejith

🗒️
Learning
View GitHub Profile
@ppsreejith
ppsreejith / Simple SMTP Server
Created January 5, 2014 23:22
A quick smtp server written in python.
import smtpd
import smtplib
import asyncore
class SMTPServer(smtpd.SMTPServer):
def __init__(*args, **kwargs):
print "Running smtp server on port 25"
#!/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 / 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 / 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 / install.sh
Last active March 30, 2021 06:16
Favourite tools
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y update
apt-get -y upgrade
apt-get -y install zsh emacs silversearcher-ag docker-ce htop nginx jq
if [ ! -f /usr/local/bin/docker-compose ]; then
echo "Installing docker compose"
VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
@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"