Tumgik
#mlem's computing stuff
mlembug · 11 months
Text
Tumblr media
@canonkalluzeb It's an attempt in mirroring terminology of IRC, which does not necessarily makes sense in context of Discord, and Discord knows this perfectly well because they're both internally, and also among programmers who make Discord bots, called "guilds", not "servers".
Some background: when two computer applications on two separate computers have to communicate, one of them has to first set up the connection, and so the program which listens to connections is often called "server", and the program which attempts to connect is called "client", which is an analogy of how restaurants work.
And of course it's not like two arbitrary programs can understand each other, so when one needs to make two programs communicate with each other, one designs a "protocol", which is a description of the exact rules these two programs are supposed to interact on.
Back in The Old Days (90s to early 00s) the most common protocol for chat-like applications was called IRC (Internet Relay Chat), which does follow the "client-server architecture", where someone (could be anyone, but usually it was universities or ISPs) runs the IRC server application on their computers, and people who want to chat, run IRC client applications which connect to these servers.
(it is still possible to use IRC today, but a lot of people don't because the newer alternatives provide features which people are used to, like... file upload/storage, persistent chat history, or transport encryption)
On the most basic level, a person that uses an IRC client first makes it connect to an IRC server by typing an address to connect to, and then picks the channels to join there, of which each functions as an independent conversation, in that
your IRC client usually displays the chat messages grouped together by the channel
the clients which joined a channel can send a message to this channel, which server receives...
...and then sends it to every other client which joined such channel
the clients which did not join a channel do not receive messages that are sent to the channel
if your client did not receive a message (due to lost connection, or maybe you were not in the channel in the first place), you will not see this message ever again, as IRC has no mechanisms of providing you a message history, nor retransmission of earlier messages
it may be possible for a regular user to create a channel, depending on how the IRC server is configured
Now here's how Discord works:
you are not supposed to run a Discord server application. Discord (the company) made one, and it is running on their computers (the ones they manage at least), but you can't run it on your computer (for whatever reason you wanted to do so), because they won't give it to you in the first place
the only thing you are supposed to run, is the Discord client application, which they offer to you for free
since no one outside of Discord (the company) is supposed to run Discord servers, the fact you're connecting to them specifically is not supposed to be relevant to the end user
your Discord client maintains a connection to a Discord server, which sends real-time information on stuff like "there is an unread message on guild number 253958353" or "you got pinged in a direct message by user with number 34235936984" to the client
any user can create a "guild", of which the person who created it is marked as a "guild owner", which is highest possible rank and everyone else on the server can only be a granted permission to do a subset of actions a server owner can do.
a guild has a list of channels, a list of users joined it, and a list of roles
roles can be assigned to the user, and apply within a guild only
a role controls the list of possible actions a user can do in the context of the server
a channel functions as a chronologically-sorted list of messages, of which you can retrieve a part of it by clicking on it, and other parts - by scrolling
Now take this into account that what I've just called "Discord server" is usually not something the end user needs to worry about, so it's typically not mentioned at all, and "guild" is called "server" literally everywhere else outside of developer documentation, and you can see why this feels a bit confusing.
29 notes · View notes
shadowdragonia · 5 years
Text
I care more about my pet than myself
Y’all I am 32 years old. My work hours at 4pm to midnight. I would just come home and catch up on stuff at night, stay up till about 6 or 7am, sleep till 3pm and go to work. That was my life, not the best schedule but I had nothing better to do so whatever.
Then I got my little baby bearded dragon, Mlem.
Mlem requires a good sleep schedule because Mlem is precious baby that needs healthy life.
I still get home at Midnight, so I check on Mlem when I get home, get some basic stuff done, then its light out at 2am at the latest. I’ll still stay up another hour maybe on the computer but when the room is dark its too tempting to go to bed. I set my alarm for noon now so I can get up and turn Mlems lamps on and get him all warmed up and ready for breakfast.
I am 32 years old and didn’t give a shit about my sleep related health patterns until I got a baby bearded dragon. I changed my life for Mlem. 
32 notes · View notes
rjshepherd · 5 years
Text
crowley and kids
i know its kinda tumblr canon that crowley loves kids but can you imagine him 5-10 years down the line after the notpocalypse , meeting up with newt and anathama and their psycic little grub worm? he and aziraphale show up with baby presents .Aziraphale brings baby grows that are self cleaning, diapers that never stink , extra strong coffee for newt and anathama. you know, normal baby stuff. crowley on the other hand already seems to be planing the childs future. he shows up with stuff like a tiny set of divining rods or a kids first computer electronics kit. either way newt and anathama are glad to see them. 
aziraphale is talking away to anathama and newt at the table about being new parents over tea, crowley is on the floor playing with the baby. he does a little snakey mlem and the baby errupts with laughter and everyone turns round to look at crowley .crowley promptly bursts into tears holding onto this glorious giggling wrinkly thing like “angel i want one T-T”
aziraphale makes his excuses and leaves. que a long car ride about how they couldnt empty water out of a shoe with instructions on the heel nevermind raise a child or that demons/angels chant have offspring . aziraphale nearly chokes when crowley implies that they could still have fun trying >:D
44 notes · View notes
mlembug · 1 year
Text
Relay operated power button
Tumblr media
What you need:
a 5V relay module
Raspberry Pi
a bunch of cables
Explanation:
A power button on a computer case lets electricity flow between two power pins upon it being pressed, which is when the motherboard detects the button is pressed and reacts accordingly.
Tumblr media
A relay is a specific kind of switch which lets electricity flow conditionally upon the flow of electricity in another circuit. The voltages involved both in motherboard power pins and on Raspberry Pi are generally low to not damage both, but we're taking extra precautions to electrically separate them both.
"5V relay module" here means that 5V is the voltage that is required for the relay module to work, while the controlling voltage can be lower. It being relay module it means it also has a flyback diode we'd otherwise have to provide ourselves.
Tumblr media
Raspberry Pi's GPIO pins are programmable and can be controlled through Python code, and operate on 3.3V. Raspberry Pi also provides 5V output, but this one is not controllable.
By
connecting a power button to rPi GPIO pins
connecting the 5V voltage output pin from rPi to the relay module's Vcc input pin
connecting the ground pin from rPi to the relay module's groud pin
connecting programmable GPIO pins as the relay module's input pin
connecting the relay module's outputs (the normally open one and the ground) to the motherboard power pins
running some code on rPi
We can extend the power button functionality so Raspberry Pi can turn on and off our computer, while also still keeping the power button working.
Which is what I use to remotely turn on my computer on, by SSHing to rPi and running a script to turn the PC on while I'm away from home.
Why not Wake-On-LAN?
Wake-On-LAN has restrictions which makes it not as reliable as it could be, for example:
The ability to wake from a hybrid shutdown state (S4) (aka Fast Startup) or a soft powered-off state (S5) is unsupported in Windows 8 and above
The code and explanation for it in Part 2, when I get to writing it.
17 notes · View notes
mlembug · 1 year
Text
I checked out that post about restarting and what OP writes is one thing (his rationale is nonsense and also incredibly vague, so even in circumstances when it could apply you don't know when and therefore you fall into cargo culting), but somehow the replies are even worse.
Tumblr media Tumblr media
This person doesn't know what registry is. Rule of thumb: if someone talks about "registry" in terms of computer optimization you can safely ignore them altogether.
Also the whole section about "RAM buffers" is also buzzword nonsense. There's one thing that could potentially be called a "RAM buffer" and it's I/O cache (yes, the link talks about Linux but every modern OS does this because it's common sense to do it), except I/O cache being used is a good thing, and in fact your OS will attempt to fill it as soon as you restart. Unused RAM is wasted RAM. If your applications are not using RAM entirely, OS will use it for I/O cache. If you start using more RAM with your applications, OS will hand it over from the RAM used for I/O cache.
EDIT: I also missed out on "deleted files are not marked as rewritable until after restart". Holy shit this such massive bullshit of incredible proportions. To elaborate: deletion is what marks disk space as "rewritable" in the first place.
Restarts in general are done in response to a problem that could potentially be solved in different ways (but it's not always feasible to do so), but thinking that the problems arise from not restarting is cargo cult mentality. OP of the post talked about OS restarts which are needed even more rarely.
11 notes · View notes
mlembug · 1 year
Text
Random Numbers 101
(actually "pseudo-random number generators" but we'll get to that later)
Attempting to write for a general audience which is why I'm attempting to use simple explanations and focus on explanations rather than code.
How do they work
Step 1: prepare a bunch of bits (a seed), and from these bits, create the initial state of the generator
Step 2: modify current state
Step 3: given current state, produce a number from it
Example 1: MINSTD
Step 1: The state is a single 32-bit unsigned integral number variable. We don't know how to create a seed yet, so let's pick a number 23455264 as a seed.
state = 23455264
Step 2: Calculate the new state using the equation
(a*state + c) % m
MINSTD in particular uses a = 48271, c = 0, m = 2147483647
state = (48271 * state) % 2147483647
Step 3: use the new state directly as the output number
output = newstate output = 485166575
Done: this generator provides numbers in range from 0 to 2147483647 (exclusive, so it will generate every non-negative smaller than 2147483647). Want another number? Go through steps 2-3 again.
Example 2: Doom (1993) pseudo-random number generator
Step 1: prepare an array of 256 (hopefully) random numbers. The array is not part of the current state, as it is not modified during step 2.
rndtable = [ 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, # the full table is too long, here is it if you're curious 120, 163, 236, 249 ]
Also prepare an integral number variable. This is the state of the generator.
state = 0
Step 2: Increase the number by 1. If the number goes beyond what is an acceptable range of indexing the array, set it to the index of the first element.
state = (state + 1) % 256
Step 3: use the state to index the array.
output = rndtable[state] output = 8
Done: this generator provides numbers in range from 0 to 255 (inclusive)
Tricks and Traps
Generating a number from range 0 to N*N (exclusive) when your generator only provides numbers from range 0 to N (exclusive)
Generate two numbers using your generator
high = gen() # let's say N = 10 low = gen()
Multiply one of the numbers by N and add the second number
x = high * N + low
Because "N" (10) is bigger than any possible value of "low" (0, 1, 2, ..., 9), no two different generations of "high" and "low" will result in same "x". The lowest possible value of x is 0 for high = 0 and low = 0, and highest is 99 for high = 9 and low = 9.
Generating a number from range 0 to H (exclusive) using a generator that provides numbers from range 0 to N (exclusive), and H is less than N
Let's say N = 10 and H = 4.
Step 1: find the biggest possible integral number divisible by H which is smaller than N. Let's call that number S.
Here S = 8 as 2*H = 8, but 3*H = 12, which is already bigger than 10.
Step 2: generate a number. If the number is not smaller than S, throw it away and generate another one until the generator will get you a number smaller than S
while True: x = gen() if x < S: break
Step 3: Put the generated number into one of H buckets by using the modulo operation. Let this will be the resulting number.
b = x % H
Generated number: 0 1 2 3 4 5 6 7 8 9 Resulting bucket: 0 1 2 3 0 1 2 3 0 1
As you can see, if we were to not apply the step 2, before doing step 3, values 0 and 1 would be 50% more likely to be generated than values 2 and 3. Good thing we discarded 8s and 9s before doing that.
Pseudorandomness
We're calling these numbers pseudorandom because we used a fairly simple step-by-step procedure to generate them, but also it is fairly difficult to say what would true randomness be.
Tumblr media
We will never know if the devil creature will say something else than nine.
The two examples listed above were very simple pseudo-random number generators (PRNGs), but we have PRNGs which are good enough to generate numbers which must be unpredictable enough to secure your connection to your online bank. We call these cryptographically secure pseudo-random number generators. Explaining on how to use them will come in another post.
Picking a seed
We deliberately avoided explaining how to pick a seed for step 1 in both of these examples. Doom (1993) always picks 0 at the start of the level, but we have to keep in mind that using the same seed will result in the same sequence, which is why if we want to have different sequences, we will have to pick different seeds.
Two most common ways are using the current time, which is extremely predictable (everyone knows the current time), but good enough for quite a lot of programs. The alternative is using a better generator to seed our generator.
Picking a specific seed
The flip side of the fact that using the same seed results in the same sequence is that we can deliberately pick a seed to create the same sequence every time.
If you have ever played Minecraft or Factorio and saved a specific world seed to share with your friends, you know what I'm talking about.
Because Doom (1993) always uses the same seed and also has two separate generator states, one specifically for game logic and other for everything else, it can record your playthrough by recording your inputs and then replay it by simulating a player that rather than taking inputs from your keyboard or mouse, it takes input from the replay file.
8 notes · View notes
mlembug · 1 year
Note
yes please write more about programming! i love your blog and translation work, i didn't know you were a programmer. obviously don't stress yourself out in addition to your job but im sure people would appreciate it. embarassing saying this kind of thing off-anon lol
Thanks for showing interest, I'll try posting what I think people may find interesting, from a sort of generalized perspective first, and then maybe in the detail later on. I'll probably start first with stuff that is already done or has sat on my mind for a while, just needs pouring into words first.
I already used "#programming" and "#technology" but the first one feels too narrow and the second one could be too wide, so I guess the new tag is in order, for now that will be named "#mlem's computing stuff" as a provisional name until I come up with something better.
2 notes · View notes