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

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.

String manipulation in C#

- Posted in Coding by

Here is a method that, if passed a proper noun, such as a person's name or a street address, will return a properly formatted version of that string:

And here is an example of using method ProperlyCapitalizeName in a program:

Encrypt to HTML

- Posted in Coding by

I can't remember who put me onto this nifty javascript utility. It was someone on the donationcoder forum, but it's been a long time ago and cursory search didn't turn up the relevant post.

Anyway, encrypt-to-HTML is a real jewel written by Steve Clay, a Floridian web dev. You supply it plain text, either by typing or pasting into a textbox, or else from loading it from a file, and it produces an encrypted HTML file containing your protected content. When you open the produced HTML file in a browser, you're provided with a password textbox. You must enter the correct password and then your plain text will be decrypted and shown to you.

You can download this utility here. It's a 12.6 Kb download.

This small download is downloadable here on my website.

Lazy day

- Posted in Coding by

I've been lazy today. I finished a sci-fi movie named 'Quanta', did a little website updating, ran some backups, started Season 3 of Colony, and made a payment on my Amazon Store card.

Learned that Hannah's fiance's grandfather fell and broke a hip. Mother has left for the Outer Banks with Sharylon. She plans on getting back on the 6th. We got a $200 bonus at work Friday in the form of a credit card. I spent mine on a Windows 10 Pro PC-on-a-stick. Should be a handy gadget to have. I've also ordered a 10" android tablet for Susan, and an identical one for me. They run the latest Android OS, Pie.

Emma got in from the University of Kentucky last night, and slept late today. Her classes are difficult, but I think she's enjoying college life. She heated up a pizza for lunch, and Susan and I had some. It's in the 90s today through next Thursday. Then, starting next Friday we should have a few cooler days in the 70s.

I wrote a C# console app today that will wind up saving me a few minutes everyday that I had been spending to launch 7zip and manually zip multiple subdirectories of my My Documents for backup via uploading. Note: I commented-out the section that zips my DokuWiki, because I hope to replace it with localhost-hosted blog entries.

Here is the source code:

using System;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace ZipThem{

    class Program {

        static void Main(string[] args){

            ProcessStartInfo startInfo = new ProcessStartInfo();
            Console.Clear();            

            startInfo.FileName = @"C:csdevtoolsZipFolder.exe";
            if(!File.Exists(startInfo.FileName)){
                Console.WriteLine("n Couldn't find ZipFolder.exe in csdevtools... goodbye...");
                Thread.Sleep(1500);
                Environment.Exit(0);
            }

            string startPath = @"C:UserskyratDocumentspublic_html";
            string zipPath = @"C:UserskyratDocumentspublic_html.zip";
            ZipDirectory(startPath, zipPath, startInfo);

            startPath = @"C:UserskyratDocumentsTwine";
            zipPath = @"C:UserskyratDocumentsMyTwineStories.zip";
            ZipDirectory(startPath, zipPath, startInfo);

            startPath = @"C:UserskyratDocumentsMySquiffy";
            zipPath = @"C:UserskyratDocumentsMySquiffy.zip";
            ZipDirectory(startPath, zipPath, startInfo);   

            startPath = @"C:Zwamp";
            zipPath = @"C:UserskyratDocumentswebsite atop zwamp.zip";
            ZipDirectory(startPath, zipPath, startInfo);       

            startPath = @"C:csdev";
            zipPath = @"C:UserskyratDocumentscsdev.zip";
            ZipDirectory(startPath, zipPath, startInfo);            

/*             startPath = @"C:UserskyratDocumentsDokuWik";
            zipPath = @"C:UserskyratDocumentsDokuWik.zip";
            ZipDirectory(startPath, zipPath, startInfo);               */

            Console.WriteLine("nn Press any key to exit...");
            Console.ReadKey();
        }

        static void ZipDirectory(string startPath, string zipPath, ProcessStartInfo startInfo){
            if(Directory.Exists(startPath)){
                try{                                        
                    if(File.Exists(zipPath)){ File.Delete(zipPath); }
                    Console.Write("n Now zipping '{0}' folder...", startPath);
                    Console.WriteLine(" to {0}", zipPath);
                    Thread.Sleep(2000);
                    startInfo.Arguments = startPath + " " + zipPath; 
                    var proc = Process.Start(startInfo);
                    proc.WaitForExit();
                    Console.WriteLine(" Successfully zipped folder {0}", Path.GetFileName(startPath));
                }catch(Exception ex1){
                    Console.WriteLine("n Exception thrown while trying to zip folder 'public_html':n " + ex1.Message);
                }
            }            
        }


    }

}

How to capture output from a process using c-sharp

- Posted in Uncategorized by

C# Capturing output from a process

namespace LaunchAndCaptureOutput{

    class Lacout{
    static void Main(){

        var proc = new Process{
                StartInfo = new ProcessStartInfo{
                    FileName = @"C:csdevlessonslessonette7hello.exe",
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    CreateNoWindow = true
                }
        };

        proc.Start();
        string p = proc.StandardOutput.ReadToEnd();
        proc.WaitForExit();
        Console.WriteLine("Captured output: " + p);
      }
    }

} 

Some of my programming creations

- Posted in Coding by
C# Programming

I've dabbled in C# since this programming language was first introduced. Here I provide links to useful tips and snippets, source code, and related thoughts. And let me assure you, these source code files represent a lot of time and learning on my part.

My C# Projects (you're welcome to use/modify the source code of any of these projects, even for commercial purposes) ↓

Found Money: A GUI for tracking piggy-bank deposits over time → | on box.com | on GDrive

Sudoku: My take on the Sudoku number grid gameon box.com | on GDrive

Proofy: My proofreading jobs / words-proofed tracker → | on box.com | on GDrive

KyrCrypt: My files and folders encrypter → | on box.com | on GDrive

<

p class="tab40">KyrHangman: a game I wrote for a donationcoder NANY → | on box.com | on GDrive

SLOC: My counter of source code lines → | on box.com | on GDrive

How Long Since?: Calculates elapsed time between any two dates → | on box.com | on GDrive

KyrPrayerMinder: Prayer journal or use as diary; searchable → | on box.com | on GDrive

Basic BlackJack; decent implementation of a card Deck class → | on box.com | on GDrive

Example of Square Proximity Algorithm: demonstrates detection of square proximity/overlap → | on box.com | on GDrive

Twine and Glaive Seeker

- Posted in Coding by

I'd estimate I'm probably halfway through the development of Glaive Seeker, a play-in-your-browser game I'm authoring with Squiffy for the player in my Earth Apotheosis game on r.rpol.net.

I've not been impressed with the robustness with which Squiffy handles variables. Twine seems more robust in that regard. In fairness, though, I just wrote a very brief example source file, and variable incrementing worked as expected. So perhaps I have syntax errors in the game I'm writing. I'm not experienced using Squiffy, after all.

I'm thinking that Twine is a more mature tool, certainly in terms of its age. However, in doing some reading about the new v3.01 Harlowe story format, it seems far more complicated than what I want to fool with or need. At the time of this writing, I'm thinking future games or tutorials might best be fit by the SugarCube2 format for Twine.

Incidentally, the nodes screenshot above was taken from a layout created using Twine. That's right, I'm using Twine to help visualize the flow of my Squiffy story.

I shared the above screenshot with my player on 9/16/2019 (note that this assertion conflicts with the date shown above this post's title; that's because Flatpress uses UTC time) in msg 120 of a private message thread and will be interested in the player's reaction.