Skip to content

Instantly share code, notes, and snippets.

View maheshgawali's full-sized avatar

Mahesh maheshgawali

  • Pune
View GitHub Profile
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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 / ffmpeg_3.4.2_full_help.txt
Last active July 22, 2021 15:11
ffmpeg 3.4.2 full help / all options / all flags / all commands , refer https://www.ffmpeg.org/ffmpeg-all.html for detailed explanation of all options
root@f827ea48f84f:/code# ffmpeg -h full
ffmpeg version 3.4.2-2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu2)
configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --e
@maheshgawali
maheshgawali / useful_rsync_copy.sh
Created January 2, 2019 06:24
rsync cmd with flags for optimal data transfer
# Tested on ubuntu-18 and mac os x (mojave)
# I also tried the ssh compressed way of doing things, but this is much simpler
# There might be better combinations available, please leave a comment and I shall test and update this gist
rsync -vaHxPz username@IP:SOURCE_PATH DESTINATION_PATH
# rsync options explanation:
# -v, --verbose increase verbosity
# -a, --archive archive mode; same as -rlptgoD (no -H)
# --no-OPTION turn off an implied OPTION (e.g. --no-D)