Skip to content

Instantly share code, notes, and snippets.

View guilhermegazzinelli's full-sized avatar

Guilherme Gazzinelli guilhermegazzinelli

View GitHub Profile
@guilhermegazzinelli
guilhermegazzinelli / create_contact.js
Created May 20, 2024 12:10
Envia contato para o RD Station Marketing
const axios = require('axios');
const apiKey = 'SUA_API_KEY'; // Substitua com sua chave de API RD Station Marketing
const endpoint = 'https://api.rd.services/platform/contacts';
const leadData = {
name: 'Nome do Lead',
email: 'lead@example.com',
job_title: 'Cargo do Lead',
company_name: 'Nome da Empresa',
@guilhermegazzinelli
guilhermegazzinelli / backup.sh
Last active January 14, 2024 21:26
Backup postgres inside docker container
#!/bin/bash
#### Definitions
db_username=user
container_filter=cimentao_db
backup_dir=/home/ubuntu/backup
### Variables
date=`date +%Y-%m-%d"_"%H_%M_%S`
filename=dump_$date.gz
@guilhermegazzinelli
guilhermegazzinelli / ability.rb
Created October 2, 2023 17:58 — forked from hrdwdmrbl/ability.rb
CanCan -- HowTo cache the ability.rb file
class Ability
include CanCan::Ability
def marshal_dump
#blocks cannot be cached
@rules.reject{|rule| rule.instance_variable_get :@block }.map{|rule| Marshal.dump(rule) }
end
def marshal_load array
#blocks cannot be cached, so blocks must be re-defined
can :read, Comment do |comment|
@guilhermegazzinelli
guilhermegazzinelli / vnc_install.sh
Created July 17, 2023 19:31
Instala e configura o VNC
#!/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 / bash_tricks.md
Last active February 14, 2023 13:01
Bash Tricks

Passing arguments

  • Verify is Supplied any argument
  ((!$#)) && echo No arguments supplied! && exit 1
  • If you need to ensure a minimum ammount of args
  if [ $# -ge 3 ]
 then
@guilhermegazzinelli
guilhermegazzinelli / reboot_if_needed.sh
Last active February 14, 2023 12:39
Reboot linux if Needed
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'Must pass an time for reboot in form hh:mm'
exit 1
fi
if [ -f /var/run/reboot-required ]; then
echo 'Reboot required, scheduling based on parameter'
sudo shutdown -r $1
fi
@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() {
@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 / 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 / Commands.md
Created April 11, 2022 12:49
Useful file commands