This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ipaddress import ip_network | |
start = '0.0.0.0/0' | |
exclude = ['192.168.1.0/24'] | |
result = [ip_network(start)] | |
for x in exclude: | |
n = ip_network(x) | |
new = [] | |
for y in result: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
server_name DOMAIN.ro; | |
return 301 https://www.DOMAIN.ro$request_uri; | |
listen 443 ssl http2; # managed by Certbot | |
listen [::]:443 ssl http2; | |
ssl_certificate /etc/letsencrypt/live/DOMAIN.ro/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/DOMAIN.ro/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function makeSlugFromTitle($title) | |
{ | |
$slug = Str::slug($title); | |
$count = Conversation::whereRaw("slug RLIKE '^{$slug}(-[0-9]+)?$'")->count(); | |
return $count ? "{$slug}-{$count}" : $slug; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Force URLs in srcset attributes into HTTPS scheme. | |
* This is particularly useful when you're running a Flexible SSL frontend like Cloudflare | |
*/ | |
function ssl_srcset( $sources ) { | |
foreach ( $sources as &$source ) { | |
$source['url'] = set_url_scheme( $source['url'], 'https' ); | |
} | |
return $sources; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# some inspiration https://mensfeld.pl/2013/04/backup-mysql-dump-all-your-mysql-databases-in-separate-files/ | |
TIMESTAMP=$(date +"%F") | |
BACKUP_DIR="/root/backupdb/$TIMESTAMP" | |
MYSQL_USER="" | |
MYSQL=/usr/bin/mysql | |
MYSQL_PASSWORD="" | |
MYSQLDUMP=/usr/bin/mysqldump | |
mkdir -p "$BACKUP_DIR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOME=/mnt/e/work | |
DIRS=`ls $HOME` | |
TIMESTAMP=$(date +"%F") | |
for dir in $DIRS;do | |
echo "START backup $dir" | |
zip -rq "$HOME"/"$dir".zip "$HOME"/"$dir"/* | |
echo "START transfer $dir" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function csvToArray ($csv_file) { | |
$rows = $keys = $csv = array(); | |
if (($handle = fopen($csv_file->getRealPath(), "r")) !== FALSE) { | |
$i = 0; | |
while (($data = fgetcsv($handle, null, ";")) !== FALSE) { | |
$i++; | |
if ($i == 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function csvToArray ($csv_file) { | |
$csv = array_map(function($csv_file) { | |
return str_getcsv($csv_file, ";"); | |
}, file($csv_file, FILE_SKIP_EMPTY_LINES)); | |
$keys = array_shift($csv); | |
foreach ($csv as $i=>$row) { | |
$csv[$i] = array_combine($keys, $row); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove | |
apt install software-properties-common nginx git htop zip unzip curl nload | |
add-apt-repository ppa:ondrej/php | |
apt update | |
apt install mariadb-server memcached php-memcached php7.4-cli php7.4-fpm php7.4-mysql php7.4-curl php7.4-xml php7.4-mbstring php7.4-gd php7.4-intl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
root /var/www/html; | |
index index.html index.php; | |
server_name localhost; | |
location / { | |
try_files $uri $uri/ =404; | |
} |
NewerOlder