This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAllActivePostsIds(postsIds) { | |
return _(posts) | |
.filter(post => post.is_active) | |
.map('id') | |
.value() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$allUserNames = explode(',', $userNames); | |
$validUserNames = Contact::whereIn('user_name', $allUserNames) | |
->pluck('user_name') | |
->toArray(); | |
$invalidUserNames = array_values(array_diff($allUserNames, $validUserNames)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Carbon\Carbon; | |
class SystemInformation | |
{ | |
public function avg() | |
{ | |
if (is_readable('/proc/loadavg')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function isMultiDimensionalArray($array) : bool | |
{ | |
if ( !is_array($array) ) return false; | |
return count($array) != count( $array, COUNT_RECURSIVE ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tail -f -n 450 storage/logs/laravel*.log \ | |
| grep -i -E \ | |
"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \ | |
--color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Traits; | |
trait Sluggable { | |
public static function bootSluggable() { | |
static::creating(function ($model) { | |
$model->slug = (new static)->generateUniqueSlug($model->name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dates = [ | |
DateTime::createFromFormat('Y-m-d', '2000-02-01'), | |
DateTime::createFromFormat('Y-m-d', '1994-01-30'), | |
DateTime::createFromFormat('Y-m-d H:i:s', '2018-07-27 12:03:33'), | |
DateTime::createFromFormat('Y-m-d', '2006-07-27'), | |
DateTime::createFromFormat('Y-m-d H:i:s', '2018-07-27 12:04:15'), | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// App\Address Model | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
use App\Observers\AddressObserver; // included our Model Observer | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$foods = array( | |
array( | |
'id' => 4, | |
'name' => 'Banana', | |
'color' => 'Yellow', | |
), | |
array( | |
'id' => '5', | |
'name' => 'Apple', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
git show-branch -a \ | |
| grep '\*' \ | |
| grep -v `git rev-parse --abbrev-ref HEAD` \ | |
| head -n1 \ | |
| sed 's/.*\[\(.*\)\].*/\1/' \ | |
| sed 's/[\^~].*//' | |
# How it works: |