This video demonstrates how to implement file processing and random line selection in D programming, covering key concepts such as file reading with file.readline(), random number generation using uniform random, array bounds checking, and proper file handling with file.close() and file.reopen(). The presenter shows how to create a program that selects random lines from a file, handling edge cases like empty files and ensuring proper resource management through scope guards and explicit file closing.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Live programming (I use Arch btw)
Added:Oh. Oh, yeah.
This is it, guys.
Welcome back to another text stream. [clears throat] Question mark exclamation point, comma, colon, exclam started with with that.
Wow.
Wowee, what a great new background. It's um it's like the other one. It's like that one but uh different.
My friend made this for me. So, thank you to them.
Um anyway, we're going to do some programming, but we also have to do some server stuff. So, we're going to go ahead and do some of that today as well. So, let me go ahead and power on the server.
You'll see it here.
When it turns on, you'll see a green light on one of the blue cables.
You also hear a massive amount of noise from the double GPU setup. I thought GPUs were silent. Oh. Oh, [ __ ] Explosion.
[ __ ] Explosion.
Okay, my server K serioso I'm spy.
By the way, I color code my cables. So, if you didn't know that, now you know.
It's partially why all of the cables are different colors. The gray one goes to my hosts and [ __ ] Um I think that's what I need, bro.
End map.
Yeah, give me that. I I don't go anywhere without a copy of N mapap on me. At all times I carry one copy of end mapap if not more.
So congratulations.
Congratulations.
Good job. Time to continue.
Oh wait, did I even check the audio test? Yeah, the voice of God. Beautiful SSH Heisenberg at uh 10.110.237.
Give it a second. It's just It's just booting up actually. Well, it's already booted up.
is just opening up my um stuff.
I have it preconfigured to launch. Holy [ __ ] bro. The CPU usage is like 0%. God damn.
There's literally nothing plugged into it and there's nothing enabled that's going to use a lot of CPU like, you know, Wi-Fi for example. So, this thing is amazing. You got that much. Then you got your two GPUs.
Arguably the most important feature of this server is the two GPUs. I see a bunch of migratics, but they're not doing anything. They're just sitting there. I guess they're waiting. I don't know. AMD GPUs. Only real thing going on. Barely increases GPU usage. You can only tell because the VRAM is a little bit up.
Anyway, so that's one of the things. Now, if I go over to my other side, if I hit controlB and I go and control B and I do a zero, take myself to the this is a mess, but um we we'll probably mess around with all of this eventually.
I just have to update it today.
And then um anytime I reconnect to it, you'll see that it will just take us to here. It'll be like t-mucks attach. So all I would do is I I'd type in detach or something like that like t-mucks detach and then um yeah that will happen. [clears throat] So anyway pseudo void no what am I doing bro? What is it? Xbps kbps. What is it? The [ __ ] Xbps dashinstall-su.
Cool. Yes, it's going to take a minute. So, meantime going to take us to the other side. Uh going to open me uh thingamajib Kate. Bro, we're we're going to do most of the programming here that we're just we're just going to use um SCP to copy it over. Thank you to the SCP Foundation for making this possible today.
Fastfetch.
What do I What do I have fast fetch in there? Wow. Why is Kate so [ __ ] small for some goddamn reason?
[clears throat] Nice. I can just watch it update. How how how the void machine so far? Void machine's good. What I want to add to my void machine is probably this thing. So every time I log in, it just spits a random bunch of information into one of those. So that way I have something to go learn for each day. So it'll be like a thing do thing. trans. Bro, also I realized you can have multiple this constructors with different things in them and you can add up unary for adding a minus and minus to the front. I was thinking what if we made our own version of that [ __ ] C++ cubes using classes and opinary and I'm like oh yeah, but is that something we really want to do today?
Also, I can send this to send files to the server too using SCP and I can just SCP them into the one directory. So, like if I go to my server real quick, um let's go ahead and do su. Now, I have no idea how updating on this void works.
All right, let's go ahead and clear the screen. So, ls drive to lost and found. That's all there is there. Now, if I do lsbk, you'll see I got my two different drives. SDA is a 500 gigabyte hard hard drive. I don't know. It It's beautiful though.
It's beautiful. So, um, how do you even measure hard drive health? I have no clue even.
What if I use smart? Is smart a tool have access to? I don't know. Anyway, smart hard drive health or some [ __ ] Hard drive health assessment.
I finally can hear you. My audio lost and void. So, I have sept DN my time or set my time in the wiki and the Reddit to fix the audio.
Red hats. Redat's the answer to most problems. By the way, guys, do you have a problem? It's probably on Reddit. Oh, actually, no. Not not the problem. The problem's not on Reddit. I think I think Lionus would agree with the sentiment that u Reddit's the solution to a lot of the problems. What's the small box? Uh, this is the router. I I don't know. I just needed something that looks cool for the video. And so, I was like, um, [ __ ] my 5 a.m. alarm, bro.
5 a.m. alarm.
But anyway, I just needed something that is interesting besides what? The keyboard.
So that way you guys have something interesting to look at.
[snorts] Bro, I'm just bullying this [ __ ] what what do you call it? Tripod.
The camera is mounted on some in very interesting stuff.
OMG, use Arch Linux, bro. It's It's Linus, bro. Look, it's Lionus.
Also, you should try more desktop environments for your needs or varying ones. Oh, I like this one.
I I've tried Flux Box and I've tried FVWM3. I like them both. [clears throat] Although, I feel like um Fluxbox is kind of lame though cuz look at this. I got menu stuff and I just click on the screen. I be like Blender, OBS Studio, VLC, [ __ ] Prism Launcher, my gamer tools. Bro, you guys have seen me set this up. Oh, yeah. Lus looking good. Yeah.
[snorts] All right, back to We could uh What are we doing? So, we need to do some stuff with DUB. Do I even have DUB installed? These are the questions I have to ask myself today.
But but before we do anything, um I want to see where we're at with jester.d and see if it's worth working on so I can add it to my server as a a greeter to my server and be like logging into fish server message of the day [snorts] and it just spits out some thing from the dedic.
And then it's just an excerpt from the dangling book. It's like be movie script.
That's that's the idea. I'm getting distracted.
So let's go ahead and mkdur slash uh drive to and uh let's make a dur called delaying uh backup I don't know it just created dlang in there permission denied So, pseudo ls/d drive2.
Nice.
Oh, wow.
CD drive to I wonder how this even works, bro. Drive 2/ain.
U CD to my home, please.
Heisenberg. Yeah.
All right. For now, I don't really need the server, but I turned it on. That's cool. Let's go ahead and get Kate open so I can start working on this stuff.
And I have no idea where we left off with this. It's time to uh also open the anime arch tab.
Xterm.
Wowee.
Uh cd/ lang should have projects in here. I think it was uh jester bro. Jarvin's failed. I like object oriented code though. Cat and then jester.
Oh, nice.
uh slash gesture core exceptionarray index error index zero is out of bounds for array length of zero. Oh, I know exactly how to fix that one. Cool. Back to the top.
So, what's going on is that one of these things is uninitialized. Which one was this? If I go back down, it'll tell me index zero is out of bounds for array length. Uh, D17. So, I guess it's on line 17. It doesn't really tell me what it is. Uh, 17 right here. Do thing.trans this.orgs.
Ah, okay. Well, maybe jester dash.
Actually, if we we'll handle we'll add a error handling for that right away.
Jester dash dlang fail. Okay, cool.
Uh supporter fail.
Nice. What's going Why is it failing?
Yep. Yap path.orters. Yipyap path.
Dealing. Then we were working on.
So yip yap is just supposed to spit out a chunk of text.
We're supposed to be working on open CL at some point. We have Okay, so here we open a file. That's going to be the part where it opens the file for whatever the path is which is enumerated up here in that. And so when that's called here, it just uses the enumeration.
This is also static. So I got to keep in mind there is a lot of there's a few rules of static. If you have a static thing like this, you have to do things in a very specific way. You can't really be like this dot and then call this dot from static. I don't think that works.
All right. So, rand equals uniform else write ln todo. Where does it do the fail?
H default path.fail.
So, path.fail.
Is this in a thing that handles that?
Like does eval for path.fail fail equals no arguments provide escape shift uh control S. No need to do the shift Z today. I I hope we can avoid Vim by just doing all the work here and then sending it over to there. Really trying to avoid Vim for the life of me.
Anyway, also are we doing f read ln when did I come up with that? Anyway, where where's the this fail go to?
Maybe is at the top static void trans file.
All these take string file though.
Technically, we could just pass it to like up here and just have it inside of this this.org.
All right, let's add in that that exception for if um technically you can add exceptions though.
Anyway, we'll just do use an if statement for now. If runtime or if this args Then uh do thing fail.
So we'll do do thing.
No do think that isn't it do you think?
Where do we call that?
Well, actually we don't want to do that because if it has nothing, it just goes and fails.
But this needs to be called before this.
Also, that will take this.orgs of zero, which is basically taking runtime.orgs of one. Although we don't really need to initialize this.orgs at zero. I don't think we should do that. I think that's kind of dumb. It just looks cleaner when you have this. Zero.
Honestly, kind of unnecessary, but also what why doesn't it take like all of this args and pass them into here?
Well, this args at zero would be okay.
So, maybe it has multiple args and we're just handling it that way.
You know, it's been like a week since I looked at this. Like, it feels like it's been a week. I haven't looked at this since last week. It's been ages.
No, we don't need to do that. We need to actually just throw the exception.
Um, so what it will do actually, yeah, we can just do Yeah, we can do this. This will work.
And then we'll just go ahead and uh do nothing, I suppose.
Uh we'll just put a string fail.
Actually, that'd be a bad idea. We'll just put path.fail, right? Because default would be write ln path.fail.
But then if you have a a directory called no arguments provided, what if we just did a break instead?
So it breaks the entire thing. Yeah, I think that should do.
Let's go ahead and LDC DMD break is not inside a loop or a switch.
Got it.
Um, so it needs to have at least one arg.
We know that much.
And you can't we can't we don't want to initialize it with that because it doesn't look clean.
Um exit one you can do though. Uh maybe return.
All right. Let's switch over to here.
Try it again.
Yeah. Okay. So, dot slash Yeah, do it. Index is out of bounds for railing zero. Uh, if okay if this.orgs.length equals then return.
So, that's uh one way I could do it is to take the length property.
See, nothing happens now. And what we can also do is before we do the return, we'll put this all in a scope. I I would really love to just use this. Um, but this is how I'm going to handle the potential that you don't initialize anything.
So um what the [ __ ] [ __ ] me failing right Ellen and then uh path do fail fel fail fail All right, cool. So, that should handle all of that. Go ahead and tab that.
God damn it. I'm thinking of whatever the [ __ ] it was. V. I'm thinking of Vim too much, guys. I need I need to stop viming so hard. Start cading.
Fail. fail.
I mean, it does write ln here. Right ln pathfail.
Okay. Guess I guess it doesn't do anything really.
There we go.
Fail.
Fascinating.
Fail.
It's just writing fail.
Right. Ellen path.fail fail should [snorts] give us that.
And these also fail.
But also, doesn't that just pass?
Um, this just passes to Does it pass to that anyway? Must it must just pass to that anyway.
Because if we do dealing, it just says 49. Oh, dang works supporter fail.
Let's see what's wrong with that. Maybe my typing was incorrect.
Ah, it's supporters.
Duh.
What am I thinking? Supporters three and one. Then Dang just gets like a [ __ ] huge ass number for something, some [ __ ] reason. Um, 464 89. Probably because it's using a different rand generator.
But it should just select three indexes, right? There's only really Oh, and uh the way the algorithm I made for this works is it selects a random three indexes.
So, um all we need to do is start grabbing lines from it. So, we have to write ln todo. What was todo exactly?
Well, todo is just going to grab out the lines and spit them out. Um so, todo, let's see. So, here we create our random number. Then it's going to grab like three or four lines.
We just need it to write out. Uh what was the numbers again? I was like, let's go back down and see what I'm getting.
See, three and one. And uh let's try it again.
Jester supporters two doesn't ever give you three. So it never gives you like the last index.
Okay.
So the way this works is it like reads through each line and then it creates this if file equals equals path.sup supporters and then it says rand uniform equals cast or is a casted uh short one. Oh, so I cast the uh short to one gives me a uniform which is basically to say which we make file size earlier on. Where's file size initialize? File size is made like here somewhere for each string plus+ file size that increases file size and it writes the line file size. For example, if you looked at uh whatever the [ __ ] it was, the other one writes the the the size of the file size is 4,648 lines or whatever the [ __ ] 4600 489 lines. It's a [ __ ] ton of lines. Um huge number, big but not as big as bigger in which I was working on.
Actually, it was called you bigger. The biggest int of all time. It's gonna be 128. No, it's gonna be 256 bits. Bro, eat it. Nerd. My massive ubigorant number will be amazing. It's going to be a class. By the way, CL object-oriented programming has given me such great things like constructors.
Sorry, I'm getting out of my brain cells. Anyway, you need to import standard out random uniform and then call that here path.orters write len rand. So whatever rand becomes maybe I should do file size plus one to indicate that it can be a little bit larger and then we'll recompile. So that way it can take the lines of the file.
And I think I have it's this one.
Okay.
Nice. Good job, viewer. Yeah, three lines. Technically four. So cool. I think it will work. If it has three lines, it will be like, oh, I can do all the way to this one. Generates between the two numbers. So that's why it's like 50/50 right now which number it's going to create and that will basically be the one line it's going to read since this is going to all be like one lines that's why I have it in the if statement cannot implicitly uh and then of type into you short god damn it is file size Why is it not you short? It's short. It says you short there. I guess I got to cast that to you short. You know what?
[ __ ] that. I'm just going to have a constant short one stored in memory.
Congratulations.
You're a winner.
So, we'll just create cast const.
Actually, no. Just make a con uh con constort and then just put uh one I think I don't remember how to do these consture uh fish fishes uh constant.
No, it's like Schroinger's constant, bro. No, the Heisenberg uncertainty principle.
Uncertain.
Uncertain. I like that.
Cast or consture. Uncertain plus uncertain.
Is that how you spell certain like certainly? I don't I don't actually know.
I see. English grammar is not something I learned. Anyway, save that. Hopefully, that's how you make a constant. I forgot how to do them cuz I don't ever use them usually.
Uniform cast.
Uncertain.
Okay.
Oh, there's a cast.
God damn it. Who left the cast there?
Anyway, yeah, it looks like it doesn't care about the cons being weird looking.
cannot in convert. Uh did I say uniform countort type int to ushort? What the [ __ ] do you mean int to short? It's a uh short.
It's a const. How is it changing? In what way does it change? What?
Cast int file size + one of type int to uh short cast immutable. It's not going to change or something maybe. Um [snorts] maybe I initialized the constant wrong.
You short const.
Maybe it needs to look like that.
[clears throat] I say it probably does.
God damn it.
It's killing me. My short not constant const.
Bro, my brain cells are damaged now.
Consture equals uncertain or name uncertain equals one. Okay.
Is file size a problem? Right. Fi file size scope initialize rand file size and rand for each string of i lines f. So for each of every lines of the file and so go down.
Oh my god, my brain cells are leaving my body. They're being expelled in the atmosphere. All right. cannot implicitly convert convert file size is a [ __ ] u or casting itself to a uint.
Why? Who says it needs to cast uint?
Bro, I don't want to cast to a uh short.
Why? This is lame. Pseudo lame.
It wants me to cast to keep it a short, bro. It's default thing. This is This is my brain cells.
Cannot implicit cast you short. Cast in.
What? I just added cast you short. Are you K serioso?
This is amazing. Wowee. Wowee. Okay, here's what I'm going to do. We're going to take file size and I'm going to add one.
We're going to we're going to keep my keep my con uh short uncertain equals [clears throat] 1 because I think it's funny. And instead I'm just going to create uh I'm just going to add one to file size as it exits the loop. No matter what plus+ boom.
So um now the file size should be plus+ one before it enters. So that that that's amazing. All right, let's go in bmdest.d What you short of type int to short?
I thought I said that was a constant.
My Schrodinger's constant does not work, bro. Or Avagadro's number does not work, did they? He quit.
All right, you know what? We're just going to cast you short, then cast your short, bro.
Okay. Jester.d bro. Uh, and jester runs and it gives me fail.
Now, let's do supporters for all my supporters out there. Now I'm getting random lines generated for every line that's in the file.
So, we need to add more lines to that.
And if you want to add more lines to the supporters file, feel free to do so. All you have to do is um I don't know, become a supporter or something. Oh, I'm shilling, bro. I'll put shield hard or something. But anyway, yeah, this is from a viewer, so we put that in there.
It's basically any like thing, I guess.
I don't know. If if you support in any way, I'll just put put it in here. You can just tell me what you want. Be like, "Oh, yeah. I want uh you to write this in here and I'll I'll write it regardless of what it is. Uh so as long as it's as long as as long as it's not something too terrible or evil or something like that, I'll I'm sure nobody's going to come up with well depends. Just just u no slurs or stuff like that, I guess. Otherwise, I'll put it in there because who am I to care destio?
Coolioso. So, we're ready to um implement the next feature then. So, now that we've got rand, we're going to select a line from the file. So this one should go for each from I semicolon zero to rand which is created here. However, rand is initialized here. So here's here's where rand's at where it starts. You can see it's inside the main scope which is because it's a scope guarded. It's up there. So that means that when it gets to here for each from zero to rand and then for each I from zero to rand and you also can't initialize I'm going to Rewrite this and use a for loop. If I equals equals rand, write ln.
Oh, okay. So this is working.
However, so write ln file readline.
What?
I bet I can do file readline. line file [snorts] that freine.ight line.
Goddamn. What the hell does it want to do? Right line or reline? Both. Doing all of the above and then some extra extra.
I guess I should retitle this video creating programs to rice out my server because I mean technically that's what I'm doing. It's going to rice out my server. But why no workie? Let's go ahead and write ln I and put a semicolon afterwards and then hit controls and an escapes on that thingy, bro. DMD gesture.d supporters 0123 for each from zero to rand.
Ah, that's why.
So, instead of doing that, just go to file size because I had the logic wrong.
So, that's going to go to file size. So, now when I run viewer, it will just give me a random line of the viewer file. So hopefully the viewer files are clean and and good. Control S and work out too good. Yeah, works really good. All right, supporters 410.
Just what what room? went hold on I need to read the that and redm hold on I'll check your comment or the message in a second slash okay it gave it it actually is working is it is it actually work oh it is working cool it's working very strange though what's up PewDiePie uses Arch by the way Archin yeah That's uh Yeah. Oh, have you seen my uh Lionus Torvolts backgrounds? It's inspirational to me.
Hold on. H my Linus Torvald's background is my inspiration. Very nice.
I don't know why I have it set up like this, but yeah, sure, why not?
Anyway, I'm writing my terrible objects oriented code.
Why is there an else here?
What about what if the else statement is ah that's probably why it's not working.
No, no wonder there was an else statement.
If file Oh, actually, no. Oh, it would work because that cuz if it's this Oh, but maybe it's not executing the rest of the code. There is no thing in the else parameters.
You don't need an else statement there either. That's just going to select an endpoint kind of. So really, I don't need that.
Get rid of that.
Crl S.
Go back down and compile on this page.
Dot slash gesture.sup supporters.
Just go ahead and DMD that thing. Yeah.
And then todo. Aha. See, now it's executing lines below it. Although it still looks a little weird.
Just got to keep hitting it until eventually it selects line zero.
Uh, I think it's because what it's doing is it doesn't actually give you an option to have a a zero. Um, let's remove the to-do for now because eventually I'm going to need to add one of these that does the same thing, but what will just be in another if statement pretty much. So if the file uh if file equals equals path dot um should be at the top of the class path dot dlang then it's going to have to choose like a couple of them. The god Linus the god Gab Gabin Gabin mentioned.
So it will have to count back and stuff.
It'll have to like it'll have to like decide where to end and start for a file. I'm like file readon with this thing, but it's going to give us an excerpt of the dlang bible. So that way we can uh learn something every time I log into my gigaserver TM which uh you can see here. The giga server is up and running.
Still works weird. Every software still works a little weird. Every software developer ever.
I mean to be fair, I mean expected behavior is just random accident.
[laughter] At least that's how I see it. All I do is just slap a few lines of code in there and it doesn't work. I'll keep doing that until I eventually hit the point where I get my expected result.
Just tweaking every line of code until I get there.
So from zero to file size. Here's the thing. In this file size is plus+.
So, um, instead of doing plus+ file size, we'll just do some kind of counter.
So, file size equals I guess file size equals I.
I hope that works. But that's a string eye.
So you I don't think you can do a for each for this either. But this would be how I how do I how do I do this? I guess you'd have to do a count, but I'm not doing that.
We're going to add + one for each line.
So, but the thing is is that line zero can never end up in there. So actually no because it's a random number based off of that.
So the random for paths supporters should give us a zero.
However, because it might not maybe I have to subtract one from rand.
No, I don't think we need to worry about incrementing this because it just it's just used to sort of generate the random number. So, I think what happens is when we get to rand, we have to subtract one because otherwise it's out of alignment from the rest of everything. I I think that's what it is.
So, maybe you just subtract one from it.
Obviously, we add one to file size.
That's probably not the right answer.
That probably explains why it's so out of sync is because RAND is generated off of this. Um, so if it because it will never be zero. We know that.
No, it should be fine. It's that's default for D is it initializes as zero.
I know exactly what to do.
Should be minus equals rand or no just minus minus rand.
I learned about op oper yesterday where you can add your own operators to your own strus. And I was like, I'm going to make biggerant eventually. It's going to be 256 um bits. So be ready for my 256 bit biggerant number. It's going to be like big but bigger.
Anyway, I've created my very nice code today. I think this should work. So let's go ahead go ahead and compile.
Yeah, look. It gives me zero there.
Perfect. Question is gesture. Dlang.
Oh, wow. It just wrote out every single line of [snorts] that's great.
But is it selecting the index? So we we're getting we're getting that. We need to write the line for the thing big begins.
Yeah, massive int.
My huge int, bro.
H.
So, we need to read the line though. So, if I equals equals rand.
So, when we do this, let's remove the right ln because it's kind of making things unclean. So, I can't really tell what things are. Either that or I have to re redo how I do my right lines.
Let's go back down three 0 and then it just puts out a space.
So what's on index zero?
Viewer zero should just be that line.
But uh what if we wrote out what the strings are?
write len and then put string or actually write len I I want I want to know what the strings are too that's something else I need to do I want to see what that is because that might help me understand what it's doing me forgetting to so supporters that's the file path ass.
And then there's just a bunch of blank space in there. What if I remove some of the blank space? Why is there blank spaces though? What? What is that? Hold on. So, we only have this really.
There's There should be no blank spaces.
We really need to get more viewer quotes or supporter quotes for that. My bad.
Oh. Oh, maybe it has a new line character at the end.
Maybe it writes the new line character.
Ah, but if we were to do f for each and then it does f read ln.
What if we initialize a string and then just assign it f read ln and then pass the string to a right line inside this.
That might be a bad idea though. I feel like it' cause a lot of problems because it would potentially use a lot of memory. I I don't want to do that.
Um, if I equals equals rand, well, does I ever equal rands? Then that's the real question. So when we get to that, does I ever equal rand? That's a good question to be asking. Now, so if I never equals rand in that case, then we know something's wrong. Um, I equals equals random I guess I could do write ln I equals equals rand.right Right, Ellen?
Because there's a weird reverse syntax in vine where you can true false.
Okay.
And then comma actually don't do that there, comma.
I I also put a space in there. So like space it out.
All right, let's try that one.
True and then false.
So it said line two hits true. Oh, it says rand is two zero true zero. So in line zero it then it writes the line. It's not even taking anything out of the Let's try the other technique I was thinking of. String line equals F read and then just write ln for the line. This is messy, but I I it is what it is. If I can't get the line out somehow, we're just going to have to do that. And then maybe I can do manual memory allocation for these, but I don't know. I don't think it actually I think at the end of each for each loop I think it just deallocates that. I'm not sure though. I should definitely check that.
That's something I need to know and make this look prettier.
Keep the string away from this and the if away from that because eventually it will look really nice. I'll have it looking beautiful.
Yeah, it's still nothing.
If I equals equals rants, it doesn't even return. Maybe that's basically how you would exit.
Maybe it needs a return.
So now it doesn't get to that part where it checks false. That's a good thing I just noticed. Um, let's try writing file uh writing it here. Maybe it just doesn't want to write the line.
Maybe I'm doing that wrong. Maybe it doesn't even have that initialized. No, it's got that. It's a global import.
Hm. How the How the hell does this not even really work? Maybe file isn't open.
Well, file clearly is open.
Maybe it can't do it from a for each loop. Like maybe it's like weird.
We do it here. We We have it here.
Let's try switching to a for loop, which is probably not awesome, but it is what it is.
So, four and we can initialize int.
Uh, let's just do a short or actually, why am I doing though? File size. File size should never be more than you. Anyway, we don't need a super big number. Yeah, let's go ahead and do U short I and then put I ++ at the end.
Switch it to this. Maybe that gives us better results because maybe it's having trouble with the for each loop doing it even though for each looks really nice and the more for eaches you use the more confused those beginners will be.
Uh let's see found dot dot when expecting semicolon maybe oh it has to be initialized differently um I does not yeah it has to be like I does not equal.
So as long as I does not equal file size.
Yeah. So if technically, oh right, technically you could do rand here and you would just parse all the lines and when it hits that line, then you just boom. Or we do an if statement that creates that and then we write that one. Anyway, we'll just just play around and see what we can get.
Still no worky.
All right. Well, then let's try reading lines of the file. f read ln inside this loop. And then write ln.
There's a lot of right lines here.
Crl s. Maybe we complicated it by putting a string line equals there. But we are getting closer slowly.
It just finds a blank space.
Maybe maybe don't minus minus rand maybe if I because I'm minusing minusing rand.
True.
Hold on. Did I DMD it?
Yeah, it's weird. Okay.
Let's just do minus minus rand again.
Okay. Let's see.
Uh, should we change that? We change that.
Am I dumb? Maybe the if I it's writing. There is no read lines though.
Am I misunderstanding f readm?
Does it not have read access? It has read access.
Let me see. Let me open up the ah f read lnm dealing.
All right, cool. function read line read line from standard in uh let's See, okay, that's not an example of how to use it from file.
Where's um where's where's standard diio?
Maybe it doesn't have it imported, so it just doesn't do it. [snorts] What if it needs the number to be passed to it?
Scroll down. Where's the standard standard DIO IO stream, bro?
StDio. And inside we have read F We need to go to file.
Bro, I've read a lot of these.
Just scroll down. Wait a second. What?
It's been changed. I don't remember it looking like this.
Name it is open. Detach.
Lock.
Opa sign open. Pop open raw read.
Interesting.
Rewinds calls rewind file handle sync to be any any data buffered by the OS to be written to the disk. call flash before calling this function to flash the C file buffers first.
I don't know what that is, but that's [ __ ] cool.
I I don't know why. Warp file.
Ah, read ln data reads a line using formatted read.
Oh, okay.
but return it as a specified type a terminator like null terminator. So read Ellen can also do that but also reads it to a buffer I guess if you want it. Oh because if you have like a massive file you don't want to just read the entire file.
We've messed up read and roll write.
These are important for writing binary bits parameters by default line terminator.
Oh, okay.
Interesting.
There's a D car in there.
All right. So for each well standard in readall inn buff it's putting into a buffer buff0 zero equals nothing or like a hashtag then oh interesting standard in readln oh but that's how they initialize their file so you can see that or maybe They're just reading from the standard input H.
Yeah, it's a file.
EOF if line.length greater than buff.length length buff equal line.
Then add that towards line.split.length.
Oh, nice.
Well, I didn't really learn much.
Although maybe I'm calling read ln wrong. I need to get called to a buffer.
The buffer is a car array buffer or can it be a string buffer?
So, I guess you could do a buffer.
But, um I don't know.
We'll just try using a a line for my buffer.
And then I'll just put read ln and we'll put it into line actually now.
Oh, you know what it is?
There's only a few ways you can call it, but it's not incrementing the actual line in the file.
See, it needs to do file.c close and then reopen the file.
I figured out because you read the file, right? You're incrementing the line.
So the second we get done with that, we need to call file.close.
So for each string of i lines plus+ file size write on file size. This is where we need to call f.close.
So let's create a scope.
[laughter] Let's not do that. Let's just remove the scope exit and just recall f.close. See, the thing is is that actually maybe we do need to have that there just in case.
But um regardless, you should put F.Close here. Okay. So F.Close needs to be here. After No, no, no, no. After not doing that, don't don't do it there because then it's just going to break. But um it needs to be on that like right after that. So we need to call F.Close. close and we need to reopen F.
So [snorts] I guess reopen it.
Hold on. There was something ah too late now. I'm not reopening that tab.
auto unless f.close doesn't um hold on. Is there filereopen?
We'll just use file.reopen. Read open.
Reuses the file object to either open a different file or change file mode. If the name is null.
Let's see about file that close.
Okay. And as you can see, file object.
Oh, file object. This different from detach.
It always closes the file.
All other file objects referring to the same handle will be closed.
We'll see a closed file henceforth.
I see.
So reopen would just be to open it again as another file.
[snorts] Hey, we'll just do I think file.c close and then we'll just autof equals and it will tell me if I'm wrong. So that's the great thing about a compiler is it can't compile if it if it thinks you're wrong.
I don't think there's a file deconstructor. Imagine imagine file de file deconstructor.
It just atomizes all the bits.
Reopen it with r access.
Okay. Okay. And that should just be what I need to do. So this block here just reopens the file unless there's file.open.
But I need to reset the line count. So see because that's what happens.
And so I think that's what I need to do.
We don't need to do f read ln. We don't need to do all of that. We just need to write ln and then we need to put an f read ln here.
Save it. So that means every time it does that it will do f.redellon and it will then write the line of f.redell.
variable f is shadowing just a few thing. Yep. Yep. Figures.
All right, we'll try f.open.
Maybe we'll try f.reopen.
Oh.
Ah. F.open R.
It needs a um R. I think it needs that.
Let's see. Is it Is it asking for a string?
Write ln lines.
F read ln.
All right, it should work now.
Then we'll make it clean again in RB.
Can I open file R?
Oh god, he wants a path.
Oh.
Uh, f.open just means reopen. F.
Let's try reopen.
Understanding standard.file.
No property reopen. Okay. I think it needs to be lowercase.
>> [snorts] >> using argument types um for string name this file and the yeah this is this is kind of dumb though. Why am I why am I doing all this? I feel like we'll just do it simpler because because [clears throat] I'm not trying to So, we'll get our file size. We have that. We got our file size.
Jesus, your background is AI swap. Have you guys fully brace embraced AI swap?
Bro, this is linols.
It's beautiful.
How dare you?
Anyway, I just think it's funny. It's funny background that my friend sent me.
I was like, damn.
But uh anyway, back back to it.
Let's see.
Read line.
Uh, [sighs] where was I at? My brain just stopped for a second.
I think the problem is when we read the line and then I'm guessing it just counts up here.
What if I did a second for each that writes out every line and then it goes, okay, well, now that we have a random number, let's redo this whole entire for loop because it's just shitty. Anyway, um, instead we need like a for each loop with a counter that also is able to do the four lines.
The other option is to do while not end of line.
I wonder are we at the file end of line write ln foof which is a boolean so it should just write a true or false statement um we're pretty good on random uh what am I doing eof F.
Cool. Why not do that? Oh, yeah.
Try that out. Yep. Exactly what I thought it was. So, what we need to do is close and reopen the the creotone of Lionus.
[snorts] So we have eof is true on scope exit file.close.
So that just means what exactly? So it just closes the file. Um, we might have to pass these out of this and then somehow reopen the file.
But with I guess maybe yeah, guess maybe I have to just reopen the file and then start the line read again.
But that just means that my original code will work. So, we'll just change this back to for each. And then we'll just do a for each of I from 0 to do file size cuz this is terrible and hurting my [ __ ] eyeballs. Um, so it incremented all of the lines of file. That's cool to know. um to file size and if we need to add a one to it, we'll do it here because I don't want to do all the dumb stuff. It wasn't this initialized as stream, was it?
See if this gets us back to where we were at. This is why you should keep a a copy of your files, bro. So you don't end up doing this stuff.
Still true. So yeah, still at eof. Um, unless we read the file backwards and decremented it.
Yeah, that's a bad idea. I don't know why I'd think of that.
We could also try moving all of that into this portion.
So like instead what we would do is this. So since we can't reuse the file, we're going to do a lot of fun stuff today.
By fun stuff, I mean things that I'm absolutely going to hate doing because I I really don't want to have to do all this. But uh you know, sometimes it's okay to make a massive change to your code and uh enjoy it.
Enjoy the massive lines of code that massive lines of changing. So that just means on scope exit file close. Um this we're getting rid of all of the tabs and indentations today. That's right. There will be no scope cards in my codebase because because you don't need scope cards for this. It's It's literally just just a function.
So, lower everything down.
This is why I said I was going to enjoy this because I am enjoying it so much right now. Can you tell?
See, the scope guard was over complicating everything.
We only need to open file when it's like necessary to open the file. So, that's what I'm going to do. Um, are these lower?
I'm confused now.
This is why we don't we don't do such things as this. All right, so here we go.
Looks a lot better, right?
And then I got my for each. Ah, you know what? It looks weird. I know why it looks weird. Boom. Save it.
Beautiful.
identif Okay, see that means good things have just occurred because that means that there is no longer a file readm. So all I have to do is create another scope which has that as a feature. It's a it's a feature.
Wait, is this Oh, right.
I'm confused. Do I need to tab it all again? I thought I just untabbed it for for good reason.
No, those need to be down one. God damn it. My brain cells are leaving my body.
They're being extruded as a paste.
Fine paste, bro. All right, cool. So now we got the file size and RAM initialized here.
Cool.
And now all I have to do is reopen file, which I don't have to really reopen anything necessarily. All it is is just redo the whole auto file and put it in this one as well, which might not be the best because it has to open the file twice, but I suppose it is what it is.
So, um, no, no, no, don't open the same file 20 times. Then we'll be stuck there for like ever.
Paste it. Pasta.
So there's my beautiful, beautiful code.
It does a lot of beautiful things.
Reopens the file.
All right, cool.
Last line.
It took me this long to figure out what it was doing. However, Rand is not Rand anymore. Where's Randy?
Random.
last line.
So, um that needs to happen as well. We need to plus our file size.
How is this fun?
Bro, all this is Bro, you you came here, bro.
Why are you saying it's boring?
Bro, you chose this, man. I'm just saying you chose to watch this. You're watching a guy program.
Very interesting.
Anyway, that should be good.
God damn it. Why I snake case it, bro?
Yeah, bro. On the weekends, this is all I do.
Last line.
Interesting. My brain cells are rapidly quantumly uh dematerializing. What was the file size again? It was like four lines. Oh, it said three lines.
Why is it always choosing the [ __ ] last line?
Is it just doing file readn?
Actually, let's go ahead and read ln to a So you can take make a buffer read ln. Uh we'll just put a string. I don't need a string buffer. What the hell?
Uh so write ln i equals rand. So it writes that there and it's like write f.
read ln.
Maybe it's because I'm doing read ln every time and I only need to do it and then I just need to read ln and then put it into a string uh string uh match equals read fra.
Bro, I can't even spell math C.
Uh, yes. Math C, right? Ln match.
And I can just put in match right here.
Nice.
Then return. So that way it doesn't continue.
That should be it.
Question mark exclamation point comma colon exclamation point comma.
Last line.
Good.
[laughter] This is beautiful.
How much Bill Gates pay you?
[snorts] So, right ln I equals rand. So, no longer do I need any of these right lns.
But now we've created a way of doing that. And we also don't really need to do much else besides this. Although this is going to become an if else statement because now I need to add in dlang. So if we go to dlang, it just reads out the numbers of dlang and I don't really want that um because that's [ __ ] terrible.
So we need to add if file.path supporters might we could just turn this into a function anyway.
If file dot what is it or what is it path my brain cells uh path dot oh it finally equals pathport why would why wouldn't we do this again bro every time you say cake it translates or or cake it translates to take I think it's beof under a different name.
Oh [ __ ] All right. file equals equals path supporters and then why am I doing this twice?
I mean I guess I do need to do it twice.
No, Rand can just be anything from there.
We don't need to worry. Why is Rand in that bro? This doesn't need any eval.
This is just kind of a no-brainer. Rand just exists, bro.
See, RAM.
So, that's how we're going to do that.
We just need to initialize file size first, which is all of that block. And I can remove the right ln file size as well.
So, that way we can do that.
Hello. Hello.
Every nickname with a number is a bot.
Truly like TH3 fish. Whoa, whoa, whoa. What are you saying, man? I haven't I haven't finished I haven't finished my super AI cluster yet. I haven't been replaced yet just yet.
I I keep knocking the camera tripod around like like this one.
Windows 3 uh one lover is back.
Me knocking around the camera is awesome.
So we got to here. So if that equals paths supporters else if So where is that at? Where does that end? Okay. So, we add an else if and we can do uh file equals path delay.
And that's how it'll do its actually.
If the path doesn't equal that then just to actually yeah that way if I had different files I wanted to put in for paths it just automatically knows what to do with that. Does else need a um need a thingy?
We might want to do else if anyway just because uh I think we'll do it we'll do else and then do do a scope after it. I think that works.
Then I can have this.
We're going to copy that.
And so we're going to use file size as an endpoint and we're going to read the last three lines.
Although in this case because we're not reading the file backwards, which is um which one does that go to? Where's the scope end at? Where does that go?
Okay, that's not supposed to be down there. That's it needs another one.
Needs another closing bracket.
Where do you go to? Oh, you go to that.
What do you go to? That. Okay. What about What about you? You go to Oh, you go to that else. Okay, cool.
Is Windows 3.1 better than DOSs?
You know, some people usually run Windows 3.1 in DOSs.
There's like a thing called DOSBox I heard about yesterday. I don't I don't know what dossbox is but it sounds interesting. Honestly I think doss is interesting else and then we have our thing here.
So instead of doing match we need to create a range and it needs to be if I equals any index within random or like if I equals equals 0123 or something like that.
I guess we don't even need that anymore cuz we know that the um supporter string works and that's just one line. So it only reads one line at a time. Um cuz that that that one I get to make. So that I can make it easy on myself and just make it one line. One liners. Um many liners. Let's see.
So here does that matches the thingamajib right ln match if i equals any index of rans like if I had like rand minus Maybe I need to increment have have an increment for it to like count it up for every match it finds.
Let's say for example we have like a ushort array. Uh not usort go with you bite.
And um actually no not don't do that.
that that'd be a bad idea cuz what if it's what if it's a massive we we need to use a short array with like I don't know let's say five lines and uh equals a slice of any let's just call it any and uh put 0 rand Or no any of five to rand or for example instead rand - 5 to rand uh minus 4.
So that will be zero will be rand minus 4 and rand will be five and that'll create our ramp. Um and so for each of those like that's kind of what we want to do.
But the problem is you need to have it within an or statement.
So that's not going to really work.
Well, actually, we could do a count here a second counter.
I wonder if I can do double I.
So, instead of I I equals rand, that's the um secondary one. So, anything that was I before needs to be that. and then rand of I.
Let's try that out.
And don't do a return this time.
Now, if we've incremented i and equals rand.length, then we can just know that it's time to exit. So, we'll put a return on that.
>> [clears throat] >> If I equals any uh equals equals 5 because we know the length is five no matter what length is five. Even if I is initialized at zero which I is a ulong by the way as well as that one they're both ulong. Um but if but if they're initialized if they're at zero then of course that is going to apply which ulong is the maximum 64-bit uh data type for numbers for integer even though it's not integer you just say inure because it's it's ulong. Ulong is a ulong not an integer but it's 64 bits.
Um let's see I if I equals equals that then return.
Um and then also for each of those technically we don't need to do this you short any um instead we just do equals if I equals any actually I guess we would need to do that because it would need to have the this is kind of a weird way of doing it. I'm sure somebody has a better way of doing it. Any of I.
So that will just be the index and then plus plus I.
This is one way it would work. The problem is I is initialized there.
So um instead we'll just do we'll create int i on the outside. And we're also going to need to do this before we get in there.
Oh [ __ ] Comma semicolon and uh u u short i cuz that's going to be like 32 bits. I know that's uh it's over 32 bits, isn't it? Wait. Wait, what is a ulong? Oh, well, actually, no, this is 16. Oh, that's 16 bits. Okay, cool. So, we're only using 32 bits total.
Well, actually 32 * 5 bits when we initialize this. Although, once it exits the scope, it should just destroy that in the garbage collector.
Still, I don't really like opening a file and having all this in a string and all that. Well, the string should be like destroyed with every single operation of the for each loop. So, every time it hits the end of the scope, technically it has to return back. So, that string should just get reinitialized and reused or something along those lines.
I'm pretty sure this is as effective as I can get it.
Although, it's not going to work.
So, um odds are not going to work.
And if it doesn't work, we'll just have to write out I and I want to get uh I do or actually any.length just write out any and uh give me the i value.
That should be good.
So now if I go to here, okay, I see that is kind of annoying.
Plus, it needs to be a dot dot right between them.
That should do it better. See if that works.
Separating an array and initializers.
Okay, we'll redo it without using array.
That's where I'm at with that.
Technically, we still need the usort I.
Okay, that makes sense. Okay, so what's going to happen? We're going to need the short eye and um instead of using any, we're not going to use any array initialization at all. It's kind of wasteful, honestly. So, um, we're going to still have a write out for I make sure to put a space there.
We're still going to have that. Uh, it's going to just write all this information. So, if it's II equals rand, uh, which will be just a random number. Technically, I don't even need to write that out.
We'll just write out if this is fun. I like that.
But anyway, the reason I was using any of I is because it's like Yeah, there's clearly not great ways of doing this, but I is just going to equal rand and then but that's the problem is I either need to make it equal to a range cuz I is never going to equal the range from this to that.
So what we could do is when it equals that we exit the for each loop. So here's what I'm going to do. I have a better idea that avoids initializing a second uh short called I and instead it brings us to creating a second loop. also avoids this val handling for that. So instead if I equals the value of what we're looking for which is rand minus one. We will exit to the lower level or the lower scope and then we'll enter another loop from there. It's kind of interesting. So uh return so return there which should drop us break and if it equals that minus one that should be fine I think I'm going to get rid of this and then we're going to move everything else into another one.
So that means that if it's less than rand minus 5 however we can go for rand minus 5 and then create another for each loop which handles the rest which this is a easier way of doing it with less thinking involved and then enter for each i from although this needs to be passed to the next one as um ushort i semicolon and uh there's no initialization there. I think you can get away with this and then do for each zero to file size.
Although you still need the read line cuz that keeps the file incrementing. F dot read ln.
So if it equals that and then this minus 5 then for each I we're going to read.
Oh, right.
I guess I passed off to the next one for each I and then continue on and just do the next one. So uh but the problem is then we're handling I here. So let's call that one I I create double I. I think you still need that there though.
I equals rand minus 5.
Otherwise read ln and plus i because that's going to keep our count when we go to the next one. Then we do our for each.
We do plus uh we will plus+ I I again somewhere in there. We'll do the same things. F dot readal ln but we're going to be writing that. So we're going to do string match equals f read ln. And that will give us our read lines.
Yeah. So that creates plus+.
And then I just got to write them out.
Um because those will do it. Uh and we'll only do 0 to five.
Zero to five.
Hello. How are you? I'm doing good. How are you? Um I don't know. That's weird.
I I don't know. I don't usually ask people how they are, but uh what's up?
I I streaming and I think we're good. Oh, me being dumb. plus+ I I so I I plus+ it'll be the next language to be sloppy is I can't wait for i lang bro I wonder if there is an i programming language oh god I programming is it a thing is it real IO is a object-oriented object-oriented.
Thank you for AI overviews. Whoever invented such a thing is a genius rle learn programming Python. No, let me post Dlang. I sold Java.
Java, bro. No, don't don't do that. It's [ __ ] terrible. I started Visual Basic around 1995.
Wow, that's crazy.
Use what? Uh, I use FVWM3.
I can switch between desktops. It's really cool.
Well, desktops actually, it's a window manager. My bad. Um, yeah, I just use a window manager and then I set everything up uh on my own. So, I use FVWM3 though.
I can switch I can go to uh Nvidia land or um the Linux Linux Deluxe.
So, I have many many desktops in one essentially. It's nice. I like it. It's like really simple and works out pretty well for me.
It's like the the coolest setup I think got got on KVE users out there being like, "Ah, yeah, KDE."
Um, we're going to just put a very simple if I I or it should just return if it's zero to five because I is going to add every time. So like that's literally everything I need to do. There is no need to add a return or anything. So this is everything it needs to hopefully work as all the programmers say. And I've wrote 106 lines of code in my class.
Message retracted. Oh, damn.
Oh, nice. It just it just compiled.
Thank you for this.
It works good. Jester deal.
It is selecting a random index.
The problem is now the problem is simple. What do you think of hyperlink? I think it's interesting. I haven't really seen much of it. I I think I tried it once.
Let's see.
How is this handled?
[cough and clears throat] Write on path. And then do thing. Yep.
Yep. Path. Dline. So passes off path.blink with. So when we get into this should be passing use short file size.
I guess maybe I need an else if.
Man, I don't want to do an else if for that. That's lame.
So, it does write the random number it generates, but it doesn't get into here.
Dline. I've tried others. I've tried like V and Odin and stuff. I really want to get back to V, but we got we got big things ahead of us. Big things as in giant machine sitting behind me that's making a lot of noise right now. I don't know if you guys can hear it, but the most beautiful machine of all time, the GPUron 500. We're going to make some great things on this. I've already come up with ideas on how I can use these GPU buffers for unintended things like I don't know packets and servers and things. Very interesting stuff. Packets.
I got ideas potentially using it to communicate between um the smaller ones or like communicating directly to the GPUs bonnets. This machine is very nice.
It's idle at zero.
[laughter] It's literally doing nothing in there.
It just sits there doing nothing.
Bro, I just like to look at this thing.
Void OS, by the way. That's what this one is. Oh, we've had it up for 4 hours.
Is that up time or That's the time right now. Oh, okay.
Wow. What does this button do? Can I Can I click it? Oh, that's just the time it updates. 200,000 milliseconds to update.
Oh, so it's doing it's doing like a watch dash N2 or whatever.
Load average 0.01.
It's it's idle right now. It's waiting for me to tell it to do stuff. Drive two 476 gigabytes.
Anyway, I'm going to make that tiny.
Send it to the background to the back rooms, bro. Technically, I have multiple layers, too. If I wanted to click on one, I can just go to window layer one.
So, I have six times four desktops essentially.
Pretty much 24 different desktops I could use because there's four window panes and six desktops.
Very nice. We I think we all understand math, though.
else execute this code and it's in a scope so execute this code in the scope and maybe I didn't write it in there good I mean it goes into the thing jesterdlang we open it here get our count of the files Uh then we close it, reopen it here, and then we just got to do something from there.
Um, let's see if it's actually entering the scope.
Entered.
Entered. Nice.
Entered.
Entered.
DMD. The brain damage. Compile my brain damage into a one one one one Dlang file right there. Entered it in. Good stuff, guys.
Nice. So, it entered it in.
What's going on inside of here, Shudo?
What's going on? Tell me.
Let's go ahead and do for each I and then write ln I right ln I see if it's actually entering the loop might want to initialize that zero although I think it will be fine okay counts up to the number that's good to see it settles on 3,000 600 or whatever the [ __ ] it was. Um, gets a file size number.
So, it reads all the lines.
Does it make it to the next loop?
See if I is making it in the next loop.
So, if it makes in the loop, then see what's going on here. One, two, three, four. Okay. And it's not writing those. Oh, god damn it. I am dumb. This is a good thing, though. I found out what I'm doing wrong. And it's really simple. I don't even need to do anything other than write ln read ln.
wouldn't have noticed that unless this happened.
All right, here's the Bible today. It's giving us an excerpt of the Bible block by other means by core standard CF free. In some cases, there may be no reference in the program to the memory block.
also to make it better uh make it formatted better. Let's just write each each um line so that to do that it's going to be math and I hate math. But let's go ahead and redo this but make it like six.
But I I guess I suppose it's what it's doing is reading it forward. So, we're reading it forward actually.
Oh, that means if it gets the last number, it will throw an exception and break. Ah, because I didn't start from the end and read it backwards. Uh, here here's what I can do to destroy that problem.
Instead of operating on a range and doing it nice and pretty, I'm going to have to use a disgusting for loop or you short I, which gives you gives you a lot more control though.
I does not equal zero. You do need to initialize I as a number in this case for a for loop and it needs to be initialized as five.
Then we need to put in minus minus i and create a string array which we can still do that like that.
string array which is uh five appends or match appends equals fred readellin and then we can operate on that in a for each loop afterwards.
This needs to be done out here now, which we'll do that into our for each loop.
Create a scope guard.
Nice. So that creates my scope guard for that string.
Scope guarding a single string. That's how much I care, guys. I really care about my scopes.
Um, semicolon and then that just initializes it. So then I can just do match appends that in here match appends read line and then that puts them in a reverse order. So the match of let's redo. Oh, actually if I does not equal zero, which means we no longer need to have a U short called I I removes the need for I I right there, but adds a need for a string match array.
Man, I want to keep going, but I gotta gotta go at like five, bro. I got 10 minutes left.
I want to get on the server, which we can remove the II from here.
Although, appends them in reverse order. We would want to if I'm going to read them normally, we'll just append them in set this to zero. And we're just going to change some numbers five, bro. Then we do for each for each uh member of I writes ln.
Wouldn't this just be the [ __ ] same [ __ ] I just did? Wait, no.
Oh, right. That's why I was subtracting.
This adds it up and keeps going forward.
We want to go backwards. We want to read from the end to the beginning.
Although the problem with that is what if you get the first one. Either way, it doesn't matter.
But this way removes all of the need for the [ __ ] one thing. So I'm going to use a for each loop. I'm going to make it look nice.
Right. L me and uh boom. two loops though. I don't know.
I don't know if I like that. Anyway, write a one and then also we're going to take the number we're at.
So, we'll just write out where is I?
Right. So, for each I actually let's add in uh let's add uh short I back in.
So that way I can have my account of II.
Then boom.
Eventually, I could just do a random length from like zero to Oh, we could even add random length sizes for different things. Yeah, we'll continue as we're going.
So, what if it just gives you a couple lines of index?
That'd be amazing.
So I could read a paragraph.
[snorts] Okay, that's cool. Write len I I comma colon.
Okay.
Oh, and plus+ I I since that's going to be like the overall count I I and file or the position was at should be the same. So, um at the end of this plus+ I I should work nice.
So, that gives me a good count for actually the whole thing. Let's go ahead and give it a shot and test it out so that way we can make sure it works.
Oh, I love that. Nice match of I But if well yeah I starts at zero so it'll just go plus plus I um so I equals four then so it'll go zero from four 1 2 3 4 and stop because it should only have yeah zero and then instead just set it equal I think I think that'll work Um before we before we do that, write ln i uh match.length just to give it a test so that way I can check it.
N. So it has a slash new line character.
Oh, it's writing ends. Okay. Uh, let's import strip actually. Chomp.
Maybe read f.
Readf.
Never mind.
Read ln.
Put in slashn.
Set the new line character.
Decart terminator readalong string and decart terminator.
in a second one.
Okay. Put in a slashn in here.
Hopefully that removes it. I don't know if that works.
What? Super interesting. Okay.
Read al stream.
So as a buffer or an R for terminator.
Does it need both the buffer and terminator?
S equals string.
Maybe we put it in match I and we do a that at the end.
So we use match I as a buff and then new line.
Hopefully that's how that works.
If that's how that works, that makes things really easy. Just saying that makes it really easy.
Read on C.
Oh, if C equals immutable car must satisfy the or R equals car equals immutable car.
Um, yeah, let's not let's not screw around with read ln yet. I don't I don't I don't think I understand what I'm doing at this time.
Although we I know we want to try to remove those, but match always is going to be um here's what we can do from zero to dot dot Actually, no, no, no, no, not not not there, but on me. So, member of of match, right, from zero and then just subtract two from length.
So, uh it's still it's still taking up the same amount of memory, but you just you just don't see it. And it's more CPU intensive masking my shitty ideas. um minus one.
Should be minus one.
I think that will do. And then it's gonna tell me, you can't do that. You're subtracting, mister. Did I actually just total total duration?
Oh god. extends past the in [clears throat and laughter] integer limit. Oh yeah, I love integer limit.
Oh wait, what? Hold on. Um, assert students.length equals equals female count plus male count. I love this thing, bro. This thing's already cooking. So, it works until you realize that that's caused by subtraction. That's a subtraction overflow. And how does that happen?
Well, somehow somewhere something is getting subtracted.
Probably this one for each member of So from zero to dot.length minus two maybe maybe.
Oh yes.
Let's see.
Oh, so it doesn't even initialize the last member object.
Wonderful. Go to five then.
Try that again.
Nice.
Slice zero to that.
What is that? Why is it giving me this number?
So right from there to your length minus whatever is not your length or unless let's check the um actual log.
So did it even initialize a final one?
Yeah. And it's slashn.
So um it just initializes an n character in the last one.
What's in this one's last slot? Oh my god, these strings are huge, bro.
Huge strings, bro.
Just a slash N on that.
Oh, it worked. Wait, it actually just did it.
I guess if it catches a number and it tries to write that out, it freaks the [ __ ] out. It's like, what? What? What?
Okay, so um what did I do? Change it to two. Is that what happened?
Many else many. This slice may have room for new elements before.
Okay, it needs to be minus one, not two.
Who dares send me messages at this time, bro?
All right, so we got it working and then it's time to send it to the server.
Oh, wait. What? What did it catch this time?
Core exception slice0 dot. Maybe we shouldn't be reading dang with dlang slice084.
Oh my god, it hit something. It's like integer overflow. Overflow error exception went since pass array length of one.
Oh hey if that last array.
Um this needs to be done with an if.
If mem dot length greater than one I don't need to do anything else that see that just works that that will just work See the reason it's catching that is because it's like um trying to trying to subtract from zero.
See it's going to work every time unordered with respect to comparison operators.
short circuit short circuit write associative as I've mentioned above in this chapter I will cover only function strcts and class templates and the type template parameters 64.1 function templates bro this is so [ __ ] amazing bro we have seen earlier above that input and output functions like write ln cannot be used in pure functions because they only access global state. Sometimes such limitation are too restricted.
Next episode we'll add in random uh ranges but I'm going to implement this to the server. Um so that way every time you log in or every 20 minutes it sends a message and it's like oh here's a message about um about delaying for you.
So you can keep keep thinking uh and then something like that. We'd also do uh supporters.
So for all our supporters out there, I can do uh supporters.
Boom. Zero. I dislike when something.
Anyway, I can remove the debug lines as well. So um right len match right len rans we no longer need to write the line for random we no longer need to write the line for our path wherever that might have been done at actually we'll keep that we'll keep the writing the line for path all of the strruct members of a strruct object. Well, actually I'm going to add a random length.
Copy lem.
So length can be anywhere from 0 to 10.
So let's go ahead and create a random length generator. So, um, since it's really easy to make these anyway, I'll just go ahead and show you all. We just need to do auto and I pretty sure you just do auto uniform or something like that. Oh, actually just rand equals. Never mind.
I'm going to do that with the other ones, too.
So um down here rand equals or actually let's do r lm uh let's just ln right. Right. So we have len equals rand uh no equals like uniform then cast us and I'm pretty sure one comma uh cast you short to like 20.
So that way I can give me 1 to 20 lines of a of the book.
Actually we'll do from five to 20. And that way it gives me the most lines.
So now if I do that, how do I implement that here? So what I'm going to do then is instead of using I or using these we're going to do len and it's also going to go into here.
So from there to len for each member of match. I don't need to write ln match anymore either. So get rid of that too.
So I should just be able to compile that. It will throw an exception though.
If he was pushing expression leen. What is it that should be correct found if expecting semicolon following expression?
Ah, just means the one before it was [ __ ] Then compile dot slash uh run the one of the other ones. SL gesture detailing index 5 is out of balance for length of five. Exactly. So um that has to be dynamic now. No longer can it be that it has to be dynamic.
So match of I next zero is out of bounds for array length of zero and the length should just equal you can set length property equals lemm that gives you a 20 length thing. what information you going to send from the server with this program. Uh, anytime I log into this server, this will give me a daily message return format class teacher string name slash infinite range.
Yes, very good stuff. Return current.
Oh, here we go. If the value of the left hand expression is true, it produces false without and that's really early in the book. So I probably read that portion and I just don't remember what it was.
Int the compiler generated constructor is sufficient for the single member strct 13.3 specifying float point values. Floating point values can be built from integer values without a decimal point like one two three or created directly from decimal point like 123.0. Floating point values can also be specified with special floatingoint syntax as in 1.23 E+ 4. The E+ part is [ __ ] 10 to the power of um blah blah blah blah blah blah blah. and then uh print it out. httpdang.orgpropy.html.
There's links to stuff in there.
External resources in the PDF file.
Wait, that's like saying files twice.
Oh, 6,000 16,000.
This is the gospel of deb bro Jesus Christ right here. delaying the output.
This is very good.
This is good. Awesome. I will be releasing this program at some point.
Yeah. Yeah. Like a random quote from Cat V. Yeah, almost. But it's quotes from the Dlang Bible. Bible of D.
Technically, I could put in Vlang, too.
See, now all I have to do is just be like, well, we have VLAN. So, if the case is not if it's not supporters, if it's one of these cases, then it will do yip yap and pass the path off to it. Um, so if the path is the lang, then it just passes it off.
There's no really um there's not even a seat anymore. Nice.
Technically, you can also inherit a class from this, which would probably mean need me to define an interface. So you can take what you want. But now it's time to set this up on the server. I'm going to do this in record time. So, um, we're going to do SCP, uh, dot SL, uh, jester.
And then we're going to, uh, and we're going to copy that over to, uh, the one thing. Do I need to do slash on that? Probably need to.
Heisenberg at 10.1.10.237.
put a colon uh okay just for now just do that colon and then the path.
All right, that was really fast.
I don't think I'm going to find my SSH there. Actually, I already have my SSH is in this one.
Cool.
Heisenberger.
All right, we're gonna go ahead and control B and go to zero ls.
Should see gesture.
Um, we'll just go ahead and MV gesture to uh bash scripts.
Actually create a Yeah. Yeah. Bash scripts.
Oh, you know what else it needs?
It needs me to copy the um other stuff.
We We'll leave it there uh for now. We need to copy other stuff to the server.
That's going to be dot slash tab tab data slash.
All right. On the receiving end, I'm going to go ahead and uh create a new directory called uh data actually. Gesture slash and then Yeah. Yeah. Wait, no, don't do that one.
Um gesture tool actually just just lowerase. What am I doing, bro? I'm dumb.
[snorts] And then uh slash data.
And then that will give us a place to put data. And then we're going to MV into slash.
All right. That's um a route.
Hopefully I didn't delete it. Nice.
Cool.
Then I go back to here and then I can uh put all of that into there and then put it into Cool.
And then all I have to do now is vim.bash rc to just kind of link it in there.
Temporary linking.
Insert. Enter. Enter.
export path equals.
I should probably test that it works first. I'll do that in a second.
And then this could also really break everything too. Oh, what's that one say? Do uh [ __ ] path at the end. So like add a path path.
Cannot read that font color, bro.
All right, that should be it.
Escape. Shift.
Wait.
Shift is easy.
All right. Now source dot bash rc.
Yeah, not found.
Let's try dots. Uh, echo path.
Yeah. All right, I'm dumb.
I had this problem yesterday. It needs to be.
Try it again. Jester.
cannot execute required input not found.
Required file not found. H fascinating, right? Oh, did I put the correct?
Yeah, it's there. So, what else?
required file input not um try executing it without a dot slash and there should be required file not found what's fascinating required file cannot execute.
Huh. So that's something I don't know about.
Cannot execute required file not found.
Maybe I need to recompile it on that system because that one does use the musel tool chain or like backends for all the C stuff potentially might require that. Oh, chod plus X.
Maybe I should Yeah, I should definitely try that.
I that should be my first thing I thought of.
chod plus x. No, not equals x plus x cd slash chmod plus x ls data.
Uh, let's see.
LS data.
Yeah, it's about right, I guess. Um and then put that one in the chest so I can compile it there.
All right, we sent it all the way over.
Let's go ahead and uh LBC2 All right, now try it again.
Yep.
It doesn't like it when it's not compiled with the local stuff.
Oh yeah, void OS with musel back end.
Ah, okay.
Jester Beang.
Thank you. All right.
Um, so on startup ls actually cd into my home and uh let's try it here.
No such path for a directory. Uhhuh.
I'll figure that one out later. Anyway, all we need to do is add a thing onto the T-Mox instance.
Well, I guess I you know what I could do is if I really wanted to, I could just add one of these is just watch N3 [snorts] and it reads it every so often.
[laughter] Bro, I'm having fun with ricing out my server.
Oh, wait. Did I LDC it? Anyway, see the problem is it needs to have the path. So anyway, I'm going to go ahead and vim sl uh bash.
This is the server init script and it looks really [ __ ] painful, but don't worry, it's okay.
Um, T-Mox. Oh, T-Mox new dash window.
Uh, we'll call it session name underscore name and uh we'll just say that that's fine and then [clears throat] we'll give it a name. Right? It needs a So, the name is here and we'll just call it um DB Bible Watch dash N 30 actually. Yeah. Watch- N30 slash and then send it into um jester.
actually do do home path gesture slash gesture and then uh dealing.
Actually, we'll just do that for now.
Oh, and then it needs a cm at the end.
No, maybe not. That's when you send keys, though.
I'm just going to assume it works with a full window, too.
No, it won't work if you unless you send the keys to it.
T-Max uh send dash keys dash T for target underscore name zero.
Nice.
Oh, cool. That's all it should do. Uh, but when it sends keys, it doesn't do anything else. Also, there is literally only one ping. Um, server dashboards.
This is cooler than server dashboards.
So, we're going to do t-mux dash kill.
Uh, actually, no. T-max kill server.
Then we're going to exit resh.
That's not good.
Ah, vim uh bash can't find d bible h send keys and it sends it to monitors. So when we create the new window Oh, I'm dumb. Got two things mixed up right there. Delete that.
Insert.
I said insert mousish.
Insert that.
And then do dash n. Pretty sure that's what it is.
T-Max kill dash sererver and then just run it again. Oh, exit.
That's all I got for today. I think um what is this? Dang can't open file data.
D Lang I uh every 30 seconds run that cannot open filed data slashBang the path needs to be resppecified for the server's case.
Um, however, what does it think the path is? Yeah.
Recompile then.
Um, we'll SCP this over to there.
All right. And then we'll recompile it.
Go to the other one and recompile.
CD LDC2.
It should be recompiled. Control B and then two.
So every 30 seconds it should just send me the message.
But uh let's go ahead and exit that.
Redo that command.
Ah resend that over there because it's trying to open home data.
That's not correct.
Hold on. If it's trying to open home data, use uh let's just find a way to create a path for it.
Actually, I'll do that on my own probably. Uh [ __ ] it. That's enough for today. Enough fooling around. I'll see you guys next time. It's been a good one.
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23