Skip to content

Instantly share code, notes, and snippets.

@tjade273
tjade273 / Database.sol
Last active April 6, 2024 04:32
Example of separated storage and logic
contract Database{
mapping(uint => uint) public _data;
mapping(address => bool) _owners;
function Database(address[] owners){ //Called once at creation, pass in initial owners
for(uint i; i<owners.length; i++){
_owners[owners[i]]=true;
}
}
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@3n21c0
3n21c0 / main.go
Last active December 30, 2025 18:52
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
<!DOCTYPE html>
<html>
<head>
<title>JavaScript file upload</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script src="https://wzrd.in/standalone/buffer"></script>
<script src="https://unpkg.com/ipfs-api@9.0.0/dist/index.js"
integrity="sha384-5bXRcW9kyxxnSMbOoHzraqa7Z0PQWIao+cgeg327zit1hz5LZCEbIMx/LWKPReuB"
crossorigin="anonymous"></script>
</head>
@asimjalis
asimjalis / fast-clojure-hello-world-using-graal-vm.md
Last active March 14, 2019 12:42
How To Speed Up Clojure Hello World 100x Using GraalVM

How To Speed Up Clojure Hello World 100x Using GraalVM

Performance

Version Command Time (seconds)
Java time java -jar target/fastclj-1.0-standalone.jar 1.354
GraalVM time ./fastclj-1.0-standalone 0.014

Details

@christroutner
christroutner / js-buf.md
Last active September 8, 2020 16:58
Working with Buffers and Hex Strings

Working with JavaScript Buffers, Hex, and Strings

// Start with a normal base-10 number.
const numNum = 123; // 7B in hex
console.log(`numNum: `, numNum);
// numNum:  123

// Convert the Number to a String
@Phate6660
Phate6660 / rust recommendations and alternatives.md
Last active May 29, 2024 12:35
My growing list of Rust programs to use.
@gorgos
gorgos / MultiSwap.sol
Created August 22, 2021 11:04
Example for how to swap multiple tokens in one on Ropsten
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;
pragma abicoder v2;
import "https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/interfaces/ISwapRouter.sol";
import "https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/interfaces/IQuoter.sol";
import {IERC20, SafeERC20} from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4-solc-0.7/contracts/token/ERC20/SafeERC20.sol";
interface IUniswapRouter is ISwapRouter {
@dabit3
dabit3 / ceramic_identity_playground.js
Last active February 26, 2022 17:12
Playing around with Ceramic identity and self.id
import { useState } from 'react'
import Head from 'next/head'
import styles from '../styles/Home.module.css'
import { CeramicClient } from '@ceramicnetwork/http-client'
import { DID } from 'dids'
import { ThreeIdConnect } from '@3id/connect'
const SID = require('@self.id/web')
const { EthereumAuthProvider, SelfID, WebClient } = SID