Install dependencies:
npm install -g @microsoft/rush
Initialize the project:
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()); |
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); | |
} |
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) | |
} |
```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 |
// 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) |
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": { |
``` | |
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 "*" \ |
export default { | |
build: { | |
extend(config, { isDev }) { | |
if (isDev) config.resolve.symlinks = false | |
}, | |
}, | |
} |
--- | |
language: node_js | |
node_js: | |
- 9 | |
- 10 | |
script: | |
# use latest npm to work on node9 | |
- npm install -g npm | |
# codecov | |
- npm install -g codecov |