Skip to content

Instantly share code, notes, and snippets.

View scrubmx's full-sized avatar
🏴‍☠️

Jorge González scrubmx

🏴‍☠️
View GitHub Profile
<?php
namespace App\Models\Traits;
use LogicException;
trait Immutables
{
/**
* Set a given attribute on the model.
@scrubmx
scrubmx / fizzbuzz.ex
Created January 3, 2018 08:27
FizzBuzz in Elixir
defmodule FizzBuzz do
def print do
Enum.each(1..100, &FizzBuzz.print/1)
end
def print(n) do
result = cond do
divisible_by_3?(n) && divisible_by_5?(n) -> "FizzBuzz"
divisible_by_3?(n) -> "Fizz"
divisible_by_5?(n) -> "Buzz"
@scrubmx
scrubmx / InteractsWithElements.php
Created November 1, 2017 23:20
Facebook\WebDriver\Exception\UnknownServerException: unknown error: Element is not clickable at point
<?php
namespace Laravel\Dusk\Concerns;
use Exception;
use Facebook\WebDriver\WebDriverKeys;
trait InteractsWithElements
{
/**
@scrubmx
scrubmx / Application.php
Created October 25, 2017 23:18
Register custom model events in laravel 5.5
<?php
namespace App\Models;
class Application extends Model
{
/**
* The attributes that should be mutated to dates.
*
* @var array
@scrubmx
scrubmx / CreatesApplication.php
Created September 1, 2017 19:17
Use a stub log driver in your laravel tests
<?php
namespace Tests;
use Illuminate\Foundation\Application;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
@scrubmx
scrubmx / converter.php
Last active August 22, 2017 20:02
Convert html string to markdown
<?php
class MarkdownConverter
{
protected = $original;
protected = $formatted;
public function convert(string $html)
{
$this->original = $html;
@scrubmx
scrubmx / _analytics.blade.php
Created March 15, 2017 16:46
Google analytics blade partial for laravel.
<script>
(function (i,s,o,g,r,a,m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
};
i[r].l = 1*new Date();
a = s.createElement(o);
m = s.getElementsByTagName(o)[0];
a.async = 1;
@scrubmx
scrubmx / TestCase.php
Created March 13, 2017 16:29
Laravel authorization test helpers
<?php
namespace Tests;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
@scrubmx
scrubmx / deploy.sh
Last active August 22, 2017 20:05
Laravel deploy script
# Change to the project directory
cd /home/forge/appname.com
# Put the application into maintenance mode
php artisan down
# Get the latests changes
git pull origin master
# Install composer dependecies
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros