Skip to content

Instantly share code, notes, and snippets.

View lorisleiva's full-sized avatar

Loris Leiva lorisleiva

View GitHub Profile
@lorisleiva
lorisleiva / phpcs.xml
Last active May 4, 2019 14:42
The default PHP Code Style of my Laravel projects.
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Laravel">
<description>The default PHP Code Style of my Laravel projects.</description>
<!-- Files to include. -->
<file>app</file>
<file>config</file>
<file>routes</file>
<file>tests</file>
@lorisleiva
lorisleiva / ArticleUpdateTest.php
Created August 5, 2019 10:16
✅ Set up traits dynamically for tests
<?php
namespace Tests;
use Tests\Authenticated;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ArticleUpdateTest extends TestCase
{
@kieranajp
kieranajp / gimmesecret.sh
Last active June 10, 2020 17:25
An easy way to look at multiple data items in a Kubernetes secret.
#!/usr/bin/env bash
function usage {
echo "An easy way to look at multiple data items in a Kubernetes secret."
echo " Usage: $(basename $0) <secret> <data ...>"
exit 1
}
if [[ $# -eq 0 ]] ; then
usage
@GuyARoss
GuyARoss / main.js
Created August 9, 2020 08:22
stripe noise thing
import {_ as e, L as t} from "./index-4deec983.js";
import {a as n, C as i} from "./Controller-26bd1e9e.js";
import {S as s} from "./ScrollObserver-d0732a2c.js";
import {F as o} from "./index-bee741e4.js";
class r {
constructor(e, t, n, i=!1) {
const s = this
, o = -1 !== document.location.search.toLowerCase().indexOf("debug=webgl");
s.canvas = e,
s.gl = s.canvas.getContext("webgl", {
@lorisleiva
lorisleiva / pipeline.js
Last active February 23, 2023 17:28
Laravel-like pipelines in JavaScript and TypeScript
export function pipeline(initialValue, pipes, then) {
then = then ?? ((t) => t);
const pipelineCallback = pipes
.slice()
.reverse()
.reduce((next, pipe) => (passable) => pipe(passable, next), then);
return pipelineCallback(initialValue);
}
@paulund
paulund / phpcs.xml
Created August 20, 2017 16:50
PHP PSR-2 CodeSniffer Config for Laravel
<?xml version="1.0"?>
<ruleset name="Laravel Standards">
<!--
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument. The description tag below is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
-->
@cabloo
cabloo / DebouncedJob.php
Last active August 22, 2024 18:09
Debounced Laravel Jobs
<?php
namespace App\Support\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
class DebouncedJob implements ShouldQueue
{
use \Illuminate\Foundation\Bus\DispatchesJobs;
use \App\Support\Cache\PrefixedCache;
@lorisleiva
lorisleiva / workflow.yaml
Last active September 18, 2024 11:24
🐳 GitHub Actions using Laravel Docker
name: My Workflow
on: [push]
jobs:
build:
runs-on: ubuntu-latest
container:
image: lorisleiva/laravel-docker:7.4
steps:
- uses: actions/checkout@v2
@PCreations
PCreations / rxjs-diagrams.md
Last active September 26, 2024 01:44
Super Intuitive Interactive Diagrams to learn combining RxJS sequences by Max NgWizard K
@brunogaspar
brunogaspar / macro.md
Last active November 25, 2024 11:01
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup