Eduardo Zepeda's latests posts

Codewars is a social network of programmers who get together to challenge each other to solve code challenges. Codewars is one of the best websites for practicing algorithms and solving Katas. Katas? Yes, as in Karate.

","datePublished":"Sat, 30 Apr 2022 00:00:00 +0000","dateModified":"Sat, 30 Apr 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/opinion/top-5-favorite-algorithm-problems-at-codewars/"}},{"@type":"BlogPosting","headline":"REST API: Best practices and design","description":"

How do I design a REST API? How many levels should I nest my related resources? Relative or full URLs? This post is a compilation of some recommendations about some good REST API design practices that I have found in books and articles on the internet. I leave the sources at the end of the article in case you are interested in going deeper or see where this information comes from.

","datePublished":"Thu, 28 Apr 2022 00:00:00 +0000","dateModified":"Thu, 28 Apr 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/software-architecture/rest-api-best-practices-and-design/"}},{"@type":"BlogPosting","headline":"REST API basic characteristics and recommendations","description":"

This publication is a minimal guide of practical tips on REST API design, what is a characteristic of the REST API? I don’t go too deep into the theory. On top of that, I may oversimplify many concepts in order to keep the text as short and simple as possible.

In the next post I will talk about some more subjective questions such as: how to return JSON correctly, how to nest an API, what are the ways to version a REST API, and what are some of the ways to version a REST API.

","datePublished":"Thu, 07 Apr 2022 00:00:00 +0000","dateModified":"Thu, 07 Apr 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/software-architecture/basic-characteristics-of-an-api-rest-api/"}},{"@type":"BlogPosting","headline":"Categories in Django using ForeignKey to self","description":"

Grouping by categories is quite common in web applications, from movies, courses or any other resource that presents a hierarchical relationship to another object. In Django there are different ways to model these relationships. Probably, the first that will come to your mind will be to create a category object, and then relate it by means of a ForeignKey with a subcategory.

One subcategory or level per model

What I meant by one category or level per model is something like this:

","datePublished":"Wed, 30 Mar 2022 00:00:00 +0000","dateModified":"Wed, 30 Mar 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/django/categories-in-django-using-foreignkey-to-self/"}},{"@type":"BlogPosting","headline":"Debounce and Throttle Interactive Explanation","description":"

I thought let’s do a Debounce vs Throttle. Debounce and throttle are design patterns used to limit the execution of functions, generally they are used to restrict the amount of times an event is fired: click, scroll, resize or other events. This patterns are not exclusive to Javascript and can be used in any language or can be used as high level abstractions; in a previous post I explained how to use throttle to limit the number of requests received by the nginx server .

","datePublished":"Wed, 23 Mar 2022 00:00:00 +0000","dateModified":"Wed, 23 Mar 2022 00:00:00 +0000","author":{"@type":"Person","name":"Eduardo Zepeda"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://coffeebytes.dev/en/javascript/debounce-and-throttle-interactive-explanation/"}},{"@type":"BlogPosting","headline":"How to customize the User model in Django?","description":"

In this post I explain three methods to extend or customize Django’s User model, without having to rewrite it from scratch, and keeping all Django’s user management features

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

","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/"}}]}