Skip to content

Instantly share code, notes, and snippets.

View finagin's full-sized avatar
🖖

Igor Finagin finagin

🖖
View GitHub Profile
#!/bin/bash
# Initialize the wiki
if [ ! -d .git ] && [ "$(git rev-parse --is-bare-repository 2> /dev/null)" != "true" ]; then
# Check if the parent repository has a wiki
REPO=$(git --git-dir=/.git config --get remote.origin.url | sed -e 's/.git$/.wiki.git/g' -e 's/:/\//g' -e "s/git@/https:\/\/$GIT_AUTH@/g" -e "s/:\/\/@/:\/\//g")
[ ! -z $REPO ] \
&& git clone --no-tags --single-branch --depth 1 $REPO . 2> /dev/null \
|| git init 2> /dev/null
fi
<?php
namespace Finagin\Support;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Database\ConnectionInterface;
use LogicException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
<?php
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
Auth::macro('shadow', function ($user = null) {
$ability = 'shadowLogin';
$key = 'shadow.user.id';
<?php
namespace Finagin\Support\Logging\Handlers;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Utils;
class ClassFile extends StreamHandler
#!/usr/bin/env php
<?php
namespace {
use Finagin\Phar\Builder;
Builder::make()
->setCliEntryPoint('cli.php')
->setWebEntryPoint('web.php')
@finagin
finagin / AttributeRouts.php
Created July 2, 2022 06:32
Attribute Routing
<?php
namespace App\Services;
use App\Attributes\Route as RouteAttribute;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route as RouteFacade;
use Illuminate\Support\Str;
use ReflectionClass;
use ReflectionMethod;
@finagin
finagin / Dates.php
Created July 15, 2021 09:35
Month boundaries
<?php
/**
* @param \DateTime|null $date Дата для которой рассчитать начало и конец месяца.
* Если не передать считает от текущего момента.
*
* @return array<string, int> Массив из трёх timestamp: начало месяца, конец месяца, дата от которой производился расчёт
* @throws \Exception
*/
function boundaries(\DateTime $date = null)
<?php
namespace App\Services;
use App\Contracts\Helper;
use Illuminate\Contracts\Container\BindingResolutionException;
use Laravel\Nova\Nova;
class HelperService implements Helper
{
@finagin
finagin / UsesUuid.php
Last active December 19, 2020 23:11
Laravel Eloquent uses UUID
<?php
namespace App\Traits;
use Illuminate\Support\Str;
trait UsesUuid
{
/**
* Boot the UUID trait for a model.
@finagin
finagin / lazy-loading.html
Last active May 4, 2020 01:08 — forked from droganaida/lazy-loading.html
Intersection Observer + custom lazy loading demo
<html>
<head>
<title>Lazy loading by #Blondiecode</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, "Helvetica Neue", Helvetica, serif;
}
footer {