This file contains hidden or 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
| class Node | |
| attr_accessor :edges, :jobs, :id | |
| def initialize(id, arrivals_per_tick) | |
| @id = id | |
| @jobs = 0.0 | |
| @tick = 0 | |
| @edges = [] | |
| @arrivals_per_tick = arrivals_per_tick | |
| end |
This file contains hidden or 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
| require 'socket' | |
| def internet_checksum(packet) # https://tools.ietf.org/html/rfc1071 | |
| packet += [0].pack('C') if packet.size.odd? # since we read 2 bytes at once, append 0 if odd | |
| sum = packet.unpack("n#{packet.size/2}").sum | |
| sum = (sum & 0xffff) + (sum >> 16) while (sum >> 16 > 0) # fold 32 bits -> 16 | |
| ~sum & 0xffff # 1s complement | |
| end | |
This file contains hidden or 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
| n_shards = 128 | |
| n_simulations = 1_000_000 | |
| processed_booted_for_minimum_two_per_shard = [] | |
| n_simulations.times do |i| # Number of simulations | |
| booted = 0 | |
| booted_by_shard = [0] * n_shards | |
| done = [false] * n_shards | |
| done_count = 0 |
This file contains hidden or 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
| switch_strategy = 0 | |
| no_switch_strategy = 0 | |
| n_simulations = 1_000_000 | |
| n_simulations.times do | |
| winner_door = rand(3) | |
| chosen_door = rand(3) | |
| if winner_door == chosen_door | |
| switch_strategy += 0 |
This file contains hidden or 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
| function isColliding(a: DOMRect, b: DOMRect) { | |
| return !( | |
| ((a.y + a.height) < (b.y)) | |
| || (a.y > (b.y + b.height)) | |
| || ((a.x + a.width) < b.x) | |
| || (a.x > (b.x + b.width)) | |
| ); | |
| } | |
| // Move the footnotes from the bottom to become sidenotes if the viewport is |
This file contains hidden or 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
| #!/bin/bash | |
| # FZF quotes field names so I can't easily get preview to work otherwise | |
| cd "$ZK_PATH" | |
| # --bind="2:preview(echo '\"{q}\",\"{4..}\",2' >> judge.csv && echo Rated 2!)" \ | |
| FZF_DEFAULT_COMMAND="python ~/src/semsearch/search_webhook.py learning" | |
| fzf \ | |
| --bind="0:preview(ruby ~/src/semsearch/write.rb {q} {4..} 0 && echo Rated 0!)" \ | |
| --bind="1:preview(ruby ~/src/semsearch/write.rb {q} {4..} 1 && echo Rated 1!)" \ |
OlderNewer