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;
<?php
$ips = [
'127.0.0.1',
];
$ports = [
20 => 'FTP data',
21 => 'FTP control port',
22 => 'SSH',
@finagin
finagin / socks5.sh
Last active September 29, 2021 12:23
#!/usr/bin/env bash
SUDO=''
if [ "$(id -u)" != "0" ]; then
SUDO='sudo'
echo "This script requires superuser access."
echo "You will be prompted for your password by sudo."
# clear any previous sudo permission
sudo -k
fi
@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)
@finagin
finagin / Laravel Spark disable registration.md
Created April 20, 2017 14:35
Laravel Spark disable registration

Laravel Spark disable registration

php artisan make:command CreateSuperUser

Open app/Console/Commands/CreateSuperUser.php and insert

<?php

namespace App\Console\Commands;