Skip to content

Instantly share code, notes, and snippets.

View lorisleiva's full-sized avatar

Loris Leiva lorisleiva

View GitHub Profile
lorisleiva / PaymentRequest.js
Created June 4, 2018 22:02
Renderless VueJS component for Payment Requests using Stripe Element
export default {
props: {
stripe: {
type: String,
required: true,
options: {
type: Object,
required: true,
lorisleiva /
Last active May 13, 2024 14:20
This gist describes two processes allowing us to access the Google API and to register some webhooks

Access Google API credentials and domain verification

This gist describes two processes allowing us to access the Google API and to register some webhooks. At the end of both processes we will obtain all variable needed to start using their API and we will have whitelisted all necessary URL to get started. We will be using the Google Calendar API and the Google Plus API to access the email address of the user.

This gist has been created as an Appendix to this article (part 1) and this article (part 3).

Note that, I will be using a randomly generated ngrok domain during this presentation. Simply replace with your domain name

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. -->
lorisleiva / ArticleUpdateTest.php
Created August 5, 2019 10:16
✅ Set up traits dynamically for tests
namespace Tests;
use Tests\Authenticated;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ArticleUpdateTest extends TestCase
lorisleiva / workflow.yaml
Last active November 18, 2023 04:59
🐳 GitHub Actions using Laravel Docker
name: My Workflow
on: [push]
runs-on: ubuntu-latest
image: lorisleiva/laravel-docker:7.4
- uses: actions/checkout@v2
lorisleiva /
Last active December 26, 2021 13:09
Webpack aliases with Laravel Mix

Step 1: configure Webpack aliases

// webpack.mix.js

const mix = require('laravel-mix')
const path = require('path')

// ...
// resources/js/services/Form.js
import FormErrors from './FormErrors'
export default class {
constructor (initialData = {}, submitCallback = null) {
this._initialData = initialData
this._submitCallback = submitCallback
this.errors = new FormErrors()
// resources/js/models/Model.js
export default class Model {
constructor (attributes = {}) {
static make (attributes = {}) {
return Array.isArray(attributes)
? => new this(nested))
lorisleiva / toSqlWithBindings.php
Last active November 15, 2023 08:54
A little macro to get the SQL from a query builder without the annoying "?".
use Illuminate\Database\Eloquent\Builder;
Builder::macro('toSqlWithBindings', function () {
$bindings = array_map(
fn ($value) => is_numeric($value) ? $value : "'{$value}'",
abstract class Node {}
class Calculator extends Node {
public function __construct(public array $statements){}
class Add extends Node {
public function __construct(public Node $left, public Node $right){}