Skip to content

Instantly share code, notes, and snippets.

View lorisleiva's full-sized avatar

Loris Leiva lorisleiva

View GitHub Profile
@lorisleiva
lorisleiva / pipeline.js
Last active February 23, 2023 17:28
Laravel-like pipelines in JavaScript and TypeScript
View pipeline.js
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);
}
@sindresorhus
sindresorhus / esm-package.md
Last active March 1, 2024 05:07
Pure ESM package
View esm-package.md

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@GuyARoss
GuyARoss / main.js
Created August 9, 2020 08:22
stripe noise thing
View main.js
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", {
@kieranajp
kieranajp / gimmesecret.sh
Last active June 10, 2020 17:25
An easy way to look at multiple data items in a Kubernetes secret.
View gimmesecret.sh
#!/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
@lorisleiva
lorisleiva / workflow.yaml
Last active November 18, 2023 04:59
🐳 GitHub Actions using Laravel Docker
View workflow.yaml
name: My Workflow
on: [push]
jobs:
build:
runs-on: ubuntu-latest
container:
image: lorisleiva/laravel-docker:7.4
steps:
- uses: actions/checkout@v2
@lorisleiva
lorisleiva / ArticleUpdateTest.php
Created August 5, 2019 10:16
✅ Set up traits dynamically for tests
View ArticleUpdateTest.php
<?php
namespace Tests;
use Tests\Authenticated;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ArticleUpdateTest extends TestCase
{
@lorisleiva
lorisleiva / phpcs.xml
Last active May 4, 2019 14:42
The default PHP Code Style of my Laravel projects.
View phpcs.xml
<?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>
@dunglas
dunglas / example.php
Created April 19, 2018 06:25
A minimalist GraphQL client for PHP
View example.php
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}
@PCreations
PCreations / rxjs-diagrams.md
Last active January 18, 2024 08:52
Super Intuitive Interactive Diagrams to learn combining RxJS sequences by Max NgWizard K
@brunogaspar
brunogaspar / macro.md
Last active February 15, 2024 20:23
Recursive Laravel Collection Macros
View macro.md

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