Skip to content

Instantly share code, notes, and snippets.

View maheshgawali's full-sized avatar

Mahesh maheshgawali

  • Pune
View GitHub Profile
@maheshgawali
maheshgawali / sample_code.swift
Last active August 25, 2020 13:37
explore whats happening here in swift?
class Car {
var plate: String
var driver: Driver?
init(plate: String) {
self.plate = plate
}
}
class Driver {
@maheshgawali
maheshgawali / ffmpeg_with_srt.sh
Last active January 17, 2024 12:53
build ffmpeg with libsrt libx264 libx265 libaom libvpx libopus libfdk-aac
# combination of steps from
# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
# and
# https://seanthegeek.net/455/how-to-compile-and-install-ffmpeg-4-0-on-debian-ubuntu/
response=
echo -n "Do you want to compile the optional libpulse as well (yes/no) > "
read response
@maheshgawali
maheshgawali / most_time_consuming_cmd.sql
Last active April 16, 2020 10:12
get the most time consuming cmd from mysql (innodb)
# HIGHEST TIME CONSUMING QUERY AT PRESENT
select ID,INFO,COMMAND,STATE, TIME from information_schema.processlist where STATE != 'Sleep' and COMMAND!='Sleep' order by TIME desc limit 1\G
@maheshgawali
maheshgawali / mysql_innodb_space_usage.sql
Created February 10, 2020 12:09
mysql query to get approximate space usage per table (for innodb)
SELECT table_schema as `Database`, table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES where table_schema = "<YOUR_DATABASE_NAME_HERE>" ORDER BY (data_length + index_length) DESC;
@maheshgawali
maheshgawali / keepcleandb_test_runner.py
Last active May 7, 2024 06:21
custom django test runner to flush db after all tests are done, but retain schema
'''
This test runner flushes the test db after all tests are run, and retains the schema (all tables will be truncated)
You can safely run all tests using --keepdb (recommended) parameter where in it will only keep the schema , but not the actual data
This saves times in frequent test runs as the entire test db schema doesnt have to be recreated every time
note that this will still apply newer migrations (if any) from last known point when the tests were run
if you actually want to retain test data, then do not use this test runner
'''
@maheshgawali
maheshgawali / csv_to_json.py
Last active February 23, 2019 07:41
a simple python script for converting a csv to json, you can choose to use json, ujson or simplejson based on performance requirements
# inspired from http://www.andymboyle.com/2011/11/02/quick-csv-to-json-parser-in-python/
# refactored for using in python-3
# Also added ability to change json lib easily within json, ujson, simplejson
# reference for performance comparison json, ujson, simplejson - of https://medium.com/dataweave/json-vs-simplejson-vs-ujson-2887b2c128b2
import csv
import importlib
# you can use 'json', 'ujson' or 'simplejson'
json_lib_name = 'json'
@maheshgawali
maheshgawali / settings.json
Last active February 22, 2019 05:02
vscode settings for working with python, pylint, yapf, django
{
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "/Users/abc/Envs/venv/bin/pylint",
"editor.formatOnSave": true,
"python.formatting.yapfPath": "/Users/abc/Envs/venv/bin/yapf",
"python.formatting.provider": "yapf",
"python.formatting.yapfArgs": [
"--style",
@maheshgawali
maheshgawali / .pylintrc
Created February 22, 2019 04:59
pylintrc to work with yapf and pylint_django, keep at top level in your project
[MASTER]
# reference : https://raw.githubusercontent.com/google/yapf/master/pylintrc
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
init-hook='import sys; sys.path.append(".");'
@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)
@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