Skip to content

Instantly share code, notes, and snippets.

View a-patel's full-sized avatar
👨‍💻
while (!sleep) { learn(); }

Ashish Patel a-patel

👨‍💻
while (!sleep) { learn(); }
View GitHub Profile
@a-patel
a-patel / NullCoalescingAssignmentOperator.cs
Last active July 14, 2023 11:44
C#.NET - Null Coalescing Assignment Operator (??=) Example
/* Example-1 */
// Without null coalescing assignment operator
string name = null;
if (name == null)
{
name = "Unknown";
}
// With null coalescing assignment operator
string name ??= "Unknown";
@a-patel
a-patel / NullConditionalOrSafeNavigationOperator.cs
Last active July 14, 2023 14:35
C#.NET - Null Conditional (or Safe Navigation) Operator (?.) and (?[]) Example
/* Example-1 */
// Without null conditional or safe navigation operator
string name;
int? length;
if (name != null)
{
length = name.Length;
}
else
{
@a-patel
a-patel / NullForgivingOrNullSuppressionOperator.cs
Last active July 14, 2023 11:34
C#.NET - Null Forgiving or Null Suppression Operator (!.) Example
/* Example-1 */
// Without null forgiving or null suppression operator
string name = null; // WARNING
// With null forgiving or null suppression operator
string name = null!; // NO WARNING
@a-patel
a-patel / TernaryConditionalOperator.cs
Last active July 14, 2023 14:52
C#.NET - Ternary Conditional Operator(?:) Example
/* Example-1 */
// Without ternary conditional operator
int age = 25;
string type;
if (age >= 18)
{
type = "Adult";
}
else
{
@a-patel
a-patel / NullCoalescingOperator.cs
Last active July 14, 2023 11:36
C#.NET - Null Coalescing Operator (??) Example
/* Example-1 */
// Without null coalescing operator
string name = GetUserName();
if (name == null)
{
name = "Unknown";
}
// With null coalescing operator
string name = GetUserName() ?? "Unknown";
@a-patel
a-patel / Kubernetes-Probes.yaml
Created July 16, 2022 09:09
Kubernetes - Probes (Liveness, Readiness, and Startup) Overview
apiVersion: v1
kind: Pod
metadata:
labels:
app: myapp
name: myapp
spec:
containers:
- name: myapp
image: k8s.gcr.io/myapp
@a-patel
a-patel / Terraform-Project-Directory-Structure.tf
Last active October 27, 2023 15:49
Terraform Project Directory Structure
-- PROJECT-DIRECTORY/
-- modules/
-- <service1-name>/
-- main.tf
-- variables.tf
-- outputs.tf
-- provider.tf
-- README
-- <service2-name>/
-- main.tf
# Source: https://gist.github.com/bc1188d2a4b8d5295890e9c5438b9ce4
#################################
# 10 Must-Have Kubernetes Tools #
# https://youtu.be/CB79eTFbR0w #
#################################
# Additional Info:
# - How To Replace Docker With nerdctl And Rancher Desktop: https://youtu.be/evWPib0iNgY
# - k9s Kubernetes UI - A Terminal-Based Vim-Like Kubernetes Dashboard: https://youtu.be/boaW9odvRCc
@a-patel
a-patel / execution.sh
Created February 26, 2022 11:44
Amazon EKS Terraform Workshop: Execution
# initialize terraform configuration
terraform init
# validate terraform configuration
terraform validate
# create terraform plan
terraform plan -out state.tfplan
# apply terraform plan
@a-patel
a-patel / outputs.tf
Created February 25, 2022 20:57
Amazon EKS Terraform Workshop: Outputs
output "cluster_name" {
value = aws_eks_cluster.this.name
}
output "cluster_endpoint" {
value = aws_eks_cluster.this.endpoint
}
output "cluster_ca_certificate" {
value = aws_eks_cluster.this.certificate_authority[0].data