This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
build: { | |
extend(config, { isDev }) { | |
if (isDev) config.resolve.symlinks = false | |
}, | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
docker run -d \ | |
--name geth-test \ | |
-p 8545:8545 \ | |
-v ~/.docker/machine/volumes/geth-test/data:/root/.ethereum \ | |
ethereum/client-go \ | |
--testnet \ | |
--rpc \ | |
--rpcaddr "0.0.0.0" \ | |
--rpccorsdomain "*" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Cert } = require('@0xcert/cert'); | |
const { HttpProvider } = require('@0xcert/ethereum-http-provider'); | |
const { AssetLedger } = require('@0xcert/ethereum-asset-ledger'); | |
(async () => { | |
const schema = { | |
"$schema": "http://json-schema.org/draft-07/schema", | |
"description": "A digital assets that have a unique combination of different properties.", | |
"properties": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parameter that each resolver accepts. | |
pub struct Intent {} | |
// Resolver definition. | |
pub trait Resolver { | |
fn resolve(&self, intent: Intent) -> Result<usize, usize>; | |
} | |
impl<F: Fn(Intent) -> Result<usize, usize>> Resolver for F { | |
fn resolve(&self, intent: Intent) -> Result<usize, usize> { | |
self(intent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```rs | |
// Based on: https://www.reddit.com/r/rust/comments/ehr8ct/announcing_impls_a_macro_to_determine_if_a_type/ | |
// trait for T | |
trait TTrate { | |
const VALUE: bool = false; | |
} | |
impl<T> TTrate for T {} | |
// custom trait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ops; | |
#[derive(Debug, Default, Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)] | |
pub struct U32(u32); | |
impl ops::Add for U32 { | |
type Output = Self; | |
fn add(self, rhs: Self) -> Self { | |
Self(self.0 + rhs.0) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
use std::io::Read; | |
fn main() { | |
let mut f = File::open("/dev/urandom").unwrap(); // from Linux | |
let mut buf = [0u8; 16]; | |
f.read_exact(&mut buf).unwrap(); | |
println!("{:?}", buf); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
// vector of data built from 4-bytes chunks | |
let mut buf = vec![]; | |
buf.extend(1u32.to_be_bytes()); | |
buf.extend(10u32.to_be_bytes()); | |
buf.extend(20u32.to_be_bytes()); | |
buf.extend(47u32.to_be_bytes()); // searching for this one | |
buf.extend(59u32.to_be_bytes()); | |
buf.extend(63u32.to_be_bytes()); |
OlderNewer