I did two days work to run laravel-websockets on my server. It will be nice to share with you.
Laravel WebSockets can be installed via composer:
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 URLNo 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 |
| pipeline { | |
| agent { | |
| docker { | |
| image 'hashicorp/terraform:latest' | |
| label 'LINUX-SLAVE' | |
| args '--entrypoint="" -u root -v /opt/jenkins/.aws:/root/.aws' | |
| } | |
| } | |
| options { | |
| ansiColor('xterm') |
| #!/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 |
| \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); |
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
| 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 |
| ; 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) |