Skip to content

Instantly share code, notes, and snippets.

View ghomem's full-sized avatar

Gustavo Homem ghomem

View GitHub Profile
@ghomem
ghomem / reliable.py
Created February 11, 2024 20:11
reliable invocation
requester = requests.session()
retries = Retry(total=nr_retries, backoff_factor=backoff_factor,
status_forcelist=FORCE_RETRY_STATUS_CODE_LIST)
requester.mount("https://", HTTPAdapter(max_retries=retries))
requester.mount("http://", HTTPAdapter(max_retries=retries))
try:
response = requester.get(url=url, timeout=client_timeout)
@ghomem
ghomem / htmx-form.html
Created December 13, 2023 23:40
htmx div replacing form
<!-- this form includes the HTMX hx-post and hx-target elements -->
<form hx-post="/render" hx-target="#the-image" autocomplete="off">
<! ... div with code for the input fields here -->
<!-- Buttons -->
<div class="grid">
<input type="submit" value="Generate" />
<! ... code for the other buttons here -->
</div>
@ghomem
ghomem / htmx-replaceable-div.html
Last active December 13, 2023 23:36
htmx - replaceable div
<div id="the-image" hx-swap-oob="true">
<figure>
<img src="/static/img/initial-image.jpg" alt="Default image" style="border:1px solid {{img_border_color}}; margin-top: {{img_top_margin}}px"/>
</figure>
</div>