Skip to content

Instantly share code, notes, and snippets.

async function signMessage(message) {
await web3.personal.sign(args...);
}
async function signPayment(contractAddress, amount) {
var message = constructPaymentMessage(contractAddress, amount);
var signed = await signMessage(message);
}
signPayment(args...)
@Kaisle
Kaisle / knapsack.js
Created June 12, 2018 22:44 — forked from danwoods/knapsack.js
Knapsack algorithm in JavaScript
//Knapsack algorithm
//==================
// wikipedia: [Knapsack (0/1)](http://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_Knapsack_Problem)
// Given a set `[{weight:Number, benefit:Number}]` and a capacity,
// find the maximum value possible while keeping the weight below
// or equal to the capacity
// **params**:
// `capacity` : Number,
// `items` : [{w:Number, b:Number}]
// **returns**:
alias "smoke" "dota_shop_force_hotkeys 1;toggleshoppanel;shop_nav_to_tab 0;shop_select_itemrow 5;toggleshoppanel;dota_shop_force_hotkeys 0"
bind F3 "smoke"
alias "obs" "dota_shop_force_hotkeys 1;toggleshoppanel;shop_nav_to_tab 0;shop_select_itemrow 10;toggleshoppanel;dota_shop_force_hotkeys 0"
bind F1 "obs"
alias "sents" "dota_shop_force_hotkeys 1;toggleshoppanel;shop_nav_to_tab 0;shop_select_itemrow 11;toggleshoppanel;dota_shop_force_hotkeys 0"
bind F2 "sents"
alias "dust" "dota_shop_force_hotkeys 1;toggleshoppanel;shop_nav_to_tab 0;shop_select_itemrow 7;toggleshoppanel;dota_shop_force_hotkeys 0"