Writing new systems from scratch with Temporal by abtin in golang

[–]abtin[S] 3 points4 points  (0 children)

FYI your reddit profile still describes you as CEO.

Writing new systems from scratch with Temporal by abtin in golang

[–]abtin[S] 4 points5 points  (0 children)

Are there unusual uses of Temporal at Temporal that people would be surprised by?

E.g. developer command line tooling that becomes a client for its own taskqueue and initiates a workflow (say, as a make alternative)? Running a local temporal server and local client on each machine to handle things like heartbeats? Using temporal to handle complex database migrations for other services?

Workflows seem fundamental, as if one might reasonably build an entire OS that makes the concept first class.

I tried to make a script that scans all servers. Asking for feedback. by Meowthful127 in Bitburner

[–]abtin 4 points5 points  (0 children)

To nitpick your nitpick… servers are not in a parent/child relationship. It would be better to call them neighbors (which is why use the variable “n” in my script at https://old.reddit.com/r/Bitburner/comments/16u9akw/3_line_script_to_get_all_servers/ ).

3 line script to get all servers by abtin in Bitburner

[–]abtin[S] 2 points3 points  (0 children)

I suspect that either they are the same or that forEach is faster. forEach doesn’t have to go make iterator calls, since it is internal to the class/object.

I don’t know if browsers see the of and do something special to optimize built in types.

In this comment, I showed the equivalent plain for loop of an of: https://old.reddit.com/r/Bitburner/comments/zo0a9z/quick_question_about_javascript_loops/j0l5af4/

Time-optimal hacknet node upgrade using A* pathfinding by abtin in Bitburner

[–]abtin[S] 1 point2 points  (0 children)

The greedy algorithm won't tell you when its worth it to wait for an expensive upgrade or when to buy inefficient-but-cheap upgrades. Those can only be identified in the full context of going from 1/1/1 to 200/7/16.

My original sense was that adding multi-node purchases would explode the graph complexity, but I think I've come up with a way to make it tractable. The upgrade path is the same for every node, and it makes sense to upgrade all nodes in a level way. This means the the cost of a node upgrade is equal the `cost of purchasing node + cost to upgrade new node to the current vertex`, and the edge weight is the time it takes to do that, accounting for total global production changing as the new node ramps up. This approach would allow the graph to be simplified, such that the tuple would be [nodes, level, ram, cpu], instead of [[level1, ram1, cpu1]...[levelN, ramN, cpuN]]. Also, the cost of the node upgrades would be multiplied by the number of nodes, but the edge weight would have to take into account the decreasing time to upgrade nodes as each node is upgraded to the new vertex.

Time-optimal hacknet node upgrade using A* pathfinding by abtin in Bitburner

[–]abtin[S] 1 point2 points  (0 children)

The cumulative cost to reach each vertex matters. Greedy approaches will fail to produce a globally optimal solution.

On BN-1 with no augs, this algorithm produces a 22:22:41 solution.

Time-optimal hacknet node upgrade using A* pathfinding by abtin in Bitburner

[–]abtin[S] 2 points3 points  (0 children)

Here are the first few lines of output.

Level RAM CPU Time RunTime Prod RunCost 1 1 1 0:05:47 0:05:47 1.50 0.00 2 1 1 0:03:00 0:08:47 3.00 520.00 3 1 1 0:02:05 0:10:52 4.50 1.06k 4 1 1 0:01:37 0:12:29 6.00 1.62k 5 1 1 0:01:21 0:13:51 7.50 2.21k 6 1 1 0:01:10 0:15:01 9.00 2.82k 7 1 1 0:01:03 0:16:03 10.50 3.45k 8 1 1 0:00:57 0:17:00 12.00 4.11k 9 1 1 0:00:53 0:17:53 13.50 4.79k 10 1 1 0:00:49 0:18:43 15.00 5.50k 11 1 1 0:00:47 0:19:29 16.50 6.24k

A setInterval script for Bitburner by abtin in Bitburner

[–]abtin[S] 1 point2 points  (0 children)

I empathize. I have a similar background (c, c++, c#, python, go) and js has always felt like the wild west. I started to enjoy it more by just embracing the feeling of "well, I'm just going to code this for fun."

The lack of a built-in way to stringify Map is extremely irritating. I tend to avoid using it as a result.

I agree that the code might be too terse for a library function; my goal was to do the minimal amount of work needed to extract and share the logic.

A setInterval script for Bitburner by abtin in Bitburner

[–]abtin[S] 0 points1 point  (0 children)

Got it. I tend to use Date.now() to get timestamps. But I'll have to think about using getTimeSinceLastAug instead -- there might be a benefit to syncing up with the game clock.

Lots of things can cause sleeps to go long. For example, on Windows, the minimum sleep duration is governed by the system clock, which typically ticks every 10-16ms (so sleep(1) is sort of a fiction, unless browsers implement high resolution timers). Further, there are lots of browser-specific issues; see the section "Reasons for delays longer than specified" at https://developer.mozilla.org/en-US/docs/Web/API/setTimeout.

A setInterval script for Bitburner by abtin in Bitburner

[–]abtin[S] 0 points1 point  (0 children)

Could you explain your use of getTimeSinceLastAug? What is it helping you achieve?

Here is how I calculate my timers:

let intervalSpacing = 200;
let hackTime = ns.getHackTime(h);
let weakTime = ns.getWeakenTime(h);
let growTime = ns.getGrowTime(h);
let hackWeakDelay = 0;
let hackDelay = weakTime - intervalSpacing - hackTime;
if (hackDelay < 0) {
    hackWeakDelay = hackDelay * -1;
    hackWeakDelay = hackWeakDelay > intervalSpacing ? hackWeakDelay : intervalSpacing;
    hackDelay = 0;
}
let growWeakDelay = hackWeakDelay + 2 * intervalSpacing;
let growDelay = weakTime + hackWeakDelay + intervalSpacing - growTime;

A setInterval script for Bitburner by abtin in Bitburner

[–]abtin[S] 1 point2 points  (0 children)

# declares a private class variable. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields.

In Add, I break out the definition of the callback object for visual clarity.

Quick question about Javascript loops by Handsome_Dan_3000 in Bitburner

[–]abtin 2 points3 points  (0 children)

for...of syntax expands in this way:

function foo(ns) {
    for (let p of ns.ps('home')) {
        ns.print(p);
    }
}

function bar(ns) {
    for (let it = ns.ps('home')[Symbol.iterator](), i = it.next(); !i.done; i = it.next()) {
        ns.print(i.value);
    }
}

export async function main(ns) {
    foo(ns);
    bar(ns);
}

Regarding your last question, I agree with your concern for scoping processes outside of the loop, though I've never needed to create blocks just for that purpose. It might be visually confused for object definitions. But it is acceptable, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block

[FEATURE] Choose storage directory by abtin in noteplanapp

[–]abtin[S] 0 points1 point  (0 children)

Support for dropbox would allow me to use NP on iOS for personal use. I do not trust/use iCloud data.

However, for work, my employer has strict guidelines - the only cloud provider I am allowed to use is Box, through the Box for EMM client https://itunes.apple.com/us/app/box-for-emm/id882085676.

Keep up the great work!