Skip to content

Instantly share code, notes, and snippets.

@jahil
jahil / mysql_backup.sh
Last active August 29, 2015 14:08
MySQL Backup Script
#!/bin/bash
DB_USER=root
DB_PASS=""
HOST=localhost
DBS_LIST=$(mysql -u $DB_USER $DB_PASS -Bse 'show databases')
BASE_BAK_FLDR=/www/backups/dump
RM_FLDR_DAYS="+7"
index=0
PING=$(mysqladmin ping --host $HOST -u $DB_USER $DB_PASS 2>/dev/null)
@jahil
jahil / ebs_backup
Last active August 29, 2015 14:08
EBS Backup and Rotation Script
#!/bin/bash
export EC2_PRIVATE_KEY=~/.ec2/pk.pem
export EC2_CERT=~/.ec2/cert.pem
ec2-create-snapshot vol-ab0921c0 -d "Intellinar Server ROOT - $(date +'%d-%m-%Y')"
ec2-create-snapshot vol-110d257a -d "Intellinar Data - $(date +'%d-%m-%Y')"
ec2-create-snapshot vol-8bbb93e0 -d "Database Server aka RDS - $(date +'%d-%m-%Y')"
Purge EBS Snapshots
-------------------
export EC2_PRIVATE_KEY=~/.ec2/pk.pem
@jahil
jahil / trends.py
Created November 4, 2014 12:03
Twitter Trends - Major Cities of Pakistan
@jahil
jahil / usbreset.c
Created November 4, 2014 12:04
usbreset -- send a USB port reset to a USB device
/* usbreset -- send a USB port reset to a USB device */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
@jahil
jahil / aws.py
Created November 4, 2014 12:25
AWS Report Tool
__author__ = 'mohsin'
import boto.ec2
import optparse
from termcolor import colored
parser = optparse.OptionParser()
parser.add_option("-r", action="count", dest="regions", help='list all regions')
parser.add_option("-i", action="count", dest="instances", help='list all instances in region')
parser.add_option("-a", action="count", dest="all_instances", help='list all instances in all region')
@jahil
jahil / decoder.py
Created November 4, 2014 12:42
Remmina Password Decoder
__author__ = 'mohsin'
import base64
from Crypto.Cipher import DES3
secret = base64.decodestring('nMfNBx9y1T7Xe+DvWmsFwTeGUevEw3WLQlD5pl74qvo=')
password = base64.decodestring('temWEHt1x/0=')
print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)
import requests
url = 'http://kitaabghar.com/bookbase/idara/KrishanChandKeBehtareenAfsanay.html'
def download_file(url,path,filename=''):
try:
if filename=='':
Patch for OpenSSH Portable to log passwords
Tested on:
OpenSSH 5.3p1 - OpenSSH 6.6p1
May apply to older versions.
To apply:
patch --dry-run < sshlog.patch
@jahil
jahil / mongodb-backup.sh
Last active August 29, 2015 14:27
Simple MongoDB Backup Script
#!/bin/bash
HOST=localhost
BASE_BAK_FLDR=/backup/mongodb
RM_FLDR_DAYS="+7"
DB_BKP_FLDR=$BASE_BAK_FLDR/$(date +%d-%m-%Y)
[ ! -d $DB_BKP_FLDR ] && mkdir -p $DB_BKP_FLDR
mongodump --host $HOST --out $DB_BKP_FLDR
@jahil
jahil / .vimrc
Created September 21, 2015 12:26
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
Plugin 'kien/ctrlp.vim'
Plugin 'bling/vim-airline'