Skip to content

Instantly share code, notes, and snippets.

View lomotech's full-sized avatar

Muhammad Syafiq Zainuddin lomotech

View GitHub Profile
@lomotech
lomotech / RealDateWithLongMonth.php
Created December 4, 2023 03:27
Dapatkan tarikh hari ini jika bulan tersebut di panjangkan
<?php
use Carbon\Carbon;
$targetDate = '2023-08';
$today = Carbon::parse();
$target = Carbon::createFromFormat('Y-m', $targetDate)->endOfMonth();
@lomotech
lomotech / DateRangeConverter.php
Last active January 13, 2022 06:54
Date range converter
<?php
namespace App\Libraries;
use Carbon\Carbon;
class DateRangeConverter
{
public static function humanReadable($startDate, $endDate)
{
@lomotech
lomotech / array_test.php
Created July 15, 2021 23:47
array test
// 1. Given an array of [4,1,5,6], write a function that returns to me the lowest number.
// 2. Given an array of strings ['apple', 'banana', 'orange', 'apple'], return an object with the count of each element in the array.
{ 'apple': 2, 'orange': 1, 'banana': 1 }.
$a = [4,1,5,6]
sort($a)
$a[0]
$b = ['apple', 'banana', 'orange', 'apple']
json_encode(array_count_values($b))
@lomotech
lomotech / Yii2ValetDriver.php
Created February 19, 2021 01:54
Yii2 Basic Template Valet Driver
<?php
// put in into .config/valet/Driver/Yii2ValetDriver.php
class Yii2ValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
@lomotech
lomotech / Yii2AdvanceValetDriver.php
Created February 19, 2021 01:52
Yii2 Advance Template Valet Driver
<?php
// put in into .config/valet/Driver/Yii2AdvanceValetDriver.php
class Yii2AdvanceValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
@lomotech
lomotech / trash.php
Last active May 21, 2020 03:19
Laravel scriptkiddies redirect route
<?php
Route::redirect('admin/.env', 'url_here');
Route::redirect('administrator/.env', 'url_here');
Route::redirect('ads.txt', 'url_here');
Route::redirect('atom.xml', 'url_here');
Route::redirect('config/.env', 'url_here');
Route::redirect('core/Database/.env', 'url_here');
Route::redirect('core/app/.env', 'url_here');
Route::redirect('cron/.env', 'url_here');
@lomotech
lomotech / uiblock processing box
Created October 4, 2019 21:31
uiblock processing box
// CSS
/*block ui loading*/
.blockui > .boxes {
--size: 32px;
--duration: 800ms;
height: calc(var(--size) * 2);
width: calc(var(--size) * 3);
position: relative;
-webkit-transform-style: preserve-3d;
@lomotech
lomotech / bank code
Created October 4, 2019 08:24
additional bank code
$data = [
'AFB' => 'AFFIN BANK',
'ALB' => 'ALLIANCE BANK',
'AMB' => 'AMBANK',
'BMB' => 'BANK MUAMALAT',
'BIM' => 'BANK ISLAM MALAYSIA',
'BRB' => 'BANK RAKYAT',
'CIM' => 'CIMB BANK',
'NULL' => 'EON BANK BERHAD',
'HLB' => 'HONG LEONG BANK',
@lomotech
lomotech / StatusRepo.php
Created March 13, 2019 19:05
repository problem
<?php
public static function getAll()
{
return Cache::remember('status:all', 60, function () {
return Status::all();
});
}
/**
table.table.table-striped.table-bordered>(thead>tr>th{head}*3)+(tbody>tr*5>td{datum}*3)+tfoot>tr>td{total}*3