Skip to content

Instantly share code, notes, and snippets.

View D4R4's full-sized avatar

Dara Ardalan D4R4

  • SCALINX
  • Paris, France
View GitHub Profile
@D4R4
D4R4 / regex_select
Created January 30, 2019 09:00
Regex to select between apostrophe and quotation marks, Great to automate translating combined with Qtranslate and MacroRecorder
(?<=[ ](["']\b))(?:(?=(\\?))\2.)*?(?=\1)
@D4R4
D4R4 / Prevent automatic streaming of MP4 files in Nginx
Created February 7, 2019 06:13
It should probably be placed before the "location /" part of the configuration, also remember to clear cache
location ~ ^.*/(?P<request_basename>[^/]+\.(mp4))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
@D4R4
D4R4 / load up vsftpd virtual user database
Created February 7, 2019 06:16
Loads up and updates vsftpd virtual user database, requires to restart the vsftpd service to take effect
db_load -T -t hash -f /etc/vsftpd/virtual_users /etc/vsftpd/virtual_users.db
@D4R4
D4R4 / ssacli to configre HPE Raid Controller from inside the host OS
Created February 7, 2019 13:35
Can convert raid 0 to 1 and 10 live without downtime
Show configuration
ESXi 5.5 -> /opt/hp/hpssacli/bin/hpssacli ctrl all show config
ESXi 6.5 -> /opt/smartstorageadmin/ssacli/bin/ssacli ctrl all show config
Controller status
ESXi 5.5 -> /opt/hp/hpssacli/bin/hpssacli ctrl all show status
ESXi 6.5 -> /opt/smartstorageadmin/ssacli/bin/ssacli ctrl all show status
Show detailed controller information for all controllers
ESXi 5.5 -> /opt/hp/hpssacli/bin/hpssacli ctrl all show detail
@D4R4
D4R4 / allow services and ports in firewalld
Last active February 16, 2019 10:07
Usefull for RHEL 7 and up
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --zone=public --permanent --add-port=5000/tcp
firewall-cmd --reload
@D4R4
D4R4 / yummy yums
Last active February 16, 2019 18:41
handy bunch of tools for CentOS
epel-release
wget nano htop nload mc net-tools screen iperf3
@D4R4
D4R4 / change_mysql_root
Created February 17, 2019 07:45
shell script to change MySQL root password
#!/bin/bash
mysql.server start
mysql -u root -e "SET PASSWORD FOR root@'localhost' = PASSWORD('admin');"
@D4R4
D4R4 / nginx-attachment for media
Created February 20, 2019 17:41
Tell nginx to treat mp3 mp4 and any media extention as attachment and go straight to download instead of browser player
location ~ ^.*/(?P<request_basename>[^/]+\.(mp4))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
location ~ ^.*/(?P<request_basename>[^/]+\.(mp3))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
location ~ ^.*/(?P<request_basename>[^/]+\.(ogg))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
@D4R4
D4R4 / nginx_cross_origin
Created February 20, 2019 18:05
allow cross origin requests from parent website and what not
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
@D4R4
D4R4 / backup to ftp
Last active February 25, 2019 07:59
postgres db for IBSng
#!/bin/bash
su postgres -c "pg_dump IBSng" > IBSng_"`date +%Y-%m-%d`".sql
#tar czf IBSng_"`date +%Y-%m-%d`".tar.gz IBSng_"`date+%Y-%m-%d`".sql
DELDATE=$(date -d "-31 days" +"%Y-%m-%d")
HOST=aaaa
USER=ssss
PASS=zzzzz
ftp -inv $HOST << EOF
user $USER $PASS