Skip to content

Instantly share code, notes, and snippets.

View willemolding's full-sized avatar

Willem Olding willemolding

  • Hobart, Tasmania
View GitHub Profile
# Inspired by Moonbeam Dockerfile (which was inspired by the Polkadot Dockerfile)
FROM phusion/baseimage:0.11 as builder
LABEL maintainer "willem@chainsafe.io"
LABEL description="This is the build stage for Polkadot. Here we create the binary."
ARG PROFILE=release
ARG POLKADOT_COMMIT=72243baaedf3ded4226032949a23f8478f5565d9
# need to keep commit has in sync with lockfile for PINT
ARG POLKADOT_REPO=https://github.com/paritytech/polkadot
@willemolding
willemolding / callback-example.rs
Last active July 14, 2020 12:43
Elrond contract callback example
#![no_std]
#![no_main]
#![allow(non_snake_case)]
#![allow(unused_attributes)]
#![allow(unused_variables)]
imports!();
#[elrond_wasm_derive::callable(TransferFromProxy)]
@willemolding
willemolding / elrond-rust-cheat-sheet.md
Last active July 12, 2020 07:48
Elrond Rust dev cheat sheet

Elrond dev cheat sheet

Smart contracts in Rust

All contracts need to begin with the following imports

#![no_std]
#![no_main]
#![allow(unused_attributes)]
@willemolding
willemolding / brands-en.json
Created April 20, 2020 01:53
Translated TUYA brand IDs
[
{"brand_id": "232", "brand_name": "Sanyo"},
{"brand_id":" 12 ","brand_name": "Samsung"},
{"brand_id": "487", "brand_name": "Fujitsu"},
{"brand_id": "7", "brand_name": "Hisense"},
{"brand_id": "22","brand_name": "Toshiba"},
{"brand_id": "137","brand_name": "Electrolux"},
{"brand_id": "32", "brand_name": "LG"},
{"brand_id": "52", "brand_name": "Philips"},
{"brand_id": "57", "brand_name": "Sharp"},
[package]
name = "test-hyper"
version = "0.1.0"
authors = ["willem <willemolding@gmail.com>"]
edition = "2018"
[dependencies]
hyper = "0.12.21"
tokio = "0.1.14"
hyper-staticfile = "0.3.0"
@willemolding
willemolding / Cargo.toml
Last active March 17, 2019 09:33
Valid holochain agent address generator
[package]
name = "agent-address-generator"
version = "0.1.0"
authors = ["willem <willemolding@gmail.com>"]
edition = "2018"
[dependencies]
holochain_core_types = { git = "https://github.com/holochain/holochain-rust", branch="develop" }
@willemolding
willemolding / holochain-mermaid-overrides.js
Last active May 11, 2018 08:16
Overrides the commit, get and message functions in Holochain to print debug messages. These messages are visualisable as mermaidjs sequence diagrams
/*==========================================
= function overrides =
==========================================*/
agentShortname = App.Agent.String.substr(0, App.Agent.String.indexOf('@'));
var oldCommit = commit;
commit = function(entryType, entryData) {
if(entryType.indexOf("private") !== -1) {
debug(agentShortname + '-->>' + agentShortname +': '+ entryType);
@willemolding
willemolding / improvement2.py
Last active March 8, 2018 02:57
lachie script improvements
def grab_prob(time_idx):
# make frame__idx an integer to avoid slicing errors
frame_idx = int(time_idx)
# get 'frame_time'
frame_time = grab_sst_time(frame_idx)
# set month of year
MoY_val = int(frame_time.month)
# get list of temperature and salinity values from subset
@willemolding
willemolding / hide-code-jupyter-notebook.js
Created February 28, 2018 04:39
Add this as a raw cell to add a 'hide code' button to the notebook when exported to html
<script>
function code_toggle() {
if (code_shown){
$('div.input').hide('500');
$('#toggleButton').val('Show Code')
} else {
$('div.input').show('500');
$('#toggleButton').val('Hide Code')
}
code_shown = !code_shown
@willemolding
willemolding / get_first_index.py
Created February 15, 2018 01:46
[Find First Occurences] Finds the index of first occurences along a dimension of a true value. Returns nonevalue if none found #python #numpy
def get_first_index(bool_array, axis, nonevalue=-1):
"""
Returns the first index in each axis that is true. Returns nonevalue if none are found
"""
return np.choose(np.any(bool_array, axis=axis), [nonevalue, np.argmax(bool_array, axis=axis)])