Skip to content

Instantly share code, notes, and snippets.

View lorisleiva's full-sized avatar

Loris Leiva lorisleiva

View GitHub Profile
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 / 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 /
Last active June 15, 2022 20:00
[Metaplex] Integrate the new JS SDK with React
lorisleiva / TweetCard.vue
Last active February 10, 2022 16:06
TweetCard and TweetFormUpdate for Episode 12 of the Solana series.
<script setup>
import { ref, toRefs, computed } from 'vue'
import { useWorkspace } from '@/composables'
import TweetFormUpdate from './TweetFormUpdate'
const props = defineProps({
tweet: Object,
const { tweet } = toRefs(props)
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 / 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);
lorisleiva / useAutoresizeTextarea.js
Created November 15, 2021 08:39
Auto-resize a textarea based on its content (Vue 3 composition API)
import { watchEffect } from "vue"
export const useAutoresizeTextarea = (element) => {
const resizeTextarea = () => { = 'auto' = element.value.scrollHeight + 'px'
watchEffect(onInvalidate => {
if (! element.value) return
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>
// 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);
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){}