Skip to content

Instantly share code, notes, and snippets.

View nihalxkumar's full-sized avatar
🎵
Tu Koi Aur Hai youtu.be/-0lql0pSSwQ

Nihal Kumar nihalxkumar

🎵
Tu Koi Aur Hai youtu.be/-0lql0pSSwQ
View GitHub Profile
#!/bin/bash
# Script to clean Cargo caches and manage Rust toolchains
# Function to check if the command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check for the cargo command
// Zed settings
// https://github.com/jellydn/zed-101-setup
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run `zed: open default settings` from the
// command palette (cmd-shift-p / ctrl-shift-p)
{
/* Duplicated key auto-commented: "agent": {
Hello World.
This gist is being made from my terminal. This is a test of GH CLI.
Good Commands
What! I can't go up or down to edit the text?
have to figure that out..
anyways here are some commands
gh gist create -f TerminalGist -
Wow. All day in terminal.
Nice
Slide
1 : Team
2 : Title of start up and intro
3 : Problem statement
4 : solution
5 : MVP
6 : How product works
7 : Market size
8 : Business model
9 : Growth strategy
class Base1:
def __init__(self):
self.x = 10
class Base2:
def __init__(self):
self.y = 20
class Derived(Base1, Base2):
def __init__(self):
@nihalxkumar
nihalxkumar / inheritance.py
Last active July 1, 2023 10:56
Method Resolution Order (MRO)
class A:
def method(self):
print("A method")
class B(A):
def method(self):
print("B method")
class C(A):
def method(self):
@nihalxkumar
nihalxkumar / iterationFunc.py
Created June 29, 2023 19:44
Iteration on multiple list simultaneously
authors = ['William Shakespeare', 'Jane Austen', 'Mark Twain']
works = ['Hamlet', 'Pride and Prejudice', 'The Adventures of Huckleberry Finn']
# Using zip()
for author, work in zip(authors, works):
print(author, 'is known for', work)
# Using range() and len()
for i in range(len(authors)):
author = authors[i]
@nihalxkumar
nihalxkumar / lamdaExplanation.py
Created June 29, 2023 19:20
Lambda functions are especially useful when we require a simple, compact function for a specific task without the need for a formal function definition.
# Sorting a list of Indian names based on their length
names = ['Aarav', 'Neha', 'Arjun', 'Sneha', 'Vijay']
# Sorting with a regular function
def sort_by_length(name):
return len(name)
sorted_names = sorted(names, key=sort_by_length)
print(sorted_names) # Output: ['Neha', 'Arjun', 'Vijay', 'Aarav', 'Sneha']