#Origami Owl by Nguyen Hung Cuong

I gotta say I love how curvy it looks, a great 3D model which is not as hard to do.

This was my second attempt and I am pretty happy with it

#art #mastoart #hobby #owls #paperfolding

How it feels when studying for Network Admin certifications and it turns out that it mention Telnet far more often than it mention SSH...

@bs As you can imagine, it get convoluted fast, because classes in C# does not always arrange it's data members in the exact order you lay them out to be unless you specify [StructLayout(LayoutKind.Explicit)] attribute for the class and define such layout the way you plan it.

Welcome to P/Invoke Hell in C#. Lol

Show thread

@bs
And then we call something like this:

var sum = new SumClass();
sum.Value = 5;
Console.WriteLine(CallSum(sum, 1));

Now the CallSum would be a wrapper for C's Sum function, because it would have to run reflection code on the SumClass if it haven't generate a VTable/Map for that given class, it would have to create new VTable and then supply function pointer to the Sum function overridden by C#'s Sum function in SumClass and finally forward it's C-object over to C.

Show thread

@bs
struct SumClass* SumClass_New(int32_t val)
{
void **newObj = (void **)calloc(sizeof(struct SumClass) + sizeof(void *), 1);
*newObj = &SumClassVTable;
struct SumClass *ptr = (struct SumClass *)&(newObj[1]);
ptr->baseObj.Value = val;
return ptr;
}

Now what if we want to do the same for C# when calling into C code?

Let's suppose we have C# code like this:

public class SumClass : BaseClass
{
public override int Sum(int val)
{
return Value + val;
}
}

Show thread

@bs
static struct BaseClassVTable SumClassVTable = (struct BaseClassVTable) {
.Sum = SumClass_Sum
};

bool SumClass_ValidateThis(struct SumClass* this)
{
if (this == NULL)
{
return true;
}
if (((void **)this)[-1] != (void *)&SumClassVTable)
{
return true;
}
return false;
}

Show thread

@bs
bool SumClass_ValidateThis(struct SumClass* this);

struct SumClass {
struct BaseClass baseObj;
};

int32_t SumClass_Sum(struct SumClass* this, int32_t val)
{
if (SumClass_ValidateThis(this))
return -1; // Error occurs, returns -1
return this->Value + val + 1;
}

Show thread

@bs
struct BaseClass
{
int32_t Value;
};

struct BaseClassVTable
{
int32_t Sum(MyClass* this, int value);
};

If we want to inherit the base class in C, we would have to do this:

Show thread

@@bs Now for some of the most advanced-niche programming nightmare...

Bridging Two Separate Programming Paradigms such as Procedural Programming Language like C and Imperative Programming Language like C#.

Suppose we have an object in C defined a VTable and the Object itself that reflects Object Oriented Programming Paradigm as such:

@bs

Paid Tiers for Memory Management.

Free Tier: 512 kb of garbage collected memory

Ad Tier: 1 MB of garbage collected memory, must watch 2 minutes ad per hour to keep this tier. Any excess memory is deleted upon failure to maintain ad tier when downgrading

Paid Tier: 5 MB of garbage collected memory for $200/mo

Enterprise Tier: 10 MB/$2000/mo

Small Footnote: All memory are continually replicated and forwarded to law enforcement authorities.

After a week of struggling with my new fancy espressomachine I finally have decent ☕️✨️

When you re-run the script, you'll notice that it won't prompt for TFA anymore, it because it would save the cookie required for authentication though cookie can expire, if that happens, you need to delete Cookie.txt.

Also if you update Firefox, you may need to update geckodriver from here: github.com/mozilla/geckodriver

All of this is from Dotnet SDK tool.

To build and run: `dotnet run` within repo directory in the terminal.

Show thread

Few things you have to do to use it:

1. Change the username and password in Program.cs file in line 35 and 40.
2. Get image url of each background in steam profile and add it to imageUrls string array.
3. Write whatever logic you want to tell program how to pick image for "selectedImage" variable
4. Run (Enter TFA, it will give you 1 min)

Show thread

Wrote up a profile background switching script on a whim (around 7 min.)

Feel free to use it if that suit your needs, more info following this thread.

github.com/LinuxLegend/SteamPr

Geckodriver was obtained from: github.com/mozilla/geckodriver within geckodriver-v0.31.0-linux64.tar.gz file.

Show older
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.