Skip to content

Instantly share code, notes, and snippets.

@kangmasjuqi
kangmasjuqi / swap_2_numeric.php
Created April 26, 2022 16:38
swap 2 numeric values without additional variable
<?php
$x = 17; // whatever integer you want
$y = 52; // whatever integer you want
echo "x : $x\n";
echo "y : $y\n";
$x = $x + $y;
$y = $x - $y;
@kangmasjuqi
kangmasjuqi / force_update_mysql_root_credential.txt
Created June 28, 2021 13:28
force update the mysql root credential
# bismillah, shollallahu 'alaa Muhammad
# force update the mysql root credential
#
# mysql Ver 14.14 Distrib 5.7.30
# on macos10.14 (x86_64)
# step 1 : find and kill the PID of the mysql process
ps aux | grep mysqld
kill -9 [PID]
@kangmasjuqi
kangmasjuqi / cherry.sh
Created June 24, 2021 09:19
cherry.sh - apply specific changes into specific branch and then push that changes into remote repo afterward
# bismillah - shollallahu 'alaa Muhammad
#
# assume you are working on your local working branch
# where the whole code is on your hand
# then you want to apply specific changes (commitId) into specific branch
# and then push that changes into remote repo afterward
#
# how to use : ./cherry.sh TARGET_BRANCH_NAME COMMIT_ID
#
@kangmasjuqi
kangmasjuqi / HACKERRANK-TEST-2
Created May 28, 2021 04:10
HACKERRANK-TEST-2
<?php
// HACKERRANK-TEST-2
//
// Question : https://imgur.com/QI2hoR0
/*
* Complete the 'minDiff' function below.
*
@kangmasjuqi
kangmasjuqi / HACKERRANK-TEST-1
Created May 28, 2021 04:09
HACKERRANK-TEST-1
<?php
// HACKERRANK-TEST-1
//
// Question : https://imgur.com/aA7JaaA
/*
* Complete the 'areAlmostEquivalent' function below.
*
@kangmasjuqi
kangmasjuqi / parentheses_validator.php
Last active May 21, 2021 03:44
Parentheses Validator
// Function that tells us whether or not an input string's openers and closers are properly nested.
// Examples:
// • "{ [ ] ( ) }" should return True
// • "{ [ ( ] ) }" should return False
// • "{ [ }" should return False
function parentheses_validatior($string){
// remove spaces
@kangmasjuqi
kangmasjuqi / Mudik.php
Created May 3, 2021 08:33
PHP OOP with Interface - 2
<?php
// INTERFACE
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
interface Vehicle{
public function getCost($d);
@kangmasjuqi
kangmasjuqi / Vehicle.php
Created May 2, 2021 04:50
PHP OOP with Abstract
<?php
// ABSTRACT
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
abstract class Vehicle{
@kangmasjuqi
kangmasjuqi / Notif.php
Created May 2, 2021 04:34
PHP OOP with Interface
<?php
// INTERFACE
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
interface Notif{
public function send($message, $contacts);
@kangmasjuqi
kangmasjuqi / Shape.php
Created May 2, 2021 04:33
PHP OOP with Polymorphism
<?php
// POLYMORPHISM
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
interface Shape{
public function calcArea();