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 / gist:3a281b4d8a2e43e4068d43a3bf69cf10
Created August 29, 2023 06:23
Command to set Laravel permission Ubuntu
#!/bin/bash
# Default variables
groupname="${1:-www-data}"
username="${2:-$USER}"
folder="${3:-.}"
# Add user to webserver group
usermod -a -G "$groupname" "$username"
@fadlisaad
fadlisaad / laravel.markdown
Last active November 22, 2022 01:12
Laravel permission

Webserver as owner (the way most people do it, and the Laravel doc's way)

assuming www-data (it could be something else) is your webserver user.

sudo chown -R www-data:www-data /path/to/your/laravel/root/directory

if you do that, the webserver owns all the files, and is also the group, and you will have some problems uploading files or working with files via FTP, because your FTP client will be logged in as you, not your webserver, so add your user to the webserver user group:

sudo usermod -a -G www-data ubuntu

Of course, this assumes your webserver is running as www-data (the Homestead default), and your user is ubuntu (it's vagrant if you are using Homestead).

@fadlisaad
fadlisaad / redirect.php
Created June 9, 2022 02:46
Laravel manual redirect
public static function render($data)
{
$url = 'https://melakapaystg.melaka.gov.my/stom/request';
echo "<form id='autosubmit' action='".$url."' method='post'>";
if (is_array($fieldValues) || is_object($fieldValues))
{
foreach ($fieldValues as $key => $val)
{
echo "<input type='hidden' name='".$key."' value='".htmlspecialchars($val)."'>";
@fadlisaad
fadlisaad / contracts...3_Coda.sol
Created April 13, 2022 01:51
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;
@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;
@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 / 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 / Set.sql
Created December 12, 2021 12:26
SQL full mode
SET GLOBAL sql_mode=(REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))
@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 / 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"