Skip to content

Instantly share code, notes, and snippets.

View ssadler's full-sized avatar
🤍

Scott Sadler ssadler

🤍
  • utxocontracts.com
  • London, UK
View GitHub Profile
#0 0x000070c84babb35a in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x000070c84baa90db in std::__throw_bad_alloc() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00000000014634a1 in std::_Hashtable<v8::internal::Tagged<v8::internal::AllocationSite>, std::pair<v8::internal::Tagged<v8::internal::AllocationSite> const, unsigned long>, std::allocator<std::pair<v8::internal::Tagged<v8::internal::AllocationSite> const, unsigned long> >, std::__detail::_Select1st, std::equal_to<v8::internal::Tagged<v8::internal::AllocationSite> >, v8::internal::Object::Hasher, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_rehash_aux(unsigned long, std::integral_constant<bool, true>) [clone .isra.0] ()
#3 0x0000000001463e33 in v8::internal::PretenuringHandler::ProcessPretenuringFeedback(unsigned long) ()
#4 0x00000000013ffa07 in v8::internal::Heap::PerformGarbageCollection(v8::internal::Gar
@ssadler
ssadler / demo.rs
Last active December 9, 2024 20:02
Anchor Refcell
// In this example, there are multiple "entites" made from multiple sets of accounts in the context.
// Would like to be able to pass around (partially) mutable entities, is use case for RefCell.
struct MyEntity<'a, 'b> {
pub &'a mut entity,
pub &'b ata
}
#[derive(Accounts)]
@ssadler
ssadler / shader.glsl
Last active August 16, 2024 20:31
shader.glsl
// FRAGMENT
#include <get_from_texture>
precision highp float;
//uniform float radius;
uniform vec3 color;
uniform float thickness;
uniform vec2 screenSize;
@ssadler
ssadler / outlines.tsx
Created August 16, 2024 17:48
Instanced Mesh
// Works
//
function simpleMesh() {
const mesh = new THREE.Mesh(geometry, material)
let b = beasties[1]
let c = b.getCell()
mesh.position.set(c.x, c.y, 0)
material.uniforms['radius'] = { value: c.r }
material.uniforms['screenSize'] = { value: screenSize }
material.uniforms['thickness'] = { value: 10 }
@ssadler
ssadler / Pack.sol
Created April 3, 2024 13:33
Lossy decimal pack uint96 to uint40
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.16;
library Balance {
uint constant internal BALBITS = 35;
uint constant internal EXPBITS = 5;
uint constant internal BALMAX = 2**35-1;
uint constant internal BALMAXS = 2**34-1;
uint constant internal SIGNED = 2**39;
@ssadler
ssadler / Provenance.sol
Last active August 17, 2023 13:54
Solidity code for cryptographic provenance verification
// See blog post: https://ssadler.substack.com/p/contract-provenance-verification-175
interface IProvenance {
function getProvenanceData() external returns (uint salt, bytes32 codeHash);
}
contract Provenance is IProvenance {
bytes32 immutable _salt;
bytes32 immutable _codeHash;
pragma solidity ^0.8.16;
import '../lib/diamond-3-hardhat/contracts/facets/DiamondCutFacet.sol';
import '../lib/diamond-3-hardhat/contracts/facets/OwnershipFacet.sol';
import '../lib/diamond-3-hardhat/contracts/facets/DiamondLoupeFacet.sol';
import '../lib/diamond-3-hardhat/contracts/libraries/LibDiamond.sol';
import '../lib/diamond-3-hardhat/contracts/interfaces/IERC165.sol';
import '../lib/diamond-3-hardhat/contracts/interfaces/IERC173.sol';
contract QueryDiamond is OwnershipFacet, DiamondCutFacet, DiamondLoupeFacet {
@ssadler
ssadler / maple.hs
Last active January 19, 2021 21:01
Maple data structure concept
-- Maple data structure concept
-- Scott Sadler, 18/01/21
-- Int is an Ethereum 32 bit word
-- Sometimes entities appear denormalized but should all be referenced by ID, either numeric or hash, depending on context
-- Fields like created, modified date not present
-- Nearly all of this was garnered from the "how-can-i-borrow-on-maple" page
--
#!/usr/bin/env python3
import binascii
import gevent
import struct
from gevent import socket
def init_peer(peer, port):
sends = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sends.connect(peer)
@ssadler
ssadler / SaplingSigHash
Created June 19, 2020 22:40
Verify sapling tx sigs / sighashes
module SaplingSigHash where
import Data.Serialize
import Zeno.Prelude
import Zeno.Data.Hex
import qualified Haskoin as H
import Network.Komodo
import Network.ZCash.Sapling