To find a DaemonSet in a specific namespace:
Code
kubectl get ds -n <namespace>To restart the DaemonSet:
Code
kubectl rollout restart ds <name-of-the-daemon-set> -n <namespace>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.
Code
kubectl get ds -n <namespace>Code
kubectl rollout restart ds <name-of-the-daemon-set> -n <namespace>Log shipping is a process used in database management to automate the backup and restoration of transaction logs (history of every action) from a primary database server to a secondary standby server. The main purpose of log shipping is to provide a disaster recovery solution, ensuring data availability and integrity in case of a primary server failureCode
:root {
/* ----- fallback value ----- */
--primary-color: #3498db;
}
h1 {
color: var(--primary-color);
}Code
const App = () => {
const primaryColor = process.env.NAME === 'a' ? '#fff' : '#000';
return (
<div style={{ '--primary-color': primaryColor }}>
<h1>Hello, World!</h1>
</div>
);
};choice Input in GitHub ActionsCode
name: Example Workflow
on:
workflow_dispatch:
inputs:
environment:
description: 'Select the environment'
required: true
default: 'sandbox'
type: choice
options:
- sandbox
- uat
- production
jobs:
example_job:
runs-on: ubuntu-latest
steps:
- name: Display Inputs
run: |
echo "Environment: ${{ github.event.inputs.environment }}"JavaScript
npm i -D prisma-erd-generator @mermaid-js/mermaid-cli
# or
yarn add -D prisma-erd-generator @mermaid-js/mermaid-clischema.prismaJavaScript
generator erd {
provider = "prisma-erd-generator"
}JavaScript
npx prisma generateuseState, useEffect, onClick, and other client-side features, add "use client" at the top of your file. This ensures the component runs on the client side.fetch function.router.push.getServerSideProps, getStaticProps, getInitialProps.Link component.*/5 * * * * in the cron expression triggers the workflow every 5 minutes.terraform force-unlock <LOCK_ID> to forcefully remove the lock.git reset --mixed HEAD~1 command to undo your last commit without losing the changes made in your last commit.?: denotes optional properties. Here's an example:Code
interface User {
name: string;
age?: number; // Optional
}
const user1: User = { name: "Joe Mama" }; // Age is optional
const user2: User = { name: "Tony", age: 30 };
console.log(user1); // Output: { name: "Joe Mama" }
console.log(user2); // Output: { name: "Tony", age: 30 }Partial<T> makes all properties of type T optionalCode
interface User {
id: number;
name: string;
email: string;
}
function displayUser(user: Partial<User>) {
console.log(user);
}
displayuser({ name: "Joe Mama" }); // Partial<T> will make the properties optional hence this is validhas_many relationship, usually in a loop.Author and Book, where an Author has many Books.Code
class Author < ApplicationRecord
has_many :books
endCode
class Book < ApplicationRecord
belongs_to :author
endCode
# Fetching all authors and their books
authors = Author.all
authors.each do |author|
puts author.books.pluck(:title)
endincludes, eager_load, or preload.includesincludes to preload the associated books when fetching authors.Code
# Fetching all authors and their books with eager loading
authors = Author.includes(:books)
authors.each do |author|
puts author.books.pluck(:title)
endincludes, Rails performs a single query to fetch all authors and another single query to fetch all associated books.eager_loadeager_load forces Rails to use a SQL JOIN to load the associated records. This can be useful if you need to filter or sort based on the associated records.Code
# Fetching all authors and their books with eager loading using JOIN
authors = Author.eager_load(:books)
authors.each do |author|
puts author.books.pluck(:title)
endLEFT OUTER JOIN.preloadpreload is similar to includes, but it always uses separate queries for loading the associations.Code
# Fetching all authors and their books with eager loading using separate queries
authors = Author.preload(:books)
authors.each do |author|
puts author.books.pluck(:title)
endpreload is useful when you know that separate queries will be more efficient, for example, when fetching a large number of records.includes, eager_load, or preload appropriately can significantly improve the performance of your application by reducing the number of database queries.Author with attributes id, nameBook with attributes id, title, published, author_idAuthor has many Books, and a Book belongs to an Author.Book model to filter only published books:Ruby
class Book < ApplicationRecord
belongs_to :author
scope :published, -> { where(published: true) }
endAuthor model to create a scoped association:Ruby
class Author < ApplicationRecord
has_many :books
has_many :published_books, -> { published }, class_name: 'Book'
endAuthor has an association called published_books, which only includes books that are published.Ruby
@authors_with_published_books = Author.joins(:published_books).select('authors.*, books.title as book_title')authors table with the books table but only includes books that are published, thanks to the scoped association published_books.Author object in @authors_with_published_books will have:Author model.book_title representing the title of each associated book.User and Post. And we want to get all posts for user. We can do this:Ruby
class User < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :user
end
user = User.first
user.postsRuby
class User < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :user
scope :published, -> { where(published: true) }
end
user = User.first
user.posts.publishedpublished scope to your query. And then you will get all posts, even unpublished. And this is not what you want. Some people use default_scope for this, but it is not good idea. So what we can do? We can use scope in association:Ruby
class User < ActiveRecord::Base
has_many :posts, -> { published }
has_many :not_published_posts, -> { not_published }
end
class Post < ActiveRecord::Base
belongs_to :user
scope :published, -> { where(published: true) }
scope :not_published, -> { where(published: false) }
end
user = User.first
user.posts # only published posts hereRuby
def index
@people = Person.all
respond_to do |format|
format.json { render json: @people}
format.xml { render xml: @people }
format.html { render :index}
end
endRuby
def index
@people = Person.all
respond_to :json, :xml, :html
endkubectl 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.Showing page 12 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.