Eduardo Zepeda's latests posts

But, before we start, let’s see where Django’s User model comes from.

Where does the Django User model come from?

Django’s User model inherits from AbstractUser which, in turn, inherits from the AbstractBaseUser class.

","datePublished":"Wed, 16 Mar 2022 00:00:00 +0000","dateModified":"Wed, 16 Mar 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/django/how-to-customize-the-user-model-in-django/"}},{"@type":"BlogPosting","headline":"Differences between Django select_related and prefetch_related","description":"

Django’s select_related and prefetch_related methods are used to reduce the number of queries made to the database. This translates into response time for each view. In addition, using these methods is one of the actions to implement to improve the performance of a Django application

Just consider that there are more important things to optimize other than your app’s performance , but if you insist, dive into annotate and aggregate, and be careful with the nested subqueries of annotate because they can make your django queries go really slow

","datePublished":"Wed, 09 Mar 2022 00:00:00 +0000","dateModified":"Wed, 09 Mar 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/django/differences-between-django-select_related-and-prefetch_related/"}},{"@type":"BlogPosting","headline":"Why using React.FC could be a bad practice?","description":"

When we use Typescript with React and we want to pass a children as prop to one of our components , we need to indicate the type. Generally we use the type React.FC, which is short for React.FunctionComponent. With this the Typescript message warning us of a children with type any will disappear.

const Component: React.FC = ({ children }) => {
    return (<div>{children}</div>)
}

In addition to allowing us to work with children, React.FC also causes an error if we try to return undefined from our component.

","datePublished":"Wed, 23 Feb 2022 00:00:00 +0000","dateModified":"Wed, 23 Feb 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/react/why-using-react.fc-could-be-a-bad-practice/"}},{"@type":"BlogPosting","headline":"Go: profiling or basic profiling of CPU usage","description":"

In addition to unit test testing and coverage measurement in go , this programming language is capable of profiling the efficiency of the code by analyzing it in a very detailed way. This is quite useful to find bottlenecks or very expensive parts of the code, which are called numerous times or whose performance can be improved.

How does Go profiling work internally in GNU/Linux?

GNU/Linux, more specifically GNU, has an alarm signal called SIGPROF , this signal warns when a timer finishes measuring CPU usage and interrupts code execution.

","datePublished":"Wed, 16 Feb 2022 00:00:00 +0000","dateModified":"Wed, 16 Feb 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/go/go-profiling-or-basic-profiling-of-cpu-usage/"}},{"@type":"BlogPosting","headline":"Go: basic testing and coverage","description":"

Go already has a testing module in its standard library that is ready for our use, we just need to import it and use it.

\"\" Hey! did you know that I wrote a completely Free Go programming language tutorial?, click here to read it it

Testing preparation in go

For the tests to be carried out we need:

A file ending in _test.go * A file ending in _test.go * Run the command go test.

","datePublished":"Wed, 09 Feb 2022 00:00:00 +0000","dateModified":"Wed, 09 Feb 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/go/go-basic-testing-and-coverage/"}},{"@type":"BlogPosting","headline":"Go: race conditions on goroutines and mutexes","description":"

In past posts I talked a bit about goroutines, deadlocks and channels . But there is another quite interesting issue about goroutines that stands out when we use asynchrony and there are many functions accessing data at the same time and. Multiple functions reading and writing the same information can lead to chaotic situations where very strange things can happen.

\"\" Hey! did you know that I wrote a completely Free Go programming language tutorial?, click here to read it it

","datePublished":"Wed, 02 Feb 2022 00:00:00 +0000","dateModified":"Wed, 02 Feb 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/go/go-race-conditions-on-goroutines-and-mutexes/"}},{"@type":"BlogPosting","headline":"Go: channels, understanding the goroutines deadlocks","description":"

When working with channels there is a quite common error that occurs when you are not familiar with the concepts, the error is “fatal error: all goroutines are asleep - deadlock!”. The first time I saw this error I was perplexed and, although I knew how to fix it, I didn’t understand why it happened, so in this post I explain why it happens as I would have liked to have read it at the time.

","datePublished":"Wed, 26 Jan 2022 00:00:00 +0000","dateModified":"Wed, 26 Jan 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/go/go-channels-understanding-the-goroutines-deadlocks/"}},{"@type":"BlogPosting","headline":"Go: use of channels to communicate goroutines","description":"

So far I have explained how to run a goroutine, execute code concurrently with the goroutines and wait for them to finish executing but our goroutines can’t do anything else, they can’t cooperate with each other to speed up the processes.

Imagine you have a web scrapper that gets data from the internet concurrently; we get the data with goroutines and process it with goroutines. do we have to wait for all the goroutines to finish to use it? Ideally, the goroutines should communicate with each other the data and continue processing.

","datePublished":"Sat, 22 Jan 2022 00:00:00 +0000","dateModified":"Sat, 22 Jan 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/go/go-use-of-channels-to-communicate-goroutines/"}}]}