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
/** | |
* @param {NS} ns | |
*/ | |
export async function main(ns) { | |
ns.print("Running hacking script..."); | |
var target; securityTreshold; moneyTreshold | |
// Identify the server to attempt to hack | |
var target = ns.args[0]; |
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
function solvePuzzle (clues) { | |
// The hint says the value | |
// that must *at least* be in the adjacent cell. | |
// 1 -> 4 | |
// 2 -> 3, etc. | |
// Calculate the possible permutations for each score in advance | |
// Rotate around in the order of hints, check if there is only | |
// one permutation that matches the hint and populated values, if | |
// so then populate it. |
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 Player | |
DIRECTIONS = [:left, :forward, :right, :backward] | |
def play_turn(warrior) | |
@warrior = warrior | |
bind_enemies! || | |
attack_enemies! || | |
heal! || |
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
# Related area of style guide: https://github.com/GetJobber/ruby-style-guide#hash-fetch-defaults | |
# Pros: Is succinct and intuitive | |
# Cons: Doesn't work for false values | |
def default_one(options) | |
options[:foo] ||= 'foo' | |
options[:bar] ||= 'bar' | |
end | |
# Pros: Handles false without issue, is succient |
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
# Usage: | |
# $bm = Benchmarking.new | |
# VisitGeneratorWorker.new.perform(work_order.id) | |
# $bm.finish | |
# $bm.results | |
# | |
# Inside what you're benchmarking: | |
# $bm.mark("This is a data point") | |
# |
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
def inject_model_fixtures(filepath) | |
content = File.read(filepath).split("\n") | |
block_start = content.find_index{|l| l =~ /^RSpec.describe/} | |
return false if block_start.nil? | |
content.insert(block_start + 1, " include_context 'model_fixtures'") | |
File.open(filepath, 'wb') { |file| file.write(content.join("\n")) } |
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 Net | |
class HTTP | |
def request_with_monitor(request, body = nil, &block) | |
# Continue with the original request | |
response = request_without_monitor(request, body, &block) | |
begin | |
::NetNanny::HttpNetMonitor.output_request_debug_info(self, request) | |
if ::NetNanny::Registry.instance.registered_address?(self.address) |
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
-- HUMAN RESOURCE MACHINE PROGRAM -- | |
COMMENT 0 | |
a: | |
COPYFROM 24 | |
COPYTO 20 | |
b: | |
INBOX | |
JUMPZ c | |
COPYTO [20] |
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
function hardClick(node) { | |
triggerMouseEvent (node, "mouseover"); | |
triggerMouseEvent (node, "mousedown"); | |
triggerMouseEvent (node, "mouseup"); | |
triggerMouseEvent (node, "click"); | |
} | |
function triggerMouseEvent (node, eventType) { | |
var clickEvent = document.createEvent ('MouseEvents'); | |
clickEvent.initEvent (eventType, true, true); |
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
" Highlight searches | |
set hlsearch | |
" Case sensitivity | |
set ignorecase | |
set smartcase | |
" Automatic Indenting | |
set autoindent |
NewerOlder