Skip to content

Instantly share code, notes, and snippets.

@andresjesse
andresjesse / caprover-autoclean.txt
Last active April 13, 2024 17:39
CapRover - Auto clean unused docker images using crontab
Setup crontab for constant disk cleanup:
# crontab -e
Add line:
antigo:
*/10 * * * * /usr/bin/docker system prune -af
3 da manhã:
0 3 * * * /usr/bin/docker system prune -af
# crontab -l
@andresjesse
andresjesse / portainer-caprover-nginx.md
Last active May 21, 2024 14:41
Portainer on CapRover OneClick Apps

Important: for docker 24+ use latest portainer image (2.20.3+)

To connect shell into containers, portainer nginx config must be updated on location block:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
@andresjesse
andresjesse / Portainer Local.md
Created December 27, 2023 17:35
Portainer Local

To setup portainer locally using HTTP instead of HTTPS:

docker run -d -p 8000:8000 -p 9003:9000 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Then create a browser shortcut for: localhost:9003/#!/home

// This is a deno script. To run it: $ deno run --allow-all post-grafana.ts
import * as base64 from "https://deno.land/std@0.207.0/encoding/base64.ts";
const lokiUrl = "https://your.loki.server/loki/api/v1/push";
const lokiBasicAuth = {
username: "user",
password: "pass",
};
const server = "frontend.staging"; //your server name

Cycle Windows on Dock:

gsettings set org.gnome.shell.extensions.dash-to-dock scroll-action 'cycle-windows'

gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'cycle-windows'

Extensions:

Vitals: https://extensions.gnome.org/extension/1460/vitals/

#!/usr/bin/python3
# Changelog:
# 2023-10-02: initial version
# To install:
# chmod a+x ssh-git-cmd.py
# sudo ln -s $(pwd)/ssh-git-cmd.py /usr/local/bin/ssh-git-cmd.py
import os, sys
@andresjesse
andresjesse / ssh-git-switch.py
Created September 5, 2023 23:09
ssh-git-switch.py
#!/usr/bin/python3
# To install:
# chmod a+x {this file}
# sudo ln -s {path to this file} /usr/local/bin/ssh-git-switch.py
# For each ssh key in ~/.ssh, create a file: {private key}.config.txt, e.g. id_rsa.config.txt, with content:
# email@forthis.key
# Username
@andresjesse
andresjesse / Laravel random stuff.md
Last active February 2, 2024 09:11
Laravel Random Stuff

Installing sail for a downloaded git project

When you download a laravel project from github it comes without the vendor folder, so it's needed to install it with a temporary container.

Docker and docker compose must be previously installed. If you don't have it, follow those guides:

When your docker and compose are ready, you can configure laravel:

Laravel Config for VSCode

Install portable VSCode

Download tar.gz version from https://code.visualstudio.com/download

Unpack, create an empty data folder in vscode root

Optionally, create the pcode command to open it from terminal without conficting with other vscode installation (run on vscode root):

Clean local branches except master|main|develop:

git branch | grep -v '\*\|master\|main\|develop\|staging\|production' | xargs -n 1 git branch -D

Execute a command using an specific ssh key:

git -c core.sshCommand="ssh -i ~/.ssh/id_ed25519" push origin main

Clone a project using an specific ssh key: