Episode Notes
On this episode, Michael discusses the following topics.
Challenge
struct ContentView: View {
// Declare the array with elements to display in the List
let names = ["John", "Jane", "Alice", "Bob"]
var body: some View {
// Use the List view to create rows for each element in the array
List(names, id: .self) { name in
Text(name) }
.navigationTitle("Names")
}
}
hash Declare the list with elements to display
names = ["John", "Jane", "Alice", "Bob"]
Hash Iterate through the list and print each name
for name in names:
from discord.ext import commands
client = discord.Client(intents=discord.Intents.default())
@client.event async def on_voice_state_update(member, before, after):
if before.channel is None and after.channel is not None:
channel = client.get_channel(123456789) hash Replace with the ID of the text channel where you want to post the message
message = f'{member.mention} has joined {after.channel.name}'
await channel.send(message) hash Replace 'YOUR_BOT_TOKEN' with your actual bot token client.run('YOUR_BOT_TOKEN')
- Pick a good Web hosting provider with good tech support. Use Michael's DreamHost Referral.
We also discuss the different styles of programing from Object Oriented programming to event driven programming, and declarative programming.
Transcript
Web Hosting And Programming Styles
Edit TranscriptRemove HighlightingAdd Audio FileExport...?
[0:19] And hello everybody, welcome back to Programatic. My name is Michael Doeys and it's good to be back with you all this wonderful week.
We recorded a day late because there was just a lot to get done to publish the last episode.
We had a lot of code that we had in the results.
So something that we thought about was if you could basically take your code that you have for a solution and throw it through chat GPT and tell it to remove, the extra text or the punctuation, could it do that?
And it does not seem to do it.
[1:02] It wants to keep it all as code and try to remove, it's trying to be smarter than we are and remove the punctuation from the actual string.
So like if there's a print statement, it would go in and remove the parentheses or punctuation and put them as words in the strings.
Now, one thing that I did get it to do, is I said replace all semicolons in this code with the word semicolon, and it did that.
So that was helpful for JavaScript. Unfortunately, that's the only language we do our examples in that are using semicolons.
So yeah, that didn't help. When I tried to do parentheses, I was like, nope, not gonna do it, won't do it.
So that was not very effective there.
So unfortunately, I still have to do those by hand. So it takes a good little while to do that.
[1:51] It takes an editing project that really shouldn't take very long, quite a bit longer to convert all of that to text, then throw it through 11 labs, and then have that converted to audio, and then put that into the tracks.
But I think it really sounds great, And I haven't gotten any feedback so far, so I'm curious what people think of how we're doing our code snippets in the episodes.
And in fact, I will have.
Snippet in here today. And I will talk about that after we do our solutions. Our last challenge was to use an array, to build an app or a, console application that could have a list of names or items and.
[2:43] Basically the results that will be in the full version, sorry YouTube folks, that will be in the full version of the podcast will be of SwiftUI and, of other possible UI frameworks showing a list.
I think I'm going to mainly focus on SwiftUI, so we may not have a JavaScript.
Or if we do have a JavaScript in Python version, it might be console applications because it's easy to generate a SwiftUI list because it's so short.
But making a whole Python UI that has a list would be a little more difficult in a JavaScript application.
So we're gonna probably just have one programming solution for this lesson or this challenge result this time.
So maybe two showing a Swift or Python array.
[3:40] So we'll see, we'll see what we get. So the other snippet, so well, let me back up.
So here's gonna be the results of that challenge.
We have the Swift.
Struct content view colon view left curly bracket. Slash slash declare the array with elements to display in the list.
Let names equals left square bracket John comma Jane comma Alice comma Bob right square bracket.
Var body colon some view left curly bracket.
Slash slash use the list view to create rows for each element in the array.
List left parenthesis names. Comma ID colon backslash dot self right parenthesis.
Left curly bracket name in text left parenthesis name right parenthesis right curly bracket dot navigation title left parenthesis names right parenthesis right curly bracket right curly bracket,and now we have our python result hash declare the list with elements to display names equals left square bracket John comma Jane comma Alice comma Bob right square bracket Hash iterate through the list and print each name.
For name and names colon, indent level one.
Print left parenthesis, name right parenthesis.
[4:56] So we'll have one of each and we may have to make some edits and things like that based on what we have.
So I want to thank 11 Labs for providing that again.
And also I want to talk about one of my projects that I just worked on, which I'm going to use 11 Labs and have it read the project because it's very short.
[5:19] And what that is is a Python script that is a Discord bot. And you'll be able to find this in GitHub.
I have to make a few edits to make that ready to go.
But you'll find it in GitHub on my repos that will send an alert to a channel when somebody joins voice.
So I'm going to have the Python voice that we use from 11 labs.
Go ahead and read that source snippet right here.
Import Discord. From discord.ext import commands. Client equals discord.client left parenthesis.
Intents equals discord.intents.default left parenthesis, right parenthesis, right parenthesis.
At sign, client.event.
Async def on underscore voice, underscore state, underscore update, left parenthesis member comma, before comma, after right parenthesis colon.
Indent level one. If before dot channel is none, and after dot channel is not, none colon indent level two, channel equals client.get underscore channel left parenthesis, 123456789 right parenthesis.
[6:25] Hash replace with the ID of the text channel where you want to post the message.
Indent level two, message equals F single, quote, left curly bracket member, dot mention, right curly bracket has joined left curly bracket after dot channel, dot name, right curly bracket, single quote.
Indent level two, await channel dot send left parenthesis message, right parenthesis.
Hash replace, your underscore BOOT underscore token with your actual bot token.
Client.run left parenthesis, single quote, your underscore bot underscore token, single quote, right parenthesis.
[7:01] All right, so that's really exciting stuff. And it's working now.
And this brings up one of the first topic I'm gonna go through today.
And that's how to pick a good web host.
I think I've, people that know me have known that I've gone through the list of web hosts.
I've gone from Bluehost to NameHero to, let's see, so many others.
I've even built my own through Linode using cPanel and DigitalOcean using cPanel and ...