Skip to main content

Posts

Why Blog Posts Can't be Trusted Anymore Because of ChatGPT

Blog posts have long been a source of information for people seeking to learn about a particular topic or to stay up-to-date on current events. However, with the advent of chatbots like GPT (Generative Pre-training Transformer), it's becoming increasingly difficult to trust the validity of blog posts. One of the main issues with chatbots like GPT is that they are able to generate human-like text, making it difficult to distinguish between content created by a human and content created by a machine. This has the potential to create a vast amount of misleading or false information that can be spread online. In addition to generating false information, chatbots can also be used to spread propaganda or manipulate public opinion. They can do this by creating fake social media accounts or using algorithms to spread false information to a wide audience. This can have serious consequences, as people may believe and act on false information without realizing it. Another issue with chatbots

Lucene Analyzer Explained

Introduction Analysis is an integral part of both indexing and searching operations in Lucene. It involves several processes including splitting the text into tokens, removing stop words, handling synonyms and phonetics, etc. Both the documents and queries are analyzed using the same analyzer, with exceptions in some cases.  Anatomy of an Analyzer   An analyzer is responsible for taking in a Reader and returning a TokenStream. An Analyzer mainly consists of 3 components CharFilter Tokenizer Token Filter CharFilter CharFilter can be used to perform operations on the data before tokenizing it. CharFilter operates on the Reader object rather than the TokenStream Object. Some of the operations that can be performed using CharFilter are : Strip HTML elements from the input. Replace specific characters. Pattern match and replace. A CharFilter itself is a subclass of Reader while Tokenizer and TokenFilter are subclasses of TokenStream.   Tokenizer A tokenizer is responsible for splitting the

How to deal with cache stampede in MySQL

The Cache stampede problem (also called dog-piling, cache miss storm, or cache choking) is not a big problem for small scale systems but is a common headache for large scale applications with millions of requests. It has the potential to bring down the entire system in a matter of seconds. What is Cache Stampede Consider an item that is expensive to generate, and is cached. When the cache expires, the application usually regenerates the item and writes to the cache, and continue as normal. Under very high load, when the cached item expires, multiple requests will get a cache miss and all of them will try to regenerate the cache simultaneously, which will cause a high load in the database. Cache Stampede can occur with any cache including MySQL query cache, or any external cache like Redis or Memcached. It is ok to ignore this problem when your application is small scale but very important to address the issues as you scale up.  Cache stampede can be seen as random spikes in the CPU us

The DRY (Don't Repeat Yourself) Principle

DRY stands for Don't Repeat Yourself, which basically means to avoid writing duplicate code. If you find a block of code that is repeated multiple places, consider using abstraction or moving the code to a separate method. Similarly, if you use a hard-coded value more than once, try making it a constant. This can be applied to every area of software development including database, unit tests, build systems, and documentation.  The benefit of the DRY principle is code maintenance. Changing functionalities in the future will be much easier because you don't have to remember all the places where the code needs to be changed.  An important point to remember here is to not abuse the principle. Duplication is not for code, but for functionality. It means you should never use a standard code for two functionalities that have similar code but are logically unrelated. Doing it will tightly couple two different functionalities together and changing one of them in the future will become h

How I learned React.js and Node.js from scratch in a few months

Recently Causematch decided to shift from wordpress based platform to React.js+Node.js stack. Causematch has indeed grown a lot in past few years that wordpress has become unable to handle us. We had to move on. I was from a backend development background, and hence a complete beginner in javascript and now both our backend and frontend was going to be in js but I was excited anyway to learn all the new stuff. Looking back now, I have come a long way in both React.js and Node.js. Here are few things that helped me on my way. Online courses It is no secret that there are plenty of online courses online. It took me less than 5 minutes to go to udemy.com and find a course with good reviews. Here is the one I chose:  https://www.udemy.com/course/react-the-complete-guide-incl-redux . Keeping an eye on reviews is the key to selecting a good course.  I was too lazy to attend online classes for Node.js too, but I bought one anyway.  https://www.udemy.com/course/the-complete

Abstract Factory Pattern

The Abstract Factory Pattern adds another layer of abstraction over the Factory Pattern. It has an Abstract Factory Interface which is implemented by several Factory classes. A Super Factory decides which Factory should be used based on the requirement. Abstract Factory Pattern is one the creational design patterns. Participants AbstractFactory An interface which for creating AbstractProduct objects. ConcreteFactory Implements AbstractFactory and creates ConcreteProduct objects. AbstractProduct An interface for type of products. ConcreteProduct Implements AbstractProduct object. Here is where the actual product code is defined. Client Uses methods provided by AbstractFactory and AbstractProduct interfaces to create objects.   UML Diagram As you can see in the diagram, There is an AbstractFactory interface which is implemented by 2 factory classes. Client doesn't access the concrete factory classes directly, instead uses the methods provided by AbstractFact

Design Patterns

Do not reinvent the wheel. Just realign it. When it comes to software world, most design level problems are already solved. Design Patterns are blueprints of these solutions which you can customize and use in your application. Advantages: Tried and tested solutions be experienced developers. It helps improve developer communication. Every developer knows what a 'Singleton' is, right? Common Design Patterns Creational design patterns Abstract Factory Builder Factory Method Object Pool Prototype Singleton Structural design patterns Adapter Bridge Composite Decorator Facade Flyweight Private Class Data Proxy Behavioural design patterns Chain of responsibility Command Interpreter Iterator Mediator Memento Null Object Observer State Strategy Template Method Visitor