Skip to content

Instantly share code, notes, and snippets.

View lorisleiva's full-sized avatar

Loris Leiva lorisleiva

View GitHub Profile
lorisleiva / AppWithLocalStorage.vue
Last active May 24, 2024 21:25
Abstraction of the local storage using Vue3's composition API
<script setup>
import useLocalStorage from './useLocalStorage'
const publicKey = useLocalStorage('solana-wallet-public-key')
<input type="text" v-model="publicKey">
<div v-text="publicKey"></div>
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 /
Last active March 20, 2024 07:44
Install and use Solana CLI in an Apple M1 before v1.9

Install Solana on Apple M1

Unfortunately, at the time of writing, the Solana installer script above will not work on Apple M1 computers.

The installation will be successful and you’ll be able to call solana commands but other Solana binaries such as solana-test-validator will throw various errors since it’s expecting dependencies to be located elsewhere. If you’ve already installed it that way, no worries, simply run rm -rf ~/.local/share/solana to uninstall Solana.

I’ll be sure to update this article if/when this will work out-of-the-box for M1 computers.

In the meantime, we’ve got a little workaround to go through. We need to clone the Solana repository and compile the binary from the source code. Don’t worry, the installation process is still super simple, it just takes a bit longer due to the compilation time. Here are the steps.

lorisleiva / test.patch
Last active March 14, 2024 15:25
Test .patch extension on gists.
From f54a9349cb1205bf34d04d2900cf5e1e69228480 Mon Sep 17 00:00:00 2001
From: Loris Leiva <>
Date: Thu, 14 Mar 2024 15:13:08 +0000
Subject: [PATCH] Fix exported extensions in package.json
clients/js/package.json | 8 ++++----
clients/js/tsup.config.ts | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
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 / 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}'",
lorisleiva / via-spl-token.ts
Created April 4, 2023 09:00
Clear the closeAuthority on a token account
import { createSetAuthorityInstruction, AuthorityType } from '@solana/spl-token';
import { Transaction } from '@solana/web3.js';
const instruction = createSetAuthorityInstruction(
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
.reduce((next, pipe) => (passable) => pipe(passable, next), then);
return pipelineCallback(initialValue);
// Nodes.
abstract class Node implements Visitable {}
class Number extends Node {
public function __construct(public float $value){}
public function accept(Visitor $visitor) {
return $visitor->visitNumber($this);
// 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()