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
// ported from: http://stackoverflow.com/questions/2140787/select-random-k-elements-from-a-list-whose-elements-have-weights | |
// each node in the heap has a value, weight, and totalWeight | |
// the totalWeight is the weight of the node plus any children | |
var Node = {}; | |
var newNode = function (value, weight, totalWeight) { | |
var node = Object.create(Node); | |
node.value = value; | |
node.weight = weight; | |
node.totalWeight = totalWeight; |
If you're trying to do this, you came to the right place!
Watch this code work in real time: https://twitter.com/CodingDoug/status/940022568089554944
See also this gist for copying in the other direction: https://gist.github.com/CodingDoug/44ad12f4836e79ca9fa11ba5af6955f7
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
files: | |
"/opt/elasticbeanstalk/support/conf/sidekiq.conf": | |
mode: "000755" | |
content: | | |
description "Elastic Beanstalk Sidekiq Upstart Manager" | |
start on runlevel [2345] | |
stop on runlevel [06] | |
# explained above | |
respawn |