kubectl rollout restart deployment <deployment-name> command used to restart pods managed by a Kubernetes deployment without making any modifications to the deployment configuration.#devops #Kubernetes #rollingrestart
TILs
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.
kubectl rollout restart deployment <deployment-name> command used to restart pods managed by a Kubernetes deployment without making any modifications to the deployment configuration.belongs_to, has_many, has_one, and has_and_belongs_to_many, allowing us to express complex relationships between database tables.three-way handshake to establish a TCP connection to the server.database authentication checks to establish the client's identity.Connection pooling is a technique where database connections are reused for multiple requests instead of being closed after each query. This approach uses a connection pooler, a software that manages the connections between the database and its client applications, optimizing the use of resources and improving performance.Connection pooler is sitting b/w client and server. client connects to the connection pooler instead of directly to the database. Req is sent to pooler and the pooler interprets queries returns back the response from DB..save.Ruby
user = User.first
user1 = user.dup
user1:
<User id: nil, name: "Rails">Ruby
user = User.first
user1 = user.clone
<User id: 1, name: "Rails">.save it will overwrite the original obj.resources method provides a convenient way to define RESTful routes for our application's resources. Instead of manually specifying separate routes for each CRUD action (Create, Read, Update, Delete), we can use the resources method to define all these routes with a single line of code.Code
# config/routes.rb
Rails.application.routes.draw do
resources :students
endstudents resource:Code
GET /students # Index action (display a list of students)
GET /students/new # New action (display a form to create a new student)
POST /students # Create action (create a new student)
GET /students/:id # Show action (display details of a specific student)
GET /students/:id/edit # Edit action (display a form to edit a specific student)
PATCH /students/:id # Update action (update a specific student)
PUT /students/:id # Update action (update a specific student)
DELETE /students/:id # Destroy action (delete a specific student)seeds.rb file is used to populate the database with initial data. This file typically resides in the db directory of our Rails application. The data added through the seeds.rb file is often used for testing or for providing initial data in a fresh installation of the application.seeds.rb file, we can populate the database by running the rails db:seedgeneric type notationCode
function identityType<Type>(prop: Type): Type {
return prop;
}
identityType(1);<> have to add, it tells ts compiler as the function in generic fn.any and unkown type in tsany type is a dynamic type, variables of type any can hold values of any data type, and TypeScript type checking is effectively turned off for them.any provides flexibility, it bypasses TypeScript's type checking entirely, which can lead to loss of type safety and potentially introduce bugs.unknown type is a type-safe counterpart of any. It represents values of an unknown type.unknown can hold values of any type, but you cannot perform operations on them without first narrowing their type or asserting a more specific type.any and unknown provide flexibility in handling values of unknown types, any completely disables type checking, while unknown enforces type safety by requiring you to explicitly narrow the type before performing operations on the value. It's generally recommended to prefer unknown over any when dealing with values of unknown types, as it helps maintain type safety in your TypeScript code.Code
class User {
constructor(public name: string, public age: number) {}
}
const ue = new User("github", 24);readonly_ name convention for better maintainbility.Code
class User {
private _currentCount: number = 0;
constructor(public name: string, public age: number) {}
get fetch_name(): string {
return this._name;
}
get fetchCount(): number {
return this._currentCount;
}
set increaseCount(prop: number) {
this._currentCount = prop + this._currentCount;
this.logData();
}
private logData(): void {
console.log("Count Increased");
}
}
const fetchUser = new User("github", 24);classes or method are marked as abstract those are only for readonly purposes, means they can be only used as base class/sub class.abstract.Code
abstract class Photo {
constructor(public isCameraOn: boolean, public isFlashOn: boolean) {}
}
class Phone extends Photo {}
const ph = new Phone(true, true);Code
let myName: string = "Vijay";
let age: number = 20;
let isActive: boolean = false;Code
function sum(a: number, b: number = 2): number {
return a + b;
}Code
let sum = (a: number, b: number = 2): number => a + b;any :any in TypeScript bypasses type checking but undermines TypeScript's static typing advantages. It's better to specify types explicitly for safer and more maintainable code.Code
For String
let users: string[] = ["a", "b", "c", "d]
For Number
let count: number[] = [1, 2, 3, 4]
For boolean
let isActive: boolean[] = [true, false]
For Mixed array
let allDate: (string | number)[] = ["a", "b", "c", 1]
Here Array contains only integers and stringsvoid is a type that represents the absence of returning value. It's often used as the return type of function that doesn't return any value.Code
function logError(msg: string): void {
console.log(msg);
}never represents the type of values that never occur:. It's typically used as the return type of functions that never return (i.e., always throw an error).Code
function throwError(message: string): never {
throw new Error(message);
}Object Types is used to pass the object as a parameter in the functions.Code
function fetchData(pt: { x: number; y: number }) {
return pt;
}
fetchData({ x: 3, y: 7 });? operatorCode
function fetchData(pt: { x: number; y?: number }) {
return pt;
}
fetchData({ x: 3 });Code
function sum(a: string | number) {
return a;
}
Here you can see value can be anything string or numberType Aliases or Interface .Code
type User = {
name: string;
age: number;
}
function displayUser(prop: User) {
console.log(prop.name);
console.log(prop.age);
}
displayUser({name: 'John', age: 22})Code
type User = {
name: string;
age: number;
}
type Role = {
role: string
}
type UserDeatils = User & Role & {
address: string;
}Code
interface User {
name: string;
age: number;
}
function displayUser(prop: User) {
console.log(prop.name);
console.log(prop.age);
}
displayUser({name: 'John', age: 22})Code
interface User {
name: string;
age: number;
}
interface Role {
role: string
}
interface userDetails extends User, Role {
address: string;
}Code
type User = {
readonly id: string;
name: string;
phone: number;
isActive: boolean;
email?: string;
};typescript will throw an exception. Also, email is not present on obj it does not make exceptions.Code
let myTuple: [string, number, boolean];
myTuple = ['hello', 10, true];numeric and string-based enums0 until we explicitly mention something:Code
const enum UserType {
ADMIN,
USER,
GUEST,
}Code
const enum UserType {
ADMIN = 10,
USER,
GUEST,
}Code
const enum UserType {
ADMIN = "admin",
USER = "user",
GUEST = "guest",
}Code
const enum UserType {
ADMIN = "admin",
USER = 0,
GUEST,
}_). For example, _sidebar.html.erb or _header.html.erb.render method with the name of the partial file (without the underscore) as an argument. For example, <%= render 'sidebar' %> will render the _sidebar.html.erb partial within the current view.rails routes command generates a comprehensive list of all routes defined in our Rails application, displaying the HTTP method, URL pattern, controller, and action associated with each route.flog . Flog finds the most tortured code in your codebase.Code
gem install flogCode
flog app libinstance variables are variables that belong to a specific instance of a class. They are prefixed with the @ symbol and are accessible within the instance methods of that class. Instance variables allow objects to maintain state and store information unique to each instance.Ruby
class Person
def initialize(name, age)
@name = name
@age = age
end
def say_intro
puts "Hello, my name is #{@name} and I am #{@age} years old"
end
end
# Create a new instance of Person
person1 = Person.new("John", 18)
# Call the say_intro method
person1.say_intro@name is an instance variable of the Person class, representing the name of each Person object created. The initialize method is a constructor that sets the value of @name when a new Person object is created. The say_intro method uses the instance variable @name to give the intro of the person with their name and age when called.docker stats command is a powerful tool provided by Docker to monitor the resource usage of running containers. It provides a real-time stream of various metrics such as CPU usage, memory usage, network I/O, block I/O, and the number of processes (PIDs) running inside each container. This command is particularly useful for performance analysis and ensuring that containers are running within their resource limits.Code
docker stats db370fc6b784
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
db370fc6b784 minikube 43.70% 1.243GiB / 2.148GiB 57.87% 35.4MB / 414MBCode
SELECT column_name, column_default
FROM information_schema.columns
WHERE table_name = '<table_name_placeholder>' AND column_name = '<column_name_placeholder>';is_nullable as following:Code
SELECT column_name, is_nullable
FROM information_schema.columns
WHERE table_name = '<table_name_placeholder>' AND column_name = '<column_name_placeholder>';active_record_doctor performs variety of health checks to identify and rectify common database issues like missing foreign key constraints, missing NON NULL constraints, missing presence validations, incorrect presence validations on boolean columns and many more. Ref: https://github.com/gregnavis/active_record_doctorsentry with gitlab ip whitelisting needs to be done on gitlab server (self-hosted)kubectl cordon NODE_NAME command is used in Kubernetes to mark a node as unschedulable, meaning no new pods will be scheduled onto that node. Existing pods on the node will continue to run unless explicitly terminated or moved.helm upgrade unleash-app-toggle . --debug--debug can provide more insight if the error persists, showing exactly what values are being passed to each template.Showing page 13 of 42
AI is everywhere but it's unclear which investments will actually move your metrics and which are expensive experiments.
Most AI projects fail at the data layer. Pipelines, quality, access all need work before LLMs can deliver value.
Your engineers are shipping product. They don't have capacity to also become AI specialists with production-grade experience.
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.