Skip to content

Instantly share code, notes, and snippets.

View TsuiAnthonYVR's full-sized avatar

Anthony Tsui TsuiAnthonYVR

  • Voleo
  • Vancouver, Canada
View GitHub Profile
@TsuiAnthonYVR
TsuiAnthonYVR / day8.php
Last active December 10, 2017 07:25
Advent of Code day 8
<?php
$max = 0;
$qk =0;$qt =0; $t =0; $hfh =0; $js =0; $b =0; $uoc =0; $yg =0; $iyu =0;$gy =0; $gif =0; $nwe =0; $itw =0; $ih =0; $hm =0; $cp =0; $x =0; $fi =0; $tc =0; $j =0; $xly =0; $yr =0; $ioe =0; $bi =0; $bhp = 0;
if ( $qk > -10 ) $ioe -= 890 ; $max = max($max, $b, $bhp, $bi, $cp, $fi, $gif, $gy, $hfh, $hm, $ih, $ioe, $itw, $iyu, $j, $js, $nwe, $qk, $qt, $t, $tc, $uoc, $x, $xly, $yg, $yr); ;
if ( $qt <= 7 ) $gif += -533 ; $max = max($max, $b, $bhp, $bi, $cp, $fi, $gif, $gy, $hfh, $hm, $ih, $ioe, $itw, $iyu, $j, $js, $nwe, $qk, $qt, $t, $tc, $uoc, $x, $xly, $yg, $yr); ;
if ( $t != 0 ) $itw -= 894 ; $max = max($max, $b, $bhp, $bi, $cp, $fi, $gif, $gy, $hfh, $hm, $ih, $ioe, $itw, $iyu, $j, $js, $nwe, $qk, $qt, $t, $tc, $uoc, $x, $xly, $yg, $yr); ;
if ( $hfh < -2 ) $nwe += 486 ; $max = max($max, $b, $bhp, $bi, $cp, $fi, $gif, $gy, $hfh, $hm, $ih, $ioe, $itw, $iyu, $j, $js, $nwe, $qk, $qt, $t, $tc, $uoc, $x, $
@TsuiAnthonYVR
TsuiAnthonYVR / BelongsToMany.php
Created July 19, 2017 13:07
How to get Laravel to fire model attach/detach events
<?php namespace App\Relations;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class BelongsToMany extends \Illuminate\Database\Eloquent\Relations\BelongsToMany {
/**
* Attach a model to the parent.
*
* @param mixed $id
@TsuiAnthonYVR
TsuiAnthonYVR / MailingListBaseDecorator.php
Last active February 16, 2017 18:10
Use decorator without making type hinting mad
<?php
namespace App;
use App\Contracts\MailingListService;
abstract class MailingListBaseDecorator implements MailingListService
{
protected $mailingList;
@TsuiAnthonYVR
TsuiAnthonYVR / AppServiceProvider.php
Last active November 18, 2016 21:21
Adding custom macros into Laravel
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Collection;
class AppServiceProvider extends ServiceProvider
{
/**