Skip to content

Instantly share code, notes, and snippets.

View finagin's full-sized avatar
🖖

Igor Finagin finagin

🖖
View GitHub Profile
@finagin
finagin / Container.php
Last active September 17, 2018 11:49 — forked from MustafaMagdi/Container.php
PHP Dependency Injection Container
<?php
namespace Core;
use Closure;
use Exception;
use ReflectionClass;
/**
* Class Container
<?php
define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br>');
$min = 1;
$max = 10;
$range = [$min, $max];
foreach (range(...$range) as $i) {
@finagin
finagin / ttl.sh
Last active May 28, 2018 09:24
Обход ограниченя раздачи интернета с телефона на MacBook
# Using curl:
curl -sSL https://finagin.github.io/ttl | sh
# Or wget:
wget -qO- https://finagin.github.io/ttl | sh
@finagin
finagin / sum_digits_of_number.php
Created May 18, 2018 12:14
Sum digits of number
<?php
function f($number, $recursive = false, $dec = 10)
{
if (!is_int($dec)) {
throw new \Exception('dec must integer');
} elseif ($dec < 2) {
throw new \Exception('dec must be >= 2');
}
<?php
class Str
{
public static function split(string $str): array
{
$words = preg_split('/(?:(?=[A-Z])|[-_\s])/', $str, -1, PREG_SPLIT_NO_EMPTY);
return array_map('strtolower', $words);
}
<?php
if (!function_exists('optional')) {
function optional($instance, $default = null)
{
return new class($instance, $default = null)
{
private $instance;
private $default;
@finagin
finagin / jQuery.shelf.js
Created April 11, 2018 08:33
Shelf input value
(function ($) {
function Shelf(value) {
var _value = value;
this.getValue = function () {
return _value;
};
this.setValue = function (value) {
_value = value;
};
function telegramShare(url, text) {
var tg = new URL('https://telegram.me/share/url');
url = new URL(url);
url.searchParams.append('utm_source', 'telegram.org');
url.searchParams.append('utm_medium', 'share_telegram');
url.searchParams.append('utm_campaign', 'share');
tg.searchParams.append('url', url);
tg.searchParams.append('text', text || 'Канал Финагина: @FinChannel');
@finagin
finagin / Log.php
Created March 31, 2018 22:29
Laravel logger
<?php
namespace App\Support;
use \Illuminate\Support\Facades\Log as Logger;
/**
* Class Log
*
* @method static emergency($message, array $context = [])
#!/usr/bin/env php
<?php
$domain = 'amobeeline';
$nginx = <<<CONF
server {
listen 80;
listen 443 ssl;