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
# max_tasks returns the maximum number of tasks the system can take | |
# tasks: an array of unordered task weights | |
# limit: the maximum load of tasks | |
# the "context switching" difference between the tasks must be considered | |
# i.e.: current is 24, next is 23, so the context switching is 1 | |
def max_tasks(tasks, limit) | |
sorted_tasks = tasks.sort | |
last = sorted_tasks.first | |
acc = limit |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
hostname h1 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 1000 | |
bgp router-id 172.31.1.100 | |
network 172.10.0.0/16 | |
neighbor 172.36.1.2 remote-as 6000 | |
neighbor 172.37.1.2 remote-as 7000 | |
neighbor 172.31.1.1 remote-as 1 |
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
module Math | |
# Erlang-B loss formula returns the probability of call losses for a group of | |
# identical resources. It uses an auxiliary function 'bloq'. Parameters: | |
# ndv = number of trunks in full availability group | |
# gos = grade of service | |
def self.erlangb(ndv, gos) | |
ndv_aux = ndv | |
incr = ndv / 2.0 | |
while incr > 0.0000001 | |
if bloq(ndv, ndv_aux) > gos |
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
class String | |
def to_bool | |
return true if self == true || self =~ (/^(true|t|yes|y|1)$/i) | |
return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i) | |
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") | |
end | |
end | |
class Fixnum | |
def to_bool |
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
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
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
# Distance units (miles) | |
AU = 93_000_000.0 | |
LIGHTYEAR = 63241 * AU | |
PARSEC = 3.26 * LIGHTYEAR | |
# Speed units (miles per second) | |
LIGHTSPEED = 186_000 | |
# Time units (seconds) | |
MINUTE = 60 |