Skip to content

Instantly share code, notes, and snippets.

View bddap's full-sized avatar

Andrew Dirksen bddap

View GitHub Profile
{
"@context": {
"credentialStatus": {"@id": "https://example.com/whereToBuyIceCream", "@type": "@id"},
"poorlyNamedProperty": {"@id": "https://www.w3.org/2018/credentials#credentialStatus", "@type": "@id"}
}
}
@bddap
bddap / different.json
Created June 5, 2020 16:41
different context
{
"credentialStatus": {"@id": "example.com/whereToBuyIceCream", "@type": "@id"}
}
// bincode is a backend for serde. bincode can serialize and deserialize type that implement
// serde::Serialize and serde::Deserialize
use bincode;
// Bincode serializes into a binary format, but other backends exist to serialize into other
// formats, like json.
// make sure to add the following to your Cargo.toml
//
// [dependencies]
@bddap
bddap / err
Created August 1, 2019 22:48
This is why macros are dangerous
Compiling substrate-warmup-runtime v2.0.0 (/Users/a/d/substrate-warmup/runtime)
error[E0277]: the trait bound `substrate_warmup_runtime::RuntimeApi: substrate_client::runtime_api::ConstructRuntimeApi<sr_primitives::generic::block::Block<sr_primitives::generic::header::Header<u64, sr_primitives::traits::BlakeTwo256>, sr_primitives::generic::unchecked_mortal_compact_extrinsic::UncheckedMortalCompactExtrinsic<srml_indices::address::Address<substrate_primitives::sr25519::Public, u32>, u64, substrate_warmup_runtime::Call, substrate_primitives::sr25519::Signature>>, substrate_client::client::Client<substrate_client::light::backend::Backend<substrate_client_db::light::LightStorage<sr_primitives::generic::block::Block<sr_primitives::generic::header::Header<u64, sr_primitives::traits::BlakeTwo256>, sr_primitives::generic::unchecked_mortal_compact_extrinsic::UncheckedMortalCompactExtrinsic<srml_indices::address::Address<substrate_primitives::sr25519::Public, u32>, u64, substrate_warmup_runtime::Call, substrate_prim
# This file encodes the formatting decisions expressed in https://wiki.parity.io/Substrate-Style-Guide
## Indent using tabs.
hard_tabs = true
## Lines should be longer than 100 characters long only in exceptional circumstances and certainly
## no longer than 120.
# max_width = 100 # default setting
## For this purpose, tabs are considered 4 characters wide.
@bddap
bddap / substrate-weakoints.md
Last active July 31, 2019 21:15
WIP Substrate code review

The following is a list of opportunities for improvement in substrate. If you personally contribute to substrate, this may be difficult to read and difficilt to accept. It's constructive critisism. You'll be tempted to ignore it, but please to consider the points, it's for the good of substrate and substrate users.

1 - don't name your traits Trait, it's a common convention in SMRL

Actual line from generated docs:

// Request -> Bids -> BidChoosen -> ProductionStarted -> ProductionComplete
// \<-----/
struct Request {
purchaser: EntityId,
id: JobId,
quantity: u64,
reserve_price_per_unit: u64,
}
<script>
fetch("http://localhost:8000", {
mode: "no-cors",
}).then(() => {
console.log("done");
let t = document.createElement('div');
t.innerHTML = "done";
document.body.appendChild(t);
})
@bddap
bddap / fullscreen-slides.html
Created July 15, 2018 20:24
slideshow with fullscreen support
<script>
let currentSlide = 0;
function display(slide) {
const sections = document.getElementsByTagName('section');
currentSlide = Math.min(Math.max(slide, 0), sections.length - 1);
Array.from(sections).forEach((section, index) => {
section.style.display = index === currentSlide ? null : 'none';
})
}
document.addEventListener('keydown', event => {
@bddap
bddap / simple-slides.js
Created July 14, 2018 01:56
link to this script and each your <section> tag becomes a separate slide.
let currentSlide = 0;
function display(slide) {
const sections = document.getElementsByTagName('section');
currentSlide = Math.min(Math.max(slide, 0), sections.length - 1);
Array.from(sections).forEach((section, index) => {
section.style.display = index === currentSlide ? null : 'none';
})
}
document.addEventListener('keydown', event => {
if(event.key === 'ArrowRight' || event.key == ' ') display(currentSlide + 1);