Skip to content

Instantly share code, notes, and snippets.

@mcuyar
mcuyar / UnevenListsZip.php
Last active May 10, 2022 13:04
create a list which alternates between elements of the two input lists, starting with the first element of the first list, then the first element of the second list and so on, until one of the lists doesn't have the next element, then you stop.
<?php
function zipLists(array $first, array $second, $index = 0, $carry = []): array
{
$firstValue = $first[$index] ?? null;
if(is_null($firstValue)) {
return $carry;
}
$carry[] = $firstValue;
@mcuyar
mcuyar / .pre-commit-config.yaml
Created June 14, 2017 02:25
PHP pre-commit config
- repo: [email protected]:pre-commit/pre-commit-hooks
sha: "20f04626a1ee7eb34955d775a37aa9a56a0a7448"
hooks:
- id: check-json
stages: [commit]
- id: check-merge-conflict
stages: [commit]
- id: check-yaml
stages: [commit]
- id: end-of-file-fixer
<?php
class PublicServant
{
protected $psClass;
protected $ClassName;
private $methods = [];
@mcuyar
mcuyar / terminal-logger.php
Created July 16, 2014 15:32
Send messages to logged in terminal user from your laravel application
<?php
if(! function_exists('tlog')) {
function tlog($logged, $message = '', $user = 'vagrant')
{
// Only available in test environments
if (app()->environment() === 'production') {
return;
}