Skip to content

Instantly share code, notes, and snippets.

@apow2
apow2 / signAndSendTransaction.js
Created April 30, 2021 00:43
Signing and sending a transaction
const Web3 = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider('https://api.avax-test.network/ext/bc/C/rpc'));
let account = web3.eth.accounts.privateKeyToAccount(yourPrivateKey);
let address = account["address"];
let accsign = account["signTransaction"]; // function for signing transactions
chain = {name: "fuji", networkId: 1, chainId: 43113}; //chain information
mycommon = {customChain:chain};
@apow2
apow2 / contractBase.sol
Last active April 30, 2021 00:35
Basic Contract
contract Base{
event Transfer(address from, address to, uint256 tokenId);
mapping (uint256 => address) public IndexToOwner;
mapping (address => uint256) public ownershipTokenCount;
mapping (uint256 => address) public IndexToApproved;
function getMyTokens(address myaddress) view public returns(uint[] memory){
uint num = ownershipTokenCount[myaddress];
uint found = 0;
using DataFrames
using CSV
using Random
using LinearAlgebra
redwine = DataFrames.DataFrame(CSV.File("winequality-red.csv"))
mat = Matrix(redwine)[:, 1:11]
A = mat[:, 1:end-1] #features
y = mat[:, end]; #labels
@apow2
apow2 / sparse.m
Last active January 11, 2021 10:59
x = diag(ones(10000, 1)) % matrix with ones on diagonal and zero elsewhere
z = sparse(x) % compressed adjacency list representation
t = 0:.05:20;
y = exp(t);
i = 0;
for t = 0:.05:20
i = i + 1;
y(i) = exp(t);
end
ddddd
a = rand(500, 500)
b = rand(500, 500)
c = rand(500, 1)
a*b*c % O(N^3) time complexity
a*(b*c) % O(N^2) time complexity
x = [1, 1];
for k = 3:1000000
x(k) = x(k-1) + x(k-2);
end
x = zeros(1000000, 1); x(1:2) = [1, 1]
for k = 3:1000000
x(k) = x(k-1) + x(k-2);
end
parfor i = 1:100
A(i) = eig(rand(500))
end
encounter(a::Person, b::Person) = "hello"
encounter(a::Person, b:: Tourist) = "takes picture"
encounter(a::Person, b::Person, c::Person) = "converses"
dine(a::Tourist) = "picks up fork"