Skip to content

Instantly share code, notes, and snippets.

View m1guelpf's full-sized avatar

Miguel Piedrafita m1guelpf

View GitHub Profile
@m1guelpf
m1guelpf / ColorExt.swift
Created March 15, 2024 03:14
Source for the Underlay demo
import SwiftUI
extension Color {
static var background: Color {
return Color(uiColor: .systemBackground)
}
static var secondaryBackground: Color {
return Color(uiColor: .secondarySystemBackground)
}
@m1guelpf
m1guelpf / route.ts
Created May 26, 2023 04:18
Next.js App Route for getting the current playing song on Spotify (or a cached version)
import redis from '@/lib/redis'
import { tap } from '@/lib/utils'
import { NextResponse } from 'next/server'
import { NowPlaying } from '@/types/activities'
import { base64_encode, use } from '@/lib/utils'
type SpotifyResponse = {
is_playing: boolean
progress_ms: number
item: {
@m1guelpf
m1guelpf / headers.js
Last active October 9, 2022 05:18 — forked from Philogy/headers.py
Transmission11s Style Headers In Node
#!/usr/bin/env node
import { execSync } from 'child_process'
const args = process.argv.slice(2);
if (args.length !== 1) {
throw new Error(`Invalid argument count ${args.length} expected 1`);
}
const word = args[0];
@m1guelpf
m1guelpf / MergeReward.sol
Created May 23, 2022 18:55
A contract that rewards its first caller after the Merge.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
/// @title Merge Reward
/// @author Miguel Piedrafita
/// @notice A contract that rewards its first caller after the Merge
contract MergeReward {
/// @notice Thrown when attempting to claim the reward while in POW
@m1guelpf
m1guelpf / attestation.txt
Created April 7, 2022 17:35
Attestation
I contributed to the Semaphore Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: semaphore16
Contributor # 193
Hash: 2b0a1a94 661f7cbd 8ab00877 f3676570
82d881d9 86990c5e 159ff5d7 1284945e
cb3b7f30 3aceb733 80e6daed 3586257e
0012aaed 8918a3c4 cff31024 5744722e
did:3:kjzl6cwe1jw148wahhdvncozedy5coxmqwso9aq23tb7xx9kxd31u9f1lesek3l
@m1guelpf
m1guelpf / Multicall.ts
Created March 1, 2022 11:00
An Ethers.js-compatible Multicall implementation
import { ethers } from 'ethers'
import { ChainId } from '@/types/utils'
import { namehash } from 'ethers/lib/utils'
import { multicallAddresses, ZERO_ADDRESS } from '../consts'
import { Multicall as MulticallInterface, Multicall__factory } from '@/contracts'
export type Call = {
contract: {
address: string
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import 'solmate/tokens/ERC721.sol';
contract NFTBillboard is ERC721('NFT Billboard', 'BNFT') {
error Unauthorized();
error TokenNotFound();
struct NFT {
@m1guelpf
m1guelpf / Leaderboard.sol
Created January 20, 2022 05:22
An optimized version of nnnnicholas.eth's leaderboard contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import 'solmate/utils/SafeTransferLib.sol';
/**
* @title Leaderboard
* @author @nnnnicholas, tweaked by @m1guelpf
* @dev Receive ETH and associate contributions with contract addresses.
*/
@m1guelpf
m1guelpf / PRMTVS.sol
Last active January 3, 2022 20:03
A lil identity namespace contract in response to jsngr's tweet: https://twitter.com/jsngr/status/1478090387101302789
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.10;
contract PRMTVS {
struct Identity {
string name;
string bio;
string email;
string website;
}