Skip to content

Instantly share code, notes, and snippets.

View lucenarenato's full-sized avatar
🐘
Remoto

Renato Lucena lucenarenato

🐘
Remoto
View GitHub Profile

Laravel-websockets, SSL Certificate, Let's Encrypt, Certbot, Supervisor, Digitalocean Ubuntu

I did two days work to run laravel-websockets on my server. It will be nice to share with you.

Steps

Step1 - Laravel Websockets Installation with composer

Laravel WebSockets can be installed via composer:

@lucenarenato
lucenarenato / ExampleGetImageUrl.md
Created August 5, 2024 19:51
ExampleGetImageUrl
protected $appends = ['image_url'];

    public function getImageUrlAttribute()
    {
        if (is_null($this->picture) || empty($this->picture)) {  // Check if $this->image is null
            return url('/images/sqlogo.png'); // Return default URL if null
        }
        $imageData = json_decode($this->picture, true); // Cast to array for access
        if ($imageData && isset($imageData['url']) && ! empty($imageData['url'])) {  // Check for non-empty URL

Gerar Codigo

No meu codigo legado feito em php puro, ao inserir o poduto na tabela bt_produtos, tem uma função "gerarcod" que gera um codigo aleatorio unico para coluna "pr_cod_produto"

gerarcod("bt_produtos","pr_cod_produto", 15);

function gerarcod($tabela,  $unico, $norma){
$pdo = conectar();
$grave = "sim";	
#!/bin/bash
# Verifica se o Zsh já está instalado
if ! command -v zsh &> /dev/null; then
echo "Instalando Zsh..."
sudo apt update
sudo apt install zsh -y
fi
# Verifica se o Git já está instalado
@lucenarenato
lucenarenato / Jenkinsfile.groovy
Created March 8, 2024 19:54 — forked from andymotta/Jenkinsfile.groovy
Use Terraform latest docker image in Declarative Jenkins Pipeline
pipeline {
agent {
docker {
image 'hashicorp/terraform:latest'
label 'LINUX-SLAVE'
args '--entrypoint="" -u root -v /opt/jenkins/.aws:/root/.aws'
}
}
options {
ansiColor('xterm')
@lucenarenato
lucenarenato / logical-replication-test.sh
Created January 31, 2024 21:11 — forked from ololobus/logical-replication-test.sh
PostgreSQL logical replication + pg_basebackup test
#!/bin/sh -ex
#export PATH=/usr/pgsql-11/bin:$PATH
pg_ctl stop -D /tmp/master || echo "ok"
pg_ctl stop -D /tmp/slave || echo "ok"
rm -rf /tmp/master
rm -rf /tmp/slave
# setup master
initdb -D /tmp/master
@lucenarenato
lucenarenato / pgbench-query.sql
Created January 31, 2024 20:57 — forked from ololobus/pgbench-query.sql
PostgreSQL pgbench schema
\set aid random(1, 100000 * :scale)
\set bid random(1, 1 * :scale)
\set tid random(1, 10 * :scale)
\set delta random(-5000, 5000)
BEGIN;
UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
@lucenarenato
lucenarenato / Install_PHP_on_Arch_Manjaro_Biglinux.md
Created July 7, 2023 20:14
Install multiple PHP versions on Arch / Manjaro Linux / BigLinux

Install Any PHP on Arch / Manjaro / Biglinux

Through the AUR it is possible to install older and newer PHP versions, simultaneously on the same system. I often had trouble installing using pacman and pamac so here's what I did:

mkdir -p $HOME/bin
mkdir ~/src
cd ~/src
git clone https://aur.archlinux.org/php72.git
cd php72
@lucenarenato
lucenarenato / iptables.sh
Created May 31, 2023 20:17 — forked from qnimbus/iptables.sh
Basic iptables configuration
trustedIP="1.2.3.4/32"
cat <<- EOF > /etc/iptables/rules.v4
# Generated by iptables-save v1.8.7 on Wed Mar 29 14:37:32 2023
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
@lucenarenato
lucenarenato / supervisord.conf
Created April 13, 2023 00:09 — forked from dkarchmer/supervisord.conf
Sample supervisord conf for running a python script in the background
; Assumes dockerfile with:
; ENTRYPOINT ["/usr/bin/supervisord", "-c", "/var/app/supervisord.conf"]
[supervisord]
;logfile=/var/app/logs/ ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=5 ; (num of main logfile rotation backups;default 10)
loglevel=debug ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)