Skip to content

Instantly share code, notes, and snippets.

View juancarlospaco's full-sized avatar
👑
https://t.me/NimArgentina

Juan Carlos juancarlospaco

👑
https://t.me/NimArgentina
View GitHub Profile
@juancarlospaco
juancarlospaco / qpdf.py
Last active April 6, 2018 19:35
PDF Conversor powered by Qt5, does NOT show up any GUI, just needs an URL string, then it Prints PDF, and returns file path string, uses UUID if no output filename is passed, optional Landscape orientation if supported, CSS3 Just Works!.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""PDF Conversor powered by Qt5."""
from uuid import uuid4
from PyQt5.QtCore import QUrl
@juancarlospaco
juancarlospaco / pretty_json.py
Last active January 10, 2022 02:58
Pretty-Print JSON from dict to string, very Human-Friendly but still Valid JSON, Python3.
from json import dumps
def json_pretty(json_dict: dict) -> str:
"""Pretty-Printing JSON data from dictionary to string."""
_json = dumps(json_dict, sort_keys=1, indent=4, separators=(",\n", ": "))
posible_ends = tuple('true false , " ] 0 1 2 3 4 5 6 7 8 9 \n'.split(" "))
max_indent, justified_json = 1, ""
for json_line in _json.splitlines():
if len(json_line.split(":")) >= 2 and json_line.endswith(posible_ends):
@juancarlospaco
juancarlospaco / templar.py
Last active April 6, 2018 19:25
Templar is a tiny Template Engine that Render and Runs native Python 3. Optionally it can Minify the rendered output, or load from a file or file-like object.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Templar is a tiny Template Engine that Render and Runs native Python."""
import re
@juancarlospaco
juancarlospaco / http_serve_livereload.py
Created September 24, 2015 05:54
HTTP Server with LiveReload if any else builtin Simple HTTP Server, asks to install LiveReload if not installed but still works Ok, tested on Python 3.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""HTTP Serve with LiveReload."""
import os
from webbrowser import open_new_tab
@juancarlospaco
juancarlospaco / stealth_string.py
Last active April 6, 2018 19:33
Stealth Strings, hidden and dangerous.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Stealth Strings, hidden and dangerous."""
import base64
import binascii
import codecs # importing codecs is optional, it will work ok if no codecs.
@juancarlospaco
juancarlospaco / html2ebook.py
Last active May 10, 2018 19:18
HTML5 to eBook converter, with Table Of Contents, Compression, optional Metadata, optional output filename, Mobile Friendly, ePub v.3.0.1 compliant, runs as standalone, run as module, Python3, NO Dependencies just Python Standard Lib only.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""HTML2eBook a tiny function that converts HTML5 to eBook,Mobile Friendly."""
import os
import zipfile
from getpass import getuser
@juancarlospaco
juancarlospaco / tinyslation.py
Last active April 6, 2018 19:32
Translate from internet via API from mymemory.translated.net, with Fall-back, DoNotTrack HTTPS, Time-Out and Legally.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tinyslations, smallest possible Translations from Internet with fallback."""
from urllib import parse, request
from locale import getdefaultlocale
from json import loads
@juancarlospaco
juancarlospaco / template.rst
Last active April 6, 2018 19:31
Universal markup for Markdown and reStructuredText. Template that works with GitHub Markdown AND ReStructuredText at the same time!
@juancarlospaco
juancarlospaco / boilerplate.py-stealth.txt
Last active April 6, 2018 19:34
Boilerplate for any Python3 App, with or without GUI, Standard Lib only, safe, common, basic, trivial, single-file App oriented. Copy at top of your code and use the functions. Includes all imports. I write it after seeing repeating same functions again and again on my code. Designed for Stealth Strings. Not designed for end-user use.
​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
@juancarlospaco
juancarlospaco / ipdb_on_exception.py
Last active August 15, 2021 14:13
ipdb on Exception AutoMagically!, Launch pdb or ipdb when an exception happens automatically.
def pdb_on_exception(debugger="pdb", limit=100):
"""Install handler attach post-mortem pdb console on an exception."""
pass
def pdb_excepthook(exc_type, exc_val, exc_tb):
traceback.print_tb(exc_tb, limit=limit)
__import__(str(debugger).strip().lower()).post_mortem(exc_tb)
sys.excepthook = pdb_excepthook