Skip to content

Instantly share code, notes, and snippets.

View ghomem's full-sized avatar

Gustavo Homem ghomem

View GitHub Profile
#!/bin/bash
timestamp=$(date +%Y-%m-%d_%H-%M-%S)
vimrc_backup=/tmp/.vimrc.bak.$timestamp
# backup previous vimrc
if [ -f ~/.vimrc ]; then
cp -R ~/.vimrc $vimrc_backup
echo "Previous .vimrc was backed up to $vimrc_backup"
fi
@ghomem
ghomem / vimrc
Last active October 15, 2024 08:33
vimrc
call plug#begin()
" List your plugins here
Plug 'ghomem/nerdtree'
Plug 'ghifarit53/tokyonight-vim'
Plug 'itchyny/lightline.vim'
Plug 'tpope/vim-fugitive'
Plug 'rodjek/vim-puppet'
Plug 'iberianpig/tig-explorer.vim'
Plug 'mhinz/vim-grepper'
@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>