Skip to content

TILs

Fueling Curiosity, One Insight at a Time

At Codemancers, we believe every day is an opportunity to grow. This section is where our team shares bite-sized discoveries, technical breakthroughs and fascinating nuggets of wisdom we've stumbled upon in our work.

  1. #nextJs #TypeScript
    useEffect is a hook that allows you to perform side effects in function components.

    TypeScript

    import React, { useState, useEffect } from 'react';
    
    function MyComponent() {
      const [count, setCount] = useState(0);
    
      // This effect will run only when the count state changes
      useEffect(() => {
        document.title = `You clicked ${count} times`;
      }, [count]); // Only re-runs when count changes
    
      return (
        <div>
          <p>You clicked {count} times</p>
          <button onClick={() => setCount(count + 1)}>
            Click me
          </button>
        </div>
      );
    }
    
    export default MyComponent;


    In the above example:
    • We have a component MyComponent with a state variable count and a button to increment it.
    • Inside the component, we use the useEffect hook to update the document title with the current count after each render.
    • We pass [count] as the second argument to useEffect, which means the effect will only run when the count state changes. This is because we want to update the document title only when the count changes, not on every render.
  2. #nextJs #TypeScript
    Function Argument Deconstructing: Deconstructing function arguments can make your code cleaner and more readable.

    Code

    // Before deconstruction 
    const BlogPost = (props) => { 
      const { title, content, author } = props; 
      // Render blog post using props
      return (
          <div>
              <h1>{props.title}</h1>
              <p>{props.content}</p>
              <p>Written by: {props.author}</p>
          </div>
      );
    }; 
    
    // After deconstruction 
    const BlogPost = ({ title, content, author }) => { 
      // Render blog post with title, content, and author 
      return (
          <div>
              <h1>{title}</h1>
              <p>{content}</p>
              <p>Written by: {author}</p>
          </div>
      );
    };

  3. Soniya Rayabagi
    CMD-SHIFT-L is a great productivity booster for VS Code. Lets you select all instances of the current selection and edit with multiple cursors.
    #VSCodetip #ProductivityHack
  4. Mahesh BhosleDevOps Engineer
    Terraform alias is a feature that allows you to manage resources across multiple regions more efficiently. It enables you to define different configurations for resources in various regions while using the same Terraform codebase.
    Here's a simple example to illustrate how to use Terraform alias for multiple regions:

    Code

    provider "aws" {
      alias  = "us_east"
      region = "us-east-1"
    }
    
    provider "aws" {
      alias  = "us_west"
      region = "us-west-1"
    }
    resource "aws_instance" "example" {
      provider      = aws.us_east
      ami           = "ami-0c55b159cbfafe1f0"
      instance_type = "t2.micro"
    }
    
    resource "aws_instance" "example_west" {
      provider      = aws.us_west
      ami           = "ami-0c55b159cbfafe1f0"
      instance_type = "t2.micro"
    }


    In this example, we define two different AWS providers with aliases us_east and us_west, representing the US East and US West regions, respectively. Then, we create instances using these providers, specifying the region-specific provider for each instance. This allows Terraform to manage resources in different regions using the same configuration file.
    #terraform #iac
  5. #devops #kubernetes
    k9s is a powerful command-line interface (CLI) tool for Kubernetes management. It allows you to interact with Kubernetes clusters efficiently, offering features like resource viewing, log access, event monitoring, and pod command execution—all from your terminal. Install k9s using Homebrew with the command brew install k9s, and access its intuitive interface by running k9s

  6. JavaScript

    Spread operator in JavaScript is represented by three dots (...). 
    It's a useful syntax for manipulating arrays and objects in various ways.
    
    Following are some of the use cases:-
    
    Spread in Arrays:-
    
    1. Copying Arrays: It allows you to create a new array by copying another array.
    
    const originalArray = [1, 2, 3];
    const copyArray = [...originalArray];
    console.log(copyArray); // [1, 2, 3]
    
    
    2. Concatenating Arrays: You can merge arrays together.
    
    const array1 = [1, 2, 3];
    const array2 = [4, 5, 6];
    const mergedArray = [...array1, ...array2];
    console.log(mergedArray); // [1, 2, 3, 4, 5, 6]
    
    3. Adding Elements to Arrays: You can add new elements to an existing array.
    
    const array1 = [1, 2, 3];
    const newArray = [...array1, 4, 5, 6];
    console.log(newArray); // [1, 2, 3, 4, 5, 6]
    
    
    
    Spread in Objects:-
    
    1. Copying Objects: It allows you to create a shallow copy of an object.
    
    const originalObj = { name: 'John', age: 30 };
    const copyObj = { ...originalObj };
    console.log(copyObj); // { name: 'John', age: 30 }
    
    2. Merging Objects: You can merge multiple objects into one.
    
    const obj1 = { name: 'John' };
    const obj2 = { age: 30 };
    const mergedObj = { ...obj1, ...obj2 };
    console.log(mergedObj); // { name: 'John', age: 30 }
    
    3. Adding Properties to Objects: You can add new properties to an object.
    
    const obj1 = { name: 'John' };
    const newObj = { ...obj1, age: 30 };
    console.log(newObj); // { name: 'John', age: 30 }
    
    
    
    Function Arguments:
    
    1. Spread can be used to pass an array as individual arguments to a function.
    
    const numbers = [1, 2, 3];
    const sum = (a, b, c) => a + b + c;
    console.log(sum(...numbers)); // 6

  7. #devops #kubernetes #helm
    To verify the Helm chart, you can use the following command:
    minikube service servicename
    This command opens a web browser and directs it to a service running in your Minikube Kubernetes cluster. It simplifies accessing and testing applications deployed locally on Minikube.
  8. Soniya Rayabagi
    git switch -c branch_name used in Git to create and switch to a new branch in one step.
    #gitcommand
  9. Soniya Rayabagi
    The helm search hub <keyword> command is used to search for charts available in the Helm Hub, which is a centralized repository of Helm charts , keyword can be prometheus, grafana, nginx, postgresql etc.
    helm search hub <keyword> --max-col-width=0 this command displays the results without column width limitations.
    #devops #helm #helmhub #kubernetes
  10. Soniya Rayabagi
    Empty a file using the > symbol. Simply typing > filename truncates the file, removing all its previous content.
    #UnixCommand
  11. Soniya Rayabagi
    chmod 777 <filename> is a command used to set permissions on a file or directory in Unix-like operating systems (including Linux and macOS). It grants full read, write, and execute permissions.
    #devops #FilePermissions
  12. Soniya Rayabagi
    Kubernetes on Docker Desktop
    • Install Docker Desktop
    • Enable Kubernetes from docker-desktop setting
    • Switch the Kubernetes context to docker-desktop
    • Example :

    Code

    ❯ kubectl config get-contexts
    CURRENT   NAME                      CLUSTER                   AUTHINFO                  NAMESPACE
              docker-desktop            docker-desktop            docker-desktop
    *         kind-kube-nginx-cluster   kind-kube-nginx-cluster   kind-kube-nginx-cluster
    
    ❯ kubectl config use-context docker-desktop
    Switched to context "docker-desktop".


    • Instead of using the command kubectl config use-context docker-desktop we can also go with kubectx to switch between Kubernetes context
    • To install kubectx on Mac: brew install kubectx
    #devops #kubernetes #dockerdesktop
  13. Access Kubernetes dashboard on minikube
    To access the dashboard:
    minikube dashboard
    This will enable the dashboard add-on, and open the proxy in the default web browser.
    #devops #kubernetes
  14. Soniya Rayabagi
    Today I learnt , REST API endpoints for organization members
    • It will List all users who are members of an organization. If the authenticated user is also a member of this organization then both concealed and public members will be returned.
    • The token must have the following permission set: members:read
    • Request example:

    Code

    curl -L \\
      -H "Accept: application/vnd.github+json" \\
      -H "Authorization: Bearer <YOUR-TOKEN>" \\
      -H "X-GitHub-Api-Version: 2022-11-28" \\
      https://api.github.com/orgs/ORG/members


    Response

    Code

    [
      {
        "login": "octocat",
        "id": 1,
        "node_id": "MDQ6VXNlcjE=",
        "avatar_url": "https://github.com/images/error/octocat_happy.gif",
        "gravatar_id": "",
        "url": "https://api.github.com/users/octocat",
        "html_url": "https://github.com/octocat",
        "followers_url": "https://api.github.com/users/octocat/followers",
        "following_url": "https://api.github.com/users/octocat/following{/other_user}",
        "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
        "organizations_url": "https://api.github.com/users/octocat/orgs",
        "repos_url": "https://api.github.com/users/octocat/repos",
        "events_url": "https://api.github.com/users/octocat/events{/privacy}",
        "received_events_url": "https://api.github.com/users/octocat/received_events",
        "type": "User",
        "site_admin": false
      }
    ]


    #githubactionspublic #rest api
  15. Mahesh BhosleDevOps Engineer
    We can leverage the AWS Systems Manager service to execute the Ansible scripts on the EC2 hosts, this removes the overhead of maintaining SSH keys and other instance details.
    How it is done:
    • Prerequisites:
    ◦ EC2 instance should have an IAM role attached for SSM
    ◦ Ansible should be installed on the instance
    • In the AWS System Manager go to State Manager and create a new association
    • The association details will include: association name, Document, Ansible playbook, Target selection, schedule, and Rate control
    • Based on the Association configuration, the playbook will be executed.
    #automation #awsssm #ansible
  16. Securing Sensitive Data in Kubernetes with Base64 Encoding
    Today I learned that the base64 command can be used in Kubernetes to encode sensitive data such as passwords and API keys when creating secrets. By encoding the sensitive information in base64 format, it can be safely stored in Kubernetes secrets without exposing it in plaintext. This adds an additional layer of security to the sensitive data used by applications running in Kubernetes clusters. echo -n "some_password" | base64
    #devops #kubernetes #encoding
  17. while doing npm install or yarn install we might run into this error mentioned below:


    Code

    error /Users/<user>/project/node_modules/sharp: Command failed.
    Exit code: 127
    Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)


    to fix this just do npm rebuild & then run npm install or yarn install .
    #sharp-error #npm #node
  18. Soniya Rayabagi
    git stash want to store commit temporarily then , stashing will save your modifications and revert your working directory to its clean state
  19. SAP is divided into two types of data:
    • Master Data - Consists product data , person data (eg: vendor, customer) or place data.
    • Transaction Data - Consists of quotation , sales order , good issue, good receipt , invoice.
    #SAP
  20. Docker Hub & Pushing Docker Images
    • Why We Need Docker Hub: Docker Hub is like a social media platform, but instead of sharing photos or updates, we share Docker images. Docker Hub provides a centralized place for storing and managing these images. We use Docker Hub to:
    ◦ Share our Docker images with others.
    ◦ Store different versions of our Docker images.
    ◦ Access our Docker images from any machine, making deployment and scaling much easier.
    ◦ Find and use Docker images created by others, which can be very helpful.
    • How to Push a Docker Image to Docker Hub: To push a Docker image, we follow a few simple steps:
    a. Log In: Just like logging into your favorite app, we log in to Docker Hub on our computer.
    b. Tagging: We give our image a label (or a tag) that describes what it is and which version it is—kind of like tagging a friend in a photo docker tag flix-rails:latest nishanthmathiyazhagan/flix-rails:latest
    c. Pushing: With our image tagged, we ‘push’ it to Docker Hub, which means uploading it so others can download and use it.
    docker push nishanthmathiyazhagan/flix-rails:latest
    • What Happens After Pushing the Image to Docker Hub: Once the image is pushed:
    ◦ It’s stored in our Docker Hub repository,
    ◦ Other people can ‘pull’ the image to their own computers or servers to run the application it contains.
    ◦ If we update the application, we can push the new version to Docker Hub so everyone can get the update.
    ◦ We can pull it down on any server
    #devops #docker

Showing page 14 of 42

Your competitors are already using AI. The question is how fast you want to unlock the value.

  • Don't know where to start?

    AI is everywhere but it's unclear which investments will actually move your metrics and which are expensive experiments.

  • Your data isn't ready

    Most AI projects fail at the data layer. Pipelines, quality, access all need work before LLMs can deliver value.

  • Internal teams are stretched

    Your engineers are shipping product. They don't have capacity to also become AI specialists with production-grade experience.

  • Legacy systems block everything

    Aging, undocumented codebases make AI integration slow, risky, and expensive. They need to move first.

Don't worry. We've got you covered.

Start with the audit.

Book a free discovery call