blog.darkstar.work - a simple url encoder/decoder

 a simple url encoder/decoder
 http://blog.darkstar.work

Labels

Wirtschaft (148) Österreich (119) Pressefreiheit (118) IT (91) code (56) Staatsschulden (37) EZB (27) Pensionssystem (15)
Posts mit dem Label code werden angezeigt. Alle Posts anzeigen
Posts mit dem Label code werden angezeigt. Alle Posts anzeigen

2024-03-07

html uft-8 symbol generation shell script

I wrote tonight a short uft-8 html escapes generating shell script.
#!/bin/sh
# generates uft-8 symbol html reference

outtext=utf8_pre_sym2000.html

modHex=256
modFF=255
modZero=0
shx=1024

printf "<html>\n<head><title>utf-8 symbol></title></head>\n<body>\n\t<h1>UTF-8 Symbols</h1>\n\t<div><span>\n" > $outtext

while [ $shx -lt 16384 ] ; do

        modZero=$(echo "$shx % $modHex" | bc)
        if [ $modZero -eq 0 ] ; then
                printf "\n<h2>hex x%x ~ dec %d</h2>\n" $shx $shx >> $outtext
                printf "\n<pre>symbol\thex x%x \tdecimal %d \t.\n" $shx $shx >> $outtext
        fi

        printf "&#x%x;\t&#x%x;\t&#%d;\t.\n" $shx $shx $shx  >> $outtext

        modFF=$(echo "$shx % $modHex" | bc)
        if [ $modFF -eq 255 ] ; then
                printf "</pre>\n" >> $outtext
        fi

    shx=$(echo "$shx + 1" | bc);
done

printf "\n\t<hr />\n\t</span></div></body></html>\n" >> $outtext


hexsym.sh

2024-02-26

Danger of huge monopolisation and checks and balances to keep up a living strong democracy

(Draft)

Monolopy (Conspiracy theory warning)

In mercantilism owning and potentially using a monopoly was considered as tactical advantage. Think about it, that China soonly has a monopoly on a lot of industrial products, but most of China's hardware exoported have an american, south korean or japanse label. 

When there might be a common closed source smart phone. personal computer or smart phone with only one operating system with market dominance over 90%, then we might run into a trap.

If later then, disassembling, reversing engineering is punished with high penalties and international legal claims, then social credit program can be introduced step by step by backdoor.

If your social credit is negative, then you might not have all functions enabled (on your monopoly phone or monopoly personal computer) (THIS MIGHT BE VERY DANGEROUS)


Attention, Huawei, Chinas biggest smart-phone brand and ready to soonly be main player also in african markets, is still android and open based on open source linux and I don't claim, that China will use such practices. But there is no guarantee, that US or Chinese companies would develop or exrend their powers to collect more data or control more individuals in entire world by monitoring them permanently. 
In open system, you can choose a other os to install on every hardware. I remember, that Sony Playstation implemented an other OS bootloader, where you could run linux on it. The community demanded it. Today no one tries to recommand LineageOS compatbility on Smart-Phone hardware.

Balances & checks for free democracies


Freedom of media index

Multiple independant print & internet media or different media blocks. +1

Fact-Checking in more serious media. +0,5

Double Fact checking, interviewing all stakeholders. +0,5

Different TV stations and radio stations in country.. +1

Access to satellite tv or streamed news in internet +1

Access to different ISPs. foreign western Proxy Services, entire Internet and Tor Onion Router +1

Possibility to blog, moderate in blogs and internet media and not permanently censhorship (censorship, when hawkishing a little bit to much for hours until 1 week is OK). +1

Possibility to report over public events in blogs, media, internet media like X or Facebook, you need special permission and agreement from company, private person and NGO, when reporting inside over companies, NGOs, military and private persons private sphere (concerning e.g. product placement, innovations, sexuality or belief). +1

Tolerate whistleblowing like in the US, when reporting over complicated human rights violences of foreign troops in war. +0,5

Storry telling, conspiracy theories and narratives are marked with a recognizable symbole, e.g. +0,5

Civil & business & companies rights

9 basic points

The word church in follwoing could also mean shrine, temple, stone circle, lgbt community or any religious monoment or place.

Freedom of assembly (if missing -4)

  • Right for workers to join a labor union or representation of employees.
  • Right for companies to join a free foundation or trade guild.  

  • Right to join a religious community or free church (no hierachically bottom up grassroot foundate non state church).

Freedom of speach, freedom of art and freedom of posts without state sanctions (exception national socialists content, radical djihadist content, stalinist content in some countries)   (if missing -4)

Right to work self choosen and startup again after phase of unemployment. Right to work no matter what in company, NGO as free artist, freelancer, whatever ... (for some non free profession, like medical doctor or train man you need a special prooved certificate or degree) (if missing -4)

Right to found, own, buy (part of) a company or poperty, right to own stock market values, money, gold, derivates, freedom to choose bank and payment provider and freedom of trade  (Excpet US patriot act or sanctions against countries as US ally) (if missing -5)

Right for worker to leave company (inside a certain time period, normally 0-3 months) when getting a better offer without extreme high penality for joining another company. Right for companies to hire & fire women & men inside a certain time period (normally 0-3 months). (if missing -4)

Right to vote, right to protest and right to access basic state services for every citizen. (if missing -4)

Freedom of operating system, freedom to choose between open & closed source and freedom to develop after a free choosen license, e.g. BSD, Apache, GNU, MIT, closed source). (if missing -4
(Standardized licenses for paying and billing closed source, 3-10 categories would be nice, like renting software as a service like office 365, paying a cloud provider on network and CPU and storage using, installing a software and paying for year a guaranteed support, ...)

Right on abortion, if both mother & father agree to it, because otherwise they would be slaves, owned by a landlord in law. Free citizens should have that right. Don't bring slavery back to US. (if missing -5)

Right to have a own sexuality, freedom for adults to have sex if both agree (maybe after rules of their church), right to marriage (maybe after rules of a church or federal state). (if missing -3)

Right to adopt non adult childs, if parents or next familiars (if parents death) of children agree to it and have a permanently visiting right at least all 2 weeks. Maybe a free NGO check is needed, that this is good too. (if missing -3)

Non discrimination rights and possibility to protest against it or go to an independant court. 
(In private companies I saw and experienced discrimination very rarley, but at civil services or police or public high schools, this is happening some times).  (if missing -2

Right of an independent and fair judgement (maybe right to have a second independant judge, if court is politically motivated).  Right of comparison between companies or private persons (both agree that one pays the other a fee of 100US$ of causing pain per day) (if missing -3

Right to wear waepons for veterans (who served at national army with locked and loaded waepons).  (if missing -1

Right for people over 16 to drive a car, ride a byke, bicycle (maybe a confirmed license is needed, horse, donkey, drink whiskey (of course not when riding or driving a vehicle) and smoking natural herbs, tobaco (but no opiods). (Maybe the right of your church doesn't allow some parts).  (if missing -2

Right to have a save and proper enviroment: State can ban bear, wolfes or elephant hunts or shutting birds or using animals for bio-nano technolgy experiments.  (if missing -2

Denied: Experiments with human beeings without their agreement (signed and 3rd party validated) (like milkram experiment) is forbidden. Long time studies of human beeings. (if missing -4

Right to access independent technology to scan your genom and verify children and parents, if they agree. (if missing -2



Social rights:

(For Europe, Great-Britain. Brazil and ???): Right of small social security (at least 1000US$ per month), if you get unemployed or need assistence.  (if missing -3) (State money transfer over 150.000 US$ per year without doing anything is strictly forbidden. Excluded: Fees from private companies as a free services for long employment, excellent performance or great innovation or great ad value).

Right for every cirtizen to access as citizen public libraries with internet access with a legitimated identifying card.

Right to repair wikipedia, right of elected assembly to transfer special money to some urgently needed NGO task forces, like open source foundation, wikipedia, ...

Right for jobless people to getting courses to be ready for a new job, where they are only 40% - 80% qualified and not enough fit 4 work.

To be continued ...






2023-12-31

Linux v6.7-rc8 kernel compiled today


Today, when I waked up before the new year, I downloaded the newest linux v6.7-rc8 kernel, made a classic menuconfig and readed a bit kernel documentation, before compiling the kernel.

 
 
processor types and features


 

processor support (new) 

 
Those new x86 based processor types are now experimental (beside AMD & Intel) supported by latest linux kernel:
 
Hygon

2023-12-09

¼ π

¼ π = arctan(1) = arctan(45°) ✓

mathematical proof still required for:
¼ π = 1 - ⅓ + ⅕ - ¹/₇ + ¹/₉ - ¹/₁₁ + (1/13) - ...
¼ π = (n=0;n→∞)∑ (-1)ⁿ / (2n + 1)
better way to approximate π is to add iteration m=n-1 and iteration n and double it.

2023-06-30

VIC20 Emulatoren

und programmierte in BASIC ein einfaches Zahlenratespiel: 

10 LET U=RND(-625)
20 LET V=RND(0)
30 LET W=V*10
40 LET X=INT(W)
50 REM X ZAHL VON 1 BIS 10
100 INPUT “ERRATE ZAHL VON 0 BIS 10” ; A$
110 G0 LET B=VAL(A)
120 IF B < X THEN GOTO 160
130 IF B > X THEN GOTO 180
140 IF B = X THEN GOTO 200
160 PRINT “ IHRE ZAHL IST > GROESSER”
170 GOTO 100
180 PRINT “ IHRE ZAHL IST < KLEINER”
190 GOTO 100
200 PRINT “RICHTIG!”
210 END

2023-05-09

2022-11-29

flex - fast lexical analyzer generator sample

Orginal posting can be fount here: http://blog.darkstar.work/2012/05/flex-fast-lexical-analyzer-generator.html

Who remember flex: fast lexical analyzer generator?

Here is a short sample, I have written it under gnu linux and ported it to win32 using gnuwin32 flex and getoptwin:

%option noyywrap

%{
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "getopt.h"
#include <string.h> 
#define MAXLEN 1024

int i, j, idx, len, mode = 0;
char tmps[MAXLEN], reverse[MAXLEN];

%}
SEGA  [2][5][0-5]
SEGB  [2][0-4][0-9]
SEGC  [1][0-9]{2}
SEGD  [1-9][0-9]{0,1}
SEG   {SEGA}|{SEGB}|{SEGC}|{SEGD}
IP    {SEG}["."]{SEG}["."]{SEG}["."]{SEG}

HOSTDOMAINSEGMENT [0-9a-zA-Z_"\-"]+["."]
TOPLEVELDOMAIN [a-zA-Z]{2,7}
HOSTNAME {HOSTDOMAINSEGMENT}+{TOPLEVELDOMAIN}
USER [0-9A-Za-z_"\-""."]+

EMAIL1 {USER}"@"{HOSTNAME}
EMAIL2 {USER}"@"{IP}

URIPROTOCOL [a-zA-Z]{2,10}"://"
URISUFFIX [^ \t\n\r"@"","">""<""("")""{""}"]
URL1   {URIPROTOCOL}{HOSTNAME}{URISUFFIX}*
URL2   {URIPROTOCOL}{IP}{URISUFFIX}*

%%
<<EOF>> {
        exit(1);
    }

{EMAIL1} |
{EMAIL2} {
        if (strchr(yytext, '@') != (char *)NULL) 
        {
    switch((mode % 16)) 
    {
case 0: strcpy(tmps, yytext); break;
case 1: strcpy(tmps, strchr(yytext, (int)'@')); break;
case 2: strcpy(tmps, &strchr(yytext, (int)'@')[1]); break;
     case 4: 
strcpy(tmps, &strchr(yytext, (int)'@')[1]);
len = strlen(tmps); 
for (j = 0, idx = 0; ((j < len) && (j < MAXLEN-1)); j++) 
{
                            if (tmps[j] == '.'
                            {
                                for (i = idx; i <= j; 
                                    reverse[(len-j) + (i-idx)] = tmps[i++]);
                                idx = j + 1;
                            }
}
for (i = idx; i <= j; 
                            reverse[(len-j) + (i-idx)] = (i < len) ? tmps[i] : '.', i++);
reverse[len + 1] = '\0';
strcpy(tmps, reverse);
break;
case 8: strcpy(tmps, &strrchr(yytext, (int)'.')[1]); break;
default: strcpy(tmps, yytext); break;
    }
    (void) printf("%s\n", tmps);
        }
    }

{URL1} |
{URL2} {
if (mode < 16) 
{
            switch((mode % 16)) 
            {
                case 0: strcpy(tmps, yytext); break;
         case 1: strcpy(tmps, strchr(yytext, (int)'/')); break;
         case 2: strcpy(tmps, &strrchr(yytext, (int)'/')[1]); break
         case 4: 
                        strcpy(tmps, &strrchr(yytext, (int)'/')[1]);
                        len = strlen(tmps);
                        for (j = 0, idx = 0; ((j < len) && (j < MAXLEN-1)) ; j++)
     {
                            if (tmps[j] == '.'
                            {
                                for (i = idx; i <= j; 
                                    reverse[(len-j) + (i-idx)] = tmps[i++]);
                                idx = j + 1;
                            }
                        }
                        for (i = idx; i <= j; 
                            reverse[(len-j) + (i-idx)] = (i < len) ? tmps[i] : '.', i++);
                        reverse[len + 1] = '\0';
                        strcpy(tmps, reverse);
                        break;
                case 8: strcpy(tmps, &strrchr(yytext, (int)'.')[1]); break;
                default: strcpy(tmps, yytext); break;
            }
            (void) printf("%s\n", tmps);
        }     
    } 

^[\n;] { ; }

[\r\n]+ { ; }

. { ; }

%%
void yyerror() { exit(1); }

void usage(const char *cmd) 
{
    (void) printf("Usage: %s [-f file] [-a ] [ -r ] [ -u ]\n", cmd);
    (void) printf("\t simple email address and uri lexer reads from stdin \n");
    (void) printf("\t -a, --noat    \t print only hostname of email address (all chars left of \'@\') \n");
    (void) printf("\t -u, --nouser  \t print email without username \n");
    (void) printf("\t -t, --top     \t prints domain toplevel only, when using option -a | -u \n");
    (void) printf("\t -n, --nouris \t print only email address and not uris\n");
    (void) printf("\t -r, --reverse \t reverse the hostdomain / ip address segments\n");
    
    exit(0);
}

int _tmain(int argc, TCHAR** argv)
{
    static int verbose_flag;
    int c;

    while(1)
    {
        static struct option long_options[] =
        {
            {_T("help"), ARG_NONE, 0, _T('h')},
            {_T("noat"), ARG_NONE, 0, _T('a')},
            {_T("nouser"), ARG_NONE, 0, _T('u')},
            {_T("top"), ARG_NONE, 0, _T('t')},
            {_T("nouris"), ARG_NONE, 0, _T('n')},
            {_T("reverse"),     ARG_NONE, 0, _T('r')},
            { ARG_NULL,         ARG_NULL, ARG_NULL, ARG_NULL}
        }; 

        int option_index = 0;
        c = getopt_long(argc, argv, _T("hautnr:"), long_options, &option_index);
        if (c == -1) 
            break;
        switch (c) // Handle options
        {
            case 0: // If this option set a flag, do nothing else now.
                    if (long_options[option_index].flag != 0)
                        break;
                    _tprintf (_T("option %s"), long_options[option_index].name);
                    if (optarg)
                        _tprintf (_T(" with arg %s"), optarg);
                    _tprintf (_T("\n"));
                    break;
            case _T('u'): mode = 1; break
            case _T('a'): mode = 2; break
            case _T('r'): mode = 4; break;
            case _T('h'): usage(argv[0]); break;
            case _T('t'): mode = 8; break;
            case _T('n'): mode += 16; break;  
            case '?': break// getopt_long already printed an error message. 
            default: abort();
        }
    }
    (void) fflush(stdout);
    yyin = stdin;
    yylex();
    exit(0);
}

Original posted 2011 here: http://www.area23.at/he/security/flex

2022-11-15

Could too much function pointers (delegates) inside many huge loops have an effect of unoptimizable code?

We have this simple c modified code from stack overflow called funcptrtest.c:

include <stdio.h>
/*   C code for program funcptrtest.c 
  => https://pastebin.com/rUtXfgSG 
*/
const int b = 23;

// A normal function with an int parameter and void return type
void fun(int a)
{
  if (a < b)
    printf("Value of a (%d) is lesser then value of b (%d)\n", a, b);
  else if (a == b)
    printf("Value of a (%d) is equal value of b (%d)\n", a, b);
  else if (a > b)
    printf("Value of a (%d) is greater than value of b (%d)\n", a, b);
}

// main => NO KNR style int main(argc, argv) int argc; char **argv 
int main(int argc, char **argv)
{
    int i = 0;
    /* fun_ptr is a pointer to function fun()
           void (*fun_ptr)(int) = &fun;
         is equivalent of following two
           void (*fun_ptr)(int);
           fun_ptr = &fun;
    */
    void (*fun_ptr)(int) = &fun;

    // call once with static int
    (*fun_ptr)(b);

    // iterate through for loop
    for (i = 1; i < 101; i+=11)  {
        // Invoking fun() using fun_ptr
        (*fun_ptr)(i);
    }

    return 0;
}

We compile it now with gnu c compiler with gcc option -S and generate an assembler file:

gcc -S funcptrtest.c -o funcptrtest.asm

Result will be something like this:

.file   "funcptrtest.c"
        .text
        .globl  b
        .section        .rodata
        .align 4
        .type   b, @object
        .size   b, 4
b:
        .long   23
        .align 8
.LC0:
        .string "Value of a (%d) is lesser then value of b (%d)\n"
        .align 8
.LC1:
        .string "Value of a (%d) is equal value of b (%d)\n"
        .align 8
.LC2:
        .string "Value of a (%d) is greater than value of b (%d)\n"
        .text
        .globl  fun
        .type   fun, @function
fun:
.LFB0:
        .cfi_startproc
        endbr64
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        subq    $16, %rsp
        movl    %edi, -4(%rbp)
        movl    $23, %eax
        cmpl    %eax, -4(%rbp)
        jge     .L2.L2:
        movl    $23, %eax
        cmpl    %eax, -4(%rbp)
        jne     .L4
        movl    $23, %edx
        movl    -4(%rbp), %eax
        movl    %eax, %esi
        leaq    .LC1(%rip), %rax
        movq    %rax, %rdi
        movl    $0, %eax
        call    printf@PLT
        jmp     .L5
        .L2:
        movl    $23, %eax
        cmpl    %eax, -4(%rbp)
        jne     .L4
        movl    $23, %edx
        movl    -4(%rbp), %eax
        movl    %eax, %esi
        leaq    .LC1(%rip), %rax
        movq    %rax, %rdi
        movl    $0, %eax
        call    printf@PLT
.L2:
        movl    $23, %eax
        cmpl    %eax, -4(%rbp)
        jne     .L4
        movl    $23, %edx
        movl    -4(%rbp), %eax
        movl    %eax, %esi
        leaq    .LC1(%rip), %rax
        movq    %rax, %rdi
        movl    $0, %eax
        call    printf@PLT
        jmp     .L5
.L4:
        movl    $23, %eax
        cmpl    %eax, -4(%rbp)
        jle     .L5
        movl    $23, %edx
        movl    -4(%rbp), %eax
        movl    %eax, %esi
        leaq    .LC2(%rip), %rax
        movq    %rax, %rdi
        movl    $0, %eax
        call    printf@PLT
.L5:
        nop
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc     
.LFE0:
        .size   fun, .-fun
        .globl  main
        .type   main, @function
main:
.LFB1:
        .cfi_startproc
        endbr64
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        subq    $32, %rsp
        movl    %edi, -20(%rbp)
        movq    %rsi, -32(%rbp)
        movl    $0, -12(%rbp)
        leaq    fun(%rip), %rax
        movq    %rax, -8(%rbp)
        movl    $23, %edx
        movq    -8(%rbp), %rax
        movl    %edx, %edi
        call    *%rax
        movl    $1, -12(%rbp)
        jmp     .L7
.L8:
        movl    -12(%rbp), %eax
        movq    -8(%rbp), %rdx
        movl    %eax, %edi
        call    *%rdx
        addl    $11, -12(%rbp)
.L7:
        cmpl    $100, -12(%rbp)
        jle     .L8
        movl    $0, %eax
        leave
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc
.LFE1:
        .size   main, .-main
        .ident  "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0"
        .section        .note.GNU-stack,"",@progbits
        .section        .note.gnu.property,"a"
        .align 8
        .long   1f - 0f
        .long   4f - 1f
        .long   5
0:
        .string "GNU"
1:
        .align 8
        .long   0xc0000002
        .long   3f - 2f
2:
        .long   0x3
3:
        .align 8
4:

Lets look, if a simple loop is faster than a function pointer delegate call:

/* program looptest.c */
include <stdio.h>

const int b = 23;

// main
int main(int argc, char **argv)
{
    int i = 0;
    int a = 23;

    /*
    if (a < b)
        printf("Value of a (%d) is lesser then value of b (%d)\n", a, b);
    else if (a == b)
       printf("Value of a (%d) is equal value of b (%d)\n", a, b);
    else if (a > b)
       printf("Value of a (%d) is greater than value of b (%d)\n", a, b);
    */

    // iterate through for loop
    for (i = 1; i < 4194304; i+=11)  {
        a = i;
        if (a < b)
           printf("Value of a (%d) is lesser then value of b (%d)\n", a, b);
        else if (a == b)
           printf("Value of a (%d) is equal value of b (%d)\n", a, b);
        else if (a > b)
           printf("Value of a (%d) is greater than value of b (%d)\n", a, b);
    }

    return 0;
}

/* program funcptrtest.c */
include <stdio.h>

const int b = 23;

// A normal function with an int parameter and void return type
void fun(int a)
{
  if (a < b)
    printf("Value of a (%d) is lesser then value of b (%d)\n", a, b);
  else if (a == b)
    printf("Value of a (%d) is equal value of b (%d)\n", a, b);
  else if (a > b)
    printf("Value of a (%d) is greater than value of b (%d)\n", a, b);
}

// main
int main(int argc, char **argv)
{
    int i = 0;
    /* fun_ptr is a pointer to function fun()

       void (*fun_ptr)(int) = &fun;
       is equivalent of following two
       void (*fun_ptr)(int);
       fun_ptr = &fun;
    */
    void (*fun_ptr)(int) = &fun;

    // call once with static int
    // (*fun_ptr)(b);

    // iterate through for loop
    for (i = 1; i < 4194304; i+=11)  {
        // Invoking fun() using fun_ptr
        (*fun_ptr)(i);
    }

    return 0;
}

Well, that's not so deterministic, of course our simple looptest.asm has a shorter assembler.

compile options

But execution time is not so huge difference, we have to simulate, that in many scenarios.

[To be continued ...]

2022-10-11

It's about creating distributed service oriented communications

Attention:
This article isn't about daily standard electronic communications via network protocols (e.g. email services or shared network folders),  neither about user authentication / authorization nor groupware. 

It's about: 
Implementing or consuming customizable reliable distributed services;
by choosing & implementing a programmable extensible scalable, easily portable, standardized inter-compatible fail-safe resilient communication middleware, that's financially essential for most critical business processes.

For what kind of companies is that useful, important or relevant?
It's relevant for all companies, that consume many crtical data from external partners / service providers; 
then process received & own data inside different departments (maybe in different locations) with different areas of responsibility (e.g. fraud detection, critical real-time scaling of dynamic hardware (memory, harddisks and available CPUs, permanent risk adjustment and last but not least anonymized [General Data Protection Regulation] precise reporting for legal reasons);
finally  and ultimately share processed data to maybe different  external organisations with very deviating requirements, like government fraud reporting agency on one side and partners inside a foundation or joint umbrella organization however.

Overview most common distributed service oriented communication technologies in history

What technologies do you use in your company / organisation or as private person for distributed service oriented communication?

    1. antique: [ 1980s ]
    2. old: [ around the millennium ]
    3. Previous generation: [ since 2010 ]


    What local software suites / solutions / products and enterprise cloud services are included in your distributed service oriented communication(s workflows)?

    1. Microsoft BizTalk Server
    2. RabbitMQ [ github.com/rabbitmq ]
    3. Amazon Web Services [ aws ]
    4. Azure RestAPI Reference 

    [ to be continued ... ]






    -


    2022-09-25

    Bridge Mini-VM for reading XFS, JFS, ext[234], minix, btrfs, reiserfs ot any other non MS filesystem

    Howto access  XFS, JFS, ext[234], minix, btrfs, reiserfs ot any other non MS filesystem from Windows 7 - 11 without installing a maybe bogus kernel filesystem driver?

    1. Make a Mini-Vm with a totally slack and stripped linux kernel, that is bridged on a VM network adapter. Include all filesystem drivers and needed network adapter & drivers in that kernel and strip / kick out everything other, what's not needed. 
      Make the kernel similiar to a cisco router or PIX firewall kernel.
    2. Give the VM direct access to your harddisk, usb-devices, firewire & bluetooth devices.
    3. Enable the Mini linux VM to reEXport mounted filesystem over smb or nfs.
    4. Calculate the memory size, which is needed, that all filesystem mounts and all fs operatons work fast enough with paging and caching. 
    5. Choose the best scheduler for that mini-VM.
    6. Optimize all ioctl, (f)lush, (f)read, (f)write, (f)seek, (f)open, (f)close and all other filesystem operations.
    7. If you are hungry => oprimize the /proc /sys /dev filesystem.

    2022-05-08

    A crazy example of a Lazy singleton as strangest singelton pattern ever

    A crazy example of a Lazy<T> singelton with privat constructor inherited form an protected DoubleLockInstance singelton with private empty and protected parameter constructor inherited form an abstract singelton template with protected constructor.


    Application settings example:


    BaseSets for basic settings as abstract singelton base


    using System;using System.Reflection;
    namespace work.darkstar.blog{    /// <summary>    /// abstract class BaseSets     /// </summary>    [Serializable]    public abstract class BaseSets    {        public string AssemblyName { get => Assembly.GetExecutingAssembly().GetName().ToString(); }        public string Copyright { get => "GNU LIGHT GENERAL PUBLIC LICENSE 2.0 LGPL"; }        public virtual string AssemblyCom { get => "darkstar.work"; }
            public virtual int AppId { get; protected set; }        public virtual string AppName { get; protected set; }        /// <summary>        /// protected empty constructor for inheritable singelton        /// </summary>        protected BaseSets() { }         /// <summary>        /// protected parameterized constructor for inheritable singelton        /// </summary>        protected BaseSets(int appId, string appName)        {            AppId = appId;  AppName = appName;        }    }}

    AppSets for application settings as instancable singelton default app sets (settings):

    using Microsoft.Win32;
    using System;
    using System.Reflection;
    using System.Windows.Forms;

    namespace work.darkstar.blog
    {
        public interface IAppSetsDomain : IAppDomainSetup    {        System.AppDomain AppCurrentDomain { get; }    }    /// <summary>
        /// application settings singelton    /// </summary>
        [Serializable]    public class AppSets : BaseSets, IAppDomainSetup
        {
            
    private static AppSets _appSets;
            private static object  _initLock, _sndLock;
            protected static AppSets DoubleLockInstance {            get {                _sndLock = new System.Object();                lock (_sndLock)  {                    if (_initLock != null) _initLock = null;
                        if (_initLock == null) _initLock = new System.Object();                    lock (_initLock) {                       if (_appSets == null)                            _appSets = new AppSets();                    }                    return _appSets;                }            }        }        public string CodeBase { get => Assembly.GetExecutingAssembly().CodeBase; }
            public string BaseDirectory { get => AppDomain.CurrentDomain.BaseDirectory; }        public string AppDataPath { get => Application.CommonAppDataPath; }        public RegistryKey AppDataRegistry { get => Application.CommonAppDataRegistry; }

            #region implementing interface IAppSetsDomain, IAppDomainSetup        
            public AppDomain AppCurrentDomain { get => AppDomain.CurrentDomain; }
            public string ApplicationBase get set; }
            public string ApplicationNameget set; }
            public string CachePathget set; }
            public string ConfigurationFileget set; }
            public string DynamicBase get set; }
            public string LicenseFile get set; }
            public string PrivateBinPath get set; }
            public string PrivateBinPathProbe get set; }
            public string ShadowCopyDirectories get set; }
            public string [] ShadowCopyDirectoryArray { 
                    get => ShadowCopyDirectories.Split(';'); }
            public bool FilesShadowCopy { get set; }
            public string ShadowCopyFiles { 
                get => FilesShadowCopy.ToString().ToLower();
                set { FilesShadowCopy = Boolean.Parse(value); }
            }
            public bool FilesShadowCopyget set; }
            public string ShadowCopyFilesget => FilesShadowCopy.ToString() set; }
            #endregion implementing interface IAppSetsDomain, IAppDomainSetup        

            /// <summary>        /// static constructor         /// </summary>        static AppSets() {
                
    _initLock = new System.Object();
                
    lock (_initLock) { _appSets = new AppSets(); }
            }
            /// <summary>        /// private empty constructor         /// </summary>        private AppSets() {            AppId = AppDomain.CurrentDomain.Id;            AppName = Assembly.GetExecutingAssembly().FullName;                      }
            /// <summary>        /// protected parameter constructor         /// </summary>        protected AppSets(int appId, string appName) : base(appId, appName) { }
        }}

    Sealed MyAppSets for application specialized appSets as Lazy<T> singelton:

    using System;
    using System.IO; using System.Security;
    /* ... */using Microsoft.Win32;/* ... */using Windows.Forms; namespace work.darkstar.blog { /// <summary> /// my application settings singelton /// </summary> [Serializable] public sealed class MyAppSets : AppSets { /// <summary> /// private static readonly Lazy<T> self containing private real singelton unique instance /// </summary> private static readonly Lazy<MyAppSets> _instance = new Lazy<MyAppSets>(() => new MyAppSets(AppDomain.CurrentDomain.Id, "LazyApp")); /// <summary> /// static instance getter for Singeltion /// </summary> public static MyAppSets Instance { get => _instance.Value; } public string UserAppDataPath { get => Application.UserAppDataPath; } public RegistryKey UserAppDataRegistry { get => Application.UserAppDataRegistry; } /// <summary> /// private constructor with partameters for sealed unique singelton /// </summary> private MyAppSets(int appId, string appName) : base(appId, appName) { } /// <summary> /// Gets name value pair for application registry key saved in registry scope for current user /// </summary> /// <param name="regName">registry name identifier</param> /// <param name="subKey">subKey in scope of current user</param> /// <returns>object value</returns> /// <exception cref="ApplicationException">application exception with detailed inner exception</exception> public object GetUserRegValuey(string regName, string subKey = null) { object o = null; RegistryKey key = null; Exception ex = null; try { key = (subKey == null) ? UserAppDataRegistry : UserAppDataRegistry.OpenSubKey(subKey, false); o = key.GetValue(regName); } catch (SecurityException sex) { ex = sex; } catch (ObjectDisposedException odEx) { ex = odEx; } catch (UnauthorizedAccessException uaEx) { ex = uaEx; } catch (IOException ioeEx) { ex = ioeEx; } finally { if (key != null && subKey != null) key.Close(); if (ex != null) throw (new ApplicationException("Error accessing registy key: " + $"{UserAppDataRegistry}\t name: {regName}\t subkey: {subKey}", ex)); } return o; } /// <summary> /// Set Value for UserAppDataRegistry /// </summary> /// <param name="regName">registry name </param> /// <param name="value"value to set></param> /// <param name="subKey">subKey</param> /// <returns>void means nothing</returns> /// <exception cref="ApplicationException">application exception with detailed inner exception</exception> public void SetUserReg(string regName, object value, string subKey = null) { RegistryKey key = null; Exception ex = null; try { key = (subKey == null) ? UserAppDataRegistry : UserAppDataRegistry.OpenSubKey(subKey, true); key.SetValue(regName, value); } catch (Exception anyEx) { ex = new ApplicationException($"Error setting value=" + $"{value} for name={regName} inside registry key: {key.Name}", anyEx); } finally { if (key != null && subKey != null) key.Close(); if (ex != null) throw ex; } } } }

    Accessing MyAppSets singelton inside any entity, framework,  helper, [...] class

    
    using System; /*  ... */
    using work.darkstar.blog;

    public class MyEntity : IAppSetsDomain {
      /* [ ... ] */
      /* [Inject] */
      /* [ ... ] */

      public AppDomain AppCurrentDomain {
        get => MyAppSets.Instance.AppCurrentDomain;     set => MyAppSets.Instance.AppCurrentDomain = value;   }   /* ... */ }