Skip to content

Instantly share code, notes, and snippets.

@mikedamoiseau
mikedamoiseau / backup-db.sh
Last active Jun 14, 2022
Script to backup a MySQL database and send the dump by email and/or scp
View backup-db.sh
#!/bin/bash
# ----------------------------------
# DEFINED - Global variables
# ----------------------------------
# defined temporary folder
DBBACKUP="dbbackup"
# database configure
@mikedamoiseau
mikedamoiseau / relaunch-services.sh
Last active Mar 30, 2017
Script to automatically relaunch Nginx and MySQL servers
View relaunch-services.sh
#!/bin/bash
#settings
EMAIL="me@example.com"
SUBJECT="THE EMAIL SUBJECT"
# date
DATETIME=$(date +%F_%T)
DATE=$(date +"%Y-%m-%d")
@mikedamoiseau
mikedamoiseau / wp-setup.sh
Created Oct 21, 2016
Wordpress project - setup script
View wp-setup.sh
#!/bin/bash
# This setup script is to be used for new Wordpress project setup
# The file structure should be like this:
# /var/www/root-folder-project
# |_ /htdocs/
# |_ /dev/setup.sh
#
# The website will be installed in the `htdocs` folder
# if you can't execute the script, try `chmod +x ./setup.sh`
@mikedamoiseau
mikedamoiseau / wget-download-ftp-recursive-folder
Created Sep 22, 2015
How to download a folder with all its content recursively using wget
View wget-download-ftp-recursive-folder
Use this command line:
wget -r -nH --cut-dirs=3 -nc --ftp-user=jfc-ftp --ask-password ftp://jfc.bitbakers-kunden.de//htdocs/wp-content/uploads
And give the password. Better to use --ask-password so that the password is not saved in the history of the bash
@mikedamoiseau
mikedamoiseau / Leaflet with Google, Bing and Openstreet Maps
Last active Dec 10, 2021
Leaflet with Google, Bing and Openstreet Maps
View Leaflet with Google, Bing and Openstreet Maps
**Create a Bing API key**
https://www.bingmapsportal.com/application/create/1354301
**Download the plugins**
https://github.com/shramov/leaflet-plugins
```html
<!DOCTYPE html>
<html>
<head>
View laravel-ums.markdown

There's no shortage of good resources for learning laravel. So instead of the usual introductory tutorial were just gonna learn Laravel by building a project from scratch and that's gonna be a User Management System.

I don't know if my definition of a User Management System is correct but here's my idea of what's it's capable of doing:

  • Register Roles
  • Register Users
  • Update Users
View git create branch from remote
git checkout -b nomDeMaBrancheDistante origin/nomDeMaBrancheDistante
if
```
fatal: git checkout: updating paths is incompatible with switching branches/forcing
Did you intend to checkout ‘origin/‘ which can not be resolved as commit?’
```
then
```
git remote update
@mikedamoiseau
mikedamoiseau / cakephp-last-executed-query
Created Jul 9, 2014
CakePHP - Display last executed SQL query
View cakephp-last-executed-query
$dbo = $this->Job->getDatasource();
$logs = $dbo->getLog();
$lastLog = end($logs['log']);
debug( $lastLog['query'] );
View monitor.sh
#!/bin/bash
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
else
echo "All is well.";
fi
@mikedamoiseau
mikedamoiseau / mysql-import-export.sh
Last active Aug 29, 2015
Mysql database import/export with command line
View mysql-import-export.sh
# Export the database to a file
mysqldump -u YourUser -p 'UserPassword' YourDatabaseName | gzip > wantedsqlfile.sql.gz
# Make a local copy the file from the server
scp user@xxx.xxx.xxx.xxx:/path_to_your_dump/filename.sql.gz your_detination_path/
# Import the database locally
gunzip filename.sql.gz | mysql -u [user] -p [password] [database]