Skip to content

Instantly share code, notes, and snippets.

View guilhermegazzinelli's full-sized avatar

Guilherme Gazzinelli guilhermegazzinelli

View GitHub Profile
@guilhermegazzinelli
guilhermegazzinelli / create_server_certificate.yml
Created June 8, 2020 20:12
Ansible recipe for creating server self-signed certs
---
- name: Create Server Certificate
hosts: localhost
gather_facts: false
vars:
certificate_path: "certs"
private_pass: "change me"
tasks:
- name: Create Directory.
file:
#!/bin/bash
#
# Docker Daemon varsayilan olarak ag iletisimi olmadan
# sadece Unix socket uzerinden calismaktadir.
# Docker Client ve Daemon arasinda HTTPS uzerinden
# guvenli iletisimin kurulmasi icin TLS aktif hale getirilmelidir.
# Client ve Server/daemon arasindaki guvenli iletisim agi
# icin gereken client ve server sertifikasyonlarini
# olusturmaliyiz.
#
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@guilhermegazzinelli
guilhermegazzinelli / jsonb_postgres_query.rb
Last active January 6, 2023 14:15
JSON Postgres query
# Sort based on the Hstore data:
Post.order("data->'hello' DESC")
=> #<ActiveRecord::Relation [
#<Post id: 4, data: {"hi"=>"23", "hello"=>"22"}>,
#<Post id: 3, data: {"hi"=>"13", "hello"=>"21"}>,
#<Post id: 2, data: {"hi"=>"3", "hello"=>"2"}>,
#<Post id: 1, data: {"hi"=>"2", "hello"=>"1"}>]>
# Where inside a JSON object:
Record.where("data ->> 'likelihood' = '0.89'")
@guilhermegazzinelli
guilhermegazzinelli / vnc_install.sh
Created July 15, 2021 22:44
Install vncserver and shows current desktop
#!/bin/bash
echo "Instalando VNC server"
sudo apt install tigervnc-standalone-server tigervnc-scraping-server tigervnc-common tigervnc-xorg-extension tigervnc-viewer
echo "Configure a senha padrão"
vncserver
echo "Realizando backup do arquivo de configuração"
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
@guilhermegazzinelli
guilhermegazzinelli / android-backup-apk-and-datas.md
Created January 7, 2022 12:38 — forked from AnatomicJC/android-backup-apk-and-datas.md
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Fetch application APK

To get the list of your installed applications:

@guilhermegazzinelli
guilhermegazzinelli / Commands.md
Created April 11, 2022 12:49
Useful file commands
@guilhermegazzinelli
guilhermegazzinelli / container_volumes.sh
Created July 2, 2022 23:11
Show the volumes and associated containers
#!/bin/sh
#!/bin/sh
volumes=$(docker volume ls --format '{{.Name}}')
dangling=()
for volume in $volumes
do
if result=$(docker ps -a --filter volume="$volume" --format '{{.Names}}' | sed 's/^/ => Used in:/' )
then
@guilhermegazzinelli
guilhermegazzinelli / install_docker_playbook.yml
Created December 20, 2022 22:40
Setup docker and docker compose with ansible in remote server
---
- hosts: all
become: true
tasks:
- name: Install aptitude
apt:
name: aptitude
state: latest
update_cache: true
@guilhermegazzinelli
guilhermegazzinelli / deploy.sh
Last active January 31, 2023 21:53
Deploy script to push files using rsync and update app based on docker-compose with migrations
#!/bin/bash
#### Script important variables
USR="user"
SERVER="0.0.0.0"
DEPLOY_PATH="/home/user/application_home"
LOCAL_PATH="<Current code path>"
# Color output
cecho() {