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.

Apr 11, 2024


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

sachin.kabadi
Sachin Kabadi
System Analyst
Apr 11, 2024
#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.
nisanth
Nisanth
Apr 10, 2024
git switch -c branch_name used in Git to create and switch to a new branch in one step.
#gitcommand
soniya.rayabagi
Soniya Rayabagi
Apr 10, 2024
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
soniya.rayabagi
Soniya Rayabagi
Apr 10, 2024
Empty a file using the > symbol. Simply typing > filename truncates the file, removing all its previous content.
#UnixCommand
soniya.rayabagi
Soniya Rayabagi
Apr 10, 2024
chmod 777 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
soniya.rayabagi
Soniya Rayabagi
Apr 8, 2024
Kubernetes on Docker Desktop
• Install Docker Desktop
• Enable Kubernetes from docker-desktop setting
• Switch the Kubernetes context to docker-desktop
• Example :


❯ 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
soniya.rayabagi
Soniya Rayabagi
Apr 8, 2024
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
nisanth
Nisanth
Apr 5, 2024
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:


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


Response


[
  {
    "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
soniya.rayabagi
Soniya Rayabagi
Apr 5, 2024
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
mahesh.bhosle
Mahesh Bhosle
DevOps Engineer

Showing 26 to 28 of 82 results

Ready to Build Something Amazing?

Codemancers can bring your vision to life and help you achieve your goals