Skip to content

Instantly share code, notes, and snippets.

View schmidsi's full-sized avatar
🦩

Simon Emanuel Schmid schmidsi

🦩
View GitHub Profile
import { gql, useQuery } from '@apollo/client';
import { useWeb3React } from '@web3-react/core';
import { useEffect, useState } from 'react';
import { useAppContext } from '../components/AppContextWrapper';
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
export const useLastMints = () => {
const [eventHandlerBound, setEventHandlerBound] = useState(false);
const { library } = useWeb3React();
@schmidsi
schmidsi / JSON.sol
Created January 16, 2022 08:54
Example how to create a JSON from solidity
function makeJSON() public view virtual returns (string memory) {
return
string(
abi.encodePacked(
"data:application/json;base64,",
Base64.encode(
abi.encodePacked(
'{"name": "Bla #',
tokenId.toString(),
@schmidsi
schmidsi / block-polling.ts
Last active December 8, 2021 15:39
Block polling pattern examples with fallback
let timeout;
const refresh = () => {
window.clearTimeout(timeout);
// do query
timeout = window.setTimeout(() => {
refresh();
}, 10 * 1000);
};
@schmidsi
schmidsi / mapping.ts
Last active September 28, 2021 19:29
Proxy Pattern
import { Address, log } from "@graphprotocol/graph-ts";
import {
ImplementationAdded,
} from "../generated/CallProxy/CallProxy";
import {
ProxyEvent,
} from "../generated/schema";
@schmidsi
schmidsi / LissajousToken.sol
Created March 19, 2021 17:36
Lissajous.art
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.3;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/math/SafeMath.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import 'hardhat/console.sol';
@schmidsi
schmidsi / ScrollPositionProvider.tsx
Last active March 10, 2021 09:03
Scribble to fix scroll position
import React, { useEffect, useContext } from 'react';
import Router from 'next/router';
export const ScrollPositionContext = React.createContext({
triggerScroll: () => null,
});
export const useScrollPosition = () => useContext(ScrollPositionContext);
let routerBound = false;
@schmidsi
schmidsi / asdf
Created August 14, 2019 10:18
Blabla
adsf
enum ParticipationType {
INVEST
REDEEM
}
enum Opinion {
UnqualifiedOpinion
QualifiedOpinion
AdverseOpinion
DisclaimerOfOpinion
@schmidsi
schmidsi / PicturesASCII.hs
Created October 7, 2017 14:41
Fun with Haskell Lists
module PictureASCII where
import Data.Char
--------------------------------------------------------------------------------
-- 1) ASCII Pictures
--------------------------------------------------------------------------------
-- A Picture is a list of strings.
type Picture = [String]
-- An example picture. Design a nicer one.
import ch.fhnw.util.math.Mat4;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.FPSAnimator;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class Lissajous implements WindowListener, GLEventListener{