Twitter | Search | |
sage
Computer Science student at Universitas Indonesia.
112
Tweets
26
Following
32
Followers
Tweets
sage Jan 25
>>> a = {1: 1, True: None} >>> a[True] = not False >>> print(a[not None], a[1]) >>> print(a)
Reply Retweet Like
sage Jan 25
Reply Retweet Like
sage retweeted
Google Open Source Jan 14
Google Summer of Code is officially open for business! If your organization is interested in participating in GSoC 2020, applications are open starting today through Feb. 5th!
Reply Retweet Like
sage Jan 7
Replying to @laymonage
aaand yep, the issue is now locked as "too heated" 😅
Reply Retweet Like
sage Jan 6
New color schemes for Material Theme on VS Code were released today and the changes are pretty drastic. I'm sure a lot of people will complain (there are quite a few already)...
Reply Retweet Like
sage Jan 5
Replying to @Jernkalv
Everyone has to start somewhere. Keep building something, you'll start to see patterns and find out what kind of solution works best for a given situation :)
Reply Retweet Like
sage Jan 5
Replying to @Jernkalv
No, just fixing some stuff. A complete rebuild in one month doesn't seem feasible.
Reply Retweet Like
sage Jan 5
Replying to @UweAimeVan
I've migrated the project to Python 3 and Django 3.0 😉
Reply Retweet Like
sage Jan 5
Replying to @AdamChainz
Reply Retweet Like
sage Jan 5
Replying to @AdamChainz
Good call. It looks like more people need to know about it though, since I didn't see anyone suggest that pattern in StackOverflow. Maybe because it's still a bit new (2.1). Thanks!
Reply Retweet Like
sage Jan 5
Replying to @AdamChainz
Wouldn't that be too much? I just want to put a Django URL into JavaScript. I'm thinking of something like: <script>var target_url = {% url 'urlname' %};</script> Or maybe make it a data-attribute of an element Then use it in script.js <script src={% static 'js/script.js' %} />
Reply Retweet Like
sage Jan 5
Replying to @laymonage
Please note that I don't mean to disrespect anyone who has contributed to the project. It's much better than nothing, and you have to start *somewhere* to build something like this. I'm very grateful that this exists and that we can all learn from it.
Reply Retweet Like
sage Jan 5
Replying to @laymonage
Oh, and fun fact: this is the very first time I ever write code using DRF. I had to skim the docs to get the gist of it. It's pretty fun.
Reply Retweet Like
sage Jan 5
Replying to @laymonage
I'm still not done, though. For now, I still put the FC code in the Django template so that I can put the ajax URL using {% url %} instead of hardcoding it. Is there a cleaner way to do this? I can think of separating the FC code and just put a url var inside the <script> tag...
Reply Retweet Like
sage Jan 5
Replying to @laymonage
I made a quick fix by creating a generic DRF view to query the data with start and end date parameters so that FC can populate the schedule dynamically via XHR. It's much faster now and the Django view is something you'd expect for a simple homepage.
Reply Retweet Like
sage Jan 5
Replying to @laymonage
Clarification: the query wasn't for all rooms. Still, they queried the entire history of reservations for each requested room, so that's still *really* slow.
Reply Retweet Like
sage Jan 5
Replying to @laymonage
Here's the best part: They put the whole data directly into the FC initialization in a <script> tag via Django templates. You read that right. Therefore, you'll get this 17500+ lines long HTML page with funny escaped HTML tags in JSON data. That data goes back to early 2017.
Reply Retweet Like
sage Jan 5
Replying to @laymonage
Here's an example of how messy the code was. The author used to show the schedules of each room. However, instead of creating an API in Django so that you can fetch the event objects dynamically in FC, they queried the ENTIRE schedules for ALL rooms.
Reply Retweet Like
sage Jan 5
Replying to @laymonage
I've migrated the code to Python 3.8 and Django 3.0. Thankfully, it didn't take long and not much stuff was broken in the process. I was done migrating in an hour or so.
Reply Retweet Like
sage Jan 5
Replying to @laymonage
I'm only given less than a month to work on this, so a complete rewrite doesn't seem feasible. Still, I'm trying my best to fix what's broken and make the code less horrendous.
Reply Retweet Like