Python Bytes - #304 Build your own text adventure language in Python

Episode Date: October 5, 2022

Topics covered in this episode: Ten tasty ingredients for a delicious pull request textX Reasoning about asyncio.Semaphore Turnstile Extras Joke See the full show notes for this episode on the w...ebsite at pythonbytes.fm/304

Transcript
Discussion (0)
Starting point is 00:00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 304, recorded October 5th, 2022. I'm Michael Kennedy. I'm Brian Ocken. Hey, Brian. Hey, you like threw me for a wrench with the whole date thing, so. I know. Well, in our notes it has yesterday, but then we had to move it. Yeah, because I mean. Some of us have meetings. Yeah, that's right.
Starting point is 00:00:25 I've moved plenty for me. Plenty of moving. Yeah. Very cool. Well, great to be back with you. Also, we have a sponsor that sponsored before, but it has been a while, a compiler from Red Hat. Excellent show. Tell you more about that later. For now, Brian, I'm kind of hungry. What can you do for me here? I've got tasty ingredients for let's see, add to stream tasty ingredients for a delicious pull request. So it's October now. So that means Hacktoberfest for some people, right? So, and actually I, I, I didn't really want to just highlight Hacktoberfest. What I really like about this. So this is an article 10 tasty ingredients for a delicious pull request. It's on the Wagtail blog and from lb
Starting point is 00:01:06 on the wagtail core team member so thanks lb but uh this it's kind of neat because there's it's not yeah it's kind of clickbaity but also it's just uh it's actually nice information so whether you're starting open source project or starting want to start helping out with an open source project or i think these tips are great or at least the 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 and there's i've had questions about that even from companies of like yeah we want to kind of work better as a team how do we do that so i'm going to run through these quickly. There's, there's 10 of them. First one is, is great. It's read the documentation or read the development instruction. So a lot of projects
Starting point is 00:01:54 have contributing guidelines. So actually read those and understand them when we're used to it. It's just a, Hey, fork it and go. But that's not trivial for some people. So, right. Well, you may have non-obvious details. Like, for example, maybe you just fork the repo. You do your work there and you contribute. But, well, you should obviously create a branch in your repo so that if they decide to not take it, then how do you stay in sync? Right. That's one of them.
Starting point is 00:02:21 Another one is, well, 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? Like you need to know here's where you put the PR back to you. And just like those kinds of details for, hey, we're a team. Yeah. And then also there's details like how do you run the tests and are there extra stuff that you have to install or any settings or for a lot of projects, it's just, you know, do a virtual environment and clone it and go. But there's, there's, it's just, you know, do a virtual environment and clone it and go. But there's there's there's some that have like extra bits that you have to set up. So good to read the instructions. But then we're going into things like read the issues and comments. So
Starting point is 00:02:55 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. 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. 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.
Starting point is 00:03:24 But pay attention to that. So that's good. Create a French branch for your. But maybe you do. There's different ways, but pay attention to that. So that's good. Create a fresh branch for your contribution. Like you mentioned, it isn't always obvious because I'm already forking, what do we need a branch for? But it does help with the branch model when it comes back in, it just looks better. It's not necessary until your change is not accepted or you want to make two changes right yeah if you ever want to get back in sync with the main repo you need to do somewhere else and it might be very much a possibility that you want to make several changes you're really excited about a project and you're making several and like you said there there might be a lot of
Starting point is 00:04:02 discussion around some and some of them are trivial things like fix and read me or something. And so, yeah, multiple do, do a branch so that you've got multiple names and that's where we come to the next tip for is keep the change focused. 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. So keep them focused. And this is great for personal or, you know, closed source projects too. It just makes the code review easier. And when you get in the habit of doing focused changes, it just, it's not harder. It's just a workflow you got to get used to.
Starting point is 00:04:44 Next is write unit tests. 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. So keep that in mind. That's a really good point because people often think, well, what can I do to contribute? I'm not an expert. Well, if it's missing tests, that's pretty easy. And there could be even like if you, so there's an idea of like testing is documentation and some tests work well like that and some tests do not. So a great way also just to walk through,
Starting point is 00:05:29 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. Give your pull request name, request a name with context. So naming well is good. And don't be surprised if your pull request name gets changed by one of the,
Starting point is 00:05:45 one of the core contributors. That's not, it's just so that everybody can track what's going on inside better. So just learn from that. If mine is associated with an issue, I try to put the issue number as part of the branch. Yes. That I'm like, you know, it'd be like add such and such if that add such and such is actually to fix you know issue 221 it'd be like the branch would be uh you know add such and such 221 or whatever for the branch name just so you're like where the heck did this come from why is it here oh yeah that's right i can go find it yep and uh reference the issue being fixed or resolved in the pull request so referencing the issue in a way that and you kind of got to get used to this with github or gitlab or other things um they'll link to the thing it links things up if
Starting point is 00:06:30 you if you name it correctly so just play with that um and then some again uh and then hopefully there's ci uh ci going on and tests so if your pull request has a break, the tests fail, address those. This is nothing more frustrating than a fairly decent pull request coming in, but the tests fail or the coverage fails or something. And the person that issued the pull request doesn't deal with it. They just leave it for you. And that's not cool. So address those. Only a couple more. Push to the same branch with fixes and do not open a new pull request. So if the CI breaks, just push to the same branch again. It'll work.
Starting point is 00:07:11 And then the lastly is be patient. 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. So it might take a while to review it and be comfortable with the changes. Yeah. That's a bit of a balance. Yeah. It's frustrating when you work on a project.
Starting point is 00:07:32 You try to enhance some project and then you put something out there and there's not even a response. After, you know, like two weeks, you're like, well, I guess, I don't know. I don't know what to do with that, you know. But at the same time, it's absolutely volunteer. So there you go. All right, let me tell you about something pretty cool for this next one, Brian. I learned about this from Rhett Turnbull.
Starting point is 00:07:51 He and I had a chat over on TalkPython about building native Mac apps in Python. Recall, we talked about TechSniper and he built a Python only equivalent. 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. So imagine somebody comes to you and says, Hey, Michael, I have a Raspberry Pi or Arduino thing in my lab and it controls,
Starting point is 00:08:16 let's say this is a biology lab, right? It controls experiments and you can build up something with like a UI or whatever. But if people want to script it, wouldn't it be cool if there's a way to express in like some form of syntax? Here's how somebody who is just a biologist can make it go. It could just be like, fill pipette seven, you know, mix, mix pipette seven and 10, wait 10 minutes, you know, heat to such and such, right? Sure, you could come up with a programming language for them. You say, well, here's your language. You know, we're going to
Starting point is 00:08:49 give you C plus plus good luck. Or, you know, more ideally maybe Python or oftentimes JavaScript, which feels like a real bad example or a choice because it's, it's kind of a complicated syntactical language, even though it's easy to execute, you know, it's like, it's easy to make a mistake and forget a semicolon or something weird. Anyway, what if you could come up with the words that I used to like introduce this idea? You just have like lines like fill pipette seven, mix pipette seven and eight or whatever. And so this thing I'm talking about here is called text X and text X is a Python library that allows you to build these kinds of grammars and map them Python implementations in a super easy way. Wow. Okay.
Starting point is 00:09:28 So let's see. It's a meta language for building domain-specific languages, DSLs, in Python. 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. So they have an example here. So they have this grammar, and this is about moving things around and basically drawing something in a language. So you come up with a grammar.
Starting point is 00:09:55 You'd say there's a shape command, which is just line to or circle. There's a move command, which is move to or move by. And then you just have these words move and then to that runs the move to command. If the word, the line is move space by that's the move by command. And then you map to the additional information to these classes. So these are all Python classes, right? So you just come up, this is what is this? 10 lines, eight lines. And then you create the class, which is a point and other pieces. And you just say meta model from string, give it the grammar and the classes involved. And then here's the new language we just created. Move space to five comma 10, line to 10 comma 10. How cool is
Starting point is 00:10:38 that? That's pretty interesting actually. Yeah. You just create the model from there and then you can, you can just basically parse it. For command in the model, start doing the things. 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. Okay. What do you think? Well, so how do you use it?
Starting point is 00:11:00 So do you put all these commands in a... Does somebody put all these move things a the somebody that put all these move things in a file and then run yeah exactly so you would you would implement the code that defines the grammar you would implement the grammar classes so like point and and vector and those sorts of things and then somebody would write the little the grammar so move space to five comma ten and then they'd probably have either a cell i or they save it in a file in some location and then like you auto discover it or however it runs. So basically from an external perspective, you now allow people to just program in this
Starting point is 00:11:34 simple way. Like another way you could do it is like you could write like a text adventure game, right? You could like look around, look at, move right, uh move east west north right attack creature run like you could really easily in python build like a pretty interesting text adventure game based on this i would imagine probably it already exists um yeah well yeah so the adventure's around so we could probably uh reimplement it with this um yeah might be fun yeah i'd be fine but the uh this or like a complete like burn way to burn up a summer um the uh this this looks cool though there's a whole bunch of cases where dsl make is appropriate especially when you're interacting with non-programmer type
Starting point is 00:12:17 people um 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. Yeah. Or maybe it is programmers and it's just easier to think about stuff in this manner. Yeah. Neat. Yeah.
Starting point is 00:12:33 I just have a real high level way to talk about what you want. Yeah. Indeed. Cool. Anyway, so text X, people can check it out. Another thing that's pretty awesome.
Starting point is 00:12:40 Compiler from Red Hat, our sponsor this week. Yeah. Let me tell folks about that before we move on. So this episode, as I said, it's by Compiler. 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 that I'm sure you know, Compiler, an original podcast from Red Hat. 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 tons of time to it. Compiler presents perspectives, topics,
Starting point is 00:13:05 and insights from the tech industry free of jargon and judgment. They want to discover where technology is headed beyond the headlines and create a place for new IT professionals to learn, grow, and thrive. Compiler helps people break through barriers and challenges, turning code into community at all levels of the enterprise. One recent interesting episode is their The Great Stack Debate episode. 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. This one is like that. This, the great stack debate episode, check it out and see if software is more like an onion
Starting point is 00:13:39 or more like lasagna, or maybe it's more complicated than food. This is actually the first episode in compil's software stack series, and I think it'll be pretty interesting. So check that one out. Learn more about Compiler at pythonbytes.fm slash compiler. The link is in your podcast player show notes. Yes, I know you can open up your podcast player and just search for Compiler, but please visit pythonbytes.fm slash compiler and click on your podcast player's icon.
Starting point is 00:14:04 That way they know it came from us. please visit pythonbystuffm.com and click on your podcast player's icon. That way they know it came from us. Our thanks to Compiler for keeping our podcast going strong. Nice. Yeah, very cool. Yeah. All right. What's next, Brian? Well, I want to talk about locks and semaphores and analogies and stuff. Oh my gosh, I've been thinking about them so much lately, actually. Have you? Yes, I have. Tell me more. Well, so this is a blog post by Guido van Rossum.
Starting point is 00:14:30 Doesn't blog often, but there's usually some interesting bits when he wants to. So this is a post called Reasoning About AsyncIO Semaphore. So it starts off with a kind of a story about a restaurant. So there's an analogy here about, um, okay, so you got a restaurant, it's a fast food place, but it only has one table. Um, and there's a line waiting for it and, but you don't want to just wait in line. So there's, there's a way for you to get a buzzer. So somebody hands you a buzzer and you go wait. And when the table's open, your buzzer rings and you can go, you go geter and you go wait. And when the table's open, your buzzer rings and you go get seated and you can eat. This sort of analogy, he talks about this as a lock. And then so with concurrent programming, so only one person can eat at a time.
Starting point is 00:15:17 But then if you've got multiple tables, things get a little more interesting. So that's where semaphores come in. And I love this mind shift of, and 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,
Starting point is 00:15:41 but then you unlock it and somebody else can grab it. But what if there's 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 a 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. And this is apparently to help himself even with the implementation of the semaphore in the new ACIO code. So in making sure that things work correctly
Starting point is 00:16:15 and using an analogy to try to figure out how things are supposed to work. And like an error. So if you've got an exception exception happening one of the problems can be it's like somebody gets but they go they're waiting and they decide they don't want to wait anymore so they go turn their buzzer in um 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 want to run so So they're never going to call the release code. And so with the, the, the common,
Starting point is 00:16:50 the interaction between cancel and release is, is, is difficult. So there's, there's, there's all this stuff and it, and it's so cool to think about this in terms of a restaurant, cause it's easy to visualize. So any great article. And then at the end, he actually links to the code that he's finished writing. So he links it to, yeah, current code. So that's pretty cool. Right on. Yeah, simul4s are, I would say, these are the things that many people don't really think to grab and use.
Starting point is 00:17:23 But they're so incredibly useful. So one example, let's imagine your job is to go scan a bunch of URLs and ingest a bunch of data and you're going to run that like 8 a.m. every day or whatever. If you've got 10,000 URLs, it would be way, way, way faster to use AsyncIO
Starting point is 00:17:41 and HTTPX to kick off those requests. 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 going to, you're going to have a bad time, right? Yeah. So one thing you could do is you could create a semaphore and say, you know, I only want to allow 10, 20, a hundred in-flight requests at a time. 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 boom you're done you've now created like i only i'm going through 10 uh 10 000 with a straight four loop and i'm doing nothing more than a hundred at a time guaranteed yeah beautiful right
Starting point is 00:18:18 that's a really good analogy i was i was trying to think of a good one where um because i was actually even looking through the, the Python code of, of any cases where they use more than one, like a, like a, a semaphore with one is just like a lock. But if you can allow more than that, then it's,
Starting point is 00:18:35 then it gets interesting. So yeah, absolutely. You can think about similar. Yeah. Thanks. You can think about similar things for like databases. If it like really can't handle a ton of requests.
Starting point is 00:18:43 One thing I, now that you point this out, I want to just give a quick shout out to Any.io. I interviewed Alex, I believe it's Alex from there, who worked on it. And it's got a really cool idea. It's similar to the task groups and stuff that you talked about. 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, because you can use it in a async context manager, like a with block, async with.
Starting point is 00:19:11 So here I can create just a capacity limiter of like my example is 100. And you just say async with create a group for all the items, you know, task starts in pass limiter and all the tasks just do like async with this limiter, do whatever you're going to do. And then boom, now you only get, you know, N of them running at a time. Super easy. Very cool.
Starting point is 00:19:28 Okay, that's not actually what I wanted to cover though. I want to talk about some annoying stuff that got slightly less annoying. Security and preventing people from doing just bad stuff to your things online, right? Web apps and mostly web apps. You know, think about a forum, people come in there just like bots come in and start posting junk. Like, I don't know why YouTube can't fix it, but I would say about one out of every three shows gets some sort of like
Starting point is 00:19:55 disgusting, come see the, come see the ladies over here sort of post with clearly text that was like, why is this still allowed? Right. And you know, if you run a website, you're going to run into those kinds of problems. So like we had big problems at TalkBython training with a bunch of bots creating free accounts and they're just free. You don't get anything by creating an account. I don't know why they were doing it, but they, they were. And so I, but they were doing it from hundreds or thousands of different IPs. It was super annoying. So we ended up having to put a recapture on there. 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. There's no
Starting point is 00:20:33 buses. What do you want me to do? You know, like how frustrating this is. So Cloudflare, they're doing a bunch of interesting branching out of just being a CDN. And they've announced this thing called TurnStyle, a user-friendly privacy-preserving alternative to Captcha or ReCaptcha. Like ReCaptcha is owned by Google and like a lot of the stuff that you do there gets sent back over there and it's not ideal. So also finding all the crosswalks, not ideal. So this thing is something they announced and it's free to use even if you don't have
Starting point is 00:21:03 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 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 it does the work and the magic that CloudFlare is 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 and if it doesn't work then you can click a little button and verify you're human hopefully but yeah so this is pretty cool you can now uh replace your recaptcha with that and it's pretty straightforward basically you drop some javascript onto the page and a little widget, and then you put
Starting point is 00:21:46 the widget in your form. 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,
Starting point is 00:22:08 it came from your domain. It just was created. It is a real one. It's a unique one and all those things. Oh, cool. Yeah. So anyway, if people want to use this, it seems pretty awesome.
Starting point is 00:22:17 Over on TalkPython, I switch the things over to it and we'll see how it goes. So for example, if you want to 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 can type it in, like select the form, type your email address and hit subscribe before like a second is up. Right. But that's pretty much it. You hit submit and then it runs some magic on the server. Right. But I'm doing this
Starting point is 00:22:44 live. I'm going to check out PyPI.org. If you check out Turnstile, 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.
Starting point is 00:23:01 Nice. 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 want to do this validation in like an async view. So it has Pydantic models,
Starting point is 00:23:18 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 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. It's kind of a cool example of seeing how to do request response with Pydantic to APIs
Starting point is 00:23:40 as well. That's pretty cool. Nice. Awesome. Well, that's a really good stuff. So here's the thing right now. It's not a package. I'm not sure I need more open source projects to manage. However, let's say if I was curious by why you didn't make a package out of that. Well, cause I only did this like Monday, right? So it's only, I kind of wanted to stabilize a little.
Starting point is 00:23:58 If sufficiently many people shoot me a text on Twitter, like a at mention M Kennedy says, Hey, please make this a package so I can use it too, more directly, or we could all contribute. If enough people do that, I'll turn it into a package, but I just haven't had the time. Because I've been playing with other stuff that I'll talk about in a minute. You can only have so many projects, you know. Yeah, yeah.
Starting point is 00:24:16 All right. Well, that brings us to all of our main items, Brian. Yeah. So one of the things for extras, I wanted to pop up just briefly. I was looking at a, so I was looking at, oh, let's go yours too. Do you have any extras? I do have some extras. Sweet. You go first though. I have a ton. This article says it's from testdriven.io, Heroku alternatives for Python-based applications. And to be fair, it's pretty fair to Heroku also.
Starting point is 00:24:50 So really, it isn't don't use Heroku. It's kind of like, what are all the things you can use? So it goes through Heroku, of course, but then it also goes through some description and pros and cons for DigitalOcean app platform and render and fly.io. And even some that we don't hear too much about, like Engine Yard, Railway.app. Railway looks pretty cool. Yeah, Railway does look cool. 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
Starting point is 00:25:28 what somebody has to say about all these different platforms that you might want to try out. Yeah, that's a ton of, that's a lot of reviews. Yeah, it's pretty neat. And, you know, these are all in the platform as a service equivalent, it looks like. Yeah. It's not like just, here's where you run VMs.
Starting point is 00:25:44 Like, well, okay, that's great, but that's not what Heroku's where you run vms like well okay that's great but that's not what heroku was helping me with yeah and so that and that's actually one of the fair comments 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 it's the start but it can go up as you grow and same with all of these really but the um uh and it's how many times more than running it just directly on aws but it's a be careful because that's a not a platform as a service is not a comparison fair comparison to just running it all yourself because then you have to do it all yourself kind of paying the service instead of paying somebody to monitor it for you. So I think it's reasonable. So the other thing I wanted to bring up was we brought it up last time and maybe the
Starting point is 00:26:30 time before the PyTest course is going well. So I'm glad people are getting use out of the PyTest course. 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. Get people up to speed and do it as a cohort. And I'd like people to get in touch with me if they think that's a good idea. I'm thinking about maybe doing it in December, but I'm not sure, December or January.
Starting point is 00:26:56 So hit me up on Twitter or you can get to my contact form on Test and Code as well. It'll get to me. So yeah, let me know. Those live events are really nice, right? It's a cool experience. So hopefully that goes off. Yeah, that'd be neat.
Starting point is 00:27:10 Indeed. All right. Would you believe that just last night I was writing some C code? No. I typically do. Come on, another semi-code that I forgot. Are you kidding me? Been a while.
Starting point is 00:27:21 But I actually did a pretty good job without pulling up any references or anything. So more on that later but i just want to give a quick shout out uh to this project called cpp front from herb sutter it's an experimental compiler for an alternative syntax to c++ that would make the language 10 times simpler safer and more coolable i think it basically is um as the name would say like cpp It's like a slightly different language that compiles to C++. So it has an interoperability and whatnot. People do a lot of C++, like for low-level integration with Python and things, might find this interesting. So you can jump over to the GitHub repo, and they have got some examples in here.
Starting point is 00:28:00 Let me see if I can find it. I think you've got to maybe go check out the tests or something like that. They don't have rate documentation. TP2. It's just text. Show it to me. Oh, wait, no, it's not. It's four megs, but it's okay. Anyway, it's got some pretty funky syntax, but it also looks pretty fun. People can check that out. So if that's interesting, well, then go for it. I don't know where I saw the full examples or something, but, well, they had some in here. What's different about this? Yeah, I find them.
Starting point is 00:28:32 Oh, well, you can look through the notes here. The language, it hardly looks like C++, but it's still the same kind of thing. What do you think about this, Brian? You do some C. I don't. Well, I've been doing it for so long that I don't know if it's that hard to do C++ i mean it's hard to get it right but the uh but there's um i
Starting point is 00:28:51 don't know that we have a lot of help now with like uh the modern compilers and linters and everything but um yeah um but i thought i always think it i think it's a neat idea uh if it's really easier that little snippet you showed me didn't look easier, but we'll see. Here's an example. If you check out this little graphic on the readme, it says cat hello.cpp2. Okay. It looks a little bit like Python type hints, doesn't it? Like the way you specify the return value and stuff.
Starting point is 00:29:19 Yeah. Yeah. Anyway, could be fun. We'll see if it goes anywhere. All right. A few other things. TypeScript is definitely something that's going somewhere.
Starting point is 00:29:27 Matt Kramer pointed out that Jeff Glass has been doing a bunch of things with iScript lately. So I want to highlight one thing and then I'm going to dive into it more next week. I just want to put this on people's radar. So PiScript September edition is out with lots of changes on it. So probably the easiest way to see that is to click on this blog post they got down there.
Starting point is 00:29:51 So if you've been doing any PyScript, you kind of want to know about this because it's like super breaking changes. So, for example, you used to have to say, use this thing PyENV for configuring like what libraries you would use and how you execute it. That thing's gone. Now you've got like a package section of a PI config and a path section for files, a bunch of other things, better logging, multiple runtimes, upgraded Pyodide and whatnot. But check that out if you're doing PyScript. Nice. And they're not even zero-ver yet.
Starting point is 00:30:23 Yeah. Well, we're going gonna need some kind of like new calendar event or something yeah because they're calver yeah cool all right uh follow up i talked about next dns last time that's like uh basically like for people do pie holes it's like pie hole but it's on the internet you don't have to manage it uh i said i didn't really try it out that much last time. So I went in and I did an interesting experiment on the family, including myself. I went to the router and I just changed it to use this blocking, ad blocking, malware blocking DNS as like for all
Starting point is 00:30:57 the network, which is good because like my TV can no longer do bad things that it was doing. You know, my kid gets ad blocking without knowing it, even visitors, I suppose, 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. And if you create it, actually you can create a free,
Starting point is 00:31:19 what I've learned is you get a free account for up to 300,000 DNS queries a month. And what happens after that is it just falls back to like standard DNS with no blocking. Just pretty awesome. And there's like $2. There's not an ad for them. It's just, I think it's pretty awesome.
Starting point is 00:31:34 So I went and ran, I went to adblock-tester.com. Okay. 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. But with that turned on and the Next DNS, private DNS, I get 96 out of 100 on Adblock Tester. With Brave, I got 100 out of 100, which is pretty awesome.
Starting point is 00:31:58 But even if I turn all the blocking off on Vivaldi, I still get 80 out of 100 just using that DNS. That's pretty awesome, right? It's like 80%. Everything is just killed before it ever gets through the network. Oh, I was curious what the number was. So it's not 80 get through.
Starting point is 00:32:14 It's 80 get blocked. It's 80 blocked. So you can actually scroll through. It'll show you like the wildcat Giphy wasn't blocked. The static image wasn't blocked basically. But you know, pretty much everything else was blocked. So, yeah, pretty awesome. Yeah.
Starting point is 00: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. Let's put it that way where I can't do, um, H I can't do IP over, uh, sorry, DNS over HTTPS or set up any details. I can just say, here's the four numbers for the DNS server.
Starting point is 00:32:58 Yeah. Right. Uh, just the IP address. 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 like clicking a button or calling an API endpoint. But what do you do when your IP address changes? How do you remember?
Starting point is 00:33:16 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. So I was like, well, what could I do? I've always wanted to have like a little circuit Python project that would be fun. So originally I wanted to get a Raspberry Pi.
Starting point is 00:33:30 Those are unattainable, it turns out. Have you tried to get a Raspberry Pi, Brian? Not recently, years ago, but. Yeah, I think they're like 35, 40 bucks for a new nice one, but they're all sold out and you can find them on Amazon for like $200. People have bought them up and then are scalping them back to you on Amazon,
Starting point is 00:33:46 which is super frustrating. Lame. You can find it for about a hundred dollars on, on eBay, right? Anyway, they're hard to get. And then if you get them,
Starting point is 00:33:55 they're way marked up and it's kind of frustrating. Well, what else could I use? So check this thing out. See, I got on the screen here. This, this Adafruit ESP32-S2 featherather is a full-blown circuit Python and Arduino,
Starting point is 00:34:09 basically, for $17.50, and it's in stock. Nice. So I got that yesterday. And just to give you a sense of how small it is, if you put it in your hand, it's probably two-thirds the size of your hand. 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. And I see Paul Cutler out there. Yes, thank you, Paul. I was actually thinking of you last night when I was working on this. It took a bit of time to set up and it was a little bit painful getting it configured from... Originally it was Arduino, which is C. So I tried to do all this stuff in C, which basically tried to like call that endpoint and pull out my IP address and everything seemed fine, except for nothing I could find supports HTTPS in C. It only,
Starting point is 00:34:54 all the rest frameworks only supported HTTP unencrypted. I'm like, what endpoint is unencrypted these days? What is this madness? Give me some requests. So I got a circuit Python going on it and now it's happily sitting over there in the corner, sending me little rake reports through like sort of like Morris code through its led. And then, yeah, it's beautiful. I just plug it into the power and it just goes constantly checks my IP address updates that, that D and S setting periodically with an API. Okay. So it's, it's monitoring. And if you're, if your IP address changes, it uploads it. 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, we're going to treat you as being from.
Starting point is 00:35:33 Okay. Nice. Yeah. You might say, well, why don't you just run that Python code on your computer? My computer is running a VPN, which is not the right IP address. So I can't, all my devices, I can't run it on. I don't want to run a whole computer for it. So like this thing is incredibly small and cheap and it was just a fun project. So nice. Nice use of that. Cool.
Starting point is 00:35:52 Yeah. Yeah. So that was, that was a lot of fun. A lot of learning, a lot of differences with CircuitPython, like similar, but then wait, why doesn't that work? Like, oh, I want to find out, you know, the relative path is, oh, there's no path lib. Sorry.
Starting point is 00:36:04 Oh, well, let me try again. Let me find some other way to answer that question. Oh, yeah. It was still fine. Yep. All right. Well, those are all my items. I know I had a bunch of extras, but there they are.
Starting point is 00:36:12 That's all right. Well, do we have a joke? Oh, you know that we do. So following on, like one of the things I had last night, I was like, God, why, why can I get CircuitPython installed in this? And it was when it came out of the box from Adafruit, maybe I'm missing something, but it didn't show up as a drive. It only could be communicated with over the serial port, right? And the way that you normally install CircuitPython is you drag this bootloader just over the drive and it just restarts and off it goes. I'm like, well,
Starting point is 00:36:40 how do I get this on? It just wouldn't work, wouldn't work. And I'm like, 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 like put it into a mode, then I could do it. I could use some help. Okay. So this woman, Annie here, she's got it figured out. If I just went on to Stack Overflow or to Reddit or whatever and post that, people are just going to ignore it, right? They're going, yeah, whatever. Newbie, he doesn't know what he's doing. Just go away. However, Annie has another idea. 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. People don't care
Starting point is 00:37:16 about helping each other, but they love correcting others. This works 100% of the time. That's pretty funny. Yeah. I bet it works too. Yeah. Right. If you went in there, like what you need to do is just type dash R, you know,
Starting point is 00:37:30 RM dash RF on forward slash. No, no, no, don't do that. Yeah. It's a take a different take on it. And so I used to do the similar thing of just a post,
Starting point is 00:37:40 post a blog post with the wrong answer and, and have, 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. Thank you. I incorporated your changes. I really appreciate it. I tried to give people credit, of course. Of course.
Starting point is 00:38:01 Of course. Awesome. Well, here's a tip if people need help. You just got to have that secondary Reddit account to get in there and stir the pot. Or a friend. Or a friend. That's right. Hey, could you just come answer this really like with this bad answer? Yeah. Good idea. That's nice. All right. Well, thanks again for a wonderful episode. You bet. Lots of fun. Thanks for being here. See you later, everyone.
Starting point is 00:38:23 Bye. Bye.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.