Skip to content

Instantly share code, notes, and snippets.

View fadlisaad's full-sized avatar
🏠
Working from home

Fadli Saad fadlisaad

🏠
Working from home
View GitHub Profile
@fadlisaad
fadlisaad / datediff.php
Last active July 30, 2016 22:35
Calculate different between two date
<?php
function daysTo($from, $to, $round=true)
{
$diff = $to-$from;
$days = ($diff/86400)+1;
return $round==true ? floor($days) : round($days,2);
}
//usage
$from = strtotime($start_date); // tarikh mula
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
location / {
if (!-e $request_filename){
rewrite ^(.+)$ /index.php?url=$1 break;
}
}
@fadlisaad
fadlisaad / nginx-instruction.md
Last active August 10, 2017 04:35
Letsencrypt manual renewal for nginx

First run this command in console:

certbot certonly --webroot -w /path/to/webroot/ -d domain.name

Then, create /etc/nginx/snippets/ssl-domain.name.conf

ssl on;
ssl_certificate /etc/letsencrypt/live/domain.name/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.name/privkey.pem;
@fadlisaad
fadlisaad / gradient.css
Last active October 31, 2017 17:20
Gradient color background CSS
.gradient {
background: linear-gradient(308deg, #4091eb, #6f5dbe 59%, #8446aa 86%, #903a9f);
}
@fadlisaad
fadlisaad / backup.sh
Created September 24, 2018 03:15
Backup database using mysqldump with daily, weekly and monthly incremental
#!/bin/bash
#----------------------------------------------------
# Preventive Maintenance Script
# Coded by Pikri Mohammad
# Updated on 5 April 2017
#----------------------------------------------------
MYSQL_USER="root"
MYSQL_HOST="localhost"
@fadlisaad
fadlisaad / update.sql
Last active October 2, 2021 14:36
Find and replace Wordpress
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');
UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');
@fadlisaad
fadlisaad / Set.sql
Created December 12, 2021 12:26
SQL full mode
SET GLOBAL sql_mode=(REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))
@fadlisaad
fadlisaad / gist:208ce0420aa9f120cfb343c07a0d3ea5
Created December 16, 2021 05:50
Generate self-signed certificate
openssl req -x509 -newkey rsa:2048 -keyout private-key.pem -out public.pem -sha256 -nodes -days 365
@fadlisaad
fadlisaad / README.txt
Created April 5, 2022 02:56
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.26+commit.4563c3fc.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads for the very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
@fadlisaad
fadlisaad / contracts...3_Coda.sol
Created April 5, 2022 02:58
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.26+commit.4563c3fc.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.4.24;
//Safe Math Interface
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;