Skip to content

Instantly share code, notes, and snippets.

View maheshgawali's full-sized avatar

Mahesh maheshgawali

  • Pune
View GitHub Profile
@maheshgawali
maheshgawali / bb_pr_checker.py
Created August 10, 2018 09:01
simple python script to check if a PR exists for the current branch in bitbucket pipeline, execute bitbucket pipelines only if a PR is created for a branch
#!/usr/bin/env python3
import requests
import json
import argparse
PAGE_LENGTH = '50'
PR_STATE = 'OPEN'
@maheshgawali
maheshgawali / stateful_dispatcher.py
Created August 7, 2018 07:36
a stateful function dispatcher using simple python using chaining vs maintaining a dict
#!/usr/bin/env python3
# OBJECTIVE
# 1. script should be able to pick up from where it left off, assume that state is saved extrenally in some datastore
# 2. order of execution of methods matters
class statefulDispatcherUsingChaining():
def __init__(self, current_state=None):
self.current_state = "one" if not current_state else current_state
@maheshgawali
maheshgawali / git_merge.sh
Created July 6, 2018 07:53
simple git merge script to merge current branch into a given branch
#!/bin/sh
# Usage: To merge current git branch into a branch called 'dev' and be back to the current branch
# ./git_merger.sh dev
target="$1"
current=`git branch | awk '/\*/{print $2}'`
git checkout ${target}
git pull origin ${target}
@maheshgawali
maheshgawali / django_related_model_names_discovery.py
Created June 5, 2018 06:44
Get all models which user a foreign key from the given model, so are related to it and should be taken care of in cleanups
@maheshgawali
maheshgawali / django_orm_logging.py
Created May 11, 2018 07:55
Django: show/log ORM sql calls from python shell
# taken from -> https://stackoverflow.com/a/30394237/1035818
# i hunt for this every once in a while, so creating the gist, all credits for this snippet at to the commenter from the link above
import logging
from django.db import connection
connection.force_debug_cursor = True # Change to use_debug_cursor in django < 1.8
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
@maheshgawali
maheshgawali / git_merged_branches_in_date_order.sh
Last active December 21, 2017 04:47
git command to find merged branch in order of last commit
#!/bin/bash
echo -n $'#####################################################\n'
echo -n $'### Find all git branches merged into this branch ###\n'
echo -n $'#####################################################\n'
response=
echo -n $'\nEnter name of the git branch > '
read response
if [ -n "$response" ]; then
@maheshgawali
maheshgawali / apache-graceful-restarter.sh
Created October 28, 2017 16:45
restart apache gracefully
#!/bin/bash
check_process() {
echo "$ts: checking $1"
[ "$1" = "" ] && return 0
[ `pgrep -n $1` ] && return 1 || return 0
}
ts=`date +%T`
echo '$ts: stopping apache gracefully'
@maheshgawali
maheshgawali / android_usb_tethering_with_mac.txt
Created October 13, 2017 05:43
how to get android device usb tethering working on your mac
Since I could not find any official support, putting what worked for me here.
How to get USB tethering on MAC working !
0. connect your android phone by usb to your mac
1. install latest package from http://joshuawise.com/horndis
2. open terminal and run this command : sudo kextload /Library/Extensions/HoRNDIS.kext
3. disable USB debugging on your phone
4. check network (your phone should show up there now) and turn off wifi