Skip to content

Instantly share code, notes, and snippets.

View SimonDevelop's full-sized avatar
🖥️
Code, always code!

Simon Micheneau SimonDevelop

🖥️
Code, always code!
View GitHub Profile
@SimonDevelop
SimonDevelop / php-package-ubuntu.md
Last active November 28, 2019 20:46
PHP package for Ubuntu
add-apt-repository -y -u ppa:ondrej/php
apt-get update
apt-get install php7.4-bcmath php7.4-bz2 php7.4-cli php7.4-common php7.4-curl php7.4-dba php7.4-fpm php7.4-gd php7.4-gmp php7.4-imap php7.4-intl php7.4-ldap php7.4-mbstring php7.4-mysql php7.4-odbc php7.4-pgsql php7.4-snmp php7.4-soap php7.4-sqlite3 php7.4-tidy php7.4-xml php7.4-xmlrpc php7.4-xsl php7.4-zip php7.4-cgi php7.4-dev php7.4-phpdbg php7.4-enchant php7.4-interbase php7.4-pspell php7.4-readline php7.4-sybase php7.4-opcache php7.4-json php-xdebug libsodium-dev -y
@SimonDevelop
SimonDevelop / letsencrypt.md
Last active April 29, 2019 08:47
Certificats let's encrypt for php webSite/webApp with nginx

Installation let's encrypt and ticket key for nginx :

sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt --depth=1
sudo openssl rand -out /etc/nginx/ssl/ticket.key 48
sudo openssl dhparam -out /etc/nginx/ssl/dhparam4.pem 4096
sudo /opt/letsencrypt/letsencrypt-auto certonly --rsa-key-size 4096 --webroot --webroot-path /var/www/domaine.ltd -d domaine.ltd

Crontabe:

@SimonDevelop
SimonDevelop / getDays.php
Created April 29, 2019 09:32
Function to retrieve the days of the month of a given date. the table contains the number of the day in index and the day of the week in value.
<?php
function getDays($month = null, $year = null) {
$list = array();
if ($month == null) {
$month = date('m');
}
if ($year == null) {
$year = date('Y');
}
<?php
function deleteDir($dirPath) {
if (!is_dir($dirPath)) {
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
@SimonDevelop
SimonDevelop / is_dir_empty.php
Created September 24, 2019 14:01
is_dir_empty php function
<?php
function is_dir_empty($dir)
{
if (!is_readable($dir)) {
return null;
}
$handle = opendir($dir);
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
return false;
@SimonDevelop
SimonDevelop / checkSize.html
Created November 14, 2019 14:33
How to checking size file in javascript
<form method="post" enctype="multipart/form-data" onsubmit="return checkSize(2097152)">
<input type="file" id="upload">
<input type="submit">
</form>
<script type="text/javascript">
function checkSize(max_img_size) {
var input = document.getElementById("upload");
if(input.files && input.files.length == 1) {
if (input.files[0].size > max_img_size) {
alert("The file must be less than " + (max_img_size/1024/1024) + "MB");