Skip to content

Instantly share code, notes, and snippets.

View LaravelSqliteBug.php
<?php
namespace Tests\Feature;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Tests\CreatesApplication;
class LaravelSqliteBug extends BaseTestCase
@DominikStyp
DominikStyp / composer.json
Created Nov 24, 2021
Laravel composer.json with phpcs phpcbf, post-cmd-scripts etc
View composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.3",
@DominikStyp
DominikStyp / line_clamp_for_multiple_lines.scss
Created Nov 8, 2021
SCSS mixin: Line Clamp for multiple lines (dots for text oferflow)
View line_clamp_for_multiple_lines.scss
// https://caniuse.com/?search=line-clamp - way around line-clamp needed
@mixin ellipsis-for-lines($max-lines: 3) {
/* stylelint-disable */
display: -moz-box;
display: -webkit-box;
text-overflow: ellipsis;
-webkit-line-clamp: $max-lines;
-webkit-box-orient: vertical;
-moz-line-clamp: $max-lines;
-moz-box-orient: vertical;
@DominikStyp
DominikStyp / ImportTableWithDataFromSQL.php
Created Oct 21, 2021
Import SQL File To MySQL Database: Laravel Ready Command (cross platform using Symfony Process)
View ImportTableWithDataFromSQL.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class ImportTableWithDataFromSQL extends Command
{
@DominikStyp
DominikStyp / DumpTableDataToSQL.php
Last active Oct 21, 2021
Dump Database Table to SQL - Laravel Ready Command (cross platform using Symfony Process)
View DumpTableDataToSQL.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class DumpTableDataToSQL extends Command
{
@DominikStyp
DominikStyp / example_table.sql
Last active Aug 21, 2021
SQL: Window Functions advanced example of extracting average (Uber)
View example_table.sql
USE test;
DROP TABLE IF EXISTS uber_request_logs;
CREATE TABLE IF NOT EXISTS
uber_request_logs (
request_id INT(11),
request_date DATE,
request_status VARCHAR(255),
distance_to_travel FLOAT,
@DominikStyp
DominikStyp / example_table.sql
Created Aug 16, 2021
SQL GROUP BY WITH CONDITIONAL SUM (CASE WHEN)
View example_table.sql
CREATE TABLE test (
id INT PRIMARY KEY AUTO_INCREMENT,
year SMALLINT,
month TINYINT,
day TINYINT,
revenue INT
);
INSERT INTO test (year, month, day, revenue) VALUES
(2020, 01, 31, 9000),
@DominikStyp
DominikStyp / example_table.sql
Created Aug 16, 2021
SQL GROUP BY WITH ROLLUP: Grouping by multiple columns and rolling up to one
View example_table.sql
CREATE TABLE test (
id INT PRIMARY KEY AUTO_INCREMENT,
year SMALLINT,
month TINYINT,
revenue INT
);
INSERT INTO test (year, month, revenue) VALUES
(2020, 01, 900),
(2020, 02, 1500),
@DominikStyp
DominikStyp / expected_result.csv
Last active Aug 15, 2021
SQL: Selecting data from JSON_TABLE()
View expected_result.csv
name color price
Laptop black 11000.00
Jeans blue NULL
@DominikStyp
DominikStyp / example_table.sql
Last active Aug 11, 2021
SQL Window Functions: Find next id for every row in result set ("holes" in ids included)
View example_table.sql
USE test;
DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NULL,
`manager_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`));