Skip to content

Instantly share code, notes, and snippets.

@abhijitmamarde
abhijitmamarde / install_python3.md
Last active September 10, 2019 10:45
installing python3 on ubuntu18.04

run using user with root access or append sudo before each command:

$ apt update
$ apt install software-properties-common
# optional: required for installing pip packages which needs compiler. ex: uwsgi
$ apt-get install build-essential
$ add-apt-repository ppa:deadsnakes/ppa

$ apt install python3.7
Bracket Pair Colorizer
Excel Viewer
Git Blame
GitLens — Git supercharged
IntelliSense for CSS class names in HTML
JSON Parse & Stringify
JSON Tools
Markdown All in One
Python
REST Client
@abhijitmamarde
abhijitmamarde / linode setting commands.md
Created February 12, 2019 14:50
linode setting useful commands

to get system public IP

curl ifconfig.me

install virtualenv

apt install virtualenv

change hostname:

@abhijitmamarde
abhijitmamarde / pub_client.py
Created January 31, 2019 15:42
pub-sub using zmq and multiprocess module
import zmq
import baker
from multiprocessing import Process
@baker.command
def start(name, topicfilter="10001", port="5566"):
print(f"listening pub-server at port:{int(port)}; topic:{topicfilter}")
# Socket to talk to server
context = zmq.Context()
@abhijitmamarde
abhijitmamarde / mock_os_path_exists.py
Created November 30, 2018 11:22
mock method from standard package
from os.path import exists as orig_exists
from unittest.mock import Mock
exists = orig_exists
def new_exists(file):
print(f"new_exists: checking if '{file}' exists:", orig_exists(file))
print("but will send exists = True")
return True
@abhijitmamarde
abhijitmamarde / mock_builtin_len.py
Created November 30, 2018 10:41
creating mock of builtin functions in Python
from unittest.mock import Mock
import builtins
len = builtins.len
def new_len(o):
return builtins.len(o) + 1
@abhijitmamarde
abhijitmamarde / sample_cmd_snippet.sh
Created September 19, 2018 07:23
add all current untracked files to git ignore
$ git status -s
?? bmp.log
?? log.html
?? output.xml
?? report.html
$ git ls-files --others --exclude-standard
bmp.log
log.html
output.xml
@abhijitmamarde
abhijitmamarde / gitprof.py
Created October 29, 2016 16:27
git profile changer tool
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
Simple utility to change the active global git profile.
sample profile config file (yaml):
mygit:
user: Abhijit
email: [email protected]
@abhijitmamarde
abhijitmamarde / schedule_event.py
Created October 9, 2016 12:27
logic for scheduling event
import datetime
import time
from pprint import pprint
# duration of each slot, in mins
mins_of_slot = 15
# default time slots info
default_time_slots = [
{
@abhijitmamarde
abhijitmamarde / daysfor.py
Created August 1, 2016 18:50
Get days remaining or passed for particular date. Can add dates/events in json file
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import time
import string
from datetime import datetime
from os.path import expanduser, join
import json