Skip to content

Instantly share code, notes, and snippets.

View FrankC01's full-sized avatar

Frank V. Castellucci FrankC01

View GitHub Profile
@FrankC01
FrankC01 / fix_alias.py
Created February 1, 2024 11:21
Generate missing aliases in out of sync Sui aliases and keystore
#
# -*- coding: utf-8 -*-
"""Script to generate missing aliases in Sui Config."""
import os
import base64
import json
from pathlib import Path
import yaml
from pysui import SuiConfig
@FrankC01
FrankC01 / gensuicfg.py
Created November 12, 2022 11:43
Generate a SUI client configuration with keypair
# Copyright 2022 Frank V. Castellucci
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
@FrankC01
FrankC01 / main.rs
Created October 20, 2021 10:38
Emulating Vector of Structures into Solana Account `data`
// Used to map pointers into data array
use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
use borsh::{BorshDeserialize, BorshSerialize};
use std::iter::repeat;
const INITIALIZED_BYTES: usize = 1;
const VECTOR_CHUNK_LENGTH: usize = 4;
const VECTOR_CHUNK_BYTES: usize = 5116;
const DATA_ACCOUNT_STATE_SPACE: usize =
INITIALIZED_BYTES + VECTOR_CHUNK_LENGTH + VECTOR_CHUNK_BYTES;
@FrankC01
FrankC01 / main.rs
Last active January 24, 2024 18:39
Faux example of serializing BTreeMap to Solana State
use std::{collections::BTreeMap, iter::repeat};
use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
use borsh::{BorshDeserialize, BorshSerialize};
const INITIALIZED_BYTES: usize = 1;
const TRACKING_CHUNK_LENGTH: usize = 4;
const TRACKING_CHUNK_BYTES: usize = 5116;
const TRACKING_ACCOUNT_STATE_SPACE: usize =
INITIALIZED_BYTES + TRACKING_CHUNK_LENGTH + TRACKING_CHUNK_BYTES;
@FrankC01
FrankC01 / argparse.lisp
Last active June 6, 2020 08:27
ChrysaLisp Argument Processor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; argparse - ChrysaLisp Argument Processor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defq +nl+ (ascii-char 10))
(defq +indent2+ 2)
(defq +indent4+ 4)
; Potential utility macros to embed in ChrysaLisp
import asyncio
import logging
import errors
from zmq.asyncio import ZMQEventLoop
from messaging import (
Connection, DisconnectError, SendBackoffTimeoutError)
from sawtooth_sdk.protobuf import client_state_pb2
from sawtooth_sdk.protobuf.validator_pb2 import Message
from google.protobuf.json_format import MessageToDict
from google.protobuf.message import DecodeError
@FrankC01
FrankC01 / partial.c
Created September 10, 2017 13:43
Simple example of lambda calculus 'partial' application in C
//partial.c
/*
Author: Frank V. Castellucci
Simple example to demonstrate 'partial' application (lambda calculus)
of function.
Brief Intro:
I've created a compiled function language 'CFL' which supports curry/partial
application of functions, lambdas and closures. CFL:
Is typeless, everything is an OBJ* (see below for simplified)