Skip to content

Instantly share code, notes, and snippets.

View gnidan's full-sized avatar

g. nicholas d'andrea gnidan

View GitHub Profile
@gnidan
gnidan / allocation-storage.md
Last active November 18, 2023 02:19
solidity allocation examples

storing things with solidity for fun and confusion

uint64[] with 9 elements

storing [ 10, 11, 12, 13, 14, 15, 16, 17, 18 ]:

   ...
@gnidan
gnidan / deployer-example.js
Last active April 6, 2020 02:50
Diamond / Truffle discussion with @mudgen
const Diamond = artifacts.require("Diamond"); // can this return a special Diamond abstraction?
const MyToken = artifacts.require("MyToken");
// - create a config to enable the EIP-2535 Diamond spec
// - when that config is enabled, check for the Diamond EIP-165 functions (so we know when we have a Diamond)
// - add special behavior to the @truffle/contract abstraction when EIP-2535 is detected
module.exports = async (deployer) => {
await deployer.deploy(Diamond);
const diamond = await Diamond.deployed();
@gnidan
gnidan / number-config.ts
Created March 11, 2020 00:23
configurable number formats
// dummy definitions
type BN = { "big-number": number };
type Big = { "big": number; "dot": number };
/*
* high-level: define a type that maps configurable things to allowable option types
*/
// main type (extended from in generics)
type FormatConfig = {
@gnidan
gnidan / testing-framework.plantuml
Last active January 3, 2020 19:03
Eth2 / Truffle Sketching
@startuml
actor User
participant TestingFramework
User -> TestingFramework : begin test
activate TestingFramework
create control EE
TestingFramework -> EE : load EE
Compiling ./contracts/Example.sol...
Compiling ./contracts/Migrations.sol...
Writing artifacts to ./build/contracts
Migrations dry-run (simulation)
===============================
> Network name: 'ropsten-fork'
> Network id: 1337
(snark) gnidan: ~ $ ssh tempest.local
___ | _ _ |"|
` _ , ' /_\ `* |.===. o' \,=./ `o _|_|_
- (o)o) - (o o) {}o o{} (o o) (o o)
+-----ooO'(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-----+
| |
| |
| . . |
| _|_ _|_ |
@gnidan
gnidan / suricata
Last active June 12, 2016 08:56
froderick the meerkat
(o) (o)
o'_
| |
\ /
|' `|
m m `_______
@gnidan
gnidan / stepper.pde
Created December 15, 2013 00:21
stepper motor code with switch controlled direction
#include <Stepper.h>
// change this to the number of steps on your motor
#define STEPS 64
#define SWITCH_PIN A0
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 10, 9, 11);
@gnidan
gnidan / quine.coffee
Created September 20, 2013 03:54
coffeescript quine
escape = (str) ->
return '' if str is ''
first = str[0]
rest = str[1..-1]
first = if first is "'" or first is "\\"
"\\#{first}"
else
first
return first + escape(rest)
str = [
#!/bin/bash
echoerr() { echo "$@" 1>&2; }
upper() { echo "$@" | tr [a-z] [A-Z]; }
if [ $# -lt 5 ]; then
echoerr "Exports data from mysql database in tables matching a like pattern e.g. 'table_%'"
echoerr "Usage: $0 host dbname dbuser dbpass pattern"
exit 1