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 / 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 / vsftpd-virtual-users
Last active September 5, 2019 07:52
Nice tutu on how to get vSFTP running over plain text authentication quick and dirty
https://www.unixmen.com/install-vsftp-with-virtual-users-on-centos-rhel-scientific-linux-6-4/
@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
@D4R4
D4R4 / wget-online-archive
Last active September 5, 2019 07:49
Grab/download bulk links following autoindex over web
wget -r -np -nH -e robots=off -R index.html http://filedump.dl/
@D4R4
D4R4 / wget-remote-ftp
Last active September 5, 2019 07:48
Get remote files over ftp plus a tip for windows users applying it
wget -m ftp://username:[email protected]
# you can use -N to ignore existing files in the destination, in case the original transfer was interrupted for some reason
# tip for windows users with slash domains:
wget -m ftp://brinkster%2Fusername:[email protected]
@D4R4
D4R4 / win_ssl
Created March 6, 2019 18:36
easy to setup windows SSL
https://certifytheweb.com/
@D4R4
D4R4 / unicode_mysql
Created March 13, 2019 17:59
For some reason altering table from editor GUI did not solve the error, meanwhile this did the trick,
ALTER TABLE countries CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
@D4R4
D4R4 / vmware powercli
Last active September 5, 2019 07:55
You gotta get this SSL stuff sorted out before literally every interaction with ESXi, frustrating
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
Connect-VIServer -server vcenter.test.com