Skip to content

Instantly share code, notes, and snippets.

View nitish6174's full-sized avatar

Nitish Garg nitish6174

View GitHub Profile
"""
Module containing utility functions to time code snippets.
"""
import contextlib
import time
@contextlib.contextmanager
def timelogger(msg_prefix:str='Executed in : ', msg_suffix:str='s', logger=print):
from crontab import CronTab
from datetime import datetime
cron = CronTab()
cmds = {
'python ~/code/reminder.py': '0/30 9-18 * * *',
'~/code/backup.sh': '0/30 9-18 * * *',
}
for cmd, cron_str in cmds.items():

Remove trailing whitespace from files

sed -i 's/[ \t]*$//' folder/*/*.py

Convert Jupyter notebook to PPT

# General use-case
jupyter nbconvert --to slides filename.ipynb
# Code-free conversion

PyInstrument

from pyinstrument import Profiler
profiler = Profiler()

profiler.start()

# --- code to profile : start ---
# e.g. :-
@nitish6174
nitish6174 / .vimrc
Last active April 4, 2022 12:11
Improve vim by installing vundle package manager, following plugins and using keyboard shortcuts
" Steps
" =====
" 1. Add below content to your .vimrc
" 2. Clone vundle : `git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim`
" 3. Run :PluginInstall in vim
" --------------------------------------------------
" Vundle package manager settings
" --------------------------------------------------
@nitish6174
nitish6174 / ubuntu-gnome-extensions.md
Created October 4, 2016 19:29
List of useful Ubuntu Gnome extensions to install
  • Alternatetab (Ungroup windows of same type)
  • Applications menu (Windows OS style Applications menu)
  • Caffeine (Disable autosuspend)
  • Clipboard indicator (Clipboard history)
  • Drop down terminal (Alternative to Guake terminal)
  • Easyscreencast (Screen recording)
  • Laine (Control volume of each application)
  • Media keys (Music control buttons on topbar)
  • Media player indicator (Music controller for topbar)
  • Pixel saver (Brings title bar applications to topbar)
@nitish6174
nitish6174 / ubuntu-gnome-themes.md
Last active October 4, 2016 19:36
List of dark themes for Ubuntu Gnome
  • Adapta
  • Arc
  • Flatabulous
  • Nebula
  • Numix
  • Paper
  • Super flat remix (Icon theme)
@nitish6174
nitish6174 / sublime_packages.md
Last active October 4, 2016 10:38
List of useful Sublime text packages
  • Manager and explorer :
    • Package manager : To manage all your sublime packages
    • SideBarEnhancements : Gives an extensive menu for renaming, duplicating file etc from the file explorer pane (The left column)
  • Themes & Color schemes :
    • Monokai Extended
    • Predawn
    • Theme - Afterglow
    • Theme - Asphalt
    • Theme - Brogrammer
  • Theme - Flatland
@nitish6174
nitish6174 / .gitconfig
Last active April 11, 2022 05:13
Git aliases
[alias]
s = status
a = add
d = diff
dc = diff --cached
dd = difftool --tool=vimdiff -y
c = commit
ps = push
pl = pull
co = checkout
@nitish6174
nitish6174 / mouse_cursor_using_keyboard.md
Last active October 6, 2018 19:12
Settings to control mouse cursor using keyboard
  1. Open 'Settings' -> 'Universal Access' -> 'Pointing and clicking' -> 'Mouse keys'
  2. Turn that option ON
  3. Now you will be able to move cursor with numpad but the speed will be extremely slow.
  4. Run the following commands in terminal to set a good to do speed :
    sudo apt-get install xkbset
    xkbset ma 60 10 10 5 2