Skip to content

Instantly share code, notes, and snippets.

View saurbhc's full-sized avatar
🎯
Focusing

saurbhc

🎯
Focusing
View GitHub Profile
@saurbhc
saurbhc / flight-tracker
Created August 25, 2024 21:45
Flight Tracker; example cities: Jaipur -> Delhi; flight number: `I5 1316`
from __future__ import annotations
import requests
import datetime
def main() -> int:
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0',
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
@saurbhc
saurbhc / list_modules.sh
Created April 20, 2024 17:36
list python modules
#!/usr/bin/env bash
set -euxo pipefail
python -c 'import pkgutil;print([x[1] for x in list(pkgutil.iter_modules())])'
@saurbhc
saurbhc / vim.txt
Last active July 4, 2022 23:24
vim — Keyboard Shortcuts (which are actually used)
gg -> takes you to the top of the file
G -> takes you to the bottom of the file
{ -> goes down (skip) down a block of code
} -> goes up (skip) down a block of code
(Number) (command) -> will do that command that many times.
Example 50 } -> will take you down 50 blocks.
Example 50 { -> will take you up 50 blocks.
:(line-number) go to a specific line
Example :30 -> will take you to 30th line
@saurbhc
saurbhc / git_commit_date.sh
Created January 13, 2022 13:28
Git commit previous day
git commit --date="1 day ago" -m "I commited yesterday, I swear"
@saurbhc
saurbhc / get_gh_blog.sh
Created January 6, 2022 19:16
Download github raw files
# wget https://raw.githubusercontent.com/{org}/{repo}/{branch}/{filepath.../...}
# Example: (as different filename .gitignore)
wget https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore -O .gitignore
@saurbhc
saurbhc / set_zen_gh_bash.sh
Last active January 1, 2022 18:39
github octocat zen on bash
echo "curl -s https://api.github.com/octocat" >> ~/.bash_profile
@saurbhc
saurbhc / gist:e6104654b1a87d525c12645d3522246f
Created December 24, 2021 15:02
Mac Copy-Paste for iTerm
#!/bin/bash
MAC_copy(){
cat | pbcopy
}
MAC_paste(){
pbpaste
}
@saurbhc
saurbhc / calculate_k_nearest_neighbors.py
Created October 3, 2021 11:15
k-nearest-neighbor Algorithm
k_in_knn_value, number_of_vectors, from_vector, to_vector, euclidean_distance_df = get_input()
knn_obj = KNearestNeighborsAlgorithm(_k_in_knn_value=k_in_knn_value, _euclidean_distance_df=euclidean_distance_df)
knn_distance = knn_obj.execute()
print(f"""
>> {k_in_knn_value}-Nearest-Neighbours are: {knn_distance.head(k_in_knn_value).Label.tolist()}
>> Most Common Label is: {most_common(knn_distance.head(k_in_knn_value).Label.tolist())}
""")
@saurbhc
saurbhc / calculate_euclidean_distance.py
Last active October 2, 2021 21:21
Euclidean Distance
def compute_euclidean_distance(self):
return math.sqrt(
sum(
[(i - j) ** 2 for i, j in zip(self.from_vector_list, self.to_vector_list)]
)
)