Skip to content

Instantly share code, notes, and snippets.

@vgk77
vgk77 / get_pdf_contract.py
Created March 15, 2020 15:13
#python generate pdf
def get_pdf_contract(context_data):
html_string = render_to_string("mobile/loan_terms.html", context_data)
html = HTML(string=html_string)
contract_file = BytesIO(html.write_pdf())
print(contract_file)
html.write_pdf(target='/tmp/loan.pdf');
fs = FileSystemStorage('/tmp')
with fs.open('loan.pdf') as pdf:
@vgk77
vgk77 / hz_setup.sh
Last active February 1, 2024 14:34
Setup #ubuntu server with #docker compose
# To start:
# curl https://gist.githubusercontent.com/vgk77/b249a4721246ca518382f8e27e78ecfa/raw/12eab95e674c0c0517c8562c7e546ed9f8fbc049/hz_setup.sh | sudo bash
#update packages
apt update && apt upgrade -y
apt install mc git vim htop iftop qemu-guest-agent apt-transport-https ca-certificates curl software-properties-common make -y
#change hostname
#sudo hostnamectl set-hostname YOU_HOST_NAME
@vgk77
vgk77 / how_to_disable_local_cors_in_firefox.txt
Last active August 12, 2024 14:26
Disable #firefox same origin policy
https://developer.mozilla.org/en-US/docs/Archive/Misc_top_level/Same-origin_policy_for_file:_URIs
about:config -> security.fileuri.strict_origin_policy -> false
@vgk77
vgk77 / djmoney_value_as_decimal
Created August 27, 2019 13:38
#django money serialize as decimal
price = MoneyField(max_digits=14, decimal_places=2, coerce_to_string=False)
@vgk77
vgk77 / trigramm_similarity_example.py
Created July 18, 2019 10:06
Example with trigramm similarity function #django #python
from django.contrib.postgres.search import TrigramSimilarity
def find_product_using_trigram_similarity(
pricelist_product: str, min_similarity=0.3
) -> Optional[Product]:
"""Find the most similar product to the pricelist product
using trigram similarity search.
"""
return (
@vgk77
vgk77 / how_much_cpu_count.py
Created January 15, 2019 16:33
How much CPU count #python
import multiprocessing as mp
print(mp.cpu_count())
@vgk77
vgk77 / mikrotik_change_mac-address.sh
Last active January 26, 2023 20:29
#mikrotik change mac-address on ethernet interface
# set mac
/interface ethernet set ether4 mac-address=XX-XX-XX-XX-XX-XX
#reset mac
/interface ethernet reset-mac-address ether4
@vgk77
vgk77 / iterm_shortcuts.md
Last active December 27, 2018 18:59
usefull #iterm shortcuts
  • Cmd+left arrow, Cmd+right arrow - navigates among tabs.
  • Cmd+number - navigates directly to a tab.
  • Cmd+Option+Number - navigates directly to a window.
  • Cmd+Option+Arrow keys navigate among split panes.
  • Cmd+] and Cmd+[ navigates among split panes in order of use.
@vgk77
vgk77 / .gitignore
Last active November 26, 2018 13:21
gitignore for #python dev
*.ipynb_checkpoints
*.DS_Store
*__pycache__
*._*
*.log
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
@vgk77
vgk77 / curl_queries.sh
Last active February 1, 2019 11:27
#curl queries
#GET
curl "uri?key1=value1&key2=value2"
#POST
curl -d "key1=value1&key2=value2" "uri"
#DELETE
curl -X DELETE "uri"
#POST request.json with headers