Skip to content

Instantly share code, notes, and snippets.

View Modelizer's full-sized avatar
💭
I may be slow to respond.

Mohammed Mudassir Modelizer

💭
I may be slow to respond.
View GitHub Profile
@Modelizer
Modelizer / index.js
Created September 2, 2021 10:16
Regex to find sentence between HTML tag.
$sentence = new RegExp('>([\w\d\$\.\,\:\-\%\s]+[^\s])\s+</')
@Modelizer
Modelizer / life.php
Created August 23, 2021 20:05
A reason to make her smile.
<?php
namespace World;
interface MarriageContract
{
public function engageTo(Person $partner): string;
}
class Person implements MarriageContract
@Modelizer
Modelizer / ide-search-and-replace.regex.js
Last active August 25, 2021 11:03
Regex Laravel Route search and replace.
// Example: controller@index to ['controller', 'index']
// Search. Note: make sure you have space at the start.
'(.*)@(.*?)'
// Replace
\[$1::class, '$2'\]
@Modelizer
Modelizer / TemplateTranslation.php
Last active October 15, 2019 15:48
Helper class to deal with placeholders and XML or HTML tags which should be replace in given text.
<?php
/**
* Helper class to deal with placeholders and xml tags which should be replace in given text
*
* ---------- Example ----------
* $sampleText = 'This is the <bold-underline>sample</bold-underline> code of {{user}}'.
* $placeholders = ['user' => 'Mohammed Mudassir'];
* $xml = ['bold-underline' => '<b style="text-decoration: underline'>%</b>']
*
@Modelizer
Modelizer / CsvFileLoader.php
Created September 19, 2019 14:02
CSV File Loader in PHP. The headers will be map as keys in collected CSV data.
<?php
use Exception;
use Illuminate\Support\Collection;
use SplFileObject;
/**
* CSV loader is a helper class to load data into Laravel Collection
*
* ----------------------------------------------------------------------------------------------------------------
@Modelizer
Modelizer / matrix.php
Created January 26, 2017 10:57
An algo to replace all the natural numbers with zero (horizontally and vertically).
<?php
/**
* This is an algo to replace all the natural numbers with zero (horizontally and vertically).
* This was an interview question to solve.
*
* If you have more better solution with less iteration will be appreciated.
*
* @author Mohammed Mudasir <hello@mudasir.me>
**/
@Modelizer
Modelizer / ApiController.php
Last active August 26, 2016 14:41
Laravel Api Controller Bootstrap to get started quickly
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Requests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
@Modelizer
Modelizer / array_recursive_value.php
Last active May 8, 2016 13:11
Get all values from array no matter array is multi dimension. Also you can maintain array dimension if you need.
<?php
/**
* Recursively get all values from array
*
* @param array $array
* @param bool $merge maintain array dimension
* @return array
*
* @author Mohammed Mudasir <md.hyphen@gmail.com>