Skip to content

Instantly share code, notes, and snippets.

View sashadev-sky's full-sized avatar

sashadev-sky

  • New York, NY
View GitHub Profile
@sashadev-sky
sashadev-sky / README.md
Created May 15, 2021 05:17 — forked from Tynael/README.md
How to use npx to run gist based scripts
@sashadev-sky
sashadev-sky / launch.json
Last active May 4, 2021 22:09
VSCODE project instance python configurations
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
9 = Bad file descriptor
function bycache() {
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
}
project
│   README.md
│   file001.txt    
│
└───folder1
│   │   file011.txt
│   │   file012.txt
│   │
│ └───subfolder1
@sashadev-sky
sashadev-sky / 00_relative_import_resolution.py
Last active April 25, 2022 15:42
"ImportError: attempted relative import with no known parent package" and its sibling "ValueError: attempted relative import beyond top-level package"
print('__file__={0:<35} | __name__={1:<20} | __package__={2:<20}'.format(
__file__, __name__, str(__package__)))
@sashadev-sky
sashadev-sky / blueprint.py
Created March 31, 2021 16:46 — forked from brenj/blueprint.py
Store application configuration in a Flask blueprint.
@blueprint.record_once
def record_params(state):
"""Store app.config in blueprint when blueprint is registered on app."""
app = state.app
blueprint.config = {key: value for key, value in app.config.iteritems()}
@sashadev-sky
sashadev-sky / render_json.py
Created March 27, 2021 05:01 — forked from nerevar/render_json.py
Pretty print json in jupyter/ipython notebook
import json
import uuid
from IPython.display import display_javascript, display_html, display
class RenderJSON(object):
def __init__(self, json_data):
if isinstance(json_data, dict) or isinstance(json_data, list):
self.json_str = json.dumps(json_data)
else:
self.json_str = json_data
@sashadev-sky
sashadev-sky / launch.json
Created March 27, 2021 04:18
fix error couldn't set PYTHONPATH of undefined in VSCode
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
@sashadev-sky
sashadev-sky / get_exceptions_tree.py
Last active March 23, 2021 20:32
Useful exception tree reference for Python3
def print_exceptions_tree(exception_class, level=0):
if level > 1:
print(" |" * (level - 1), end="")
if level > 0:
print(" +---", end="")
print(exception_class.__name__)
for subclass in exception_class.__subclasses__():
print_exceptions_tree(subclass, level + 1)