Skip to content

Instantly share code, notes, and snippets.

View asaboor-gh's full-sized avatar
👋

Abdul Saboor asaboor-gh

👋
View GitHub Profile
@asaboor-gh
asaboor-gh / broken_axes.py
Last active July 28, 2021 18:47
Matplotlib Broken Axes Example
def break_spines(ax,spines,symbol=u'\u2571',**kwargs):
"""Simulates broken axes using subplots. Need to fix heights according to given data for real aspect. Also plot the same data on each axes and set axes limits.
- **Parameters**
- ax : Axes who's spine(s) to edit.
- spines: str,list, str/list of any of ['top','bottom','left','right'].
- symbol: Defult is u'\u2571'. Its at 60 degrees. so you can apply rotation to make it any angle.
kwargs are passed to plt.text.
"""
kwargs.update(transform=ax.transAxes, ha='center',va = 'center')
_spines = [spines] if isinstance(spines,str) else spines
# This gist is developed as separate package. Do pip install ipyslides or go to https://github.com/massgh/ipyslides
@asaboor-gh
asaboor-gh / create_function.py
Created May 5, 2021 22:52 — forked from dsuess/create_function.py
Dynamic function creation in Python
"""
Python is a dynamic language, and it is relatively easy to dynamically create
and modify things such as classes and objects. Functions, however, are quite
challenging to create dynamically.
One area where we might want to do this is in an RPC library, where a function
defined on a server needs to be available remotely on a client.
The naive solution is to simply pass arguments to a generic function that
accepts `*args` and `**kwargs`. A lot of information is lost with this approach,
however, in particular the number of arguments taken. Used in an RPC
implementation, this also delays any error feedback until after the arguments
import numpy as np
import PIL
from io import BytesIO
import matplotlib.pyplot as plt
def plt_to_text(plt_fig=None,width=144,vscale=0.96,colorful=True,invert=False,crop=False,outfile=None):
"""Displays matplotlib figure in terminal as text. You should use a monospcae font like `Cascadia Code PL` to display image correctly. Use before plt.show().
- **Parameters**
- plt_fig: Matplotlib's figure instance. Auto picks if not given.
- width : Character width in terminal, default is 144. Decrease font size when width increased.
@asaboor-gh
asaboor-gh / StreamlitRemoteServer.py
Last active August 20, 2020 01:34
Streamlit minimal app to view VASP output from remote server without downloading files. See instructions in comments!
import streamlit as st
import pivotpy as pp
import os
st.write('# Streamlit from Remote Server!')
path_project = st.text_input("Literal Path to project folder", os.getcwd())
with st.spinner('Selecting Files ...'):
if os.path.isdir(path_project):
files = pp.get_child_items(path_project,include=['vasprun.xml'],filesOnly = True)
else:
st.warning('Path is incorrect, falling back to launch path')
@asaboor-gh
asaboor-gh / LICENSE
Last active February 5, 2024 08:24
JSON Encoder/Decode for Numpy Objects
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@asaboor-gh
asaboor-gh / settings.json
Created May 22, 2020 02:05 — forked from cinnamon-msft/settings.json
Windows Terminal Build Color Scheme
{
"name": "Build",
"foreground": "#f1f1f1",
"background": "#492D7C",
"cursorColor": "#FFFFFF",
"black": "#0C0C0C",
"red": "#C50F1F",
"green": "#13A10E",
"yellow": "#C19C00",