Skip to content

Instantly share code, notes, and snippets.

View akki-io's full-sized avatar
🐶
Focusing

Akki Khare akki-io

🐶
Focusing
View GitHub Profile
@akki-io
akki-io / docker-composeB13.yml
Created November 24, 2019 04:34
Setup Laravel with Docker on Ubuntu - https://www.tekz.io/
version: '3'
services:
fpm:
image: tekz/php-stretch-fpm:7.3.2
volumes:
- .:/var/www/html
utility:
@akki-io
akki-io / PopulateDateDimensionsTableCommandB14.php
Created September 23, 2019 01:00
Laravel - Creating a date dimension (calendar) table - https://www.tekz.io/
<?php
namespace App\Console\Commands;
use App\Models\DateDimension;
use Carbon\Carbon;
use Carbon\CarbonPeriod;
use Illuminate\Console\Command;
use function ceil;
use function now;
@akki-io
akki-io / DateDimensionB14.php
Created September 23, 2019 00:54
Laravel - Creating a date dimension (calendar) table - https://www.tekz.io/
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class DateDimension extends Model
{
/**
* Indicates if the IDs are auto-incrementing.
*
@akki-io
akki-io / 2000_01_01_011407_create_date_dimensions_table.php
Created September 23, 2019 00:47
Laravel - Creating a date dimension (calendar) table - https://www.tekz.io/
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDateDimensionsTable extends Migration
{
/**
* Run the migrations.
@akki-io
akki-io / CodeStyleLinterTestB13.php
Created August 28, 2019 00:53
How to add PSR-2 code check as unit test - https://www.tekz.io/
<?php
namespace Tests\Unit;
use Symfony\Component\Process\Process;
use function base_path;
use Tests\TestCase;
class CodeStyleLinterTest extends TestCase
{
@akki-io
akki-io / script.sh
Created July 30, 2019 03:49
How to effectively import large MS Access DB to MySQL DB - https://www.tekz.io/
#!/bin/bash
#===========================================================
# FILE : script.sh
# DESCRIPTION : Convert MS Access to MySQL.
#===========================================================
set -o nounset # help avoid bugs
shopt -s extglob
PATH=/bin:/usr/bin:/sbin # for consistency
# variables declaration
@akki-io
akki-io / 2010_01_01_130825_create_users_tableB10.php
Last active June 1, 2019 01:19
Laravel - PHPUnit - Testing Legacy System With Existing Database - https://blog.tekz.io/
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserTable extends Migration
{
/**
* Run the migrations.
@akki-io
akki-io / adjacencyToNestedJsonWithPerformanceMethodTwoB9.php
Created May 10, 2019 22:22
PHP – Performance – Adjacency set to nested JSON - https://blog.tekz.io
<?php
// Initialize php setting - @node - NOT RECOMMENDED FOR PRODUCTION, update your php.ini if needed.
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 30000);
// Get the tree array from DB
$treeArray = getDataFromDatabase();
@akki-io
akki-io / adjacencyToNestedJsonWithPerformanceMethodOneB9.php
Created May 10, 2019 22:21
PHP – Performance – Adjacency set to nested JSON - https://blog.tekz.io
<?php
// Initialize php setting - @node - NOT RECOMMENDED FOR PRODUCTION, update your php.ini if needed.
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 30000);
// Get the tree array from DB
$treeArray = getDataFromDatabase();
@akki-io
akki-io / adjacencyToNestedJsonB8.json
Created May 5, 2019 02:01
PHP - Convert Adjacency set to nested JSON
{
"id": "1",
"parent_id": null,
"name": "Electronics",
"children": [
{
"id": "2",
"parent_id": "1",
"name": "TV",
"children": [