Skip to content

Instantly share code, notes, and snippets.

View andrey-helldar's full-sized avatar
🧙‍♂️
It's never too late to get better

Andrey Helldar andrey-helldar

🧙‍♂️
It's never too late to get better
View GitHub Profile
@terkel
terkel / _decimal.scss
Last active June 17, 2024 14:07
Rounding decimals in Sass
// _decimal.scss | MIT License | gist.github.com/terkel/4373420
// Round a number to specified digits.
//
// @param {Number} $number A number to round
// @param {Number} [$digits:0] Digits to output
// @param {String} [$mode:round] (round|ceil|floor) How to round a number
// @return {Number} A rounded number
// @example
// decimal-round(0.333) => 0
@Thinkscape
Thinkscape / flattenExceptionBacktrace.php
Last active September 6, 2024 18:45
Make any PHP Exception serializable by flattening complex values in backtrace.
<?php
function flattenExceptionBacktrace(\Exception $exception) {
$traceProperty = (new \ReflectionClass('Exception'))->getProperty('trace');
$traceProperty->setAccessible(true);
$flatten = function(&$value, $key) {
if ($value instanceof \Closure) {
$closureReflection = new \ReflectionFunction($value);
$value = sprintf(
'(Closure at %s:%s)',
<?php
namespace App\Console;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
trait OverlappingControlled
{
<?php
namespace App\Services\Foundation;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Support\Jsonable;
use InvalidArgumentException;
use JsonSerializable;
class JsonFactory
@Ellrion
Ellrion / helper.php
Created August 22, 2017 15:28
Сортировка ассоциативного массива в порядке указанном массивом ключей.
<?php
if (!function_exists('array_sort_by_keys_array')) {
/**
* Сортировка ассоциативного массива в порядке указанном массивом ключей.
*
* @param array $array Входной массив.
* @param array $sorter Массив ключей в нужном порядке.
*
* @return bool
@Ellrion
Ellrion / FlashMessageSender.php
Last active March 5, 2018 15:04
Flash messages min service for Laravel (only backend)
<?php
namespace App\Services\Foundation;
use Illuminate\Session\Store;
use Illuminate\Support\Collection;
/**
* Register it in AppServiceProvider (or other): $this->app->singleton('flash', FlashMessageSender::class);
*/
<?php
namespace App\Services\Foundation\Routing;
use Illuminate\Routing\ResourceRegistrar;
class ExtendedResourceRegistrar extends ResourceRegistrar
{
/**

My collection of shell aliases

Common

alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

alias mkdir='mkdir -p'