Skip to content

Instantly share code, notes, and snippets.

View phuson's full-sized avatar
🌄
Focusing

Son phuson

🌄
Focusing
View GitHub Profile
@phuson
phuson / SD2ContentView.swift
Created December 4, 2022 17:46 — forked from ynagatomo/SD2ContentView.swift
An iOS app that generates images using Stable-Diffusion-v2 CoreML models.
//
// ContentView.swift
// coremlsd2test
//
// Created by Yasuhito Nagatomo on 2022/12/03.
//
// A sample code using Apple/ml-stable-diffusion library.
// Preparation:
// 1. convert the PyTorch Stable-Diffusion v2 model to coreml models using Apple's tools.
// 2. import the coreml models into the iOS project.
@phuson
phuson / SequenceConnector.ts
Created April 22, 2022 23:25
Custom connector to connect the Sequence smart contract wallet with the wagmi web3 library.
import { Connector, ConnectorNotFoundError, Chain } from 'wagmi';
import { sequence, Wallet } from '0xsequence';
type SequenceConnectorOptions = {
// see more info at https://docs.sequence.build/getting-started
network?: string; // 'polygon' or 'mumbai'
app: string;
};
const normalizeChainId = (chainId: string | number) => {
@phuson
phuson / TestUtil.sol
Last active April 5, 2022 19:31
Since OpenZeppelin AccessControl's dynamic error messaging changes based on the sender's address and the checked role, it's been a challenge to write tests against it. As part of my solution, I wrote a utility function to automate the error message generation for my tests in Foundry Forge.
function getEncodedAccessControlError(address account, bytes32 role)
public
pure
returns (bytes memory)
{
return
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and PHP-FPM
sudo yum install -y nginx php-fpm
# Install PHP extensions
sudo yum install -y php-devel php-mysql php-pdo \
php-pear php-mbstring php-cli php-odbc \