Skip to content

Instantly share code, notes, and snippets.

View steven-r's full-sized avatar
🏠
Working from home

Stephen Reindl steven-r

🏠
Working from home
View GitHub Profile
@steven-r
steven-r / restarter.js
Created May 23, 2022 17:13
Simple restarter script which runs all found scripts on all hosts. Does not run scripts twice
/** @param {NS} ns */
export async function main(ns) {
ns.disableLog("scan"); // ignore scan log messages
const servers = scanAllServers(ns);
for (const hostname of servers) {
rerunScriptsOnHost(ns, hostname);
}
}
/** Helper to get a list of all hostnames on the network
@steven-r
steven-r / replace-chars.rb
Created November 3, 2020 17:54
asciidoctor extension to replace patterns to enable german quotes
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
MAP_CHARS = {
'@,,' => '„',
'@,' => '‚',
'@´´' => '“',
'@´' => '‘',
};
class ReplaceSubsProcessor < Asciidoctor::Extensions::Postprocessor
FindReplacementTokensRx = /@(,,?|´´?)/
@steven-r
steven-r / gist:2c5897e907f38efbff9d
Created July 13, 2015 10:19
Handling messages to be displayed between pages with no direct interaction
public static class SessionMessage
{
private const string SessionKey = "TL:MSGLIST";
/// <summary>
/// The type of message to be displayed
/// </summary>
public enum MessageType
{
/// <summary>
@steven-r
steven-r / gist:90b088b99a753ea51ce9
Last active March 10, 2023 02:32
Example on how to cache values for API calls
#region copyright
// /* Copyright (C) think2infinity LLC - All Rights Reserved
// *
// * TimeJack
// *
// * Written by Stephen Reindl <stephen@think2infinity.com>, 09 2013
// *
// */
#endregion
@steven-r
steven-r / gist:eba9fda6d6e4b2c9e0ac
Created March 5, 2015 08:39
ArgumentNull exception for args with String.Format()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using RazorEngine;
namespace ConsoleApplication1
{