Coding

All things computer programming related...

ZipFolder

- Posted in Coding by

using ZipFolder from the Windows command-line

ZipFolder is a nifty little Windows command-line utility that is passed two arguments: (1) the folder that is to be compressed into a .zip archive, and (2) the name of the resulting archive (with .zip extension)

Note: this utility requires that you have installed the .NET Framework 3.5 but Windows should prompt you to install it, if it is missing.

The usefulness of this CLI utility lies in the fact that we can leverage it from programming code. Aside from that scenario, most Windows users won't find much reason to use it.

↓ZipFolder

Code Obfuscators

- Posted in Coding by

Although it's probably the case that the hobbyist developer needn't worry too much about his .NET CIL code being decompiled, there are some free assembly obfuscators that seem to work: OrangeHeap (~ 1.35 Mb download) and Confuser (~2.2 Mb download; available here). I prefer the latter.

Tools like these have a way of becoming vaporware. Nevertheless, at the time I write this, you can find OrangeHeap here on the internet, and Confuser here.

Roll dice

- Posted in Coding by

Sometimes you just want to use a simple online dice roller; at other times, you want to roll one yourself using your favorite programming language.

It can be useful to generate random numbers using C#. Here is a zipped Visual Studio Community 2022 project demonstrating rolling d6 dice. And below, I've inlined the Github gist of the class I'm using.

Website encapsulation into an executable

- Posted in Coding by

There are a couple of different ways (that I know about) to encapsulate a website (or just a subdirectory?) into an executable. There is Web2Executable and Nativefier via nodejs.

I'm basically only noting these here on the chance that someday I may do actual work with Squiffy or Twine.

I've cached a copy of Web2Executable on my Box.com account and here on my pcloud account.

Diet tracker program

- Posted in Coding by

I've been pretty pleased with recent progress I've made on diet.exe, a console program I'm developing to help make tracking my diet easier. As of today's date, the software can synchronize diet files between Dropbox and Zim. As an added benefit, when it does this, it also synchronizes blood pressure readings between those two directories. Sweet!

I've downloaded a couple of solo gaming systems I want to read and perhaps take on a test-drive: World of Dungeons is one, Notequest the other. I have a feeling that my myth-weavers game may be in it's death throes. One player bowed out, albeit gracefully. I must admit, my own interest has begun to flag. We're at a natural point for an ending, as the party has saved Slaytonthorpe from a group of bandits who appear to be working for a much more sinister (and currently unknown) force.


I've read through the pdf for Notequest and I'm intrigued. I may look into getting the Expanded World pdf. I'm going to continue reading The Solo Adventurer's Toolkit by Paul Bimler. I may wind up using it with Black Streams, which would allow me to use the wealth of OSR and 5e adventure modules I have.

Programmatically open a command prompt or Explorer window

- Posted in Coding by

To open a command prompt:

start cmd.exe /k cd C:\Users\kyrat\Dropboxcs_dev

To instead open an Explorer window there:

START C:\Users\kyrat\Dropboxcs_dev

Compressing to and decompressing from zip archive

- Posted in Coding by

This is non-trivial, but at some point in the past I looked into compressing and decompressing programmatically using C#:

I've hosted the source code on GitHub demonstrating using .NET to compress a folder and its contents into a single .zip archive. It also demonstrates decompressing such an archive into its component directory, subdirectories, and files.

And here are a couple libraries you'll need to use: /r:System.IO.Compression.dll /r:System.IO.Compression.FileSystem.dll

Zip from the Windows command line

- Posted in Coding by

If a valid subdirectory is passed in as an argument on the command-line, will zip it to .zip file that is located in same directory as executing code:

download sourcecode

Get full path of executing assembly

- Posted in Coding by

C# code to get the full path of the executing assembly:

<script src="https://gist.github.com/kyrathasoft/825c2c277bdaed4d300880415f72ab5b.js"></script>

then there's also this:

<script src="https://gist.github.com/kyrathasoft/4f4f1d6639c6faff0b2e4c77e60ede87.js"></script>

using System;
using System.Reflection; //required for Assembly namespace
using System.IO; //required for Path namespace

namespace HelloWorld {
class Hello {

    static void Main(string[] args){
        Console.WriteLine("n Now executing: {0}", ExecutingAssemblyPath());
        Console.Write("n Press any key to exit... ");
        Console.ReadKey();
        Console.WriteLine();
    }

    public static string ExecutingAssemblyPath(){
    string path = AppDomain.CurrentDomain.BaseDirectory;
    string fname = Assembly.GetEntryAssembly().GetName().Name;
    path += fname;
    if(File.Exists(fname + ".exe")){ path += ".exe"; } else {path += ".dll"; }
        return path;
    }    

  }
}

I'm very interested in Twine

- Posted in Coding by

I've been interested in Twine 2.0 since it emerged onto the IF scene in 2009. But I only recently (August 2019) revisited it and began to experiment with it in earnest. As I nail down concepts, achieve insights, and come up with snippets of script that work, I'm collecting them here.

Some credit goes to Chapel and the code and examples he's made available on the Twine lab under this license.

I keep a copy of the Windows version 2.3.3 of Twine here. It's an 84.8 Mb download.

If you want a zero-install Twine engine, with some additional story formats and an extractible Web-to-Exe that can turn your Twine stories into stand-alone applications, get this. It's an 85.8 Mb download. You can put it wherever you want on your hard drive (excepting the Program Files directory) and pin a shortcut to the Twine executable to your Start Menu or Desktop.

If you experiment with Twine and decide you want to spend some extended time using it, you may want to peruse Chapel's custom macros. You can put together a custom download of the macros you like here.

Page 6 of 10