Skip to content

Instantly share code, notes, and snippets.

@brylie
Created December 23, 2023 21:58
Show Gist options
  • Save brylie/6482cd98144d203adda1c291758b992f to your computer and use it in GitHub Desktop.
Save brylie/6482cd98144d203adda1c291758b992f to your computer and use it in GitHub Desktop.
Open Source with Brylie - e40
(...) Hello and welcome to another open source live code hangout.(...) Today we're working on the Western Friend website.(...) If you'd like to check out our source code you can stop by github.com slash Western Friend and the repository is westernfriend.org
(...)
It's the source code for the westernfriend.org website.(...) Today's task I'm going to work on an optimization.(...) A few weeks back we noticed we were getting a lot of 404s on the new site and it was because I basically neglected to migrate
(...)
some redirects or to create some redirects during the migration but also I think because we're getting a lot of bot activities that are just scanning our site and what's happening if I search for if I go to a non-existent page some page that doesn't exist our site redirects to our search page and takes the URL splits it and puts it as the search phrase.(...) We did this for a convenience to help users discover the pages they may have been looking for but what I'm realizing is it's mostly bots that are being redirected some kind of 90,000 requests this is not our site doesn't have that many active users it's causing undue load on the server and because it's making a synchronous database request it could be blocking other requests causing page slowness page load slowness and contributing to a reduced overall page quality score. I'm kind of met my camera the phrase we're monitoring I've been setting up some things in century and Cloudflare to monitor our page load performance this page is being hit so often and the load time is relatively high it's over one second it's kind of causing all of our statistics to distort now I could try to optimize the search query but I'm not really exactly sure how the wagtail CMS search internals work and so what I could do to I don't know what I could do to optimize it it's also the search page is triggering several n plus 1 queries so I'll have to come back to this and make this a lot better figure out how to prefetch related for example or yeah because here we have an article with an author and magazine issue a related issue and ostensibly those are all relevant pieces of information to see on this display but for each of those we have to select a related entity from the table of reform key relationship so it's leading to it like a cascading in plus one query for every result that's all something I'll be working on in the future but for now I'm going to try to just reduce the load on our server a little bit it's not causing any severe issues but it was just surprising the amount of time that our server is spending responding to bot requests on the slowest query of our site is the search page is the least optimized query I have a few other anyone queries that we might be able to fix possibly during the session today I've been identifying those but the search is just again more opaque to me it's coming from Wagtail search and I should open a perhaps a stack overflow question to figure out how to reduce the n1 query or prefetch related from the Wagtail search but let's go ahead and continue this so the idea is rather than doing the redirect
(...)
to kind of split the difference so when we get a 404 page that just doesn't exist or maybe has moved without a redirect we'll render the search field the form on the 404 page or a simple form that allows me to post to the search endpoint yeah I think it's basically the same thing ought to figure out and allow the user to opt in and click that now I don't know if that's going to actually resolve the issue if bots are hammering the site they might just I don't know if they're clicking buttons or submitting forms arbitrarily we enable cloudflare to see if it could reduce some of the load on the server again this is not a major issue but we can see here when I go now almost you know two and a half seconds to render this the search form is always going to be there on the page on every page but I would like to display it in a prominent location on the 404 page so let's create a branch and I'll remove my middleware which actually caused another bug unrelated bug intercepting 404s and redirecting to the search page turn out it caused one problem can't recall but I'd like to just remove the middleware so 404 I forget where our 404 page is let's see what we have this I don't even know if this idea will really work but here we have a page not found this page cannot be found here now the question is can I control the context of 404 I believe I can and it might require a middleware so I would like to inject some page context of form I'll take a look at this search form it's basically this form here and it we're doing a second get request so that's the first thing we'll look up one thing I'll do just real quick it's login we're gonna use Chad GPT I found it a little bit more efficient than searching even stack overflow
(...)
you
(...)
okay
(...)
(clicking)
(...)
So I'm running a custom 404 template and I'd like to augment the template context for the 404 page to help users find content that they may have moved. How can I add a template variable to the Django 404 page?
(...)
Okay, so it looks like we're just gonna create a custom view, that's handy.(...) And then, handler 404.
(...)
That's interesting, so just...
(...)
So we have the template.
(...)
Create custom view and you know,
(...)
this is the rendering the template and adding the response code 404.(...) Naturally, we do it, and this is the interesting thing. This must be...
(...)
Something is a...
(...)
(clicking)
(...)
Like a magic variable or something? That's kind of interesting. Yes, handler 404 is a special variable used by Django to specify a custom view function that handles 404 errors. I'm glad it does that.(...) (laughs) It's a bit obscure, but well documented and enough so that GPT knows it.
(...)
So let's see.
(...)
(clicking)
(...)
I'd like to define it perhaps in core, but not sure if core is treated like a regular app. So I would check core settings.(...) Core is the folder that Django generates automatically.
(...)
And here's our response middle world. I'd like to get rid of that during this session as well.
(...)
So we have core. Yeah, this is kind of interesting.
(...)
Core is not defined here, so I would have to... Common might be a good one.
(...)
Common, yeah.
(...)
Views, yeah, we're already kind of nothing here. Okay, never mind.(...) (laughs) All right, let's... Okay, GPT, thanks for all of this. I'll just copy the code and we'll make some adjustments to it.
(...)
So essentially the first thing I'd like to do is... Yeah, cost some variable there and exception is none. Change this to HTTP status.
(...)
Not found.
(...)
And here we go.
(...)
Cool, so then what I need to do is just...
(...)
Essentially this custom variable is the context.
(...)
(keyboard clacking)
(...)
Should I just get context or something similar?
(...)
Yeah, it's not standard review. So what we'll do is just say context.
(...)
(keyboard clacking)
(...)
(keyboard clacking)
(...)
So let's see what it did. That's kind of a vague one, but...
(...)
That's not quite it. So yeah, it's not... I'm not prompting it correctly.
(...)
We're not actually after the query string, but we're splitting the path.
(...)
(keyboard clacking)
(...)
(keyboard clacking)
(...)
Yeah, it's better.
(...)
And split the path into keywords.
(...)
Remember the first item in the list which is an empty string, really?
(...)
Yeah.
(...)
(keyboard clacking)
(...)
Search terms.
(...)
It's fine. And then what we're gonna do is give it a clue. Let me think here.
(...)
That's like actually probably it.
(...)
So it's a bit verbose. I'm not sure that this keyword's path is necessary.
(...)
We'll find out.
(...)
I'll leave the comments in.
(...)
(keyboard clacking)
(...)
Some of them are a bit...
(...)
Bit verbose. (keyboard clacking) (laughs)
(...)
(keyboard clacking)
(...)
And I'll have to check my middleware because that's not quite gonna work.
(...)
(keyboard clacking)
(...)
Well, okay. Let's look at the 404.
(...)
404 middleware, middleware, middleware.
(...)
Core middleware, I think.
(...)
Yeah, this is where I had some problem with PayPal here.
(...)
Search query equals...
(...)
Strip out the slashes.
(...)
(keyboard clacking)
(...)
Yeah, let me test this real quick. I think this strip, I should replace those with spaces.
(...)
Because page width is not what we're looking for. Page width... (keyboard clacking) Huh, okay, it works.
(...)
So I think we just need that.
(...)
(keyboard clacking) Function here, okay.
(...)
(keyboard clacking)
(...)
(keyboard clacking)(...) Yeah, and here we're not splitting it actually. We're just taking the path as a string and cleaning it.
(...)
Now, can I... See if I can format this a little bit better.
(...)
I like to do something like that, but that won't work with it. But if I do, actually surrounded by parentheses.
(...)
Then put one at the end here.
(...)
Taking inspiration from my JavaScript friends.
(...)
Yeah, format it doesn't like it, okay.
(...)
That's cleaner, smaller, shorter.
(...)
Less is more.
(...)
(keyboard clacking) Let me test this in Python.
(...)
Okay.
(...)
Because I think this strip might be unnecessary.
(...)
Got a string.
(...)
Strip is gonna take out the front.
(...)
Yeah, I see, I see, I see. (keyboard clacking) Well, that strip will, at the end, it will strip the white space up in front, so.
(...)
And trailing slashes for good measure.
(...)
Basically, path, should have done.
(...)
That's, and then what we'll do is try, let's try path.
(...)
Yeah,(...) so I'm not gonna mutate it yet.
(...)
Yep, so we get the spaces out. (keyboard clacking)
(...)
Get the slashes out, and then we have a little bit of trailing,(...) leading trailing, which strip will take care of.
(...)
I think that's it. So we don't need this strip here. I understand why it was there, but since we're handling this strip later,(...) less is more.
(...)
(keyboard clacking)
(...)
Good, search query. Now we want to search form.
(...)
I think we can get that from the,
(...)
either in the template I just create a form that posts,
(...)
makes a request.
(...)
What kind of request is this form gonna make?
(...)
A get request to the search.
(...)
So yeah, we can get requests. Fine, because we're using the query string.
(...)
I think I can just get that out of the core nav bar.
(...)
Now here, oh, it's the log out, let's see.
(...)
Here's our search. (keyboard clacking)
(...)
Making a get request.
(...)
So that name goes to the query string. (keyboard clacking)
(...)
So then,(...) our custom 404
(...)
is here in templates 404 common views.
(...)
It says 404.
(...)
And I think that 404 just needs a form.
(...)
(keyboard clacking)
(...)
(keyboard clacking)
(...)
I don't know, should be.
(...)
(keyboard clacking)
(...)
Let's try it.
(...)
Control D.
(...)
Run the server.
(...)
(keyboard clacking)
(...)
Start the development database.
(...)
Run the server.
(...)
Local host, 8,000.
(...)
And let's see if the 404 works.
(...)
(keyboard clacking)
(...)
Right, right, right, right. We have the middleware still in place. So we'll have to come back to the settings, middleware.
(...)
And remove my middleware here.
(...)
Then come back.
(...)
Page not found, okay. Oh yeah, I missed the third step. So now we have to edit our URLs. I have to read the instructions from GPT, GPT, chat, GPT, common URLs, pi. This is interesting.
(...)
I can create this here, but I'm wondering
(...)
if I just import it.(...) (keyboard clacking)
(...)
Yeah, that's all good.
(...)
Just in our main URL patterns, the core URL patterns,
(...)
we don't need a whole, just another one, URLs, pi.
(...)
And we will call it 404 handler.
(...)
And I'll point to common,(...) views, custom 404. (keyboard clacking)(...) Page not found.
(...)
Okay, okay, let's see.
(...)
(keyboard clacking) So I'm thinking I need to turn debug off, debug mode off. (keyboard clacking)
(...)
Yeah, here in the environment one moment. (keyboard clacking)
(...)
All right, so I have an environment variable there(...) in the ENV file that puts us in the debug mode in my local development environment. I've said debug is false. We'll refresh this thing.
(...)
I do not have it.
(...)
I set it to true, or do I?
(...)
Well, one thing I can do is just in my settings, strangely.
(...)
(keyboard clacking)
(...)
That's easy, we didn't do it, I guess.
(...)
Page not found, good.
(...)
Could not be found. Go to search form there without the button.
(...)
So here, we're getting close, we're getting close.(...) Value.
(...)
(keyboard clacking)
(...)
And copy and paste it, so of course we got some
(...)
copy and paste code.
(...)
(keyboard clacking)
(...)
Instead, we wanna do the value. (keyboard clacking)
(...)
(keyboard clacking)
(...)
Hey, Blaze Labs, welcome to the channel.
(...)
Yeah, it's a magazine website, basically.(...) Online community site.
(...)
However, I'm gonna be working on some other projects soon. A lot of it is Python and Django, but I've also got something cooking with Flutter.
(...)
If you're interested in learning the piano, making a piano app.
(...)
How you doing?
(...)
Let's see, is it winter in your hemisphere? Are you in the northern hemisphere? I don't wanna make any assumptions.
(...)
I can't quite recall. So let's see now, do we have any search?(...) Okay, so we got some value there.(...) And the button.
(...)
Maybe it's just not visible. Yeah, there it is, okay.
(...)
There we are, and it probably doesn't need to be so wide.
(...)
Because if I go full screen here, it's really wide. Okay, so let's see.
(...)
Piano app for your iPad, not a fan of Flutter, more Kotlin, yeah, true, true.(...) Kotlin's pretty popular. The problem is Kotlin native, I guess, you can do iOS or Android, is that right? Have you done any Kotlin, is it Kotlin native? I'm looking for a cross platform development solution, that's why.(...) (laughs) But I really like Dart, I like the Dart language.(...) I think it takes a lot of the good parts from Python, and a lot of the good parts from TypeScript,(...) maybe Kotlin. I think it really balances. It's made some interesting decisions, they assign decisions there.
(...)
Okay,(...) well yeah, I can check out Kotlin too. I've already started prototyping it in Flutter, but it's really just super early.
(...)
Oh, I'm sorry, actually I misspoke. I was originally gonna make it in Flutter, but then I started a prototype with the Godot game engine.
(...)
Now this was done for a practical reason, that Godot comes with native support for MIDI input. I think for piano apps,(...) I've tried a few.
(...)
And by the way, which piano app do you use? I'm curious to know what your experience has been.
(...)
But I think MIDI input is a good feature
(...)
from the user experience perspective.
(...)
And Godot has it built in, MIDI input at least, and that's all we need. So I don't have to worry about using a library that might go out of maintenance.(...) With Flutter, for example, there's a couple of MIDI libraries,
(...)
but I don't really trust the Flutter ecosystem yet.
(...)
I think in a similar way, I've had troubles with the JavaScript ecosystem,
(...)
with things coming and going and calling multi-platform. Okay, yeah, let me check that out. Smart one, piano app, good, because I'm wanting to do some competitive analysis for our little open source app, so that I might be able to make a little bit of a business, out of it, a little bit of side business, while building an open source project.
(...)
And not doing something like the business source license, but genuine open source software,
(...)
but sort of having a way of generating a couple dollars here and there.
(...)
Having the app being freely available, but maybe we can have content packs that let you do more advanced music theory than the basics.
(...)
Let's check this smart one out.
(...)
This is all just kind of kicking around in my head, but the main thing is I'm learning the piano,(...) and I'm at the point where I need to start doing some drills, so repeating things like arpeggios, or walking bass, with my left hand in particular, is a weak,(...) smart tone,(...) smart one,
(...)
piano app.
(...)
A smart one.
(...)
Hacking it, okay, cool. I can't find it.
(...)
One smart, oh yeah, yeah, this one, okay, this is the top one. Let's see,(...) do they have an official website or something? Okay, so you start playing in minutes.
(...)
Ah, it's got a crash course, so we're gonna teach you some theory.
(...)
Yeah, it teaches you sight reading.
(...)
I find that a lot of them do that, and I like that it seems to follow the music, so you have some guidance.
(...)
Okay, and it looks like you can do left hand, right hand, and then hands together, that's a really important thing. It's very common. I've also been observing how piano teachers teach. I'm taking piano lessons once a week, and I find that some of the apps, such as Simply Piano,
(...)
it's good, it's a really good app, but it sort of feels like I'm on a treadmill sometimes, where it wants me to play at a particular tempo, and it doesn't always feel good, and it can be frustrating. I've seen this in other people who've played the Simply Piano app, where it just sort of,
(...)
particularly when it starts to use eighth notes,
(...)
because there's an exponential curve of
(...)
the speed that you have to do these pulses, the pulse, we're talking about, it's basically binary curve,
(...)
and so you might be playing the same tempo quarter notes comfortably, but if you play the same tempo eighth notes, that's not a linear jump, and that's where it starts to get frustrating, but I've noticed to the point that piano teachers don't kind of force you to play at any particular tempo, at least not starting out, not in your first like three, five, maybe even 10 years, depending on your goals,
(...)
because they know we're not robots. You know, now we should practice with the dimension, and try to internalize the clock and things like that, but yeah, it's just the Simply Piano out of the gate and sort of felt like I was being dragged along.
(...)
Overall, it's a good app, but
(...)
this one looks cool, and oh, Ling Ling, yeah, nice, whoops, where'd he go?
(...)
Yeah, he's a good teacher.
(...)
All right, I like it, it looks pretty cool, I'll check it out.
(...)
I'll show you my favorite one, it's called Flow Key.
(...)
This one's really good.
(...)
Similar style, it shows you a video of it being played,
(...)
and highlights the notes to play.(...) You can play hands together or hands apart, you can probably, like this one, you can highlight certain sections
(...)
to play a few bars at a time, I have to, you know, we have to do that to get those bars into our muscle memory.
(...)
The nice thing about this, compared to like Simply Piano, for example, is the songs you're learning are very pianistic, they're very natural because they're actually videos, so it's like a human playing it, and so you get this human feeling.
(...)
It's not all sort of MIDI robotic, whereas Simply Piano and a couple other ones that use MIDI, it's a trade-off, they have a big repertoire, but it's not as inspiring as it is, to hear somebody play beautifully pianistic sound on a really nice piano.
(...)
And this one waits for you, if you wanted to.
(...)
You can play it at a particular tempo, but it'll wait, it'll pause here and wait for me to play those notes. And that's the way I see, that should be the default, because that's the way I see piano teachers teaching. They just wait to hold the pencil, and they say, "No, this is F sharp."(...) And they wait, because they're not playing it. There's no treadmill.
(...)
Wait mode.(...) That should be the default.(...) (laughs)
(...)
So this one's really good. The repertoire in this is excellent.
(...)
But now here's what inspired my app, is that these are focused more on repertoire and sight reading, for example, learning the notes, but not so heavily on technique building, and particularly the technique we have to just kind of drill a little bit.(...) Every one of our practice sessions should start out, perhaps with a warmup that's a little bit of a drill, like arpeggiations, for example,(...) or chord inversions. Just things we have to get into our muscle memory and not have to think so consciously about, so that we can start playing more and more advanced pieces, or more expressively our own pieces.
(...)
So I think there's an actual gap in the market for these sort of drilling-oriented apps to complement the repertoire ones that do such a good job,
(...)
with even introductory lessons and things.(...) And that's all our little game is gonna be, is just kind of a drilling thing.
(...)
Call and multiply one. So it's a long story, but that's another project I'll be working on here in the Godot engine, Godot game engine. (keyboard clicking) Cookie consent forms. Okay, so you got server, Kotlin on a server,(...) pretty common.
(...)
We're using that a bit at my day job.
(...)
But then we have true multi-platform, not just mobile.
(...)
Very cool, and they'll probably have embedded.
(...)
Cool, it's got a UI.
(...)
Yeah, Flow Key is really good. I highly recommend it. Now we've tried several of these competitive apps. If you look at the top piano apps,
(...)
list, you know, from any arbitrary one.
(...)
I also have a piano note subscription. They're really good.
(...)
But if you look, so we've tried Usition, we've tried Flow Key.
(...)
Piano is really fun, it's like video things. And piano actually is good because it comes with four subscriptions in one. It comes with piano, guitar,(...) singing, and drums.
(...)
So you subscribe to one, and you get four instruments. For a little bit more, it's like three Netflixs.(...) A little bit more than other subscriptions, but it's not super bad compared with, you know,(...) it's not gonna replace lessons if you can do them.
(...)
But they're very good instructors.(...) Very friendly, it's got a community.
(...)
Good grief, let me just see the top list.
(...)
Flow Key will usually be, we've tried Scoove.
(...)
There's a site that ranks in music radar, it's probably one of the ones. But anyway, Flow Key's usually up in the top.
(...)
10 top tier apps.
(...)
Good grief.
(...)
And then simply, piano's usually like the number one.
(...)
Flow Key would probably usually have the number two.
(...)
Scoove is up there, but they're not as good.
(...)
Yeah,(...) and we did simply piano for like probably three years we had down, so it's good, but treadmill-y. Anyway, I don't wanna keep going through all these cookie consent pop-ups,(...) but
(...)
I don't think this is super-sold on this method of learning. I don't think this is superior(...) from a pedagogical perspective. I'd like to learn site reading because that's gonna open up the most doors.
(...)
And this would feel treadmill-y. You have to, maybe we'll wait, I don't know if that's waiting.
(...)
Online pianist is similar, perfect piano. Simply piano's there.(...) Scoove,(...) piano academy, Flow Key.
(...)
There's several of them.
(...)
And there's one to teach you reading.
(...)
For Flow Key, you don't need a, yeah, I'm a bit of an entrepreneur.(...) Trying to learn to,(...) I've got several open source apps and we're trying to build a business around one of them.
(...)
Musician, this is the one from Finland.
(...)
Playground sessions, I tried that very briefly.
(...)
Just to get an idea of what's out there.
(...)
For Flow Key, you don't need any special keyboard.(...) I was gonna mention this earlier. It will try to interpret your piano playing from the microphone. So to that end, if you have a piano and your device has a microphone,
(...)
it will, you will be able to play. But it's better to have a MIDI device for any of these services.
(...)
It's pretty complicated to,
(...)
for software to kind of figure out what chords and notes you're playing, when you have many of them playing polyphonically.(...) If you're just playing one at a time, it's pretty simple.
(...)
But once you start playing multiple, because there's, every note contains many other notes called partials or harmonics, it starts to get much more complicated. And so the accuracy of these software, any of the software is gonna suffer.
(...)
I just think this is a fundamental problem with microphone oriented frequency analysis.
(...)
And to add to that, there's room noise,(...) microphones, the piano may be in or out of tune, the microphone may be high or low quality, there's too many variables to have a good experience with microphones. So if you can get a,
(...)
like any piano with a MIDI cable or Bluetooth MIDI, you're gonna be having a great experience. Cause there's no ambiguity there. It knows exactly which MIDI note you played. And each of these is essentially a MIDI note.
(...)
I work at a day job and we do entrepreneurship in our spare time. We're trying to move into full-time entrepreneurship. I've got a co-founder on one project called Jerry Life.(...) (keyboard clacking)
(...)
We try to do open source work and we try to do work that's in the public interest,
(...)
promoting like wellbeing.
(...)
And so this is one of our tools.
(...)
We built this here in Finland
(...)
as a prototype with the city and it was very widely adopted. There was a government transition in Finland and we had to put the,(...) it was kind of a prototype project on hold during the transition. And now that we're out of the transition, I'm taking the lessons learned from this JavaScript project, porting it over to Python
(...)
and we're trying to reboot the business.
(...)
So this is also built with Python and Django.
(...)
I'm finding those for entrepreneurship, Django is a really good fit. It allows you to iterate quickly. It's very mature and stable, generally backwards compatible, batteries included.
(...)
And we're keeping things very simple. So we're not building
(...)
like a complicated single page app front end. I think that's a big mistake that a lot of projects make(...) and it really introduces a lot of complexity
(...)
and disconnect. You have to have basically at least two people almost. It's hard to be a full stack developer
(...)
with the JavaScript ecosystem being so complicated as well as getting to know the Python ecosystem deeply. I don't know how practical it is. So we're just going all in on Python with a little bit of JavaScript(...) and no single page app framework. Keep things simple.
(...)
So that's the other project here.
(...)
So it'd be nice to be able to focus on these projects more full time in order to do that.
(...)
Having a day job is very beneficial and value that.
(...)
I'd like to make these my day job while still being able to do these actually open source.
(...)
Okay, so we've got the test coming in. So the value can actually just be now the context variable.(...) Whoops.
(...)
And I've already forgotten the context variable.
(...)
What kind of keyboard do you have? How do we measure the impact of our work versus an open source? What are your aspirations? Yeah, very cool. By the way though, what kind of keyboard do you have? I can take a quick look at that and see if you would have a good experience with Flowkey with the one you already have. Generally it should work with any keyboard,(...) particularly if they support MIDI.
(...)
Yeah, measuring the work is a bit hard, but that's exactly the purpose of this Jerry life in fact.
(...)
For the backstory,(...) this was built in caregiving,
(...)
elder care community here in Finland. And we realized that there was a lot of work going on and the basic needs of the residents were being met fairly well. I think Finland is famous.(...) World renowned for the healthcare and particularly the elder care.
(...)
But we realized that there wasn't any kind of coordinated effort for enrichment activities like fulfilling activities going to a concert or reminiscing or group activities.
(...)
So we built this essentially platform
(...)
to help make it visible.
(...)
The people that were living in the home that they were living fulfilling lives. Some people reportedly were sitting in their room in this institutional care and pretty inactive. Sometimes the families would be really concerned even there were newspaper articles written about it.
(...)
And we didn't want that to happen.
(...)
But we have to make it visible and measure the impact. How can we make it visible? Well, if we record just a little bit of data,
(...)
we can make it visible. So that way the nurses in this home(...) could check it out and be like, okay,
(...)
Eva and Kaiser are very inactive right now.(...) We should probably prioritize them today. This Marti is good to go. Pecatine, all these, I know it, LAS.
(...)
Maybe Pecatine, I've only had three in the last week, three activities. And these could be things like listening to music or doing, I guess, arts or going to concerts and this is outdoor activity.
(...)
Sometimes you do self-guided activities.
(...)
And we also can tell what kinds of activities are going on and maybe what they prefer.
(...)
We can sort of personalize the care, which is another important aspect. So this is sort of how we measure the impact.
(...)
And we ran this in a citywide elder care system for I think around two and a half years. I can't remember the exact duration, but we were able to show that the trend increased, activity trend increased from when we initially installed the system through the adoption phase. And then once it becomes visible,
(...)
this is actionable information, not just for nurses, but a lot of times the activities are coordinated by volunteers. I'm looking for this real quick.
(...)
Or family members, or we now have hobby instructors.(...) So the new version of that shows the types of activities as well as like who's doing them. And it helps, this is at an individual level, but the homes, we can see that as well. It helps to know, oh, we might need more staff. We're understaffed or the nurses are doing too many of these activities. It's pulling them away from their,
(...)
the work that they're uniquely able to do, such as dispensing medication or things like that. So the volunteers are absolutely important. And there's particular other types of nurses,(...) Laahioita,(...) like, I forget the word for that.
(...)
Something nurse, who aren't quite certified for certain activities, but can do the wellbeing activity. So yeah, this is how,(...) it's a long story again, but how we're trying to measure the impact of the open source. (keyboard clicking)
(...)
Yeah, the MIDI is gonna be making the experience really good. So you can connect via a cable,
(...)
or Bluetooth, but a MIDI cable shouldn't cost very much.
(...)
And it just depends on the device that you're connecting to, Android or iPad.
(...)
And then the type of keyboard, sometimes they'll have this square end that's like you find on the printers. I think it's USB B, like this one here.
(...)
Yeah, this is the USB B.(...) A lot of keyboards have this,
(...)
and this is gonna plug into the iPad.
(...)
And I don't know about this particular cable, it's three euros, but AliExpress, I don't know. I wouldn't go that cheap.
(...)
In fact, this is an interesting thing. Simply Piano has such good customer service. They actually paid for our USB cable, and they sent us one. They paid for the, they reimbursed me for it. So I do like Simply Piano. I just sort of, we kind of fell out of the service, and I had to choose only one app. I can't have all these apps subscriptions.
(...)
So it kind of went with Flow Key in the long run. Anyway, yeah.
(...)
The piano shouldn't cost.
(...)
The one piano needs MIDI, so yeah.
(...)
And our aspirations are to be a self-standing business. We just wanna be a small business, and have a product that we can sell and develop openly
(...)
that other people can use and benefit from, but we would like to sustain the business,
(...)
and pay salaries for ourselves, and maybe some other people offer benefits,(...) like a small business, but not like a Silicon Valley business, where you kind of wanna get really big, and expand, and expand, and have an exit strategy, and get bought out. We're not in that mindset.
(...)
So let's see, our value should be coming in to the template from the view.
(...)
Okay.
(...)
So here I just need to rejoin the context.
(...)
I think render, does render, what is it? I'm gonna say render take request, content, status, context, okay.
(...)
It goes context. It goes context.
(...)
Render status, very cool. Okay, now I think we're good to go.
(...)
And the search query as well pop into the search form.
(...)
Right, boom.
(...)
Now let's try getting a page not found. So this should be page not found in our search.
(...)
There it is, okay. I think this is gonna be the good solution.(...) (keyboard clacking)
(...)
Yeah, so another page that we may have moved, or may never have existed. Now we wanna try that.
(...)
Or may have existed in parallel universe.
(...)
Okay,(...) we get it, it works.
(...)
So yeah, the search term and then I can say, oh yeah, well I'll just search for that.
(...)
So now they opt into searching. (keyboard clacking)
(...)
So I'm gonna have GPT kind of give me some writing assistance.(...) The ownership is structured right now. We're an LLC, so limited liability company, more or less in Finland. It's not exactly the same, but it's very similar.
(...)
So we have, I miss myself and my co-founder, and we don't have any other ownership structure. Originally we incorporated a cooperative,
(...)
and we just decided that in order to attract other potential investors, like not venture capital, but just people who wanna support the company or be part of it, and have shares in that I guess, we should probably incorporate, or get support from the government. I think we also, some grants have to be a limited liability company for some reason, they don't support cooperatives.
(...)
So that's the basic structure. It's just a regular business, essentially.
(...)
It's the most common form of business to my understanding.
(...)
All right, so.
(...)
And I probably don't need this to be a header too, I'm not sure why I did that. That was kind of strange, but here we go. We apologize, but it seems like this page doesn't exist. Don't worry, we're here to assist you in finding what you're looking for. You can use the search form below to help locate the content you need. All right, that's sort of friendly, yeah, yeah.(...) So refresh that.
(...)
So I think this is overall an unusable approach. It's gonna reduce the load on our server and let people opt in to search in. Now, can I do,
(...)
let's see, make it a little more narrow.
(...)
What's the name?
(...)
(keyboard clicking)
(...)
Let me double check this. I can't even remember.
(...)
(keyboard clicking)
(...)
Grid system.
(...)
There's a newer version, what are we at? 5.3.
(...)
That's right, I just updated that yesterday.
(...)
I wish just the dang Google results were linked to the latest, but they have to have 5.3 in the URL.
(...)
And that causes the Google results to always be pointing to the wrong version.
(...)
Full stack or just front end? Full stack, I would call myself. I do dabble in JavaScript. I built a full stack app with JavaScript.
(...)
And welcome to the channel, crazy.
(...)
Nice to see you.(...) However, in this project, I'm full stack, so back to front.
(...)
However, I try not to get too deep into the infrastructure. So we're using a platform as a service. So I don't have to do like Kubernetes or AWS type stuff. I don't wanna waste time. I don't wanna spend too much time there. So I don't get that deep in the stack. And I've opted out of using a single page app framework because I don't believe it's a good fit for this project. It would introduce too much complexity.(...) So full stack by keeping things simple.
(...)
It's a bit of a philosophical approach, but it's in line with this recent trend towards,
(...)
well, back to rendering things on the server, as well as using more lightweight JavaScript for reactivity on the front end,(...) rendering partial content on the front end, such as using HTMLX,
(...)
which is becoming very common.
(...)
So using HTML powers that have existed for a long time, but haven't been as well leveraged. We kind of took a detour through this single page app
(...)
hypothesis, and I believe that it isn't appropriate for most apps.
(...)
And it's sort of like it was big tail chasing exercise in a way. And kind of constantly reinventing, based on the mistakes that each generation, so to speak, of SPA technology introduced. And those generations come quick, come and go quick.
(...)
About every six months to a year, React is including its own generational cycle.
(...)
But I'm not using HTMLX here. So that's a long way of saying I'm full stack, but keeping it simple.
(...)
Like I use bootstrap,
(...)
because it's actually really good. It's still keeping up and making changes.
(...)
So yeah,(...) no JavaScript build system, no build tool needed.
(...)
So I believe this works. Now I can remove my middleware.
(...)
Crazing, do you build any projects? What are you working on? Or what are you interested in learning about?
(...)
Right now I'm working on a project for this community website in the United States, mostly United States and Mexico,(...) maybe in Canada as well, called Western Friend.
(...)
So it's a live website and basically has a lot of features. Primarily it's a magazine.
(...)
And we have magazine issues.
(...)
The most three recent issues are pretty much subscriber only,
(...)
except some articles that are featured.
(...)
The rest of them, if you're not a subscriber, it'll ask you to subscribe and you can read the full articles.
(...)
But once the issues are about six months old,(...) they go into our archive and everybody can access those.
(...)
And this is just to generate a little revenue. It's a nonprofit organization, so it's not like super commercial or anything.
(...)
And you can just read everything here.
(...)
And the cool thing, this archive of magazine issues is deep. It goes back to 1929, I think.
(...)
1929, boom.
(...)
And all these are online and they're hosted by the Internet Archive.
(...)
And that means it's also the full text search capabilities. Like I can highlight the text and search is crazy. It's cool. Here's a bug. I don't know how to fix this. A UI bug. But anyway,(...) we also have like a bookstore.
(...)
So long short, it's a community website, but it has a lot of features that maybe you'd find another website. So e-commerce, it's got donations, subscriptions.
(...)
We calculate shipping.
(...)
We have a library of multimedia items. We have podcasts, an events calendar, contact form,
(...)
subscriptions and donations. So it's not just like a simple blog website. It's a pretty,(...) actually it took us five years to build this. And we launched it a month ago, I think.
(...)
Okay. What kind of site are you building? Yeah.(...) Front end is a big challenge already.
(...)
Back in, and if you try to juggle front end and back end, yeah, I can see how it would be very challenging.(...) What are you considering building? And are you thinking about Python or what have you already started? Is it open source? Can we take a look at the code? I can offer some perspective here. So let's go ahead and remove the old middleware.
(...)
That was again a core middleware. I think I can remove this whole file now.
(...)
HTTP response middleware. Very good.
(...)
So we don't need to do that anymore.
(...)
But if you have the choice and you're still in the early stages of the project, I really recommend using Django if you can. I could make some solid arguments as to why that should be the case. Although I see that you're using a single page application. Front end, you might be tempted to use something more lean, I would say, such as like fast API, which we use in my day job.
(...)
But Django actually will provide you some surprising features that you don't really know you need until you need them. And they're there just waiting for you.
(...)
So we can commit these.
(...)
And I can actually revert that. We don't need debug now.
(...)
Now we're just.
(...)
I just reverted that.
(...)
Oh, I see. So you got to save it. Of course.
(...)
Yeah, I can do a code review. Blaze glad to. I like checking out open source projects.
(...)
You should be able to paste it in the chat. I think that I've got the settings to allow URLs there.
(...)
Okay, so now we're just we'll remove the middleware. So that's good.
(...)
And we replaced it.
(...)
There we go. So it looks like you can share that. Good. Oops, hold on a second.
(...)
Come on. Pre-commit hooks. They're helping me write cleaner code.
(...)
All right. Copying that link. And then we can do a quick demo. So I'm going to go to the next one. And I'm going to go to the next one. And I'm going to go to the next one. So I'm going to copy that link.
(...)
We'll paste in a tab that we're.
(...)
Blaze Labs.(...) Good. So HTMX don't need it right now. We're thinking about adding it to projects I'm working on.
(...)
Tragedy. Okay. Blaze Labs. Let's see what we got. Twitch agents.(...) Convo XML. Python. SQL to graph.(...) SQL to mermaid.
(...)
To site that links builders to users. Sort of like Upwork. But hard-nished into the construction industry. Okay, cool. That's a big project which I'm starting on January 1st. Nice. Yes.
(...)
Yeah, you could do that.
(...)
That's a CRUD application. So you're going to be interacting with the database. You'll be creating items in the table. You'll be reading from the database, updating and deleting items. CRUD app, right?
(...)
And.
(...)
SQL mermaid probably the best one. Okay, cool.
(...)
Oh yeah. The other thing is you'll probably have a lot of relationships in your data.
(...)
Such as project could be related to organization or user could be relating to project or builders and users. Builders to users. So even in a description you've got relationships.(...) So please,(...) at the very least, use a relational database.
(...)
Don't go with MongoDB or some kind of schema-less, as they call them, database. You'll find that you're going to be reinventing relational logic.
(...)
That's what I found at least with our project that we originally prototyped JerryLife using MongoDB. We have libraries that basically reinvent things that would have been done all ready for us had we used Django even.
(...)
So you have relational database.
(...)
And you can do full stack Django for that. You probably don't need a single page app framework.
(...)
And for the dynamic parts, if they do emerge, you can get by with Ajax requests and HTMAX to have that really full first-class user experience without full page refreshes for the dynamic parts. But start with just a full stack.(...) Django.
(...)
Yeah, what are your language preferences?
(...)
Okay, good. Yeah.
(...)
Because we're using MongoDB at my day job and basically we're also there. We're just struggling with some of the fallacies that MongoDB has introduced to our team.(...) We believe, for example, we don't need data migrations because we can just put any shape of data into the collection and just get it out. And then what we ended up doing is just, well, since we're not migrating the shape of the old data, we have a bunch of logic in our views essentially that has to handle permutations of data structures from previous, essentially, evolutionary stages in our data model.(...) Or we need a migration. But then we don't have a framework or any guidance on how to migrate the data or even some of the gotchas that have come up during that discussion. We're having to operate at a lower level.
(...)
And the guys I work with are really skilled and talented and knowledgeable. But even then, those are very complicated things to sort out. And if you have a framework that just has it sorted and encourages best practices out of the box, save yourself time and focus on your domain, which is what makes your app unique. Don't build migration framework.
(...)
Django's got it built in. Or Ruby on Rails, something like that. Build something Laravel. I've looked in the JavaScript ecosystem and not found one. There's a couple of attempts emerging, but I don't trust them. They have usually only one core developer. So that's a situation where you could even have a fly-by-night or they are even the ones that are built by companies like we originally did Meteor.
(...)
And then that company that was building Meteor kind of bailed and sold it to a venture capital firm. And also they bet on some questionable-- they made some questionable design decisions here.
(...)
Yeah, that's cool.(...) And JavaScript is popular.
(...)
The closest I found, though, in the JavaScript ecosystem is--
(...)
there isn't really one that you could compare to Ruby on Rails, Laravel, Django. It's really surprising. And I think this is a symptom of the JavaScript community mentality where they can-- I don't know how to describe it, but things just aren't built for longevity. I think there's a lot of hubris and a lot of ego also involved with evolution and people wanting to be on the stage and presenting their ideas the most revolutionary and newest thing. And please adopt this thing that I've invented.
(...)
There would be Dan Abraham Hobbs type people. I don't see that as much in the Django community.
(...)
Maybe Ruby on Rails has David Hennemeyer Hanson or whatever his name is. But JavaScript--
(...)
I've looked in the JavaScript web frameworks. And most of these frameworks aren't really like frameworks in the sense of the word. And now the JavaScript community has invented this thing called a meta framework, which is making it even more confusing. It's like they don't realize-- really even understand what a framework is in terms of rich web framework.
(...)
Most of these are just front-end libraries or conventional packages that--
(...)
Let's see. But I also see these Google results. But there's one.
(...)
Yeah, that's right. I don't hate it. I like-- I wouldn't mind writing JavaScript.
(...)
I'm not super excited about TypeScript, but I don't like to churn. I don't like to do this function. And I don't trust it to bet our products and projects on. I don't have the resources or energy or capacity to keep up with things. And having your dependencies wrought out from under you, it's a really weird feeling. Like having to really get down into the weeds on framework level stuff. Like your test framework stops working one day. Your UI component, which the library is no longer compatible with your storybooks and components. And you're just having to fight your tooling. It's like, what is going on? I need to just focus my energy on building and the product.
(...)
While Django, for example, is not perfect, my energy has been going much more into just building and focusing on making the thing that's unique.
(...)
So I've stayed away from that. Next.js is not the one I was thinking of, but it's very popular. There's just one I can't recall.
(...)
I'm not going to be able to find it, but believe me, I...
(...)
See, that's the confusing part. It's BUN is not even a framework.(...) A framework is a set of tools and conventions that help you complete tasks based on collective experience of other people in the same domain.
(...)
And so,(...) a UI component library or like BUN is pretty phenomenal in what it's trying to achieve. And hopefully it maybe will help contribute to some standardization and stability in the JavaScript ecosystem. I would like to see that, you know, because it's got a build. It's a build tool and a language runtime and Linter. I think it's combining a lot of things into one.
(...)
But all of those are just tools.
(...)
Even the language runtime, that's not a framework. A framework is like having something that's going to help you write views, like render data to the client,
(...)
interact with databases,(...) handle middleware requests, responses, validation, authorization, authentication.
(...)
That's a framework. It's like high level stuff. That's like batteries that you need in your app, but they're very complicated to write.(...) Like authentication is a really complicated thing. And there's a lot of things, mistakes that can be made. So, how do you, you know, hash passwords, those like types of things.
(...)
That's what a framework like Django is going to provide or Ruby on Rails.
(...)
I'll find the one for JavaScript. I'm not in any way, I don't hate JavaScript, the language. It's the ecosystem. And I wish that, really do wish that more longevity could emerge there. I think a lot of people are wasting so much time and not even realizing it because of the inadequacy of the ecosystem.
(...)
So, here's what I mean by a framework. So, you got data models. You can design your data in the language of choice. So, JavaScript, you could write a JavaScript class.
(...)
Or here's a Python you're writing classes that these are actually tables in a SQL database, a relational database.
(...)
You have views and you have a conventional way of writing views. You have ways of getting data in and out of a database, CRUT operations.
(...)
You have this admin interface, which is good for when you're starting out and prototyping.(...) You have a URL, you know, like design and handling. So, you have a, in fact, this was funny that the Meteor framework didn't come with a router, like a way of routing URLs. You had to turn to a third party ecosystem and there was competing routers in the Meteor JS ecosystem. It's like, I think React router is like not a core thing. It's like a framework includes a router. You don't have to choose that. It's just part of it. Here you go. Use your router and use it. This is server side routing, not client side.(...) But here's a way of writing views. And you have this conventional signature. A view takes a request and potentially some arguments passed in from URL parameters and does something. It's just a function that does something, typically function based views and returns a response that probably renders that data to a template or can return JSON response if you have a front end framework.
(...)
But don't overlook a template library and JSX is a bit of a mess as well with the giving you so much freedom of everything being in JavaScript. JSX code starts to turn into very confusing,(...) like really fast. It's just because you get this tangle of imperative logic and template logic and potentially CSS and JS or it's like really like early 2000s PHP where everything was just sort of bashed together.(...) This gives you a little bit of imperative logic like loops and interpolating data into the template. But it's primarily in just HTML and I know JSX sort of emulates HTML as well, but it's not.(...) And critically,(...) some of the semantics of HTML aren't like are changed. So you're actually you're learning a meta language.
(...)
Currently working on sub projects.(...) OK, five locations from five input boxes.
(...)
Rank them in order.(...) Closest to use location. Yeah, this is interesting. Google Maps APIs, but yeah.
(...)
There's with the node things. OK, cool.
(...)
So the locations or kind of location data is it? I'm on a big tirade about frameworks, but seriously, this is very important to consider, especially if you're wanting your project to last more than one, two, three years. And these projects do they last very easily.
(...)
I'll try to remember that JavaScript framework. I don't know that it'll last. I don't trust much in the JavaScript ecosystem. But anyway, back to your thing. Sales.js, we did take a look at that.(...) It's been around for a while, but it's not really so rich.
(...)
Maybe Hacker IO has this.
(...)
Framework's using 2023.(...) Starts with a C, I think. C. So it reacts to another framework.
(...)
Jeez.
(...)
Views, not a framework. No, just not really a framework. It's a language runtime. Ember's not so much a framework. Meteor didn't turn out to be a framework. They don't have a router. They don't have a ORM or ways of defining schemas for the database. They had user authentication, authorization. No, they didn't have authorization yet. I don't know. Mythril might be. Polymer's not a framework. These are libraries that for user interfaces, Backbone is kind of a conventional, but yet not here in a bunch of garbage.
(...)
Whoops. So front-end framework, I can get the idea there. So are you taking just basically a formatted address that's comma-delimited locations, or are you splitting up the address components? I have this exact problem I've been working on at work, literally.(...) During my day job, we've been fighting the geocoder.
(...)
So I can offer some advice there, language agnostic, about geocoding and what might help your project.
(...)
We're using Python, but we're interacting with the Google geocoder APIs. So it doesn't really matter if you do that with a JavaScript or whatever.
(...)
Here, comparison.
(...)
Okay, web frameworks.
(...)
These are all front-end frameworks. It's not here either.
(...)
[sniffs] So this is just weird. Murn.
(...)
It's like there's so much churn.
(...)
Remix.
(...)
Granted, I mean, there are some exciting things coming up in JavaScript, so I can see the appeal.
(...)
But hopping from stone to stone is not a way to manage a sustainable project.
(...)
It starts with a C.
(...)
Google autocomplete. Okay, good. From Commodilla, divide it up.
(...)
Okay, cool. And then you get coordinates back from that, right? Now, here's a good thing. So how do you measure the distance of the coordinates? We use a GOPY.
(...)
To get the distance, the--
(...)
[sniffs]
(...)
Here's where we use-- there may be something for JavaScript.
(...)
So you don't have to invent your own habber sign function. Turf was the-- yeah, about the closest. I've got a JavaScript project that was doing some geospatial stuff. [clicking]
(...)
So this would be a good one.(...) Because these--(...) your graphics stuff can actually be surprisingly complicated.
(...)
As you probably have experienced.
(...)
[clicking]
(...)
Almost have to log into my work, and we have this...
(...)
...document that describes it. So much of it is attached to the template language. EJS is template language. These are spells that sort of-- So there's so much confusion about what it is a full stack framework, even. Granted, these are just trash sites,(...) like...
(...)
SEO content stuff.
(...)
Hmm.
(...)
Google has Google Maps Distance Matrix API, which can just straight-- Okay, cool.
(...)
Okay,(...) so how come you're struggling on that? Is it-- you're not getting results back like you expect, or are the results--
(...)
the quality of the results not good?
(...)
Because that's our main fight right now,(...) where I work, is that the quality is not good uniformly. Some places, like the United States, I would suppose are much higher quality, but we have addresses around the world, and in particular, some markets, you know, just have poor or non-existent coverage in a way. So, like...
(...)
Yeah, it's a bit of a challenge.
(...)
And you don't want to invent your own geocoding service. That's really complicated.
(...)
[typing] [typing] [typing] [typing] [typing] [typing] [typing] [typing] [typing] No,(...) no, no, no.(...) Feathers. Wow, so look at feathers.(...) Huh. I can log into my company...
(...)
Wiki.
(...)
Ah, yeah, okay, gotcha. So, yeah, you want to be careful about that, but...
(...)
You should be safe to make those requests at Google.
(...)
So now you're trying to convert it to Node, but it won't find your server. Huh. Where is your server deployed? Is it behind a firewall? Or what...(...) I don't understand the kind of architecture there. Can you run this service locally, though? I mean...
(...)
Blaze...
(...)
I'm sorry.
(...)
[laughs] Yes, code review. Excuse me.
(...)
This is a really interesting conversation.(...) You said the sequel to Mermaid, right?
(...)
[laughs]
(...)
[typing]
(...)
Okay, so let's see. So first thing I noticed, there's no license.
(...)
So that's one thing. Add a license. So what you can do is, up here, there's this button that says, like, "setting" or "insights."
(...)
It's right here. Community standards. There we go.(...) Yes, so do these. As many of you as you can.
(...)
There we go. First code review. So that's a project-level review. I work with a lot of open-source projects, so I know the importance of these documents.(...) Code of conduct, okay. It depends on how popular you expect it to be. But the contributing guide, that's really useful if you would hope that people will get any interest in your project and want to write a pull request. Give them some helpful tips on how to run the thing locally, for example. And you can look up some templates, contributing guide template. Here, I'll actually give you one from chatdbt.(...) [typing]
(...)
Contributing guide template. What do you include in there? It's, you know, not always that easy.
(...)
But yeah, like, these are all pretty important things. Whoa, it's even giving me the whole dang thing.
(...)
Let people know how to help you out. And you will be surprised. People will help you out. So I can open a pull request real quick. Where did it go? Where did it go?
(...)
I hope that JavaScript framework just jumps out at me.
(...)
So we're missing those, but you got a lot of, got the description to read me, that's good. So choose a license, though. It's not open-source until it's got an open-source license. It's surprising. Even though you put the source out there, it seems like it's open, publicly available. But open-source means also that people can adapt it, modify it, and potentially reuse it for other purposes.
(...)
And you probably don't need a security policy or issue templates or pull request templates until you start getting contributors.
(...)
So let's start there.
(...)
So what I'll do is just open a PR.
(...)
Contributing.
(...)
.md. And you can just take this or leave it. I won't feel offended.
(...)
This is just to give you something to work with.
(...)
In that way, because I can't paste it into Twitch chat.
(...)
But surprisingly,(...) instructions like this can be really useful to new contributors. It can be confusing to even how to get your project running.
(...)
At the bottom, there's MIT license. Okay, so here I'll just propose these. You can check them out.
(...)
SQLite to mermaid.
(...)
I see that now. Okay, so that's not obvious, but that's good. You got it in your readme that counts.
(...)
Also, GitHub can't detect that. But if you put that in your license file, in this button here, the Choose a License will actually do that for you. Whoops, community standards here. This one right here.
(...)
Damn, RIT.
(...)
Blaze Labs, twenty-three.
(...)
Here you go.
(...)
Same thing. Couple pull requests there to get you off and running so that you don't have to do too much of this groundwork.
(...)
Yeah, cool. My pleasure. And I like this mermaid. Yes, this is a cool library. I like there's a lot of cool stuff in the JavaScript ecosystem, like libraries. Library level stuff, but not for a whole product, but just to do like a widget or some kind of feature in your user interface. But I don't trust to turn my whole project over to JavaScript or even just over in the front end. Yeah, I tread cautiously.
(...)
Okay, so that's good. So community insights from a perspective.
(...)
So let's come to the code level here.
(...)
So I see you're using poetry,(...) PyProject.
(...)
Okay, so your PyProject could use some hygiene a little bit here.
(...)
What do you like? What do you think about PyRite? Is it pretty good?(...) Oh, you're using rough. Very cool. We've been using that at work. We just changed this into a rough. Pretty nice. It's kind of like Bun has got a little more batteries included.
(...)
And it unifies a few tools, which is nice. And it's built with Rust, so it's fast. PyRite though, I haven't used. So yeah, this is cool. So clean this up a little bit. Just put in that metadata there.
(...)
And consider supporting Python 3.12.
(...)
So suppose that you're using rough, so the code's going to have good lint. I won't have to pay much attention there. It's got good docstrings. Nice.
(...)
Everything is documented. Very good.
(...)
That's not common.(...) Surprisingly, things are a mess. Okay, and then you got things are pretty well named.
(...)
Okay.
(...)
This is, I don't know. Is this SQL injection?
(...)
Vulnerable.
(...)
The F string.(...) So that's one thing the Django framework kind of prevents or doesn't make it easy for you to have SQL injection.
(...)
I'm always just cautious when I see SQL with interpolated values.(...) I don't have a lot of experience there, but make sure that this is safe.
(...)
Cursor is coming from connection, which is coming from SQL injection. So let's check chat GPT.
(...)
GPT knows it is Python.
(...)
So the Git tables I'm not so concerned about because that's just iterating.
(...)
And who's going to be invoking this also? You've provided a Python class named SQLite to mermaidjs. It appears to interact with the SQLite database and use for generating table details, including foreign key information. Here's a concise, straightforward explanation.
(...)
All right, cool.
(...)
Pragma fetch all is the...
(...)
You've probably already checked this.
(...)
Okay, now the Git table details method in your code is potentially susceptible to SQL injection because it directly interpolates the table name variable in the SQL statement without proper sanitization. It's going to allow malicious users to manipulate a table name parameter and execute arbitrary as SQL. It's meant to make DB relationships easy to visualize.
(...)
There should be a GIF in the README. That would be good. Yeah, and you README always include like a screenshot or something like that. Very good idea.
(...)
But I would even for some internal functions that you may think are safe, do this. So watch out for SQL injection. If you just let raw SQL string be interpolated, F string into a SQL thing, you're setting yourself up for data loss. I don't know where this table name comes from. So it could be just an internal thing, but even for internal functions, just don't go there. A framework also helps you avoid that.
(...)
So I think you're using...
(...)
What was it? Yeah, anyway, not being...
(...)
That's me.
(...)
Not being too critical. I'm just double-tricking. You're using Flask is what it is, right? Or what are you using? What are your dependencies?
(...)
Okay, so you're not using poetry markup save.
(...)
Yeah, and get in the habit just of avoiding it.
(...)
So for example,(...) I'll open a PR. I haven't trusted this code, tested it or anything like that. But just to give you an example,(...) can I... Where's the thing?(...) This one here.(...) Can I just comment on this?
(...)
No, I can't.
(...)
But this is susceptible to a SQLite injection. To SQL injection, SQLite injection as well.
(...)
Also, the lint...
(...)
I don't know, this turns out to be two lines.
(...)
Or consistent spacing. One or two, but not one and two. And you had white space there. So I don't think rough is running.
(...)
So use this pre-commit.
(...)
Every time you want to commit, this will run.
(...)
We use this. It will run certain jobs. But let me just really quick give you the example.
(...)
Get table details. Get table details.
(...)
Parameterize query.
(...)
Thanks to chat GPT.
(...)
Test that code out.
(...)
But you get the idea. And read more about this. Parameterization.
(...)
It's a small change, but makes a big difference.
(...)
Check out pre-commit.
(...)
This, like I can show you our pre-commit.
(...)
So we're going to... Jerry Live Caregiving.
(...)
This will help you keep your code clean. And make peer review easier. Because if everybody is just automatically linting and taking care of low-level details. The peer reviewer can focus on higher-level details. And not have to worry about, oh, there's double... There's two lines there. So what it does is just runs commands called hooks.(...) Every time you commit or every time you push, you can configure it. I do it every time I commit. And it just does things like make sure your YAML is formatted correctly. Or your JSON objects and Toml. Or you didn't leave any merge conflict strings in there. That happens actually. Surprising amount. Or that you're using the latest Python semantics.
(...)
Latest features.(...) Or Django features in our case. You got trailing commas. And you pick all these things. You're running rough every time you're running the rough linter and the formatter. Because now it does both.
(...)
Currently linting... Here I'm linting my templates.
(...)
Making sure we got our documentation strings are formatted correctly. Our Django HTML is formatted correctly. We're running prettier on our CSS JavaScript JSON markdown on SES and YAML. And we're keeping some things sorted.
(...)
So all of this is just run every time automatically. Super easy.
(...)
Here's our example. Precommit.
(...)
Okay, cool. Remember to test.(...) That just came straight from GPT. I just copied and pasted it.
(...)
Both of those. So put your own flavor in there. Make sure it's meaningful to your project. Okay, cool. So there's a few things.
(...)
And let's continue the peer review.(...) So that's the main one.
(...)
But I like the idea. It's really cool actually to help people see their SQL, their relationships.
(...)
This is nice.
(...)
I can see myself using this project. There's a similar one for Django.
(...)
Called Django tools.
(...)
I think.
(...)
Maybe Django...
(...)
I'm going to surrender schema diagram.
(...)
Can't remember.
(...)
Django something.
(...)
Django extensions.
(...)
That's the one.
(...)
Oops.
(...)
So I'm not saying that this is in any way related or should be.
(...)
Anything about your project in relation to just coming up with an example of a utility
(...)
that renders the schema. That can be really valuable.
(...)
Well, I thought it had to there. Django extensions.
(...)
Render...
(...)
At least at one point it had that. It renders it like this.
(...)
It's using graphvis.
(...)
So it comes up with a static set to log me in.
(...)
Oh, here we are.
(...)
Graphvis.
(...)
Py. So it's static images that it comes out with.
(...)
Whereas the...
(...)
Whereas your library is going to be an interactive one. That's actually pretty cool. It's nice to see reference code to see how other projects are doing it.
(...)
Mermaid. Are they interactive or static? I can't quite remember.
(...)
Static rendered in the client though. Or in this case on the server and sending it to the client. All right. So we've got tests. This is great.
(...)
So one thing you can check out, you're an open source project that you qualify for free CodeCove.io. Sign up.
(...)
By Sentry.
(...)
I'm using this on pretty much all of my open source projects. Project CodeCove got acquired by Sentry. We're also using Sentry on our production app. Really good.
(...)
And it'll help you keep your coverage in check.
(...)
So basically it makes sure that for every line of code you write, there's a test to cover that behavior.
(...)
Sometimes you'll have a test that goes over a whole function, but certain paths in the function like if statements, like branches. For example,(...) you won't have tested a particular case for that. So,(...) I mean the code in yours is pretty straightforward. So this coverage is probably complete, but it's without measuring it. We don't really know.
(...)
So all we're doing is like, what is good coverage?
(...)
Boom.
(...)
And here's an example of what it looks like. It shows me like, okay, these lines, well, this is interesting. Yes, these lines are covered. These lines aren't. And then you have to figure, oh yeah,(...) there's an if statement here and my test doesn't ever get that condition. So it's not covered.
(...)
So I can give you an example on our Western Friend project.
(...)
We have our code coverage right here. Reporter running 98% code coverage.
(...)
This is CodeCove.
(...)
It shows you your whole project on complex projects. There's so many lines of code.(...) You're in some mind-boggling too even. There's no way you can really keep it all in mind.
(...)
But this one shows me, there's a couple of hooks files.
(...)
And my helper is pi.
(...)
That one probably I should be worried about.(...) So let's check it out. My helper pi.
(...)
What was that under?
(...)
Library helpers.
(...)
And the key is,(...) not only will this show you where your coverage is missing,
(...)
dang,(...) that's a fortunate error.
(...)
But it'll come up during your pull request.(...) So if you take the lines of code you change,
(...)
what's a good example?
(...)
It's part of your CI process if you want it to be.(...) I don't have any good examples here.
(...)
Here's one. Code coverage.
(...)
This is the percentage of coverage we have. And particularly how this pull request affects our coverage. Is it going to decrease it? Are there lines of code in this pull request that the coverage was affected?
(...)
Something's going wrong. It's like processing commit message unavailable.
(...)
It's like a bug or not sure.
(...)
You don't have to use this particular service in general for Python.
(...)
In fact, this service uses Python coverage.
(...)
So consider just adding, you would need to add it if you use code coverage. But coverage in general is somehow into your development mindset.
(...)
We use coverage pie at work. We don't use coverage where I work.
(...)
But we use some other services.
(...)
And with Western Friend, I'm also keeping track of the maintainability using code climate. So that might be the better. I think now I've merged test coverage into code climate.
(...)
So actually this one is the one I'm moving towards. For some reason,(...) code cove is not working so well.
(...)
But code climate, it's a bit tricky to set up.
(...)
But it'll be part of your pull requests. And it'll keep track of your coverage as well as some code smells and potential bugs that you should avoid.
(...)
Making things too complicated or not writing tests.
(...)
For example, my model is pi. It says F. No issues here. It's strange.
(...)
Oh, because there's no code there.
(...)
It's a bit hard to get into the details.
(...)
Anyway, so these projects help you write better code. And they keep the peer review process at a more interesting level.
(...)
Strange. And I guess I've disabled this one. So that's why I've integrated them here.
(...)
Pull request time.
(...)
SQL mermaid.
(...)
So yeah, it's good though that you've got tests and you probably have sufficient coverage given the scale of that template. Let's see mermaid template.
(...)
So this is stuff that your lender should have caught. It's not a big deal.
(...)
But just this indentation sort of a sign of sloppy coding.
(...)
Also try to use const. Let or const. We shouldn't really need to use var anymore.
(...)
So GPT says.
(...)
OK, thanks for the start. I appreciate it.
(...)
OK, this is kind of interesting. So GPT recommends a refactoring sort of like this is good high level stuff.
(...)
So what you should do is initialize mermaid. Then you add zoom to mermaid diagrams. Now granted, initialize mermaid is only one line of code. So that's a bit of a unnecessary abstraction.
(...)
But this is nice.(...) Add zoom to mermaid diagrams is kind of self-explanatory. If it was more complicated project, there was more JavaScript and you're on load function.(...) That would make sense.(...) So what you should do is that a function should only do stuff at one layer of abstraction.(...) So in other words, initialize mermaid is a layer of abstraction. You're telling it telling me what you're doing, but not how I don't care how not at this level. I just want to know, OK, you're initializing mermaid and then adding zoom. That's all I need to know. But then if I need to know, OK, how do you manage initialize mermaid?
(...)
I can read that. But more complicated code is encapsulated. How do you add the zoom to mermaid diagrams?
(...)
I see you're using D3, but I typically don't need to know those details. They're there when I need them. Then you can add a docstring also that I could actually hover my mouse over and just read the docstring. So it's like a level in between of understanding.
(...)
So it's about a developer experience and about cognitive load. How much do I have to think to understand the code?
(...)
If I'm just seeing that you attach an event listener load, I don't want to have to think very much here.(...) I don't really care that you know that the D3 is part of the thing or these imperative steps. They're not so relevant to me. But when they do become relevant, then a docstring could just be all that's needed.
(...)
Now this docstring just kind of reiterates the function name. That's not very useful, honestly.
(...)
But here's one.
(...)
Oh,(...) and it wrote a function within a function.
(...)
This function gets hoisted.
(...)
So it's available here, but it doesn't need to be within here. So that's a bit a weird thing. There we go.
(...)
So let's see what it does here.
(...)
Yeah, it's good. And the more contributors you have with a bigger team and a bigger project, you're going to want to care about developer experience. Now it still didn't quite move that D3 select all. Okay.
(...)
Yeah, and that's an implementation detail. So we can go inside there again.
(...)
Yeah. So let's take a look at this code. I think this is pretty good. So it's using constants. It's moved the constants to the top of the file so that they're easier to maintain that way. And they are using upper case and it's just a convention, but it shows it, you know, not only that you can't be mutated.(...) The reference can't be changed. If I understand something about anyway, it's also using capital. So you single that you shouldn't change the contents of the reference. Yeah. And then if you're a mermaid class changes in the template, you just change it here. It's easier. You don't have to kind of zoom into the details and read through all the imperative logic. So the things that these would otherwise be called magic kind of magic values.
(...)
So here you're using a literal, a string literal. And rather than tell me, you know, what is this string representing?
(...)
But here,(...) gosh, darn it.(...) I know that. Oh, it represents a mermaid class.
(...)
Plus SVG.
(...)
Yeah. Very cool. So I'm going to copy this. I think this is a decent code copy out empty or I didn't write it. I haven't tested it, but I would rewrite this more similar to what chat. GPG has produced for us over a couple of iterations.
(...)
And I would put this.
(...)
I would actually put this in a JavaScript file and load that JavaScript and be mindful about indentation and linting. Just like, um, it's a sign of a craftsmanship or of attention to detail.
(...)
And it's a lot of details to pay attention to. So have the tools do the work for you pre-commit.
(...)
But let's see. So what we would do is create, um,(...) uh, JavaScript file.
(...)
So we're going to do this. SQL is a mermaid.
(...)
Create a branch.
(...)
Yeah.
(...)
Add a file.
(...)
And this was under templates. So, yeah, where's your, these are JavaScripts are coming from. Okay. So this has been challenging here. Isn't it moved just to an own JavaScript follow.
(...)
Yeah. And all these things don't take these as like criticism. These are just, as you asked for some constructive feedbacks, practical things. And literally when I write, could it work? This is the kind of stuff we get.
(...)
And we try to also not just explain the what,(...) what the why as well as the how.
(...)
The reason that I think this is better to be in its own JavaScript file is you'll have tooling like prettier. Uh,(...) that's going to really work well with JavaScript, but might get tripped up on JavaScript within HTML. I think prettier is going to be pretty good at it, but then you introduce these types of things. You got HTML and then you have a JavaScript and then this is what's the name of this template and the name of it. But you see, we're getting multiple languages intermixed and then the linter might get chipped like tripped up on it.(...) So you would need a much more complicated linter.
(...)
What's the template of that language here? I can't remember.
(...)
And so you have a little string literal here or just the class diagram, I guess. Wrap this in a paragraph. It's not just a naked string.
(...)
Do you need that there?
(...)
Ginger two. Thanks. Yeah.
(...)
Yeah. Ginger two.
(...)
Can you delete this class diagram? I don't know. Or is it necessary? I didn't quite recall it.
(...)
At the very least, move it here and put it in the heading.
(...)
For example,(...) some kind of semantic unit.
(...)
By semantic, I mean it tells me, oh, this is a header.
(...)
This is a page division or a paragraph.
(...)
But as it was, you had a div.
(...)
And a div isn't telling me what kind of content is there. It's just a page division. It's not semantic. So if it's text to a user is going to see, use like a p tag, paragraph tag or h tag.
(...)
Yeah.
(...)
This is looking good.
(...)
Yeah.
(...)
This is kind of complicated. You might move this.
(...)
You might do some pre-processing in the Python code to make your template more straightforward.
(...)
Like we're stripping out. This is sort of getting into the JSX thing where I'm like sort of thinking that.
(...)
When we're grabbing indexes and we're stripping out is one thing, you know. Django has like a filter tags, but I would consider prepping this a bit better in the back end.
(...)
I don't know on a pragmatic level.
(...)
But I can ask Chad GPT.
(...)
So, templates should be really simple. That's the Django philosophy I owe to here to it. I agree with that. Django.
(...)
Yeah, tests are challenging, aren't they?
(...)
Essentially tests often are more difficult to write and can even be a lot more time consuming, but the majority of your project code can actually be living in tests because of the setup and the context and all the things you got to keep in your mind to even write them. It's a very painstaking process. So yeah, I understand the focus there.
(...)
And remember, our projects are just iterative, right? So while your initial battle was with the tests, now you got those written, you probably have good coverage. Yeah, so now you have a little bit of time to kind of relax or recompose yourself and clean stuff up a little bit more.(...) And so here's an example.
(...)
So original...
(...)
This is your original Genre 2 template.
(...)
But here you go. So this can live more comfortably in Python. It's still doing all the work,(...) but it's a lot... This is like, you know, you're expecting this in Python. You got list comprehensions and things like that.
(...)
So you just put it in a Python function, prepare schema data, and then look at the template for data and schema data. Data table name, column and data columns, much cleaner,(...) much cleaner. You're still doing iteration, you know, you have some basic template logic there, but templates should be real simple.(...) Keep logic out of those as much as you can.
(...)
Interesting. So I don't know if this would work in your case,(...) but the general philosophy. Now are you able to use GPT?
(...)
I just use it like all the time. It's such a helpful tool.
(...)
I think this is a pretty good example.
(...)
Keep the imperative logic in programming languages and keep the programming languages out of the templates, right? Even JavaScript in the template, I think is, you know, unnecessary, but then how to link them up, I'm not sure in your particular case, because do you have a server running or it's just pretty much invoking that. So it might not be good in this case.
(...)
But at the very least, here's an example of how you could refactor the JavaScript.
(...)
Okay, I'll be right back. I'm going to use the restroom and get some tea started. But yeah, thanks for hanging out. It's really interesting. This is a cool project too. I like this idea.
(...)
And I could use this actually in my Django projects because often in Django, I'm using SQLite and it's not always easy to see the database structure.
(...)
And your project is really light, like it has very few dependencies. So I think this is really cool.(...) Is it published to PyP? That would be another thing. Okay, I'll be right back.
(...)
Very cool.
(...)
Or for a search page opening pull request.
(...)
Then what I'll do is I think this is a good idea on this refactoring.
(...)
We'll open that.
(...)
And branch.
(...)
Oh, cool. Yeah. Animated web P. Did you just put that there? I didn't notice that before.
(...)
Last month I see. Okay.
(...)
Yeah, that's really cool. And you just put it in the remade. Yep, that's good.
(...)
Man, cool. And just pan, you can pan it and everything.
(...)
Or simplify templates.
(...)
By moving this stuff to the backend and letting Python handle this stuff. Let's see.
(...)
So what we can do probably in here.
(...)
Okay. I don't know if I installed poetry.
(...)
Sort of had a love-hate relationship with poetry.
(...)
What?
(...)
I don't have a virtual environment there.
(...)
Yeah, exactly.(...) Okay.
(...)
Yes.
(...)
All right. So we got the dependencies installed.
(...)
And then if I reopen that maybe.
(...)
So here's the thing. Rough organize your imports.
(...)
What editor do you use? And we're not using OS.(...) And you're not using unit test. And you're not using templates. Good. Clean those up.
(...)
Okay. So you've got this. In it.(...) Get tables.
(...)
Get table details.(...) Generate schema diagrams.
(...)
What's this?
(...)
E501.
(...)
Ah, it's too long. The line's too long, I guess.
(...)
Rebel it.
(...)
Okay. Cool. I haven't actually tried. Replit. It seems like a good kind of a platform is a service in a way. It makes it really easy to run some code.(...) However, this project you only need to really run it locally.
(...)
So let's see,(...) somehow,(...) rough things for not using those.
(...)
The template for, I guess,(...) if we do a case sensitive search,(...) case sensitive.
(...)
We're not. I don't know, even GPT got confused by that. So this may not work. So how do we run the project? Let's see the read me now. I'm going to be, I've cloned and I've installed requirements. By the way,(...) this is bad advice.
(...)
Need to create a virtual environment.
(...)
I didn't mean to activate it. Then install.(...) Don't install global dependencies.
(...)
Lint your markdown.
(...)
Add help text,(...) alt text.
(...)
Animation.
(...)
This is shell command.
(...)
White space shell python is fun or pie.
(...)
After your headings do that, you got extra space there.
(...)
Not bad, not bad. Good. Linted that.(...) Thousand changes. Need to get ignore.
(...)
You might not use the virtual environment. You might use .env.
(...)
I don't know if you got a preference on a naming convention for your virtual environments, but you should ignore that.(...) Your Git will be happy and you can run this thing locally.
(...)
But you didn't probably catch that one because you're maybe not working with virtual environments. Start using virtual environment. Really important. I heard the T bell. I'll be right back. I'm going to get my cup of tea.
(...)
Cool. By the way, do we have an example SQLite? I have one I guess I can bring over.
(...)
Let's see. One thing I'd like to do.
(...)
Nice.
(...)
Let's separate these into really helpful documentation.(...) So we'll use GPT. I'm going to use GPT.
(...)
I'm going to use GPT. I'm going to use GPT.
(...)
We're just going to split that out a little bit.
(...)
Are you in a development environment or are you using operating system? I'm sorry.
(...)
Yeah. Replo makes it easy.
(...)
Yeah. And the coach would always be running in a local machine. That is one of the main pain points that I face at work. We're developing microservices architecture sort of. It's basically a service oriented architecture at least. And we can't really run the project locally. We're working on it.
(...)
We can run tests locally or have those in a Docker container.
(...)
But man,(...) it is challenging.
(...)
All right. So installation still needs to be there.
(...)
And where the command is on Windows the same.
(...)
Git Bash or GitHub Desktop. Yeah. Pretty good.
(...)
I think GitHub Desktop is on Mac as well.
(...)
But the CD remains the same. So I'll just take that out.
(...)
And Windows seems to be the same. Cool.
(...)
This is where there's a little bit of difference.
(...)
And these are all the same. All right. So I'm kind of lumping things together here. Simplified template.
(...)
And most of this can actually go into the contributing.md, but it doesn't exist. So we'll put it in the read me. Actually, yeah, all the installation instructions should go into contributing.md.
(...)
Later you can do that. Ignore virtual environment.
(...)
Dang it.
(...)
No.
(...)
Okay. So let's focus here. This is a dangerous change. So I actually want to be able to run this locally.
(...)
So what I can do, what I can do is read the read me again.
(...)
How do I do this?
(...)
Okay. So it's a bit verbose.
(...)
But you do give an example.
(...)
Yeah, and it's following the same thing now by splitting all the commands. But the problem is these aren't actually commands.(...) So here, this is what we need.
(...)
So I'm going to do a simple example.py. The problem though,(...) there are examples. Oh, of course. Yes. Good. Thank you.
(...)
Really good.
(...)
So you create some tables.
(...)
You create a sample DB.(...) Very cool.
(...)
And you do the thing and you do. Wow. Really good. Okay.
(...)
So organize the imports.
(...)
Remove the unused imports.
(...)
This is copy and paste code.
(...)
So yeah, double.
(...)
Yeah. A lot of small details and a lot of this stuff you just work out over time, right?(...) Or peer review. That's what it's good about working in a team.
(...)
So you get people looking at it from different perspectives, but let's go ahead and just enrich the, uh, give a full example here.
(...)
And now one thing there is.
(...)
Just see what the initial feedback is from GPT.
(...)
It'll read over the code. It helps you come through. In fact,(...) to use this script as an example, follow these steps.
(...)
That in the read me.
(...)
Okay. This is interesting project structure.
(...)
Stunning to hallucinate a bit. The quality is degrading. Oh, it's cause I'm using Chad GPT 3.5 this whole time. Wow.
(...)
Shoot.
(...)
Shoot. Yeah, that could work. Okay. So let's just try it out. See you. Ah,(...) okay. So that's a problem. Okay. So we can't import it. So we don't have a Python module structure. So yeah, the example is usage won't work.
(...)
So we can't import it directly without modification.
(...)
Because we're not technically in a Python module, right?
(...)
There's no init.py. So I can't really import.
(...)
So let's try testing these. How do you.
(...)
Yeah. And how do you run these tests?
(...)
My big country used. Perhaps you've got a simple solution.
(...)
Okay.(...) All right.
(...)
Yeah.
(...)
So that won't work.
(...)
Okay. It's a bit challenging.
(...)
Yeah. I just tried that. I changed into tests and tried running the unit tests. But we're not able to import.
(...)
Yeah, good point. I'm a bit perplexed, but it should be a simple solution. I don't want to turn your whole project into a Python module.
(...)
Yeah, it's confusing. Okay. Let's just.
(...)
This is not the right idea, but.
(...)
Okay. Okay. Okay.
(...)
Okay.
(...)
And ideally you wouldn't have this in the base directory anyway. So you have to fix that.
(...)
You could wrap all of these sort of in a lib directory. Man, this is tricky, but let's see.
(...)
Okay.
(...)
Let's head over. Head over to our.
(...)
Friend GPT for.
(...)
Okay.
(...)
Templates.
(...)
Now the GPT for has got a pretty big context window recently.(...) So let's go all in on this and we technically could be using, um, co-pilot to help us out a bit, but I like the conversational style.
(...)
Yeah. Yeah. Okay. You had the period in front of it. That makes sense, but I'm not sure if the parent directory can, uh, this one right here.
(...)
Can locate that. It's not a Python.
(...)
I can't resolve it.
(...)
But it's able to resolve that. So, okay. Why can't I run it?
(...)
Like.
(...)
Yeah. Two periods. I sort of think I do it. Oops. All right.
(...)
No, no, parent package. So here we would need the init pop. I don't think this is greatest idea, but okay.
(...)
It works.
(...)
Okay. Okay. Okay. Okay. Okay. Okay. Okay. Okay. Okay. Okay. Okay.
(...)
Yeah. When I get into these mind bogglers, we'll just have some help here real quick. One moment.
(...)
To showcase.
(...)
How useful GPT four is in particular.
(...)
Let me see if I can commit anything real quick.
(...)
Cause I want to make sure this change works.
(...)
And this was just a lint.
(...)
So couldn't commit that. We didn't really change anything there. Just lint.
(...)
The fix is crazy bad. We'll, we'll fix this. Get it. Cause then you can publish this to pipey. I'm Tony. This is a really good library. This is really fun and useful. And it's important to see your data structures, your data model. I'm just going to replenish my tea. We'll be right back.
(...)
Okay.
(...)
So we'll use a couple of first. We'll just tell.(...) Chad should be to the structure. Just the file structure.
(...)
And I'm going to omit the ones that aren't so important.
(...)
Pyproject requirements, but we do need the SQLite.
(...)
All right. So we got the, I believe the crux of it. Oh, I forgot.
(...)
Test has an init py, doesn't it?
(...)
So yeah, I just gave it a bit of information and it's kind of helping us out with some general guidelines. It doesn't quite know what we're struggling with yet.
(...)
Okay.
(...)
So the templates are examples. So only the init py is in the tests.
(...)
There we go. So we should put it in a dedicated package directory. This makes your project structure clearer and more scalable.
(...)
Additional consideration, setup.py, create this file for packaging, include details like install requires for dependencies, requirements text, use it. Okay, we do have that.
(...)
And gitignore,(...) like pycache.
(...)
And GitHub has a nice Python oriented gitignore that includes more packaging and distribution,
(...)
setup tools, or you can use poetry,(...) testing CICD, version control, community engagement. Yeah, this is good advice now.
(...)
Okay.
(...)
[typing sounds]
(...)
Or example usage either way. Let's see which one's shorter.(...) 30, 50, 60 lines of code tests.
(...)
60.
(...)
[typing sounds]
(...)
And in the tests...
(...)
[typing sounds]
(...)
[typing sounds]
(...)
Alright, so we're gonna just have to restructure it.
(...)
From the parent folder. Okay. You got it. Oh, that's the fix though. Yeah. And what does it say?
(...)
And necessary only. So... Pydraft. Knowing it, py.
(...)
2.5... dot, dot, dot.
(...)
[typing sounds]
(...)
Absolute and relative imports.
(...)
[typing sounds] SysPath.(...) Yeah, which answer were you thinking of?
(...)
I think if we just restructure this, it's gonna be better.
(...)
Yeah, we don't want to do that.
(...)
Just restructure it into a proper package, I think.
(...)
Should be good to go.
(...)
Yeah, there we go. There we go. Look at that.
(...)
Set up py.
(...)
And this is a big gray factor though.(...) Just to be able to test it though.
(...)
[typing sounds]
(...)
[typing sounds]
(...)
Cool. Let's try it.
(...)
Thing.
(...)
We'll put your thing there. [typing sounds]
(...)
And then we need...
(...)
init py. [typing sounds]
(...)
[typing sounds]
(...)
It's so weird.
(...)
It's almost like I'm doing something wrong here. Can you run this locally on yours? Are you able to run these commands in your local environment? I'm not sure what's going on here. No fun. [typing sounds]
(...)
[typing sounds]
(...)
Okay.
(...)
[typing sounds] Yeah.(...) Not in Python. Modular search. Okay. That's not a good idea.
(...)
Good grief.
(...)
[typing sounds]
(...)
Option two.(...) Yeah, there we go.
(...)
[typing sounds]
(...)
There we go.
(...)
[typing sounds]
(...)
Now we're running them. Okay. So that was the deal.(...) [typing sounds]
(...)
[typing sounds]
(...)
Yeah, let's check it out. [typing sounds] Oopsie daisy.
(...)
[typing sounds]
(...)
Yeah. Nice.
(...)
[laughs]
(...)
We're going to run it.
(...)
[typing sounds]
(...)
No, it's not unforgivable. Believe me.
(...)
[typing sounds]
(...)
Everything's forgivable.
(...)
And that is important to think about to avoid a culture of blame.
(...)
[typing sounds] And it's really been made clear to me the importance of that blameless culture
(...)
by virtue of the place I work,(...) practicing that. It's hard.
(...)
It's really tempting to want to blame somebody or some thing for problems, but the idea is to focus on the solution in what to...
(...)
[typing sounds] Alright, so shell.
(...)
[typing sounds] How do you do the shell here?
(...)
Replit. [typing sounds] Run.
(...)
[typing sounds] I have no idea how to use Replit.
(...)
We'll come to this in a moment, but I need to just fix this.
(...)
[typing sounds]
(...)
First, it's just either the tests are working.
(...)
[typing sounds] Boom! Yes.(...) Okay.
(...)
So I'm going to refactor the project real quick and then refactor the code.
(...)
The GPT 3.5 had hallucinated some code trying to simplify the Jinja template a few steps back.(...) And that's a good idea. We'll do that.
(...)
But first, let's get your project in a way that's ready for packaging.
(...)
[typing sounds]
(...)
That's a new file and it generated the output. Okay, so we can go to...
(...)
[typing sounds]
(...)
Logos 8000.
(...)
And look at...
(...)
Test HTML.(...) Beautiful!(...) Yes. Nice.
(...)
Okay.
(...)
Oops.(...) Can I highlight text? It wants to move. Okay. Not a big deal.
(...)
It's not quite SVG or something, I guess. Anyway, cool.
(...)
Yeah, it's working now. After the refactor, we just had to put things in the right thing. And then I had to use the proper module syntax. So yeah, you know, always learning. Always a beginner. Don't ever worry about these mistakes or lack of knowledge because there's so much to learn and so much to know, so much detail.
(...)
Every day I learn.
(...)
So, let's see.
(...)
Let me be real careful here.(...) All I really have done here, just so you know, and you'll see this in your pull request,(...) I'll open in a moment. We're just putting it in a namespace.
(...)
And I won't commit the output of the test.
(...)
So in fact, we might ignore that.
(...)
And so these changes, you know, the slash stuff, I just moved the file without any change to the file. It's still... It's the exact thing.
(...)
The tests, there was a bit of linting.
(...)
You know, using indentation, using double quotes, which is more common in Python to use double quotes.(...) It's not a big deal.(...) But just so you know, it was done by default. And we need to add pycache to the gitignore.
(...)
Oops. And anything else? Let's see. Pystartup.py. I don't know what that means.
(...)
Pyinstaller. Pycharm. Pyinstaller. Pycommile.op. Do I deal with all those?
(...)
That's probably good enough.
(...)
And it always have a little bit of a white space at the end now.
(...)
So this is essentially a refactor in lint.(...) Refactor slash lint. And we added a module structure.
(...)
So...
(...)
Now the other thing we can do is describe how to run the tests and clean up the tests.
(...)
Because there's some things.(...) And this is the code.(...) Not the tests, but there's some imports that aren't being used. So it's like easy to remove those. And hopefully, I guess, the replet doesn't have a nice IDE to highlight with the squiggles.
(...)
Yeah, and this is just a line too long. Not a big deal here.(...) What's this?(...) Oh, that's just my rainbow indent.
(...)
I guess these are a little bit too far indented.(...) There you go.
(...)
Everything else is looking great.
(...)
I don't think the GPT-4 has the readme in its little buffer thing yet. No memory.
(...)
Very cool, so we'll just add that to the readme.
(...)
Under usage.
(...)
So we have the usage section.
(...)
I think since you've got an example script, we probably don't need that to live here anymore.
(...)
So we can replace the whole usage with just this GPT thing.
(...)
Use the tool to maximum potential.
(...)
And then be careful to scrutinize the output of the tool.
(...)
So we were able to successfully run the tests.
(...)
Let's try this one. Whoops.
(...)
Darn it.(...) So we have the same diagram generated there.
(...)
This is the diagram. It works.
(...)
Might work on the width, the content width, but not a big deal. But if you could use some scaling just to let it fill the whole horizontal thing.
(...)
And then the tests.
(...)
And since we know the output of these tests,(...) an example generates some files basically. We'll put those in to get ignored so they don't accidentally get checked in to the project by an unassuming developer. Sometimes you'll see people who will just stage all commits and commit everything. So we want to not do that, but in case somebody does do that,(...) this is a little bit of a safety guard. So we don't want the sample DB.
(...)
And we don't want schema.
(...)
We don't want test.
(...)
Good.
(...)
And usage instructions.
(...)
Okay the last thing is I think this would be a good improvement. Moving the stuff from Jinja. This was the whole thing earlier.
(...)
Simplifying the template.
(...)
So we've got...(...) Okay.
(...)
And we did make those adjustments.(...) So here is the template.
(...)
Let's just see what it says.(...) Sometimes we want to minimize the output of GPT so it doesn't use...
(...)
It doesn't flood our context buffer with things that we're not concerned about, but also, sometimes it gives us just helpful advice without prompting really if I just say here's what I've got and it'll tell me stuff about it.
(...)
Okay.
(...)
First,(...) we had refactored this using GPT 3.5 in my previous conversation.
(...)
Okay. I can be a little bit more confident that the changes I'm making aren't breaking anything. This is good. You wrote those tests. Super good.
(...)
All right.
(...)
Ready?
(...)
Test passes.
(...)
Boom.
(...)
Hey, TikTok boom. Thanks for the follow.
(...)
That's a ton of emojis.(...) Okay.
(...)
Ah, so the table users already exist. So this is sort of a bug. If I rerun the example,(...) it attempts to create the SQLite again. So that's okay. Easy.
(...)
Yo.
(...)
So basically we might put a safeguard in there so people can rerun it. It doesn't need to generate the SQL again. You could even just check if the file exists and then don't generate it. But I wouldn't worry about too much of the checking the tables exist. Probably let's try it again though.
(...)
All right. So we're gonna, I believe this is just good.
(...)
Oh,(...) we got this HTML boom. Oh, the refactoring though broke. So I've got a regression.
(...)
I've got a regression unfortunately,(...) but no problem. That was the SQL. That was the GPT 3.5 output. Let's ask GPT for it's a bit.
(...)
More skillful.
(...)
Yeah, good point.
(...)
That's why I was able to do that regression in the test passed.(...) So now you know a new test case. Boom.
(...)
Okay.
(...)
What else was it?
(...)
Holy gosh, it already did it. Wait, wait, wait, wait, wait, wait, yeah, adding docstrings. Okay. I think it's JS docs syntax, right?
(...)
What were the other things that we can do to make it more developer friendly?
(...)
I think there's about it. We just have magic, magic strings, magic variables. Okay.
(...)
And we'll leave it open ended to any other best practices for the JavaScript language. I'm not an expert in anything, let alone JavaScript.(...) Oh, we're dang it. We're on the GPT 3.5 again.
(...)
All right.
(...)
No problem.
(...)
Here's a nice GPT 4 conversation.
(...)
Same prompt.
(...)
Yeah.
(...)
So this is nice. It didn't encapsulate the single line. That's cool. Cause I mean, it is basically mermaid initialized. That is one level of abstraction.(...) Now it noticed that ads zoom to mermaid diagrams was several lines of imperative logic. So it did encapsulate those and that ads zoom to SVG is sub.
(...)
It's like imperative logic at a different level of abstraction, different level of details, kind of like zooming in and out of a map, right? You want only,(...) you want to see the States of the United States or the country or the counties and the cities. So we just use encapsulation for that.(...) And it's got doc strings.
(...)
I'm still using magic,(...) but that's okay.
(...)
It did not create any constants.
(...)
The reason for that is you don't really know what G means. Why are we selecting G?
(...)
You know, on zoom, okay, that's self-documenting on zoom. That makes sense. If you have specialized knowledge, you probably know this is G is the SVG element.
(...)
But here we go. Now we've got mermaid SVG selector, SVG group element, engine event type.
(...)
So these are called constants or variables, named variables or explanatory variables.
(...)
For as kind of debatable as clean code is, I think it has some good nuggets of wisdom, including use meaningful and pronounceable variable names, but using searchable names or explanatory variables. Check these two out in particular.
(...)
And these apply to any code you're writing.
(...)
I know there's other viewpoints on clean code, but a lot of the guidelines here are actually pretty useful.
(...)
The book itself, I don't know, maybe has questionable advice, but I think this is a pretty good refactor now.
(...)
However, does it work?
(...)
I have higher confidence in the,(...) oh, you know, why didn't work. Maybe.
(...)
Wait a minute. There we go. And the GPU for, you know, why didn't work probably.
(...)
Oh, no, no, no, no.
(...)
The indentation is just throwing me off.
(...)
Yeah, I use that on a pretty regular basis. They also have a Python version, clean code, Python's the same principles.
(...)
And when we're giving peer review, we can point to these,(...) just like I did, I linked to the exact guidelines.
(...)
And so we have a shared reference and it's nice to have conventions.
(...)
Python is really big on conventions.
(...)
You probably know the zenopython and it is very useful. Also Django is full of conventions.
(...)
So let's see then.
(...)
In order to run the examples usage, I have to delete the database.
(...)
And in order to run the tests, I can just run the tests.
(...)
Okay, here's the moment of truth.
(...)
Does the interactivity work?
(...)
Yeah.
(...)
Where'd it go? I can't read.
(...)
Okay, so I think this is a good refactor. So more trust in GPT-4.
(...)
You know, we've got documentation, got constants,(...) we got a name, meaningful variables. I think a lot of this you were already doing, but in particular the encapsulation is good.(...) And also having these named constants at the top,(...) in case your template changes, your selective changes, you don't have to go dig down through your code, you just change this here.
(...)
Some of this may be not so important, but nonetheless it's just to illustrate the idea.
(...)
Another benefit that comes out of this type of a move is that you can then, maybe not in this exact case, but you can unit test these so much easier than you could the entire imperative block.
(...)
You can mock and just test very encapsulated code.
(...)
And I find that particularly when I can't run the code in my local development environment,(...) having these granular functions that I can run unit tests against in an isolated fashion, using mocks, for example,
(...)
really helps me when I'm coding by abstraction. A lot of the time, since I can't run the code, I have to just think how it would work or use GPT to help me with that.
(...)
Yeah, very cool. Yeah, and by the way, cookie cutter, have you found those? Have you used a cookie cutter before?
(...)
Python, for example.
(...)
A lot of these base practices we learn over years.
(...)
But really, there's some projects that help you get a new library off the ground, a new Python project off the ground. Cookie cutter is an example,(...) cross-platform command line utility that creates projects from cookie cutters, project templates,(...) Python packages, C projects. So in your case, it's a Python package more or less. You can use this cookie cutter, but I think they have cookie cutters for using the same cookie cutter library defined for JavaScript projects as well. There's probably something similar in the JavaScript ecosystem that lets you initialize a project like node, like view has these scaffolding things. I don't know, but this one's great for Python projects.
(...)
You run it.
(...)
It's interactive. It asks you a series of questions,(...) and then it'll, for example, output a project structure with best practices baked in. Here's the Py package one. This would be really good for the type of work you're doing where you have a package that's ready to publish.
(...)
And it includes things.(...) Some of them are sort of maybe not what you want, but at least you can learn from the structure of these. We're probably using GitHub actions now.
(...)
Pytest runner. Yeah. So just the general idea is it'll help you out and you might find one that fits your style. Saves you some time and get you off the ground.
(...)
Let's see. I saw I kind of made the case that it'd be better to follow the Django guidelines to keep the template logic minimal by moving the table and column parsing logic to a Python function that returns the appropriate structure for gender two. This way the gender two template would be easier to maintain. And essentially, here's what we've got. I'm going to go to the restroom while the,(...) well, does its work.
(...)
Cool.
(...)
I got some tea.
(...)
Yeah. So one of the other big takeaways you'll see here is that you can see that you can see that there's a lot of people who are using the code.
(...)
Yeah. So one of the other big takeaways you'll see here is that now I'm leaning pretty heavily on GPT and GPT four.(...) And in my opinion, that doesn't make me worse or like somehow. Anyway, the idea I'm sort of getting a little bit brain fog, but the idea is that it's an assistant and it actually makes you more effective, more efficient.
(...)
And it's teaching me quite a lot all the time. I'm learning. It's like having a senior software engineer at your side.
(...)
It's not perfect, but then humans aren't infallible either. We also make bugs and hallucinate and all these things that we're complaining that large language models do. Frankly, I think the large language models are pretty miraculous and take them with a grain of salt, just like you would a person.
(...)
But really, I think it's valuable to invest time in working with these because I believe they're going to be basically the future of knowledge work.(...) I don't know that they will replace people.
(...)
As you see, I still have this dialogue. I still have to guide.
(...)
They're not fully autonomous.(...) And if they were,(...) it's not certain that they would be working towards the same goals as we would. That's a bigger discussion.
(...)
But I think it's really important to work with them. It's going to make a difference between, I believe,(...) well, in higher ability.
(...)
And it'll, I believe, have a strong impact on the effectiveness of yourself or your team or your company. And there's already been anecdotal but academic evidence of this.
(...)
I could find the study, but essentially they compared two teams in marketing.
(...)
One team that used the large language model or generative AI in general, not just LLMs. And the other that didn't. And they found increased productivity and quality of work. I think this was also demonstrated in a promotional material by Microsoft.
(...)
But I've experienced the same quality improvement in my own code.
(...)
And ability to move with high levels of uncertainty.
(...)
A lot of times I don't really know what the heck's going on. And this is like having a flashlight. It illuminates this stuff and gives me insight into the inner workings of Python.
(...)
But still needs guidance. So here it is generated two functions that I can use. One,(...) let me just follow.
(...)
Complex out of the templates and into Python functions aligns with best practices and template design.
(...)
JSX.
(...)
Don't.
(...)
It improves maintainability, readability, separation of concerns. The refactor your mermaid template HTML. You can pre-process the schema data in Python before passing it into the gingi2 template. Yeah, we don't want to process all the schema and gingia.
(...)
So here's all the processing the schema and stripping and doing that and selecting.
(...)
So create a function in your Python mermaid JS or suitable module to pre-process the schema.
(...)
Very cool. So this is just module level function. It could be pre-pended, prefixed with a underscore and underscore.
(...)
I was thinking this would be a class member.
(...)
Since it's the only thing using it.
(...)
Yeah.
(...)
Yeah.(...) Also moving this into Python is going to make it easier to unit test. I think the templates are a bit trickier to test, particularly we noticed the interactivity. But also the fact,(...) I didn't notice the unit test, the details there, but the output of this.
(...)
I think it's kind of fuzzy and maybe you're testing that there's a, I'm not sure, mermaid class. Oh, look more to the test. But regardless, I think Python's a bit easier to test.
(...)
Process schema and generate schema diagram. So we're just going to move these into the class level.
(...)
And we might consider making them private members.
(...)
And why is that giving me this squiggles?
(...)
Rough.
(...)
Hey, 11 should tell me what's going on here.
(...)
Remove them up redundant. Oh, okay.
(...)
Yeah. Wait a minute.
(...)
Right.
(...)
So I'm going to use this.
(...)
It's got updated.
(...)
Generous schema diagram.
(...)
Or just remove that and then use this.
(...)
After pre-process, so it flows.
(...)
Here goes, I guess now we update our template. This is a bit.
(...)
Well, let's see. It's a bit worrisome. Let's see.
(...)
But it's essentially the old div here.
(...)
And then indentation.
(...)
And we'll remove sample DB.
(...)
We'll start with the interest tests. Test pass.
(...)
We will then use the example usage schema generated diagram generated.(...) HDB server.
(...)
Which one are we doing?
(...)
Well, I can just refresh it, but schema diagram interactive.
(...)
Test HTML interactive. Okay. Good. Wow.
(...)
So I think we can at this point publish the branch.
(...)
Create pull request.(...) And if you're still with me, Blaze.
(...)
Might have a couple other touches that we can do here.
(...)
Wow. I've got a magic button.(...) Whoa.
(...)
I like that.
(...)
Yeah. My pleasure. One thing here.
(...)
I don't think we need to dig into the table level.
(...)
Okay.
(...)
So that's actually probably the more legit solution.
(...)
So make sure you have the right structure.
(...)
And is there actually data in the database?
(...)
Just simpler.
(...)
Okay.
(...)
Right. And that's true. I enjoy it and I hope other people can learn. I don't know how interesting it is to watch somebody code, but anyway, I do it because it's sort of like watching people work is really informative, but boring at times.
(...)
Learning is spread out
(...)
It's not necessarily in any meaningful order so it's not quite like a watching tutorial although I find a lot of the YouTube tutorials are pretty thin and Oftentimes more oriented towards like
(...)
Getting people to view them but not like pedagogical purposes so it's more about what's the YouTube algorithm feeding popularity and a lot of times they're really just like(...) Almost click Beatty. I don't know a better word of saying it. Are we using the develop branch you have main
(...)
Not really using develop(...) Might be good later in the project to use a develop branch. That's why this latent knowledge is in the large language model But as a single developer I can see why You just fork off the main and develop just gives you a little bit breathing room to decide when to release.(...) I Suppose you can do it with main anyway, I don't know We just conventionally do that and have a development testing environment staging mode So what this is gonna do is check out the repository
(...)
I think we're actually to check out version 5 by now
(...)
4 ok not too far behind and set pythons maybe a version 5 and Specify the Python version. So this is an interesting thing. I would recommend testing against a matrix(...) Oops, oh
(...)
Oh
(...)
Python 3 9 is deprecated
(...)
3.10 is a bit problematic. It'll have to quote that
(...)
Might not work the 3.10 might not work like that Blaze Labs Wow. Thanks for Helping out I know hey welcome. I know didn't even notice. Yeah. I hope you haven't said anything that I missed. Sorry. I Know thanks for the subscribe. That's interesting time
(...)
So I see I get it I don't know how this twitch thing works, I'm sorry
(...)
So I notice you blaze subscribe I know very cool gifted tier one Wow I Don't
(...)
Let's find out Pretty straightforward and a random unit has discovered. Well, let's see if that works all these I should build around my local environment
(...)
Didn't discover any of them so that's okay
(...)
The test command now, why didn't the discover work?
(...)
Search for tests. I think that's why we might need to rename this just(...) We might need to rename this just
(...)
Test up pie is fine
(...)
Yeah, that's all okay and for example this could be just example.py not a big deal Small changes, so I think this is a lot better than General the going through all this stuff and doing a pull request show don't tell I mean I'm kind of telling a bit But I'm also just like literally showing and I'm learning a lot. So this is great
(...)
So since you're open source you get a little bit of a
(...)
Free totally CI minutes or something from github just by doing this
(...)
Let's see
(...)
I'm like should work
(...)
Okay, so check out v4
(...)
Set up Python, I think is that v5?
(...)
and We're gonna just try this but let's see here
(...)
And I'll double-check If you might have money to be an action to get hub sessions or workflows that's right workflows
(...)
And In test your test will close here move
(...)
Okay, might be able to make it
(...)
So Get you in better shape now, we'll check the pull request on on I Guess it's against your report was a dory
(...)
And see
(...)
I
(...)
Think that's correct. You might need to enable it or the first time we added it might not run it
(...)
GitHub
(...)
Spell it correctly and workflows
(...)
Test I am I'm
(...)
I One of the things I think the deal is(...) I'm an untrusted external contributor So you might if you hop over here to this pull request it might say enable it won't just run Arbitrary things I put into your repo which essentially github actions runs commands like this Python command So I could be putting malicious code here. That's gonna try to steal your secrets or something So it's gonna ask you to verify that this command is safe to run
(...)
Like all of these this whole pipeline it's gonna be safe to run I I'd want to run it because I'm not sure that this will work I think it's gonna search for Python 3.1 because this is zero, but it might might work
(...)
See what other people have had this yeah, see this is what I would have worried about I
(...)
Think we just have to quote it
(...)
Yeah, okay, no problem I
(...)
Quote them all for consistency I Think we're good to go. This has been a pretty extensive session
(...)
256 lines added 72 removed so Mostly documentation lines some refactoring
(...)
Simplification and the test is still passed linting linting, of course
(...)
I
(...)
Let me see how well the Western friend come on just go go go rage clicking
(...)
Probably wouldn't eat all of these but
(...)
Paste these in we can look at him So checking yaml into file fixture white space during white space a large file checker Case conflict Jason Toml merge conflict. Those are all good pie upgrade. This will keep you fresh
(...)
With the Python 3 11 and above semantics
(...)
Django upgrade don't need that one
(...)
I'm a fan of trailing commas. I think they help with pull request review in particularly in particular
(...)
I don't know if that any exclusions are needed
(...)
Rough it'll fix it for you
(...)
Curly lint maybe doc formatter
(...)
DJ HTML don't need that one
(...)
Pre-commit mirrors prettier can be helpful and the Google keeps worded is optional
(...)
Don't think you will probably need that
(...)
If I pre-commit stall And run it on all the files invalid config repos missing key hooks. Oops. I missed a line there
(...)
So this is a fairly opinionated pull request But it's gonna help out I think in the long run let's see if the tests still run doc formatter
(...)
Run it again, it should pass this time
(...)
And let's generate the schema diagram
(...)
And test HTML rerun those so make sure the tests still pass
(...)
And
(...)
The example usage
(...)
Doesn't oh right right right right because I renamed it
(...)
So Local host
(...)
Test HTML works
(...)
Just give me another image to know works. So basically all this did is just linted everything added a trailing whitespace here
(...)
Mainly trailing whitespace doc formats to it tightens up our comments a bit Trailing commas here. It's just a good practice
(...)
What is this
(...)
Interesting no modules
(...)
No modules
(...)
Strange okay
(...)
So, yeah, these are all just trailing comma fixes
(...)
So just removed a little bit of trailing whitespace there added the end of line into file
(...)
These all look good
(...)
And this will just keep things in good order and it saves hassle during the pr review process
(...)
So
(...)
So
(...)
Pretty good instructions
(...)
This should go in a contributing guide
(...)
So
(...)
That's correct, that's correct
(...)
So Cool
(...)
All right Quit while we're ahead. This is a big pull request. I know it's like Not good to always include so much stuff
(...)
400 lines is a bit hard to review but we've written it here on the live stream and I've demonstrated how it works
(...)
So it's probably wrapped down wind down the session
(...)
That's basically how it approached A
(...)
new project and This is the most mostly ideas. I've I could think of for improving here
(...)
Let's go back to our western friend pull requests
(...)
Search page
(...)
Deep source complaining So
(...)
Well, I don't mind
(...)
So
(...)
Yeah, I guess we don't need it too common view is
(...)
So
(...)
Strange
(...)
So Yeah, that's weird yeah, so I can't change that
(...)
So
(...)
I wonder if that's the correct rule to disable the con If it's using pilot rules or where that's coming from
(...)
Well, let's just do this pwh
(...)
It's a bit of a long line so
(...)
I think there's no curation work
(...)
So
(...)
All right, it's a bit slow it's going to take a little bit but all of our tests are passing change is fairly minimal
(...)
So So wrapping up
(...)
Let's see, I don't know if I want to do an outro
(...)
So Four hours wow, it's been a long session. I didn't realize okay. I'll do an outro that way I can kind of
(...)
Sort of share the content on youtube in a way that's easy to digest
(...)
Without having watched full four hour thing(...) Yeah,(...) that's what I'm thinking I don't know if i'll be able to write
(...)
Scripted uh tutorial videos. Maybe i'll figure that out Mostly i'm working on stuff, but okay ready
(...)
So Hello and welcome to a recap of today's open source live code hangout
(...)
in today's session(...) We've been working on two projects(...) The western friend website which can be found here on github
(...)
And
(...)
Blaze Labs is
(...)
Very interesting sequel light to mermaid.js project
(...)
Also open source on github
(...)
We've got a couple pull requests
(...)
On the western friend side
(...)
I realized that our previous decision to redirect 404 pages to the search page was causing unnecessary load on the database(...) In particular there are a lot of bots kind of crawling and scanning the site Maybe even coming up with a random pages and each of those is being redirected to the search causing our slowest database query to run
(...)
Which happens to also be a synchronous Operation, so it's kind of blocking potentially other database operations. So I decided rather than redirecting to the search page We will just put a search(...) Form on the 404 page and let users opt in to searching by clicking that little button it also populates the search
(...)
field with the Essentially url string all the keywords all the words from that(...) stripping out the hyphens and slashes so that way it gives them a little something to search for typically the Page title is embedded in the url string so that might get them a little closer
(...)
You can see here we use the search query and we have a function
(...)
custom 404
(...)
That grabs the request path Splits replaces actually just string operation doesn't split it just replaces and returns that as the search query renders a form that meant I was able to remove a middleware function
(...)
That was previously(...) redirecting as mentioned
(...)
And the last change was to define the handler 404 in our(...) Core url is pi. So jango knows to use this custom 404 views
(...)
Pretty good. I still have a couple of things to perhaps fix
(...)
with deep source Complaining in my test coverage complaining. I'm not sure why there could be non-deterministic(...) some of these tests periodically fail
(...)
And re-running them typically clears it up but I'll follow up with that after the stream
(...)
Now the bigger pull request here on the sqlite to mermaid.js. This is very interesting. We just typical look through the whole project found some
(...)
Possible improvements. I'll read through these top to bottom, but we basically(...) Added a python testing continuous integration step for every pull request It's going to test against a matrix of python versions checks out the repository sets up python Installs the dependencies and runs the unit tests from the test folder pretty common But really important particularly for open source projects that might be Used in downstream projects you want those tests to run? We did find some improvements for the test cases Uh where there was a lack of coverage. We discussed briefly the importance of test coverage Uh automatically determining Which lines of code aren't covered but also sometimes you have to just manually try things out and find test cases That aren't covered such as the interactivity on the svg diagram um, we added a get ignore because we were
(...)
Trying out to Check some files into get accidentally We added a pre-commit configuration that runs a bunch of hooks every time you commit essentially to help keep your code Up to standard. These are low level checks that oftentimes are kind of um
(...)
Not so interesting for a pull request reviewer or sometimes tedious and easy to overlook While you're coding this will fix most of them for you Your formatting and jason and yaml toml You know removing merge conflict strings making sure you're using the latest python features trailing commas and formatting and fixing and linting your code with rough your curly braces in your Uh ginga two templates and running prettier against similar things Every commit this is really handy. I highly recommend it. We use it at my day job. I use it on all the open source projects pretty much Uh, then I actually ran the pre-commit hooks. So some of these are going to be lint. Uh, this is just a lint uh, we expanded on the
(...)
Read me so just a bunch of improvements to help uh other developers or even ourselves our future selves to
(...)
Know how to use the project So most of the changes here in the read me to be honest Uh, we used chat gpt to help us out with a bunch of things We reorganized the project structure so it was easier to run the examples and the tests um, these are mainly linting changes and we added a little safety check here that if the database exists we won't try to Uh create that again because it was causing errors That it already exists and we wanted to handle that exception Uh,(...) this is just lint
(...)
The bulk of the changes we did refactor this sqlite to mermaids It's all highlighted in green here because we also Moved the file so gets not able to like diff it so(...) easily
(...)
Then we kind of moved some and we simplified our templates We refactored the javascript to be more maintainable and potentially testable And we moved some the complexity out of the template basically templates should be really Straightforward and easy very minimal logic there. I know there's this uh
(...)
Tendency to put a lot of logic in templates particularly when you've got a templating language right in your programming language like jx But I think for many reasons we Have learned and potentially forgotten that that's kind of a bad practice. It makes your templates hard to maintain It kind of leads tight coupling in your code. Uh, so basically we want to We want to move the complex logic to the code and the templates should be very minimal. Uh, this is the jango philosophy I follow that Uh, that's why jango gives us minimal
(...)
Logic such as looping or filters(...) But most everything else is done in python. So that's kind of what we followed here(...) and
(...)
some refactoring and formatting of the tests(...) So that's it and the python code got moved to the um SQLite to mermaid The the complex template logic got moved here into a function That essentially does the same thing Right here pre-processed the schema. We were Previously processing the schema in the template and now we process it in python
(...)
And that's uh making it easier to unit test as well because that could be a source of um hard to Diagnose bugs where you've got template logic running and not a clean way of testing that now python Code is much easier to mock and test and things like that especially granular Uh composable python code
(...)
Great Well, this has been another open source lab code hangout. Thanks blaze labs for stopping by
(...)
Thanks Crazing for the subscribe. I knowed welcome. Uh, It's good to see new faces(...) Let's see. Who else did we see here? I think those are the main ones(...) Very cool. Yeah, I hope you're all doing well and i'll try to stream again Uh around this time tomorrow and hope you see you around the stream(...) Have a great day or evening And see you later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment