Skip to content

Instantly share code, notes, and snippets.

@pandeybk
pandeybk / get_links.js
Last active April 5, 2016 20:46
get all links and post to console
@pandeybk
pandeybk / hello-revinate.pl
Last active April 5, 2016 21:24
Hello Revinate
use re 'eval';
'?'
=~( '('
.'?'. '{'.
('`'| '%').
('[' ^'-'
).''. ('`'|
'!') .''.
('`'| ',').
(( '"')) . ( ('[')^
file=id_rsa.pub
bucket=com.dgmates.public.bucket
resource="/${bucket}/${file}"
contentType="text/plain"
dateValue="$(LC_ALL=C date -u +"%a, %d %b %Y %X %z")"
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
s3Key=<AWS_ACCESS_KEY_ID>
s3Secret=<AWS_ACCESS_KEY_SECRET>
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
curl -k -X PUT -T "${file}" \
@pandeybk
pandeybk / gist:304b80ad0955cb4550d4be0baa95c80d
Created June 7, 2016 23:49
nginx redirect multiple domains
server {
listen 80;
server_name dgmates.com dgmates.com.sg www.dgmates.com.sg dgmates.sg www.dgmates.sg;
return 301 http://www.dgmates.com$request_uri;
}
server {
server_name www.dgmates.com;
access_log /var/log/nginx/dgmates.access.log;
@pandeybk
pandeybk / reverse tunne, autossh, cron
Last active June 20, 2016 16:29
Create reverse tunnel using autossh, add pub keys using password base authenication
TUNNEL_PORT1=$1
TUNNEL_PORT2=$2
wget http://www.harding.motd.ca/autossh/autossh-1.4e.tgz
gunzip -c autossh-1.4e.tgz | tar xvf -
cd autossh-1.4e
./configure
make
sudo make install
@pandeybk
pandeybk / reboot_system.py
Last active June 23, 2016 21:51
Reboot system if telnet connection is failed for certain time
#!/usr/bin/env python
import telnetlib
import time
import os
HOST="some.host.com"
PORT=22
@pandeybk
pandeybk / SimpleAuthServer.py
Created July 28, 2016 18:40 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
@pandeybk
pandeybk / countries.sql
Created July 30, 2016 02:51 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@pandeybk
pandeybk / kops-application-load-balancer.py
Last active December 14, 2018 22:50
Kubernetes Cluster: AWS: Application LoadBalancer
# Requirements:
#
# aws configure:
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, REGION
import os
import boto3
import random
import string
import sys, getopt
@pandeybk
pandeybk / clean-docker-for-mac.sh
Created November 30, 2016 18:20 — forked from MrTrustor/clean-docker-for-mac.sh
This script cleans the Docker.qcow2 file that takes a lot of disk space with Docker For Mac. You can specify some Docker images that you would like to keep.
#!/bin/bash
IMAGES=$@
echo "This will remove all your current containers and images except for:"
echo ${IMAGES}
read -p "Are you sure? [yes/NO] " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then