Skip to content

Instantly share code, notes, and snippets.

View Magnus167's full-sized avatar
🧘
thinking...

Palash Tyagi Magnus167

🧘
thinking...
View GitHub Profile
@Magnus167
Magnus167 / custom_logging.py
Last active October 17, 2022 15:34
Logging where different loggers can be defined for each function call/process, and can also take unique IDs for "batch" of processes
import logging, sys, inspect, uuid
# pip install logging_tree
import logging_tree
def Get_Frame_Stack(asString=True):
frame_stack = inspect.stack()
frame_stack_as_string = '.'.join([frame_stack[I][3] for I in range(len(frame_stack))][1:-1][::-1])
return frame_stack_as_string if asString else frame_stack
@Magnus167
Magnus167 / Publishing_To_PyPI.md
Created October 11, 2022 10:52
Short guide on publishing to PyPI using twine;

The only dependency that needs to be installed is twine.

Use pip install twine.

In setup.py ensure:

ISRELEASED = True

Then execute the build command (make sure to clean up dist/ beforehand).

@Magnus167
Magnus167 / operator_python.md
Created October 8, 2022 18:49
Using a list of indexes to address another list/array in Python
@Magnus167
Magnus167 / run_python_script_in_conda_env.bat
Created September 30, 2022 09:41 — forked from 1kastner/run_python_script_in_conda_env.bat
Run a Python script in a conda environment from a batch file
@ECHO OFF
SETLOCAL EnableDelayedExpansion
REM Insert your conda env here
SET CONDA_ENV=MY_DESIRED_CONDA_ENV
CALL :activate_conda_env
REM Insert your python script here
@Magnus167
Magnus167 / add_anacdona_to_path.md
Created September 27, 2022 11:16
Adding conda to command promt, enabling conda usage in batch files (BAT files)
@Magnus167
Magnus167 / launch_zoom_meeting.py
Created September 26, 2022 13:54
Python script to launch Zoom/Google/Teams meetings
# useful when joining recurring zoom/teams/google meetings.
# webbrowser is part of the python (3.6+) standard library, so no installs needed.
import webbrowser
webbrowser.open_new_tab('LINK_TO_ZOOM_MEETING')
# for windows systems,
# 1. save this script in a new (empty) folder. (mine is called work_tools)
@Magnus167
Magnus167 / import_from_url_python
Created September 23, 2022 15:03
trix to import a standalone module from a url python
import urllib.request
a = urllib.request.urlopen(url)
eval(a.read())
https://stackoverflow.com/a/47341399/4417821
@Magnus167
Magnus167 / pip_install_trix.md
Last active September 27, 2022 14:33
Details about how and where pip install will look for packages; also how to install packages from a local repo

pip install from a particular Github branch or commit for a package (useful when testing)

pip install git+https://github.com/<user>/<repo>.git@<branch>

and

@Magnus167
Magnus167 / conda_4.6_powershell.md
Created September 23, 2022 09:37 — forked from martinsotir/conda_4.6_powershell.md
Enable conda in powershell

Enabling conda in Windows Powershell

First, in an administrator command prompt, enable unrestricted Powershell script execution (see About Execution Policies):

set-executionpolicy unrestricted

Then makes sure that the conda Script directory in is your Path.

@Magnus167
Magnus167 / Conda Setup for Powershell.md
Last active May 9, 2023 07:28
Setting up conda in powershell for Windows, activating on powershell startup

First, look at

Enabling conda in Windows Powershell

Once you install Anaconda or Miniconda on Windows, open a Anaconda Powershell Prompt from Start Menu.

Or, If you don't see it there, then assuming you have installed miniconda3 at path C:\miniconda3\4.9.2, do: