Skip to content

Instantly share code, notes, and snippets.

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

Md Ariful Islam marifuli

🏠
Working from home
View GitHub Profile
Route::any('/dynamic/route/{class}/{method}', function ($class, $method) {
$class = "\App\Http\Controllers\\" . str_replace('-', "/", $class);
// return $class;
$con = new $class();
return $con->$method();
})->name('dynamic.route');
global.route2 = (classAndMethodName, params = {}) => {
let array = classAndMethodName.split('@')
params.class = array[0].replace(/\\/g, '-')
@marifuli
marifuli / Save file in Laravel
Created April 2, 2022 16:58
Save file in Laravel
$file = $req->file('picture');
$old = public_path($user->getAttributes()['picture']);
if(
$old &&
is_file($old)
)
{
unlink($old);
}
$name = $user->id .'-picture.' . $file->getClientOriginalExtension();
@marifuli
marifuli / countries.php
Created May 28, 2022 10:47
Country list in php array
<?php
$countries = array(
"AF" => array( 'alpha2'=>'AF', 'alpha3'=>'AFG', 'num'=>'004', 'isd'=> '93', "name" => "Afghanistan", "continent" => "Asia", ),
"AX" => array( 'alpha2'=>'AX', 'alpha3'=>'ALA', 'num'=>'248', 'isd'=> '358', "name" => "Åland Islands", "continent" => "Europe"),
"AL" => array( 'alpha2'=>'AL', 'alpha3'=>'ALB', 'num'=>'008', 'isd'=> '355', "name" => "Albania", "continent" => "Europe"),
"DZ" => array( 'alpha2'=>'DZ', 'alpha3'=>'DZA', 'num'=>'012', 'isd'=> '213', "name" => "Algeria", "continent" => "Africa"),
"AS" => array( 'alpha2'=>'AS', 'alpha3'=>'ASM', 'num'=>'016', 'isd'=> '1684', "name" => "American Samoa", "continent" => "Oceania"),
"AD" => array( 'alpha2'=>'AD', 'alpha3'=>'AND', 'num'=>'020', 'isd'=> '376', "name" => "Andorra", "continent" => "Europe"),
"AO" => array( 'alpha2'=>'AO', 'alpha3'=>'AGO', 'num'=>'024', 'isd'=> '244', "name" => "Angola", "continent" => "Africa"),
"AI" => array( 'alpha2'=>'AI', 'alpha3'=>'AIA',
@marifuli
marifuli / sort.alpha.key.php
Created June 2, 2022 06:41
PHP array sort by key - Alphatically
$data = [
'India'=>73,
'United States'=>74,
'United Kingdom'=> 75,
'Singapore'=>77,
'Australia'=>87,
'Canada'=>102
];
uksort($data, function($a, $b) {
return strcmp($a, $b);
@marifuli
marifuli / adblock-checker.js
Last active July 2, 2022 12:42
JS Adblock checker
/*
After loading this js,Do Smething like this:
if(typeof blockAdBlock === 'undefined') {
adBlockDetected();
} else {
blockAdBlock.onDetected(adBlockDetected);
blockAdBlock.onNotDetected(adBlockNotDetected);
// and|or
blockAdBlock.on(true, adBlockDetected);
blockAdBlock.on(false, adBlockNotDetected);