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. 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
  2. Sidekiq Capsule allows to configure queues to execute jobs serially.
    Before Sidekiq version 7, to manage dependencies between jobs, a delay was often manually set with set(wait: 30.seconds) to ensure the sequential execution of dependent jobs. This can be achieved now by setting their concurrency to 1.

    Ruby

    Sidekiq.configure_server do |config|
      config.capsule("capsule") do |cap|
        cap.concurrency = 1
        cap.queues = %w[capsule-queue]
      end
    end


    #rails #sidekiq
  3. Use pluck to fetch only the necessary columns if you don't need the entire object
    This reduces memory usage and database load

    For example

    Code

    adults = User::User.where("age > ?", "18").pluck(:name)


    The above code will return an array of name of users who are above age of 18

    #rails #db
  4. Soniya Rayabagi
    ps aux | grep defunct displays information about any zombie processes (that have completed execution but still have an entry in the process table with specific PID because, their parent process has not yet collected their exit status) currently running on the system.
    #devops
  5. Vaibhav YadavSenior System Analyst
    When eslint is not working on your repository in local for any reason you can try restarting the ES Lint Server on VS Code, and if the issue is cause cause server is not reading the config from root directory you can set root: true in your eslint config file, that should resolve the issue. And to fix all your lint issue in a single commit you can use command npx eslint . --fix.

    #javascript #eslint
  6. Rails db:prepare command follows these steps:
    1. It first attempts to run db:migrate to apply any pending migrations. This step ensures that the database schema is up to date with the latest changes defined in your migration files.
    2. If the database does not exist, it falls back to db:setup to create the database, load the schema, and seed it with initial data. This step is crucial for setting up a new database or ensuring that an existing database is correctly initialized.
    In summary, rails db:prepare is a powerful command for ensuring your database is ready for use in your Rails application
    #rails
  7. The rails plugin command simplifies plugin management. Plugins can be installed by name or their repository URLs. You need to have Git installed if you want to install a plugin from a Git repo.
    $ rails plugin install https://github.com/countries/countries.git
    #rails #gem
  8. Consumable products does not have certain properties such as On Hand & Forecasted while Storable products has it.
    Reason being, storable product needs accurate inventory tracking where as consumable product focuses on purchase and expense records without maintaining detailed inventory levels.
  9. To create products in odoo.
    • Navigate to Products > Products
    • Click on "New" and fill in the necessary details like product name, sales price, cost, product type and any other relevant information.
    • Click on "Save".
    And now the product will be available in the Inventory Adjustment for us to add in stock.
    #inventory-management #wms #odoo
  10. Delivery Order in Odoo is used for sending goods from warehouse to customer and external parties, to transfer between warehouses use Internal Transfers in Odoo.
    #inventory-management #wms #odoo
  11. GautamDirector
    If using Podman (instead of Docker for Mac) and trivy for image scanning, trivy expects DOCKER_HOST env variable to be setup for scanning local images and fails unless DOCKER_HOST is pointing to the podman socket.

    Fix:

    Code

    $ export DOCKER_HOST="unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')"
    $ trivy image image_name


    #docker #devops
  12. atob() function decodes a string of data which was encoded using Base64 encoding and btoa() method encodes the data
  13. GiritharanSystem Analyst
    • ActiveSupport::TimeZone.all which likely fetches a list of available time zones supported by the ActiveSupport library in rails.
    • Date::ABBR_DAYNAMES, which is an array containing abbreviated names of the days of the week (e.g., ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]). This array is provided by Ruby's Date class, making it convenient for developers to access the names of the days without manually typing them out.
  14. Ashwani Kumar JhaSenior System Analyst
    While exploring a lengthy code file, we often need to see the available properties and methods without diving into their implementation. In VS Code, this is quite easy with "Fold Level 1" functionality. This feature collapses the code to display only the top-level structures, which makes it easier to understand the file's architecture without getting into the details.

    To Use Fold Level 1:

    1. Open Command Palette: Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
    2. Select Fold Level 1: Now, only the main parts of our code will be visible.
    #vs-code, #coding
  15. Soniya Rayabagi
    Migration of a Repository from GitLab to GitHub:
    1. Clone the GitLab Repository Locally

    Code

    git clone <GitLab-repository-URL>
    cd <repository-name>


    2. Add the GitHub Repository as a Remote

    Code

    git remote add github <GitHub-repository-URL>


    3. Resolve any merge conflicts that may arise using rebase after pull

    Code

    git pull github main


    4. Push from your local repository to the GitHub repository

    Code

    git push github main

  16. GiritharanSystem Analyst

    Code

    Resolving blocked host:


    The Blocked Host is a new feature of Rails 6. To resolve the Blocked Host error in rails, add config.hosts.clear to config/environments/development.rb in your Rails project. This disables the functionality in the development environment, allowing requests from ngrok.
    #host-block-issue, #rails
  17. Extract the source code of the gem to a local directory by using the command gem unpack GEMNAME.
  18. Setup Tailscale in local device and serve your localhost
    1. Intsall tailscale from https://tailscale.com/download for your device.
    2. Sign up and follow the steps so that your device gets connected.
    3. Open your terminal and download tailscale CLI using brew install tailscale
    4. Run tailscale serve 3000 (you might get some warning regarding client and server version mismatch)
    5. It will say Serve is not enabled on your tailnet. and ask you to visit https://login.tailscale.com/f/serve?node=<node-id>
    6. In that link enable the option , and that's it , it will serve your port 3000 successfully.
    #tailscale , #devops
  19. While changing a column type from one type to another and running rails db:migrate , it will throw the below error

    Code

    PG::DatatypeMismatch: ERROR:  column "tags" cannot be cast automatically to type jsonb
    HINT:  You might need to specify "USING tags::jsonb".


    above error ^ because i was converting tags field from type string to jsonb
    so in order to fix this we have to mention the USING tags::jsonb and cast the type.

    Code

    class ChangeTagsToJsonbInTils < ActiveRecord::Migration[7.0]
      def change
        change_column :tils, :tags, 'jsonb USING CAST(tags AS jsonb)'
      end
    end


    #migration, #database, #rails
  20. Soniya Rayabagi
    Create a PostgreSQL Database in Docker .

    Step 1: Download the latest version of the Postgres image :

    Code

    docker pull postgres


    Step 2: Create and Run Postgres Container :

    Code

    docker run -d --name <container_name> -p 5432:5432 -e POSTGRES_PASSWORD=<password> postgres


    Step 3: Verify Executing Container :

    Code

    docker ps


    Step 4: Interact with Executing Container :

    Code

    docker exec -it <container_name> bash


    Step 5: Connect to Postgresql Database Server :

    Code

    psql -h localhost -U postgres


    Step 6: Create Postgresql Database :

    Code

    CREATE DATABASE <database_name>;
    \\l


    Step 7: Establish a connection with database :

    Code

    \\c <database_name>


    Step 8: Create Database User :

    Code

    CREATE USER <user_name> with PASSWORD <password>;


    Step 9: Exit :

    Code

    \\q


    #devops #docker

Showing page 15 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