Skip to content

Instantly share code, notes, and snippets.

@luchaos
luchaos / StderrColorFormatter.php
Last active Oct 6, 2021
Monolog StderrColorFormatter using Collision\ConsoleColor
View StderrColorFormatter.php
<?php
namespace Luchaos\MonologFormatter;
use Monolog\Formatter\LineFormatter;
use NunoMaduro\Collision\ConsoleColor;
use Psr\Log\LogLevel;
class StderrColorFormatter extends LineFormatter
{
@luchaos
luchaos / migration.sql
Last active Jan 6, 2017
Laravel Spatie Activity Log for PostGRES
View migration.sql
-- use case: find activities of a resource and/or within its related resources
-- causes sequential scans and is a tad slower because of the explicit json casting:
SELECT *
FROM activity_log
WHERE (log_name = 'resources' AND subject_id = 351030)
OR (log_name = 'related_resources' AND (properties :: JSON -> 'attributes' ->> 'resource_id') :: INT = 351030)
ORDER BY created_at DESC;
View keybase.md

Keybase proof

I hereby claim:

  • I am luchaos on github.
  • I am luchaos (https://keybase.io/luchaos) on keybase.
  • I have a public key whose fingerprint is 0C50 5B34 7556 29A9 0FC3 BB2C ECDA 55D3 2195 BD55

To claim this, I am signing this object:

@luchaos
luchaos / User.php
Last active Aug 29, 2015
OAuth - Remembering granted authorization
View User.php
class User extends Eloquent implements UserInterface, RemindableInterface {
// ...
public function scopesAuthorizedByClientId($clientId)
{
$scopesAuthorized = array();
$session = DB::table('oauth_sessions')
->where('client_id', $clientId)