Skip to content

Instantly share code, notes, and snippets.

View kyrathasoft's full-sized avatar

William.Miller kyrathasoft

View GitHub Profile
@kyrathasoft
kyrathasoft / vartypesizes.c
Created August 16, 2023 01:12
C program to show size (in bytes) taken up by variables or types
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <float.h>
int main(int argc, char** argv) {
/* Shows size of variables and types */
printf("CHAR_BIT : %d\n", CHAR_BIT);
printf("CHAR_MAX : %d\n", CHAR_MAX);
printf("CHAR_MIN : %d\n", CHAR_MIN);
#include <stdio.h>
int main(void)
{
printf("");
printf("");
printf("Hello World!\n");
printf("press a key to end program...");
getchar();
@kyrathasoft
kyrathasoft / getexec.cs
Created August 28, 2022 18:10
get executing assembly directory
public static string GetExecutingDirectoryName()
{
var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
return new FileInfo(location.AbsolutePath).Directory.FullName;
}
@kyrathasoft
kyrathasoft / fileCount.cs
Created August 19, 2022 18:06
Get count of number of files in a directory
using System;
using System.IO;
using System.Collections.Generic;
namespace ConsoleApplication {
class Program
{
static void Main(string[] args)
@kyrathasoft
kyrathasoft / basepath.cs
Created August 19, 2022 17:59
Get the base path of execution
using System;
using System.IO;
using System.Collections.Generic;
namespace ConsoleApplication {
class Program
{
static void Main(string[] args)
{
@kyrathasoft
kyrathasoft / fullPath.cs
Created August 19, 2022 17:47
get full path of executing assembly using C#
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... ");
@kyrathasoft
kyrathasoft / pubconst.cs
Created August 14, 2022 13:46
declaring public constants
using System;
namespace EarthApotheosis {
public class EarthApotheosisConstants
{
public static string TITLE = Properties.Resources.Title;
public const int KILLS_TO_EARN_ONE_COMBAT_ADV_POINT = 50;
public const int MAX_CHARS_PER_LINE_IN_LABEL_DISPLAY = 80;
public const string INPUT_CURRENTLY_DISABLED = "Input currently disabled...";
@kyrathasoft
kyrathasoft / gist:e1458d0650c494eb448b5aa703f5d752
Created August 14, 2022 01:52
VbScript to archive directory or extract an archive
Function QuickZip(path)
'@description: Compress and uncompress zip files.
'@author: Jeremy England (SimplyCoded)
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
Dim oSap : Set oSap = CreateObject("Shell.Application")
Dim oWss : Set oWss = CreateObject("WScript.Shell")
Dim isZip, count, root, base, add, out
Dim isZipping, isCancelable
Const NOT_FOUND = 1
Const NOT_A_ZIP = 2
@kyrathasoft
kyrathasoft / naudio.cs
Created August 8, 2022 01:23
Use NAudio to play .wav or .mp3 files
using System;
using NAudio;
using NAudio.Wave;
namespace PlayMp3{
class Program {
static void Main(string[] args)
{
@kyrathasoft
kyrathasoft / lnchCap.cs
Last active August 12, 2022 18:04
Launch process and capture output
/*
===== Capturing Output From A Console Process =====
This example program relies upon hello_world.exe being in the same directory as this source code's
compiled output, which is directory C:\Users\kyrat\Dropbox\csdev\examples\ as of 12 Aug 2022
*/
using System;
using System.Diagnostics;