Wednesday, February 01, 2023

How to monitor background jobs?

 Here are some ways to monitor background jobs:

  1. Job management tools: There are many job management tools available that can monitor your background jobs, manage their execution, and send notifications in case of any issues. Some popular tools include Sidekiq, Resque, and Celery.

  2. Monitoring tools: You can use monitoring tools such as Nagios, New Relic, or Datadog to monitor your background jobs and receive notifications in case of any issues.

  3. Logging: You can log the output of your background jobs and check the logs regularly for any errors or unexpected results. This can be done by redirecting the output of your job to a file, or by using a logging library in your application.

  4. Job status tracking: You can track the status of your background jobs by storing the status in a database and periodically checking the status. This can be done by writing a custom script or using a job management tool.

  5. Health checks: You can implement health checks for your background jobs to monitor their status and receive notifications in case of any issues. This can be done by writing a custom script or using a monitoring tool.

These are some of the ways you can monitor your background jobs to ensure they are running correctly and alert you of any issues. The exact method you choose will depend on your specific needs and environment.

How to monitor CRON jobs?

 Here are some ways to monitor CRON jobs:

  1. Logging: You can log the output of your CRON jobs to a file and check the file regularly for any errors or unexpected results. This can be done by appending >> /path/to/logfile.log to the end of your CRON command.

  2. Email notifications: You can have the output of your CRON jobs sent to you via email by appending | mail -s "Cron job output" your@email.com to the end of your CRON command.

  3. Monitoring tools: There are many tools available that can monitor your CRON jobs and send notifications in case of any issues. Some popular tools include Monit, Supervisor, and New Relic.

  4. System logs: You can also monitor system logs to check for any errors or problems with your CRON jobs. On most systems, you can view the logs by running the cat /var/log/syslog command.

  5. Scripts: You can write a script to monitor your CRON jobs and send notifications in case of any issues. This script can be run on a regular basis as a CRON job itself.

These are some of the ways you can monitor your CRON jobs to ensure they are running correctly and alert you of any issues. The exact method you choose will depend on your specific needs and environment.

How to troubleshoot Too many connections error in MySQL?

The "Too many connections" error in MySQL occurs when the maximum number of connections to the MySQL server has been reached. Here are some steps to troubleshoot this error:


Check the maximum number of connections: You can check the maximum number of connections that MySQL is configured to allow by running the following SQL query:


SHOW VARIABLES LIKE 'max_connections';


Monitor current connections: You can see how many connections are currently open by running the following SQL query:


SHOW STATUS LIKE 'Threads_connected';


Increase the maximum number of connections: If the number of connections is close to the maximum, you can increase the maximum number of connections in the my.cnf file by changing the max_connections value.


Check for idle connections: Some connections may remain open but inactive. You can check for these connections by running the following SQL query:


SHOW PROCESSLIST;


Kill idle connections: If you have a large number of idle connections, you can kill them by running the following SQL query:


KILL [connection_id];


Check for slow queries: Slow running queries can also cause a high number of connections. You can check for slow queries by running the following SQL query:


SHOW SLOW QUERIES;


Optimize slow queries: If you find slow running queries, you can optimize them by using indexes, reducing the number of joins, and optimizing the SQL.


Connection pooling: If you are using connection pooling in your application, consider increasing the number of connections in the connection pool to reduce the number of new connections to the database.

Check if you can find the specific cause of the error.

    Tuesday, January 31, 2023

     def substitute(search, replace, text)

      text.gsub(search, replace)

    end


    text = "Hello World, this is a sample text."

    search = "sample"

    replace = "example"


    puts substitute(search, replace, text)

    # Output: "Hello World, this is a example text."

    def replace_keys_with_values(hash, text)

      hash.each do |key, value|

        text.gsub!(key, value)

      end

      text

    end

    replace_keys_with_values({ "key1" => "value1", "key2" => "value2" }, "key1 and key2")

    # returns "value1 and value2"

     

     

    In this example, the substitute method uses the gsub method, which stands for "global substitution", to replace all occurrences of the search string in the text input with the replace string. The gsub method returns a new string with the replacements, and this new string is then returned by the substitute method.

    Monday, January 23, 2023

    How to troubleshoot nil exceptions in Ruby on Rails codebase?

    Troubleshooting nil exceptions in a Ruby on Rails codebase can be a challenging task, but there are several strategies that can help you to find and fix the problem:

    1. Use a debugger: A debugger is a powerful tool that allows you to step through the code line by line and inspect the state of the variables at each step. This can help you to identify the line of code that is causing the exception and the variable that is returning nil.

    2. Check the stack trace: The stack trace is a list of the method calls that led to the exception. It can help you to identify the method that is causing the exception and the arguments that were passed to it.

    3. Check the logs: The Rails logs can provide more information about the exception and can help you to identify the request that caused the exception.

    4. Use a linter or static analysis tool: There are several linters and static analysis tools that can be used in a Ruby on Rails project, such as RuboCop, Brakeman, and Reek. These tools can help you to find potential issues and vulnerabilities in your codebase.

    5. Use the byebug gem: byebug is a powerful gem that provides an interactive debugger for Ruby. It can be used to check the state of the variables and navigate through the code.

    6. Use the binding.pry gem: pry is a powerful gem that provides an interactive shell for Ruby. It can be used to check the state of the variables and navigate through the code.

    7. Test your code: By writing tests and running them you can ensure that the code is working correctly and the test will catch any exception in the future.

    8. Check the documentation and the source code: Sometimes the exception is caused by a bug in a gem or a library that you are using. Check the documentation and the source code of the gem or library to see if there is a fix or a workaround.

    It's important to note that these are just some of the strategies that can be used to troubleshoot nil exceptions in a Ruby on Rails codebase and the approach that you choose will depend on the specific circumstances of the exception.

    Thursday, December 15, 2022

    TRIZ books

     1. Engineering of Creativity Introduction to TRIZ Methodology of Inventive Problem Solving (Semyon D. Savransky)

    2. TRIZ For Dummies (Lilly Haines-Gadd)

    3. Innovation AlgorithmTRIZ, systematic innovation and technical creativity (Genrich Altshuller)

    4. Lean TRIZ how to dramatically reduce product-development costs with this innovative problem-solving tool (Harrington, H. James)

    5. TRIZ for Engineers: Enabling Inventive Problem Solving (Karen Gadd)

    6. Advances and Impacts of the Theory of Inventive Problem Solving The TRIZ Methodology, Tools and Case Studies (Sebastian Koziołek, Leonid Chechurin etc

    7. Innovation on Demand New Product Development Using TRIZ (Victor Fey, Eugene Rivin)

    8. Inventive Thinking through TRIZ A Practical Guide, Second Edition (Michael A. Orloff)

    9. Modern TRIZ A Practical Course with EASyTRIZ Technology (Michael A. Orloff

    10. Modern TRIZ Modeling in Master Programs - Introduction to TRIZ Basics at University and Industry (Orloff, Michael A)

    11. Research and Practice on the Theory of Inventive Problem Solving (TRIZ) Linking Creativity, Engineering and Innovation (Leonid Chechurin)

    12. Simplified TRIZ New Problem Solving Applications for Technical and Business Professionals, 3rd Edition (Kalevi Rantanen, David W. Conley, Ellen R. Domb)

    13. Trimming, Miniaturization and Ideality via Convolution Technique of TRIZ A Guide to Lean and High-level Inventive Design (Saurabh Kwatra, Yuri Salamatov)

    14. TRIZ POWER TOOLS Job 1 Discovering Markets Carving out New Turf in Saturated Markets (Larry Ball and others

    15. TRIZ POWER TOOLS Job 2 Choosing Features What Features Will Excite the Target Market (Larry Ball and others

    16. TRIZ POWER TOOLS Skill 1 Resolving Contradictions The Skill that Will Give You the Confidence to Do the Rest

    17. TRIZ. Theory of Inventive Problem Solving Level 1 (Vladimir Petrov)

    18. Trizics Teach yourself TRIZ, how to invent, innovate and solve impossible technical problems systematically (Gordon Cameron)

    19. Triz the Right Solution at the Right Time A Guide to Innovative Problem Solving - Yuri Salamatov

    Monday, December 12, 2022

    Software

     Just like nature does not have any distinct fields like Physics, Chemistry, Biology etc. The software does not really have distinctions like front end, backend, machine learning etc. The examples used in this book will not have such arbitrary distinctions. So the concepts will be illustrated using devops such as Kubernetes. Because in reality the software is just software and the chosen example illustrate the principle really well. 

    The evolution might have occurred without being aware of these principles in action. The purpose of this book to bring those concepts from the realm of experts and make it available to anyone at any skill level.

    Trends of Technical Evolution

     Migration of function to super systems. Side car in Kubernetes was extracted into the Linux operating system. This is an example of the function migrating from system to super system over time. 

    Sunday, December 11, 2022

    pnpm

     Appended new lines to /Users/bparanj/.zshrc


    Next configuration changes were made:

    export PNPM_HOME="/Users/bparanj/Library/pnpm"

    export PATH="$PNPM_HOME:$PATH"


    To start using pnpm, run:

    source /Users/bparanj/.zshrc

    Saturday, December 10, 2022

    Physical Contradiction in Software

     The web app began with a simple UI with no buttons on the home page. After a few years, it had lot of buttons, similar to how Microsoft Word looks like. Not so good! How to design a product that is having the buttons and at the same time not having any buttons but provides all the features we need? Can we remove all the buttons to make the design simple and at the same time provide business value?

    The general form of physical contradiction looks like:

    X must have A and X must have -A

    The thing X must have some property and the opposite property. We can break this contradiction by asking:

    1. Do we need both A and -A at the same time?

    2. Do we need both A and -A in the same space?

    In the web app design case, we can choose the time as a way to separate the opposing properties. We can apply the Separation in Time principle to resolve this physical contradiction.

    The design must be modified by removing all the buttons or as many buttons as possible on the home page. The button should appear only when the context is right during the use of the product. One of the reasons why the product became messy page with many buttons is that the app was very CRUD based.

    It lacked clear messaging to the users when using the product and did not provide any next action to take during the workflow. By making the messages actionable, we can include the links that provides them a clear action to take to complete their task.

    Tuesday, November 01, 2022

    Prism of TRIZ

    Step 1

    Describe the problem in simple language covering all the main points.

    Step 2

    Re-describe the problem in a more general, conceptual way, stripping out the detail.

    Step 3

    Locate existing answers to the very general problem using the TRIZ Solution Catalog

    Step 4

    Use the solution triggers + your knowledge and experience to find pragmatic solutions.

    Theory of Inventive Problem Solving

    1. Systematic ways for defining and understanding problems

    2. Using the four solution catalogs to solve them


    1. Inventive Principles - For solving contradictions (conflicting requirements)

    2. TRIZ Trends - Predict the likely evolution of products

    3. Standard Solutions - For dealing with harms, inefficiencies and problems to do with measurement

    4. Effects - Answer how to questions using the Effects Database


    Sunday, September 18, 2022

    apitome ruby 3 compatibility

     https://github.com/jejacks0n/apitome/issues/121

    Based on some local testing, the apitome gem works fine on ruby 3.

    PR merged: https://github.com/jejacks0n/apitome/pull/122


    Thursday, September 08, 2022

    Action Oriented vs Object Oriented

    • Distribute system intelligence horizontally as uniformly as possible, that is, the top-level classes in a design should share the work uniformly.
    • Do not create god classes/objects in your system. Be very suspicious of a class whose name contains Driver, Manager, System, or Subsystem.
    • Beware of classes that have many accessor methods defined in their public interface. Having many implies that related data and behavior are not being kept in one place.
    • Beware of classes that have too much noncommunicating behavior, that is, methods that operate on a proper subset of the data members of a class. God classes often exhibit a great deal of noncommunicating behavior.
    • In applications that consist of an object-oriented model interacting with a user interface, the model should never be dependent on the interface. The interface should be dependent on the model.
    • Model the real world whenever possible. (This heuristic is often violated for reasons of system intelligence distribution, avoidance of god classes, and the keeping of related data and behavior in one place.)
    • Eliminate irrelevant classes from your design. Heuristic 3.8 Eliminate classes that are outside the system.
    • Do not turn an operation into a class. Be suspicious of any class whose name is a verb or is derived from a verb, especially those that have only one piece of meaningful behavior (i.e., do not count sets, gets, and prints). Ask if that piece of meaningful behavior needs to be migrated to some existing or undiscovered class.
    • Agent classes are often placed in the analysis model of an application. During design time, many agents are found to be irrelevant and should be removed.

    Wednesday, September 07, 2022

    The Building Blocks of Object Oriented Paradigm

    • All data should be hidden within its class.
    • Users of a class must be dependent on its public interface, but a class
    • should not be dependent on its users.
    • Minimize the number of messages in the protocol of a class.
    • Implement a minimal public interface that all classes understand [e.g., operations such as copy (deep versus shallow), equality testing, pretty printing, parsing from an ASCII description, etc.].
    • Do not put implementation details such as common-code private functions into the public interface of a class.
    • Do not clutter the public interface of a class with things that users of that class are not able to use or are not interested in using.
    • Classes should only exhibit nil or export coupling with other classes, that is, a class should only use operations in the public interface of another class or have nothing to do with that class.
    • A class should capture one and only one key abstraction. Heuristic 2.9 Keep related data and behavior in one place.
    • Spin off non-related information into another class (i.e., noncommunicating behavior).
    • Be sure the abstractions that you model are classes and not simply the roles objects play.


    Wednesday, July 06, 2022

    Start with the Ideal Outcome

     Start with the Ideal Outcome


    Capture


    1. All the benefits you want

    2. The primary output of your system (the reason it exists)


    Prioritize


    3. What are the primary benefits?

    4. Sort other benefits into 'must haves' and 'nice to haves'.


    Action Item


    Fill out the Ideal Outcome for Scoping New Inventions worksheet


    What benefits do we want from an ideal provisioning and deployment system?

    What benefits would an ideal system deliver?

    Wave a magic wand over it and write down all the things you want.


    Ideal Thinking


    Imagine all the things you want without worrying about the constraints of any kind.


    What are the downsides of the current systems in the market?


    Context


    Who needs to use this sytem?

    In what circumstances?