Transcript #304: Build your own text adventure language in Python
Return to episode page view on github00:00 - Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
00:06 This is episode 304, recorded October 5th, 2022.
00:10 I'm Michael Kennedy.
00:12 - I'm Brian Okken.
00:13 - Hey Brian.
00:14 - Hey, you like threw me for a wrench with the whole date thing, so.
00:19 - I know, well in our notes it has yesterday, but then we had to move it.
00:22 - Yeah, 'cause I mean.
00:23 - Some of us have meetings.
00:25 Yeah, that's right, I had to move plenty for me.
00:26 Plenty of moving.
00:28 Yeah, very cool.
00:28 Well, great to be back with you.
00:29 Also, we have a sponsor that sponsored before, but hasn't been a while, a compiler from Red Hat.
00:34 Excellent show, tell you more about that later.
00:36 For now, Brian, I'm kind of hungry.
00:39 What can you do for me here?
00:41 - I've got tasty ingredients for, let's see, add to stream.
00:45 Tasty ingredients for a delicious pull request.
00:47 So it's October now, so that means Hacktoberfest for some people, right?
00:53 So, and actually, I didn't really wanna just highlight Hacktoberfest.
00:58 what I really like about this.
00:59 So this is an article, 10 tasty ingredients for a delicious pull request.
01:03 It's on the Wagtail blog and from LB on the Wagtail core team member.
01:08 So thanks LB.
01:09 But this, it's kind of neat because there's, it's not, yeah, it's kind of click baby, but also it's just, it's actually nice information.
01:18 So whether you're starting open source project or starting, wanna start helping out with an open source project, or I think these tips are great, or at least majority of them are great even for people that are used to developing solo and are moving into developing with a team of people or a group of people.
01:37 I've had questions about that even from companies of like, "Yeah, we want to work better as a team. How do we do that?" I'm going to run through these quickly.
01:46 There's 10 of them.
01:47 First one is great.
01:49 It's read the documentation or read the development instruction.
01:53 A lot of projects have contributing guidelines.
01:56 So actually read those and understand them.
01:58 When we're used to it, it's just a, hey, fork it and go.
02:02 But that's not trivial for some people.
02:04 So, Right.
02:05 Well, you may have, an non-obvious details.
02:08 Like for example, maybe you just fork the repo.
02:11 You do your work there and you contribute, but well, you should obviously treat a branch in your repo so that if they decide to not take it, then how do you stay in sync?
02:20 Right.
02:20 That's one of them.
02:21 Another one as well.
02:22 Maybe when you do the PR, it doesn't go back to the main branch, it goes to some other like dev branch or something, right?
02:28 Like you need to know, here's where you put the PR back to you.
02:31 And just like those kind of details for, hey, we're a team.
02:33 >> Yeah, and then also there's details like how do you run the tests?
02:36 And are there extra stuff that you have to install or any settings?
02:40 Or for a lot of projects, it's just, you know, do a virtual environment and clone it and go.
02:46 But there's some that have like extra bits that you have to set up.
02:49 So good to read the instructions.
02:51 But then we're going into things like read the issues and comments.
02:55 So if you want to help out, this is a great way is to read the issues, but don't just jump in and try to solve it right away.
03:02 Read the comments around the issue, also PRs that are related to the issue if there's any PRs linked, because there's somebody that might be started on a fix and you want to either help them get unstuck or just help out.
03:17 You don't want to just take over and say, "Oh, I could solve this if somebody else is working on it already." But maybe you do. There's different ways, but pay attention to that. So that's good.
03:26 Create a fresh branch for your contribution like you mentioned.
03:30 It isn't always obvious because I'm already forking, what do we need a branch for?
03:34 But it does help with the branch model when it comes back in, it just looks better.
03:40 >> It's not necessary until your change is not accepted, or you want to make two changes.
03:48 If you ever want to get back in sync with the main repo you need to do somewhere else.
03:53 - And it might be very much a possibility that you want to make several changes.
03:57 You're really excited about a project and you're making several.
04:00 And like you said, there might be a lot of discussion around some and some of them are trivial things like fix and read me or something.
04:07 And so yeah, do a branch so that you've got multiple names.
04:12 And that's where we come to the next tip for is keep the change focused.
04:16 So if a project would much rather have several focused pull requests than a single pull request with like four different changes in it that are completely unrelated.
04:27 So keep them focused.
04:28 This is great for closed source projects too.
04:33 It just makes the code review easier.
04:36 When you get in the habit of doing focused changes, it's not harder, it's just a workflow you got to get used to.
04:44 Next is write unit tests.
04:46 Definitely for the changes, but one of the comments that I loved in this as a bonus tip is, there might be some either untested features in the project or under-tested, and adding tests around those features that you care about is a great way to contribute to a code base. Keep that in mind.
05:06 >> That's a really good point because people often think, well, what can I do to contribute?
05:10 I'm not an expert.
05:11 Well, if it's missing tests, that's pretty easy.
05:15 So there's an idea of like testing is documentation.
05:18 Some tests work well like that and some tests do not.
05:22 A great way also just to walk through, make tests around the onboarding documentation, like the getting starting guide, making sure that those features are tested is a good thing to throw in there.
05:34 Give your pull request a name with context.
05:39 So naming well is good.
05:41 Don't be surprised if your pull request name gets changed by one of the core contributors.
05:48 It's just so that everybody can track what's going on inside better.
05:52 So just learn from that.
05:54 >> If mine is associated with an issue, I try to put the issue number as part of the branch.
06:00 >> Yes.
06:00 >> That I'd like, it'd be like add such and such.
06:03 If that add such and such is actually to fix issue 221, it'd be like the branch should be add such and such 221 or whatever for the branch name.
06:13 just so you're like, "Where the heck did this come from?
06:14 Why is it here? Oh, yeah, that's right. I can go find it." >> Yeah. Reference the issue being fixed or resolved in the pull request.
06:21 Referencing the issue in a way that, and you got to get used to this with GitHub or GitLab or other things.
06:27 They'll link to the thing.
06:29 It links things up if you name it correctly.
06:32 So just play with that.
06:35 Again, and then hopefully there's CI going on and tests.
06:40 So if your pull request has a break, the test fail, address those.
06:46 This is nothing more frustrating than a fairly decent pull request coming in, but the test fail or the coverage fails or something, and the person that issued the pull request doesn't deal with it.
06:57 They just leave it for you, and that's not cool.
06:59 So address those.
07:01 Only a couple more.
07:03 Push to the same branch with fixes and do not open a new pull request.
07:06 So if the CI breaks, just push to the same branch again.
07:09 It'll work.
07:10 And then the lastly is be patient.
07:13 I know that you've worked really hard on a change and you want to see it go into the main project right away, but these are volunteer projects mostly.
07:21 So it might take a while to review it and be comfortable with the changes.
07:26 - Yeah, that's a bit of a balance.
07:28 - Yeah.
07:29 - It's frustrating when you work on a project.
07:31 You try to enhance some project and then you put something out there and there's not even a response.
07:37 After, you know, like two weeks, you're like, well, I guess, I don't know.
07:41 I don't know what to do with that, you know, but at the same time, it's absolutely volunteer.
07:45 So there you go.
07:46 All right.
07:46 Let me tell you about something pretty cool for this next one, Brian.
07:49 I learned about this from Rhett Turnbull.
07:51 He and I had a chat over on Talk Python about building native Mac apps in Python.
07:55 Recall, we talked about TechSniper and he built a Python only equivalent.
08:00 And we actually covered on the show a little bit, but during our conversation there, this is one of the recommendations he had for something really cool.
08:07 So imagine somebody comes to you and says, "Hey, Michael, I have a Raspberry Pi or Arduino thing in my lab, and it controls, let's say this is a biology lab, it controls experiments and you can build up something with a UI or whatever.
08:23 But if people want to script it, wouldn't it be cool if there's a way to express in some form of syntax?
08:30 Here's how somebody who is just a biologist can make it go.
08:33 It could just be like, fill pipette seven, mix pipette seven and 10, wait 10 minutes, heat to such and such.
08:44 Sure, you could come up with a programming language for them.
08:46 You say, "Well, here's your language.
08:48 We're going to give you C++, good luck." More ideally, maybe Python or oftentimes JavaScript, which feels like a real bad example or a choice because it's a complicated syntactical language, even though it's easy to execute.
09:02 It's easy to make a mistake and forget a semicolon or something weird.
09:05 Anyway, what if you could come up with the words that I used to introduce this idea?
09:10 You just have lines like fill pipette seven, mix pipette seven and eight or whatever.
09:16 This thing I'm talking about here is called TextX.
09:20 TextX is a Python library that allows you to build these grammars and map them Python implementations in a super easy way.
09:28 >> Wow. Okay.
09:29 So, let's see, it's a meta-language for building domain-specific languages, DSLs, in Python.
09:36 Basically, it'll help you build a textual language in an easy way, and you can invent your own language, as I said, or build support for an existing format.
09:44 So, they have an example here.
09:46 So, they have this grammar, and this is about moving things around, and basically drawing something in a language.
09:54 So, you come up with a grammar, you'd say, There's a shape command which is just a line to a circle.
10:00 There's a move command which is move to or move by.
10:03 And then you just have these words move and then to that runs the move to command.
10:08 If the word the line is move space by, that's the move by command.
10:13 And then you map to the additional information to these classes.
10:17 So these are all Python classes, right?
10:18 So you just come up this is what is this 10 lines, eight lines, and then you create the class which is a point.
10:25 and the other pieces and you just say meta model from string, give it the grammar and the classes involved.
10:30 Then here's the new language we just created.
10:33 Move space to 5, 10, line 2, 10, 10. How cool is that?
10:38 >> That's pretty interesting actually.
10:40 >> Yeah, you just create the model from there and then you can just basically parse it.
10:44 For command in the model, start doing the things.
10:48 If the commands move to or move by, it's already done the parsing, it has the command elements like the vector or the point already parsed and validated, and it just executes Python.
10:58 >> Okay.
10:59 >> What do you think?
10:59 >> Well, so how do you use it?
11:00 So do you put all these commands in a, somebody that put all these move things in a file and then run?
11:07 >> Yeah, exactly. So you would implement the code that defines the grammar, you would implement the grammar classes, so like point and vector and those sorts of things, and then somebody would write the grammar.
11:20 So move space to five comma 10.
11:22 And then they probably have either a CLI or they save it in a file in some location and like you auto discover it or however it runs.
11:29 So basically from an external perspective, you now allow people to just program in this simple way.
11:35 Like another way you could do it is like you could write like a text adventure game, right?
11:39 You could like look around, look at move right, move east, west, north, right?
11:45 Attack creature, run, like you could really easily in Python build like a pretty interesting text adventure game based on this, I would imagine.
11:53 Probably it already exists.
11:54 >> Yeah. Well, yeah.
11:57 So it adventures around, so we could probably re-implement it with this.
12:01 >> Yeah.
12:02 >> Might be fun.
12:02 >> Yeah, that'd be fun.
12:03 >> But this or a complete way to burn up a summer.
12:09 This looks cool though.
12:11 There's a whole bunch of cases where DSL is appropriate, especially when you're interacting with non-programmer type people.
12:18 >> Exactly. You want to give them some kind of text ability to interact with what you've created, but you don't want to force them to do full-on super precise programming.
12:27 >> Yeah. Or maybe it is programmers and it's just easier to think about stuff in this manner.
12:32 >> Yeah.
12:32 >> Neat.
12:33 >> Yeah, you just have a real high-level way to talk about what you want.
12:35 >> Yeah.
12:36 >> Indeed. Cool. Anyway, so TextX, people can check it out.
12:38 Another thing that's pretty awesome, Compiler from Red Hat, our sponsor this week.
12:42 Yeah, let me tell folks about that before we move on.
12:45 So this episode, as I said, is sponsored by Compiler.
12:48 Just like you, Brian and I are fans of podcasts, and I'm happy to share this new, highly respected one from an open source company I'm sure you know, Compiler, an original podcast from Red Hat.
12:59 And if you want to stay on top of tech without dedicating tons of time to it, Compiler presents perspectives, topics, and insights from the tech industry free of jargon and judgment.
13:08 They want to discover where technology is headed beyond the headlines and create a place for new IT professionals to learn, grow, and thrive.
13:15 Compile helps people break through barriers and challenges, turning code into community at all levels of the enterprise.
13:20 One recent interesting episode is there, the Great Stack Debate episode.
13:25 I love, love, love talking to people about how they architect their code, the trade-offs and conventions they chose, and the costs, challenges, and smiles that result.
13:32 This one is like that, this Great Stack Debate episode.
13:37 Check it out and see if software is more like an onion or more like lasagna, or maybe it's more complicated than food.
13:42 This is actually the first episode in Compiler's Software Stack series, and I think it'll be pretty interesting.
13:49 So check that one out.
13:50 Learn more about Compiler at pythonbytes.fm/compiler.
13:53 The link is in your podcast player show notes.
13:55 Yes, I know you can open up your podcast player and just search for Compiler, but please visit pythonbytes.fm/compiler and click on your podcast player's icon.
14:05 That way they know it came from us.
14:07 Our thanks to Compiler for keeping our podcast going strong.
14:10 >> Nice. Yeah, very cool.
14:12 >> Yeah. All right. What's next, Brian?
14:14 >> Well, I want to talk about locks and semaphores and analogies and stuff.
14:21 >> I've been thinking about them so much lately, actually.
14:24 >> Have you?
14:24 >> Yes, I have. Tell me more.
14:27 >> Well, this is a blog post by Guido van Rossum.
14:30 He doesn't blog often, but there's usually some interesting bits when he wants to.
14:35 So this is a post called Reasoning about AsyncIO Semaphore.
14:40 So it starts off with a story about a restaurant.
14:45 So there's an analogy here about, so you got a restaurant, it's a fast food place, but it only has one table and there's a line waiting for it.
14:55 But you don't want to just wait in line, so there's a way for you to get a buzzer.
14:59 So somebody hands you a buzzer and you go wait.
15:02 When the table's open, your buzzer rings and you go get seated and you can eat.
15:07 This sort of analogy, he talks about this as a lock.
15:13 With concurrent programming, so only one person can eat at a time.
15:17 But then if you've got multiple tables, things get a little more interesting.
15:22 That's where semaphores come in.
15:24 I love this mind shift.
15:27 This is often difficult for people when they're doing asynchronous programming, to have this like lock makes sense. You know, you're either a thread or some code is using a resource and it can and nobody else can, but at, but then, then you unlock it and somebody else can grab it. But what if there's like, like three people can at a time? Those are some of the different some a little bit of a mind shift. So I love this idea of three table restaurant as a way to think about this analogy. And so he goes through the analogy, but then talks about locks and semaphores.
16:04 And this is apparently to help himself even with the implementation of the semaphore in the new ACIO code.
16:12 So, and making sure that things like work correctly and using an analogy to try to figure out how things are supposed to work and like an error.
16:23 So if you've got an exception happening, one of the problems can be, it's like somebody gets, but they're waiting and they decide they don't wanna wait anymore, so they go turn their buzzer in.
16:35 Well, what happens if while they're, when they're just as they've decided to turn it in, but it's their turn and they get buzzed and they, but they turned it in anyway and they don't wanna run.
16:45 So they're never going to call the release code.
16:48 And so with the common, the interaction between cancel and release is difficult.
16:56 So there's all this stuff.
17:00 And it's so cool to think about this in terms of a restaurant because it's easy to visualize.
17:04 So any great article.
17:06 And then at the end, he actually links to the code that he's finished writing.
17:12 So he links it to, yeah, current code.
17:14 So that's pretty cool.
17:15 - Right on.
17:16 Yeah, semaphores are, I would say, these are the things that many people don't really, they don't really think to grab and use, but they're so incredibly useful.
17:25 Like, so one example, Like let's imagine your job is to go scan a bunch of URLs and ingest a bunch of data, and you're gonna run that like 8 a.m. every day or you know, whatever.
17:36 If you've got 10,000 URLs, it would be way, way, way faster to use asyncio and HTTPS to kick off those requests.
17:44 But if you just say for URL in URLs, start a task, got 10,000 pending requests and all that data is coming back into memory and it's gonna, you're gonna have a bad time, right?
17:54 - Yeah.
17:54 - So one thing you could do is you could create a semaphore and say, you know, I only want to allow 10, 20, 100 in-flight requests at a time.
18:02 And you just create a semaphore of 100 and you just pass it off to every task and they just have to start at the beginning and you know, acquire it and release it.
18:08 Boom, you're done.
18:09 You've now created like a, I only, I'm going through 10,000 with a straight for loop and I'm doing nothing more than 100 at a time guaranteed.
18:17 - Yeah. - Beautiful, right?
18:18 - That's a really good analogy.
18:19 I was trying to think of a good one where, 'cause I was actually even looking through the Python code of any cases where they use more than one.
18:28 Like a semaphore with one is just like a lock.
18:32 But if you can allow more than that, then it gets interesting.
18:36 - Yeah, absolutely.
18:37 You can think about similar things for databases if it really can't handle a ton of requests.
18:43 One thing, now that you point this out, I wanna just give a quick shout out to Any.io.
18:48 I interviewed Alex, I believe it was Alex from there, who worked on it, and it's got a really cool idea.
18:55 It's similar to the task groups and stuff that you talked about.
18:57 And it has this thing called a capacity limiter, which is much like a, it's very much like a semaphore, but a little more async native.
19:06 Because you can use it in async context manager, like a with block, async with.
19:11 So here I have created just a capacity limiter of, like my example is 100.
19:14 And you just say, async with create a group for all the items, you know, task start, soon pass limiter, and all the tasks just do like async with this limiter, do whatever you're going to do.
19:24 And boom, now you only get, you know, end of them running at a time.
19:26 Super easy.
19:27 Very cool.
19:28 Cool.
19:28 Okay.
19:28 That's not actually what I wanted to cover though.
19:30 I want to talk about some annoying stuff that got slightly less annoying.
19:35 security and preventing people from doing just bad stuff to your, your things online, right?
19:42 Web apps and mostly web apps.
19:44 you know, think about a forum.
19:46 People come in there just like bots come in and start posting junk.
19:50 Like, I don't know why YouTube can't fix it, but I would say about one out of every three shows get some sort of like disgusting, "Come see the ladies over here," sort of post with clearly text that was like, "Why is this still allowed?" And if you run a website, you're gonna run into those kind of problems.
20:07 So like we had big problems at TalkByThon Training with a bunch of bots creating free accounts.
20:13 And they're just free, you don't get anything by creating an account.
20:16 I don't know why they were doing it, but they were.
20:18 And so, but they were doing it from hundreds or thousands of different IPs.
20:22 It was super annoying.
20:23 So we ended up having to put a reCAPTCHA on there.
20:25 And every time I go to the site and I've got to sign in, I'm like, oh gosh, here come the crosswalks and the stoplights and that's not a bus.
20:33 There's no buses.
20:34 What do you want me to do?
20:35 You know, like how frustrating this is.
20:36 So Cloudflare, they're doing a bunch of interesting branching out of just being a CDN.
20:40 And they've announced this thing called Turnstile, a user-friendly privacy preserving alternative to CAPTCHA or reCAPTCHA.
20:48 Like reCAPTCHA is owned by Google and like a lot of the stuff that you do there it gets sent back over there and it's not ideal.
20:55 So also finding all the crosswalks, not ideal.
20:58 So this thing is something they announced and it's free to use, even if you don't have some kind of other reCAPTCHA thing, like you're not a customer, you should create an account for free, get an API key for this and use it.
21:10 So here, if you go to the page that I'm linking to the blog.cloudflare.com, all that happens is you go there and it just spins for a second.
21:17 It does the work and the magic that CloudFlare's already using to verify that you're a human and you're a real machine and you know, maybe do some sort of like cost, make you run like a tight loop for a second or whatever, and then you're verified.
21:30 And if it doesn't work, then you can click a little button and verify you're human, hopefully.
21:34 But yeah, so this is pretty cool.
21:36 You can now replace your reCAPTCHA with that.
21:39 And it's pretty straightforward.
21:41 Basically, you drop some JavaScript onto the page and a little widget, and then you put the widget in your form.
21:47 If somebody submits it, it comes with that validation, like some sort of validation code that was created by Cloudflare on the server side, you want to verify that because its presence isn't enough because anybody could just send like garbage with the right form ID, right? So there's a server side API, you've got to call to validate that and make sure that yeah, this is actually it came from your domain, it just was created, it is a real one, it's a unique one and all those things.
22:13 Oh, cool.
22:13 Yeah. So anyway, if people want to use this, it seems pretty awesome. Over on in talk by thon I switched the things over to it and we'll see how it goes.
22:21 So for example, if you wanna get notified about our mailing list, now you've got to wait about three quarters of a second before typing in your email address, unless you're like some kind of beast and you could type it in, like select the form, type your email address and hit subscribe before like a second is up, right?
22:37 But that's pretty much it.
22:38 You hit submit and then it runs some magic on the server.
22:43 But I'm doing this live, I'm gonna check out pypi.org check out turn style. There's a bunch of stuff up here. There's like rate limiting things and other stuff, but nothing about Cloudflare. So I created for the moment a GitHub gist that has the server side implementation for anybody who wants to do this in Python, modern Python anyway.
23:01 - Nice.
23:02 - Cool, right? So over here, you just need this one file, this one module you can use here. This one's synchronous, but you could just as well use HTTPX and async if you're want to do this validation in like an async view.
23:16 So it has a Pydantic models, like here's what you got to send over, and here's what you'll expect to get back from the API endpoints, little examples, and then just has one function called validate.
23:27 Given the thing they submitted in the form and their user IP, just so you have that as part of your information of what happened, they need to know that, and that's it.
23:35 It's a cool example of seeing how to do request response with Pydantic to APIs as well.
23:40 >> That's pretty cool. Nice.
23:42 Awesome. Well, that's a really good stuff.
23:45 So here's the thing, right now it's not a package.
23:47 I'm not sure I need more open source projects to manage.
23:49 However, let's say if-
23:51 >> I was curious why you didn't make a package out of that.
23:53 >> Well, because I only did this like Monday, right?
23:56 So it's only, I wanted to stabilize a little.
23:58 If sufficiently many people shoot me a text on Twitter, like a @mention, M. Kennedy, says, "Hey, please make this a package so I can use it too, more directly or we could all contribute." Now, if people do that, I'll turn it into a package.
24:10 But I just haven't had the time because I've been playing with other stuff that I'll talk about in a minute.
24:13 You can only have so many projects, you know?
24:15 Yeah.
24:16 Yeah.
24:16 All right.
24:17 Well, that, that brings us to all of our main items, right?
24:20 Yeah.
24:20 so one of the things, for extras, I wanted to pop up just to briefly, I was looking at a, so I was looking at, Oh, let's go years too.
24:32 Do you have any extras?
24:32 I do have some extras.
24:34 So you go first though.
24:35 I have a ton.
24:36 Okay.
24:36 So I got it.
24:37 I just have a couple.
24:38 So this article says it's from testdriven.io.
24:43 Heroku alternatives for Python-based applications.
24:46 And to be fair, it's pretty fair to Heroku also.
24:50 So really, it isn't don't use Heroku.
24:54 It's kind of like, what are all the things you can use?
24:57 So it goes through Heroku, of course, but then it also goes through, does some description and pros and cons for DigitalOcean app platform and render and fly.io.
25:10 And even some that we don't hear too much about, like Engine Yard, Railway.app.
25:18 Railway looks pretty cool.
25:20 >> Yeah, Railway does look cool.
25:22 >> So really having one person compare, look at all of these and compare them, it's just kind of a nice thing to just hear what somebody has to say about all these different platforms that you might want to try out.
25:33 >> Yeah, that's a ton of, that's a lot of reviews.
25:35 - Yeah, it's pretty neat.
25:37 - And these are all in the platform as a service equivalent, it looks like.
25:41 - Yeah.
25:42 - It's not like just, here's where you run VMs.
25:44 Like, well, okay, that's great, but that's not what Heroku was helping me with.
25:47 - Yeah, and that's actually one of the fair comments.
25:50 It says, like, for instance, Heroku, one of the things it says is the price can go up as you, it's not too bad at the start, but it can go up as you grow.
25:59 And same with all of these, really.
26:00 But the, and it's how many times more than running it just directly on AWS.
26:08 But it's a be careful because that's not a, a platform as a service is not a fair comparison to just running it all yourself because then you have to do it all yourself.
26:20 - Exactly.
26:20 - Kind of paying the service instead of paying somebody to monitor it for you.
26:23 So I think it's reasonable.
26:25 So the other thing I wanted to bring up was we brought it up last time and maybe the time before the pytest course is going well.
26:33 So I'm glad people are getting use out of the pytest course.
26:36 But I wanted, I've been kicking around the idea of doing a cohort based thing, something like the pytest course, not the exact same content, but similar sort of things.
26:47 Get people up to speed and do it as a cohort.
26:49 And I'd like people to get in touch with me if they think that's a good idea.
26:52 I'm thinking about maybe doing it in December, but I'm not sure, December or January.
26:56 So hit me up on Twitter, or you can get to my contact form on Test&Code as well.
27:02 it'll get to me. So yeah, let me know.
27:04 >> Those live events are really nice.
27:06 It's a cool experience.
27:08 So hopefully that goes off.
27:09 >> Yeah, that'd be neat.
27:10 >> Indeed. All right.
27:12 Would you believe that just last night I was writing some C code?
27:15 >> No.
27:16 >> I typically do. Come on, another semicolon I forgot, are you kidding me?
27:20 Been a while. But I actually did a pretty good job without pulling up any references or anything.
27:24 So more on that later.
27:25 But I just want to give a quick shout out to this project called CPP Front from Herb Sutter.
27:31 It's an experimental compiler for an alternative syntax to C++.
27:36 It would make the language 10 times simpler, safer, and more coolable.
27:40 I think it basically is, as the name would say, like CPP front, it's like a slightly different language that compiles to C++.
27:47 So it has an interoperability and whatnot.
27:50 People do a lot of C++, like, you know, for low-level integration with Python and things, might find this interesting.
27:56 So you can jump over to the GitHub repo and they have got some examples in here.
28:00 Let me see if I find a, I think you've got to maybe go check out the test or something like that.
28:05 They don't have great documentation.
28:08 CP2.
28:10 It's just text.
28:11 Show it to me.
28:12 Oh, wait, no, it's not.
28:12 It's 4 megs, but it's okay.
28:14 Anyway, it's got some pretty funky syntax, but it also looks pretty fun.
28:21 People can check that out.
28:22 So if that's interesting, then go for it.
28:24 I don't know where I saw the full examples or something, but, well, they had some in here.
28:30 >> What's different about this?
28:31 Yeah, I find them.
28:32 Oh, well, you can look through the notes here.
28:34 The language, it hardly looks like C++, but it's still as the same thing.
28:39 What do you think about this, Brian? You do some C.
28:42 >> Well, I've been doing it for so long that I don't know if it's that hard to do C++.
28:47 I mean, it's hard to get it right, but we have a lot of help now with the modern compilers and linters and everything.
28:57 But yeah, but I thought I always think it's a neat idea if it's really easier.
29:03 That little snippet you showed me didn't look easier, but.
29:05 Here you go.
29:06 Here's an example.
29:08 If you check out this little graphic on the readme called, it says cat hello dot cpp2.
29:13 Okay.
29:13 It looks a little bit like Python type hence, doesn't it?
29:16 Like the way you specify the return value and stuff.
29:19 Yeah.
29:19 Yeah. Anyway, it could be fun.
29:21 We'll see if it goes anywhere.
29:22 All right. A few other things.
29:23 TypeScript is definitely something that's going somewhere.
29:27 Matt Kramer pointed out that Jeff Glass has been doing a bunch of things with iScript lately.
29:34 So I wanna highlight one thing and then I'm gonna dive into it more next week.
29:38 I just wanna put this on people's radar.
29:40 So PyScript September edition is out with lots of changes on it.
29:46 So probably the easiest way to see that is to click on this blog post they got down there.
29:51 So if you've been doing any PyScript, you're gonna wanna know about this 'cause it's like super breaking changes.
29:56 So for example, you used to have to say, use this thing pyenv for configuring what libraries you would use and how you execute it.
30:05 That thing's gone.
30:06 Now you've got a package section of a pyconfig and a path section for files.
30:10 Bunch of other things, better logging, multiple runtimes, upgraded pyodied and whatnot.
30:18 But check that out if you're doing PyScript.
30:20 >> Nice. They're not even zero-very yet.
30:23 >> Yeah.
30:24 >> They're Cal-very.
30:25 We're going to need some kind of like new calendar event or something.
30:29 Yeah, because they're Calvary.
30:31 Yeah, cool.
30:32 All right, follow up.
30:33 I talked about NextDNS last time.
30:36 That's like basically like for people do pie holes.
30:39 It's like pie hole, but it's on the internet.
30:40 You don't have to manage it.
30:41 I said I didn't really try it out that much last time.
30:45 So I went in and I did an interesting experiment on the family, including myself.
30:50 I went to the router and I just changed it to use this blocking, ad blocking, malware blocking, DNS as like for all the network, which is good because like my TV can no longer do bad things that it was doing.
31:02 you know, my kid gets, ad blocking without knowing it, even visitors, I suppose.
31:07 Right. And I was like, all right, well, let's see what breaks. Who goes, Michael, I can't do this anymore. Like nothing broke, which is great. So, I'm super psyched about that.
31:16 And, if you create it, actually you can create a free, what I've learned is you get a free account for up to 300,000 DNS requirements a month.
31:25 And if what happens after that is it just falls back to like standard DNS with no blocking, just pretty awesome.
31:30 And there's like $2.
31:31 There's not an ad for them.
31:32 Just I think it's pretty awesome.
31:34 So I went and ran, I went to adblock-tester.com Okay.
31:39 With Vivaldi, with its max blocking, no plugins, no extensions for ad blocking, just the built-in one because I don't want to install more extensions.
31:48 But with that turned on and the next DNS, private DNS, I get 96 out of 100 on AdBlockTester.
31:56 With Brave, I got 100 out of 100, which is pretty awesome.
31:58 But even if I turn all the blocking off on Vivaldi, I still get 80 out of 100 just using that DNS.
32:05 That's pretty awesome, right?
32:06 It's like 80% everything is just killed before it ever gets through the network.
32:10 - I was curious what the number was.
32:12 So it's not 80 get through, it's 80 get blocked?
32:15 - It's 80 blocked.
32:17 So you can actually scroll through it.
32:18 I'll show you like, the, the wild cat Giphy wasn't blocked.
32:22 The static image wasn't blocked basically, but you know, pretty much everything else, was, was blocked.
32:28 So, okay.
32:29 Yeah.
32:29 Pretty awesome.
32:30 Yeah.
32:30 Yeah.
32:30 And last thing here, one of the things you got to do to make this work, this is like a new extra, but it is like one flows into another, one of the things you got to do to make this work is if your IP address changes and you have a crap router, I have like an insanely good router that has crap configuration.
32:46 let's put it that way, where I can't do, I can't do IP over, sorry, DNS over HTTPS, or set up any details.
32:54 I can just say, here's the four numbers for the DNS server.
32:58 >> Yeah.
32:58 >> Right? Just the IP address.
33:00 Well, if that's the way you do it, and you have some account that does blocking, you've got to go into your DNS account and associate your IP address with your account by just clicking a button or calling an API endpoint.
33:13 But what do you do when your IP address changes?
33:15 How do you remember like all your ad blocking stops every time, you know, maybe the power goes out and you got like your things come back on and they get a new IP address.
33:22 So I was like, well, what can I do? I've always wanted to have like a little circuit Python project that would be fun.
33:28 So originally I wanted to get a Raspberry Pi. Those are unattainable. It turns out. Have you tried to get a Raspberry Pi, Brian?
33:33 Not recently, years ago, but...
33:36 Yeah, I think they're like 35, 40 bucks for a new nice one, but they're all sold out.
33:40 And you can find them on Amazon for like $200.
33:43 People have bought them up and then are scalping them back to you on Amazon, which is super frustrating.
33:47 Lame.
33:48 You can find it for about $100 on eBay.
33:52 Right? Anyway, they're hard to get.
33:53 And then if you get them, they're way marked up and it's kind of frustrating.
33:57 Well, what else could I use?
33:58 So check this thing out.
33:59 See what I got on the screen here?
34:00 This Adafruit ESP32-S2 Feather is a full blown CircuitPython and Arduino, basically.
34:09 for $17.50 and it's in stock.
34:12 - Nice.
34:14 - So I got that yesterday.
34:15 And just to give you a sense of how small it is, like if you put it in your hand, it's probably 2/3 the size of your hand.
34:21 And it's a full 240 megahertz computer, four megs of RAM, Wi-Fi, Bluetooth, temperature, but the most important thing is Wi-Fi, make no doubt.
34:32 And I see Paul Cutler out there, yes, thank you Paul.
34:35 I was actually thinking of you last night when I was working on this.
34:37 It took a bit of time to set up it was a little bit painful getting it configured from, originally it was Arduino, which is C, so I was writing, I tried to do all this stuff in C, which basically, I had to call that endpoint and pull out my IP address, and everything seemed fine, except for nothing I could find supports HTTPS in C.
34:54 It only, all the REST frameworks only supported HTTP unencrypted.
34:59 I'm like, what endpoint is unencrypted these days?
35:01 What is this madness?
35:02 Give me some requests.
35:03 So I got a CircuitPython going on it, and now it's happily sitting over there in the corner, sending me little reports through like, sort of like Morse code through its LED.
35:12 And then, yeah, it's beautiful.
35:14 I just plug it into the power and it just goes constantly, checks my IP address, updates that DNS setting periodically with an API.
35:20 - Okay, so it's monitoring, and if your IP address changes, it uploads it?
35:26 - Yeah, basically it just has to call the API from the network and that'll like go, well, wherever you're coming from, that's where we're gonna treat you as being from.
35:33 - Okay, nice.
35:34 - Yeah, you might say, well, why don't you just run that Python code on your computer?
35:37 my computer is running a VPN, which is not the right IP address.
35:41 So I can't, all my devices I can't run it on, and I don't wanna run a whole computer for it.
35:46 So like this thing is incredibly small and cheap, and it was just a fun project, so.
35:51 - Nice use of that, cool.
35:52 - Yeah, yeah, so that was a lot of fun.
35:54 A lot of learning, a lot of differences with CircuitPython, like similar, but then, wait, why doesn't that work?
36:00 Like, oh, I wanna find out, you know, the relative path is, oh, there's no pathlib, sorry.
36:04 Oh, well, let me try again.
36:05 Let me find some other way to answer that question.
36:07 >> Oh, yeah. >> It's still fine. Yeah. All right.
36:09 Well, those are all my items.
36:10 I know I had a bunch of extras, but there they are.
36:12 >> That's all right. Do we have a joke?
36:14 >> You know that we do. So following on, one of the things I had last night, I was like, "God, why can I get CircuitPython installed in this?" When it came out of the box from Adafruit, maybe I'm missing something, but it didn't show up as a drive.
36:28 It only could be communicated with over the serial port.
36:32 The way that you normally install CircuitPython is you drag this bootloader just over the drive and it just restarts and off it goes.
36:39 I'm like, well, how do I get this on it?
36:41 Wouldn't work, wouldn't work.
36:42 I'm trying all these things and eventually I figured there's like a sequence of little clicks I got to do on like some of the buttons to put it into a mode then I could do it.
36:51 I could use some help. So this woman Annie here, she's got it figured out.
36:56 If I just went on to Stack Overflow or to Reddit or whatever and post that, people are just going to ignore it.
37:01 They're going to go, "Whatever, newbie.
37:02 He doesn't know what he's doing. Just go away." However, Annie has another idea.
37:06 She says, "Every time I have a programming question and I really need help, I post it on Reddit, and then I log in with another account to reply to it with an obscenely incorrect answer.
37:15 People don't care about helping each other, but they love correcting others.
37:19 This works 100% of the time." [LAUGHTER]
37:23 That's pretty funny.
37:23 What do you think?
37:24 Yeah, I like it.
37:24 I bet it works too.
37:26 Yeah.
37:26 Right?
37:27 If you went in there, what you need to do is just type rm-rf on forward slash.
37:32 No, no, no, don't do that.
37:34 Yeah, it's a different take on it.
37:37 So I used to do a similar thing of just post a blog post with the wrong answer, or a bad tutorial, and leave comments on, and then let people tell me how much of an idiot I am, and then delete that and write the real post.
37:53 Thank you. I incorporated your changes. I really appreciate it.
37:57 I try to give people credit, of course.
37:59 Of course. Awesome.
38:01 Awesome.
38:02 Well, here's a tip.
38:03 If people need help, you just got to have that secondary Reddit account to get in there and stir the pot.
38:08 Or a friend.
38:09 So you ask a friend, that's right.
38:11 Hey, could you just come answer this really?
38:13 Like with this bad answer?
38:14 Good idea.
38:16 All right.
38:18 Well, thanks again for a wonderful episode.
38:20 You bet.
38:20 Lots of fun.
38:21 Thanks for being here.
38:22 See you later, everyone.
38:23 Bye.