Skip to content

Instantly share code, notes, and snippets.

@traverse
traverse / network.js
Created December 27, 2021 23:53
Bitburner hostname path finder/printer
/** @param {NS} ns **/
export async function main(ns) {
const { hostname } = ns.flags([
["hostname", ""],
])
const network = new Network(ns, "home")
if (hostname) {
printPath(ns, network, hostname)
@traverse
traverse / machine.js
Created February 25, 2021 10:31
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@traverse
traverse / machine.js
Created October 2, 2020 11:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@traverse
traverse / machine.js
Last active October 1, 2020 14:31
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@traverse
traverse / machine.js
Created July 30, 2020 12:07
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@traverse
traverse / machine.js
Last active April 1, 2020 08:05
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const getQueryParamsFromString = (paramString: string) => (
paramString ? paramString.split('&').map(splitToPair('=')) : null
);
const splitToPair = (separator: string) => (paramString: string) => {
const [key, value = null] = paramString.split(separator);
return {key, value};
}
@traverse
traverse / meta_pattern.md
Created May 7, 2018 06:58 — forked from minheq/meta_pattern.md
Using Meta Pattern to reduce redux boilerplate

Meta Pattern

When developing with Redux, often times we spend time on a lot of boilerplate code, and some common logic tend to become repeated. We can use Meta pattern to avoid code repetition while still taking advantage of Redux features. It is a simple concept and works like this:

In actions we define the actual type in meta property with name and type fields instead of type property. So a action looks like so:

{
  meta: {
    // Use logic/flow of this action
 type: STATIC_TYPE_NAME
@traverse
traverse / quicksort.erl
Created October 12, 2016 09:51
Quicksort implemented in Erlang
quicksort([]) -> [];
quicksort([P|R]) ->
{S,L} = partition(P,R,[],[]),
quicksort(S) ++ [P] ++ quicksort(L).
partition(_,[],S,L) -> {S,L};
partition(P,[H|T],S,L) ->
if H =< P -> partition(P,T,[H|S],L);
H > P -> partition(P,T,S,[H|L])
end.
@traverse
traverse / stringsTest.js
Last active October 12, 2016 09:51
Learning unit testing with Mocha
var strings = require("./strings");
var assert = require("assert");
describe("strings module", function() {
it("should dash separate camelCase string with one capital", function() {
var camel = "sampleString";
var expected = "sample-string";
var dashed = strings.dashSeparated(camel);