Skip to content

Instantly share code, notes, and snippets.

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

Mayank Dudakiya mayanksdudakiya

🏠
Working from home
View GitHub Profile
@mayanksdudakiya
mayanksdudakiya / timezone.php
Created June 1, 2023 15:16
Dynamically generate lists of Timezones in PHP/Laravel/WordPress
<?php
public function getTimezoneList(): array
{
// Get all timezone
$timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
$findUtcKey = array_search('UTC', $timezones);
unset($timezones[$findUtcKey]);
$timezone_offsets = [];
@mayanksdudakiya
mayanksdudakiya / AppServiceProvider.php
Created May 31, 2023 13:37
Prevent lazy loading in Laravel and check for N+1 queries being fired in your App so that you can solve it
<?php
namespace App\Providers;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function register()
@mayanksdudakiya
mayanksdudakiya / DatabaseSeeder.php
Created May 31, 2023 13:28
Laravel seed millions of data for testing
<?php
public function run()
{
$totalRecords = 50000; // Total number of records to generate
$batchSize = 200; // Number of records to insert per batch
DB::beginTransaction();
Website::factory()->count($totalRecords)->create()->chunk($batchSize, function ($websites) {
Website::insert($websites->toArray());
@mayanksdudakiya
mayanksdudakiya / Journey_into_all_bles_of_code.md
Created May 20, 2023 12:41 — forked from OliverMensahDev/Journey_into_all_bles_of_code.md
Journey into writing code that is readable, understandable ,maintainable and testable as well as how to prepare codebase to embrace future changes.

Journey into writing code that is readable, understandable ,maintainable and testable as well as how to prepare codebase to embrace future changes.

I wonder from time to time whether I'm doing the right thing with respect to guidelines and principles when using an object-oriented programming approach to create application. I started reading Object Design Style Guide book last year to learn more about objects. And beginning this year, I decided to delve deeper into writing code that is readable, understandable and maintainable as well as how to prepare codebase to embrace future changes.

Here are the resources used:

Book

  • Object Design Style Guide:
  • Principles of Package Design

Pluralsight Courses

  • Writing Readable and Maintainable Code
@mayanksdudakiya
mayanksdudakiya / currency_symbols.php
Created August 29, 2019 18:18 — forked from gibbs/currency_symbols.php
An array of currency symbols as HTML entities | Currency symbols dropdown options
<?php
$currency_symbols = array(
'AED' => '&#1583;.&#1573;', // ?
'AFN' => '&#65;&#102;',
'ALL' => '&#76;&#101;&#107;',
'AMD' => '',
'ANG' => '&#402;',
'AOA' => '&#75;&#122;', // ?
'ARS' => '&#36;',
'AUD' => '&#36;',