Skip to content

Instantly share code, notes, and snippets.

View nitish6174's full-sized avatar

Nitish Garg nitish6174

View GitHub Profile
@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 / .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
" --------------------------------------------------
"""
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):

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
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():

PyInstrument

from pyinstrument import Profiler
profiler = Profiler()

profiler.start()

# --- code to profile : start ---
# e.g. :-
@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
@nitish6174
nitish6174 / bashrc
Last active June 12, 2017 01:02
Bash aliases for the lazy typers
## Add sudo wherever needed
## list all files in current directory
alias ll="ls -alh"
## apt shorthands
alias sau="sudo apt-get update"
alias sai="sudo apt-get install"
sar() {
sudo apt-get autoremove
@nitish6174
nitish6174 / server_setup.md
Last active November 1, 2016 08:44
Commands to setup development tools on an Ubuntu server
sudo apt-get update
sudo apt-get upgrade
# --------------------------------------------------
# Basic programs
# --------------------------------------------------
sudo apt-get install openssh-server
sudo apt-get install vim
sudo apt-get install git
sudo apt-get install curl
@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)