Skip to content

Instantly share code, notes, and snippets.

@chimit
chimit / index_diff.php
Last active June 13, 2025 14:12
Find the larges difference between indexes of equal array items
<?php
function solution1($arr) {
$n = count($arr);
$diff = $n;
for ($diff = $n; $diff >= 0; $diff--) {
for ($i = $n - $diff; $i >= 0; $i--) {
$j = $diff + $i - 1;
@chimit
chimit / bitbucket-pipelines.yml
Created August 7, 2020 02:35
Bitbucket Pipelines config for Laravel 7 with PHP 7.4, GD and EXIF
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.4-fpm
definitions:
services:
mysql:
@chimit
chimit / api.php
Created May 25, 2023 09:24
Output all SQL queries in Laravel
<?php
// Debug SQL queries
// Put anywhere, e.g. in routes/api.php
if (config('app.debug')) {
\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
echo 'Query: '.$query->sql."\n\n";
echo 'Bindings: '.var_export($query->bindings, true)."\n\n";
echo 'Time: '.$query->time."\n\n";
});