2coffee.dev

  • How to Delete a Pushed Commit
    • 🏷️git

    How to Delete a Pushed Commit

    There is a keyword that many people search for, which is "delete a pushed commit". Coincidentally, I previously wrote an article titled "I just accidentally committed wrong, how to fix it immediately?" This article ranked high in search results on Google, but the noteworthy thing is that the content does not mention how to solve the problem that people are facing, but simply guides you to delete a "not yet" pushed commit. Therefore, to avoid confusion, and to help readers have a more accurate solution to this issue, today let's explore how to delete a pushed commit!

    🕝1 year ago

  • Discussing the npm run build command – why is it necessary to build?
    • 🏷️javascript
    • 🏷️node.js
    • 🏷️npm

    Discussing the npm run build command – why is it necessary to build?

    The npm run build command is quite familiar to JavaScript developers when preparing to release a new version of an application. Simply put, npm run build performs the task of converting the code in the project into executable code in the browser or Node.js. But why is the build step necessary? What is the essence of building? Do all JavaScript/Node.js projects need to be built? Hopefully, readers will find the answers in the article below...

    🕝2 years ago

  • Measuring the Execution Time of Functions in JavaScript in a Graceful Way
    • 🏷️javascript
    • 🏷️node.js

    Measuring the Execution Time of Functions in JavaScript in a Graceful Way

    During the development or operation of software systems, there are times when many unforeseen issues arise. Once the application is launched to the market, the number of users increases daily, creating a diversity of behaviors and data generated within the system. These combine to explode bugs that the previous testing process was unaware of. One of these can be the API response speed suddenly becoming sluggish, even though the number of users is not high. When checking, it seems you discover or suspect that a certain function is taking too long to process. To be sure, you must find a way to measure how much processing time that function costs. There are many ways to find out which function is consuming time...

    🕝2 years ago

  • Premium
    Hello

    Me & the desire to "play with words"

    Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

    Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

    View all
  • What is Child Process in Node.js? When to Use fork and spawn?
    • 🏷️node.js

    What is Child Process in Node.js? When to Use fork and spawn?

    There is a piece of advice for anyone working with Node.js: "never block the event loop." Blocking here means preventing the Event Loop from processing tasks that need to be solved. Node.js has only one thread to execute JavaScript code; if a task takes a long time to process, it will cause a serious bottleneck in the main thread. Imagine a scenario where all subsequent requests must wait for the previous request to complete before processing begins. It's truly dreadful. Knowing this, Node.js must provide some solutions. Instead of calling synchronous functions, switch to calling asynchronous functions; for instance, when reading a file, `readFile` is preferred over `readFileSync` because `readFile` is asynchronous and processes in the main thread. Conversely, `readFileSync` is synchronous and executed outside the main thread. Additionally, if a task requires CPU computational capabilities, this is when you need to know about the built-in `child_process` module in Node.

    🕝2 years ago

  • Puzzle: What is Mozilla/5.0? Why does every browser have this string in its User-Agent?
    • 🏷️other

    Puzzle: What is Mozilla/5.0? Why does every browser have this string in its User-Agent?

    One fine day while researching the User-Agent (UA) string of popular web browsers, I noticed a common pattern among them. Apart from the unique strings that identify the browsers like Chrome/43.0.2357.65, Firefox/40.0, MSIE 9.0, almost all of them had a string called Mozilla/5.0 or sometimes WebKit. What are these strings and why do they appear in the User-Agent? I delved into the history and discovered some interesting facts about this phenomenon...

    🕝2 years ago

  • How to Fix a Mistaken Commit Immediately?
    • 🏷️git

    How to Fix a Mistaken Commit Immediately?

    A daily task for programmers is to write code, and by evening before leaving, we often ask each other, "Have you committed the code yet?". Or sometimes we hear a quirky joke like, "Even if the sky falls, don’t forget to commit the code before leaving." Because of someone’s urgent push, after committing, you realize there’s another file you forgot to add with the commit. It’s really frustrating, but should you add another commit just to push it up to remote? Many people choose to create a new commit to correct the mistake, but that might be unnecessary because you may not know that an unpushed commit can still be fixed. So how do you fix the commit immediately?

    🕝3 years ago

  • Restoring Willpower with the Power Nap Method
    • 🏷️other

    Restoring Willpower with the Power Nap Method

    Some time ago, I wrote an article about "Willpower - the art of concentration for developers". To summarize for those who haven't read it, the article mentions the power of willpower - the root of concentration. If you know how to preserve your willpower, you will have more time to focus on important tasks. Sleeping is the best way to restore your body, but not everyone has the opportunity to sleep anywhere, anytime. In addition to saving willpower, there is another way to restore it, which is the Power Nap method...

    🕝2 years ago

  • A more detailed article on ESM and CommonJS modules in Node.js
    • 🏷️esm
    • 🏷️commonjs
    • 🏷️modules

    A more detailed article on ESM and CommonJS modules in Node.js

    Previously, I have written some articles about different types of modules in Node.js as well as in JavaScript. I mentioned CommonJS, AMD, and even ESM modules roughly in those articles. You can revisit them in the articles "Understanding require in Node.js" and "Understanding modules in Node.js. Why are there so many module types?". However, I didn't delve deep into them. Many people wonder when to use require and when to use import. Can you use both in the same project? In today's article, let's dive into how these two types of modules work in Node.js to answer these questions...

    🕝1 year ago

  • Using Cloudflare Tunnel to Public Ollama on the Internet
    • 🏷️llms
    • 🏷️ollama
    • 🏷️tunnel

    Using Cloudflare Tunnel to Public Ollama on the Internet

    Hello readers of 2coffee.dev. Tet is just around the corner, have you prepared anything for yourself and your family yet? It seems to me that as the year ends, everyone gets busier. Since the beginning of the month, the traffic to the blog has decreased significantly. Sometimes it makes me anxious because I don't know where my readers have gone. Maybe they are taking an early Tet break, or the chatbot is too strong, or it could be...

    🕝3 months ago

  • .env and the Consequences of Its Usage
    • 🏷️other

    .env and the Consequences of Its Usage

    There's advice that any configuration that can change depending on the deployment environment should be turned into environment variables (OS Environment). Typically, we use a .env file to store these variables. The .env file is usually placed in .gitignore and is only created when deploying the application to the Internet environment or running it locally. A .env file may look like this...

    🕝1 year ago