Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrei Telteu AndreiTelteu

View GitHub Profile
View aapanel install mysql
cd /www/server/panel/install
bash ./install_soft.sh 1 install mysql mariadb_10.4
bash ./install_soft.sh 1 install openlitespeed 1.7
@AndreiTelteu
AndreiTelteu / Backpack export operation (excel and csv) .md
Last active May 25, 2022
Export operation for backpack admin panel, that exports the entire database table, not just the entries shown on page
View Backpack export operation (excel and csv) .md
  1. First install maatwebsite/excel package:
composer require maatwebsite/excel
  1. Copy export.blade.php from this gist in resources/views/vendor/backpack/crud/buttons/export.blade.php

  2. Copy ExportOperation.php from this gist in app/Traits/Operations/ExportOperation.php

@AndreiTelteu
AndreiTelteu / # - Jitsi meet - easy setup with custom config .md
Last active Jul 22, 2022
Jitsi meet - easy setup with custom config - customizations are: removed all branding, removed every unnecesary button
View # - Jitsi meet - easy setup with custom config .md
@AndreiTelteu
AndreiTelteu / Manual export inline with maatwebsite excel laravel package .md
Last active Feb 6, 2022
How to export/import in excel format with maatwebsite/excel using inline anonymous class, without any external files #laravel
View Manual export inline with maatwebsite excel laravel package .md

Using this plugin: maatwebsite/excel

composer require maatwebsite/excel

You can use this anywhere in your app.

<?php
@AndreiTelteu
AndreiTelteu / PHP opcache invalidate entire directory .md
Last active Jan 25, 2022
How to invalidate an entire directory with opcache, also in a laravel middleware
View PHP opcache invalidate entire directory .md
<?php
$directories = [
    'absolute/path/to/dir',
    'multiple/dirs/if/needed',
];
$extensions = [
    'php',
];
function invalidateDirectory($dir) {
@AndreiTelteu
AndreiTelteu / aaPanel howto install latest swoole version .md
Last active Nov 28, 2021
How to install swoole v4.8.2 on aapanel with php 8.0
View aaPanel howto install latest swoole version .md

As a root user, download this script and put it in /www/server/panel/install/modified-swoole-install.sh

cd /www/server/panel/install/
wget https://gist.githubusercontent.com/AndreiTelteu/c92ef2414cc97e2c76f539cc988652d0/raw/abf316cd872ad75be34ce5572bb7ff3dac6819ce/modified-swoole-install.sh
chmod +x modified-swoole-install.sh
bash modified-swoole-install.sh install 80
@AndreiTelteu
AndreiTelteu / How to install vs code server and setup supervisor with fnm .md
Last active Feb 6, 2022
Install vs code-server with fnm and yarn, and keep it runing always with supervisor (on ubuntu)
View How to install vs code server and setup supervisor with fnm .md

Install build requirements (python3 and build essential)

sudo apt-get install -y build-essential pkg-config python3

Install fnm to manage multiple nodejs versions (uninstall nodejs or nvm if you have it installed)

curl -fsSL https://fnm.vercel.app/install | bash
View How to use pm2 with a specific nodejs version from fnm .md

If you use a ecosystem file, add the following lines to your app:

      interpreter: '/home/forge/.fnm/fnm',
      interpreter_args: 'exec --using=14 node',

14 is the node version. You can be more specific like --using=12.22.4

Example configuration:

@AndreiTelteu
AndreiTelteu / Reboot server is the average load is greater than x .md
Last active Nov 5, 2021
Bash script to restart the server if the load is greater than x
View Reboot server is the average load is greater than x .md

Put the following script in a .sh file, for example in /root/reboot-load.sh.

#!/usr/bin/bash
LOAD=`uptime |awk '{print $NF}'`
LOADCOMP=`echo "($LOAD * 100) / 1" | bc`
echo "Load is: $LOAD"
if [[ $LOADCOMP -ge 2000 ]]
then echo "Greater than 20 ! Reboot !"
fi
View OpenLiteSpeed config trust cloudflare ip proxy to get the real ip in logs .conf
useIpInProxyHeader 2
accessControl {
allow ALL, 173.245.48.0/20T, 103.21.244.0/22T, 103.22.200.0/22T, 103.31.4.0/22T, 141.101.64.0/18T, 108.162.192.0/18T, 190.93.240.0/20T, 188.114.96.0/20T, 197.234.240.0/22T, 198.41.128.0/17T, 162.158.0.0/15T, 104.16.0.0/13T, 104.24.0.0/14T, 172.64.0.0/13T, 131.0.72.0/22T
}