DEV Community

Cover image for What Did You Learn This Week --May 1?
Waylon Walker
Waylon Walker

Posted on

What Did You Learn This Week --May 1?

Top comments (10)

Collapse
 
matteobruni profile image
Matteo Bruni

This week I learned something about noise generation to create something like this

I learned and implemented quad tree instead of spatial hashing but I still don't know what algorithm has the best performance.

I learned about canvas and retina/HiDPI screen, not from zero but I improved my knowledge.

I created other cool feature for particles, not really new things learned, but at least it was the first time for me to do these things

Collapse
 
sunflower profile image
sunflowerseed

how come the colliding one is all white here but when edit on copepen it has colors

Collapse
 
matteobruni profile image
Matteo Bruni

Thereā€™s a known issue with the canvas blurred, the feature is still under development, about infection timers and the pause on blur feature

Collapse
 
matteobruni profile image
Matteo Bruni

The issue should be fine now, thanks for reporting

Thread Thread
 
sunflower profile image
sunflowerseed • Edited

ah, I actually like the all-white versions since that lets you see all the particles and collisions without being distracted by color change.

hee hee... and then this is the all-white version: codepen.io/winterheat/pen/RwWjxxR
screen saver: codepen.io/winterheat/pen/qBOVpoB
would be nice to have a background image but can't see it, but the bubbles can let you see through.

Thread Thread
 
matteobruni profile image
Matteo Bruni

If you want to explore almost all features you can checkout this collection: codepen.io/collection/DPOage

I keep it updated, about the background mask the feature was already done: codepen.io/matteobruni/pen/yLNvqxG

Collapse
 
waylonwalker profile image
Waylon Walker

This is so reminiscent of the coding train

Collapse
 
waylonwalker profile image
Waylon Walker

This week I learned the power of getattr in python. I am using an API that returns an object that is not subscriptable. Attributes are accessed with .thing for instance. Its really nice that it tab completes, but it makes it really hard to loop through and access 10 items. I learned that you can get to them dynamically with getattr.

The backend library essentially looks like this.

class CantGet:
    def __init__(self, items):
        self.__dict__.update(**items)

It gets instansiated with a dictionary.

cg = CantGet(
  {
    'sales': range(10),
    'production': range(10),
    'inventory': range(10)
    }
  )

You can ask for individual items by dot notation, and tab completion works.

>>> cg.sales
range(0,10)

but it's not subscriptable

>>> cg['sales']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'CantGet' object is not subscriptable

So how do you dynamically access it by a string? The answer is getattr!

>>> getattr(cg, 'sales')
range(0,10)

Python is such a wonderful and hackable language

Collapse
 
fenildesai profile image
Fenil Desai

This week I learned about how to create a simple react app which will fetch & show data from an API.
Also learned about deploying a react app to netlify.

Here's the result - covid-19-indian-tracker.netlify.app/

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Vue slot can be used for multiple layouts.

SQLite PRAGMA functions generate a table, that can be selected.