Skip to content

Instantly share code, notes, and snippets.

@stella3d
stella3d / solidity_datatypes.md
Created July 11, 2023 18:26
Solidity Datatypes List

value types and reference types don't need to be referred to as such in the UI.

We might want to support a backup UI that allows inputting encoded constructor args in cases where a constructor argument is a struct, as that makes the UI more complicated.

Value Types

  • uint
    • default is uint256, and can be specified in intervals of 8 like uint8, uint16, etc.
    • uint256 matches regex ^\d{0,79}$
@stella3d
stella3d / .zshrc
Last active January 19, 2023 21:00
`cjq` - pretty print JSON requests in your shell
# fetch remote JSON and pretty-print it
cjq() {
curl -H "Content-Type: application/json" $2 $3 $4 $5 $1 | jq
}
{"owner":"SharedImmutable","version":"1","id":"0000000000000000000000000000000000000002","readonly":"true","objType":"Unknown Type","data":{"contents":{"Coin":"// Move bytecode v4\nmodule 2.Coin {\nstruct Coin<phantom Ty0> has store, key {\n\tid: VersionedID,\n\tvalue: u64\n}\nstruct TreasuryCap<phantom Ty0> has store, key {\n\tid: VersionedID,\n\ttotal_supply: u64\n}\n\npublic burn<Ty0>(loc0: Coin<Ty0>, loc1: &mut TreasuryCap<Ty0>) {\nB0:\n\t0: MoveLoc[0](Arg0: Coin<Ty0>)\n\t1: UnpackGeneric[0](Coin<Ty0>)\n\t2: StLoc[3](loc1: u64)\n\t3: StLoc[2](loc0: VersionedID)\n\t4: MoveLoc[2](loc0: VersionedID)\n\t5: Call[14](delete(VersionedID))\n\t6: CopyLoc[1](Arg1: &mut TreasuryCap<Ty0>)\n\t7: ImmBorrowFieldGeneric[0](TreasuryCap.total_supply: u64)\n\t8: ReadRef\n\t9: CopyLoc[3](loc1: u64)\n\t10: Sub\n\t11: MoveLoc[1](Arg1: &mut TreasuryCap<Ty0>)\n\t12: MutBorrowFieldGeneric[0](TreasuryCap.total_supply: u64)\n\t13: WriteRef\n\t14: Ret\n}\npublic create_currency<Ty0: drop>(): TreasuryCap<Ty0> {\nB0:\n\t0: MoveLoc[1](
@stella3d
stella3d / structs.md
Last active February 22, 2022 07:11
C# struct in OSC

Basics

We're only talking about writing the OSC messages here for brevity, just imagine the reverse process for reading.

Assume we already know about the OSC primitive types available. What if we want to transmit messages that involve multiple of these primitives at once?

As long as all fields of the struct map directly to an OSC primitive, then this is trivial, as OSC message have multiple fields.

struct OurOscMessage {

These benchmarks compare the results for delaunator before and after a refactor of the underlying data representation.

All tests were run on a 2018 Razer Blade with an intel i7-8750H cpu, using node.js v10.15.0.

"before" results were tested on current master branch of delaunator.

"after" results were tested on my soa (structure of arrays) branch

Comparison

uniform:

@stella3d
stella3d / FindWindowInstanceExample.cs
Created September 28, 2018 20:25
check if a window resource exists without creating it
using UnityEditor;
using UnityEngine;
public static class FindWindow
{
[MenuItem("Debug/FindWindow")]
public static bool DoesWindowExist()
{
var windowType = typeof(SceneView); // substitute with your own type
var allInstances = Resources.FindObjectsOfTypeAll(windowType);
@stella3d
stella3d / FindWindowInstanceExample.cs
Created September 28, 2018 20:25
check if a window resource exists without creating it
using UnityEditor;
using UnityEngine;
public static class FindWindow
{
[MenuItem("Debug/FindWindow")]
public static bool DoesWindowExist()
{
var windowType = typeof(SceneView); // substitute with your own type
var allInstances = Resources.FindObjectsOfTypeAll(windowType);
@stella3d
stella3d / cleanUnityGithubDiffs.js
Last active July 25, 2018 06:20
Hide *.meta & *.asset files, and load large diffs by default
const filesContainer = document.querySelector('div#files');
filesContainer.querySelectorAll('div.js-details-container').forEach(div => {
let fileHeader = div.querySelector('div.file-header');
let filePath = fileHeader.getAttribute('data-path');
let isMetaFile = filePath.endsWith('.meta');
let isDotAssetFile = filePath.endsWith('.asset');
let shouldHide = isMetaFile || isDotAssetFile;
let loadDiffButton = div.querySelector('button.load-diff-button');
if(loadDiffButton != null && !shouldHide) {
@stella3d
stella3d / itersolve.py
Created July 19, 2018 04:34
helpin' andy
import numpy as np
import random
import matplotlib.pyplot as plt
def dirichletPop(dim):
transMat = np.random.dirichlet(np.ones(dim),size=dim)
return transMat
def n0Pop(dim):
n0 = (1/dim) * np.ones((1,dim))
using UnityEngine;
using UnityEngine.Serialization;
public class NiceDataClass : MonoBehaviour {
[SerializeField]
public string name;
[SerializeField]
public int particleCount;