Skip to content

Instantly share code, notes, and snippets.

View sumanchapai's full-sized avatar

Suman Chapai sumanchapai

View GitHub Profile
@sumanchapai
sumanchapai / buddha.sh
Created March 28, 2024 06:01
shell function to see buddha air flight status
buddha() {
# Set PKR and KTM as the default arguments, converting airports to uppercase
local FROM=$(echo "${1:-PKR}" | tr "[:lower:]" "[:upper:]")
local TO=$(echo "${2:-KTM}" | tr "[:lower:]" "[:upper:]")
# Convert the airports to uppercase
local FROM=echo $FROM | tr "[:lower:]" "[:upper:]"
local LOWER=""
@sumanchapai
sumanchapai / x.py
Last active March 5, 2024 09:51
open data gov.in
import math
import pandas as pd
import json
from requests.api import get
def get_url(offset: int):
return f"https://api.data.gov.in/catalog/2c1fd4a5-67c7-4672-a2c6-a0a76c2f00da?api-key=579b464db66ec23bdd000001cdd3946e44ce4aad7209ff7b23ac571b&format=json&offset={offset}&limit=10&filters[month]=06&filters[year]=2021"
def records_count() -> int:
url = get_url(0)
@sumanchapai
sumanchapai / find-used-deps.sh
Created December 31, 2023 04:38
Find unused dependencies in the src directory (check for the presence of package name). Reads candidates from stdin or the file provided
#! /bin/bash
# Array of packages that must be kept although unused
must_keep_packages=('react-dom')
# Function to handle checking/printing if a package is unused and removable
function handle_package() {
local package=$1
# Skip this package is an important, must-keep package.
# Otherwise add it to the unused packages list
from typing import List
class Player:
def __init__(self, name:str):
self.name = name
self.earnings = {}
def earn_from(self, p, amount):
current_earning_from_p = self.earnings.get(p, 0)
@sumanchapai
sumanchapai / robocar_wifi.ino
Created September 29, 2023 19:57
rccar_wifi
* / _ \ /___)/ _ \| | | |/ _ \ / _ \ / ___) _ \| \
*| |_| |___ | |_| | |_| | |_| | |_| ( (__| |_| | | | |
* \___/(___/ \___/ \__ |\___/ \___(_)____)___/|_|_|_|
* (____/
* OSOYOO Servo Steering Robot Lesson 5 Wifi Control STA mode
* Tutorial link: https://osoyoo.com/?p=37202
* CopyRIGHT www.osoyoo.com
*/
#include <PWMServo.h>
#ifndef HAVE_HWSERIAL1
@sumanchapai
sumanchapai / rpr.go
Last active September 18, 2023 13:19
rudimentary reverse proxy without using ReverseProxy struct
// This is a rudimentary reverse proxy created for education
// Don't use it in production. Create ReverseProxy found in http.httputil
package main
import (
"fmt"
"io"
"log"
"net/http"
"net/url"
@sumanchapai
sumanchapai / rename.py
Last active July 21, 2023 12:20
Rename
from pathlib import Path
folder = "/home/LC/chapsu01/raw_data/Summer 2012/April 16, 2012/m23"
folder = Path(folder)
# Use * to select all files
# Use prefixes and suffixes followed/preceded by * to select files
# matching that pattern. For example dark*.fit to select all files whose name
# start with 'dark' and ends with '.fit'
@sumanchapai
sumanchapai / astro_brightness_duplicate.py
Created May 27, 2023 15:27
Luther Astrophysics. Brightness duplicate
# Boilerplate to allow importing `trout`
import sys
if ".." not in sys.path:
sys.path.append("..")
if "." not in sys.path:
sys.path.append(".")
from trout.exceptions import StarNotPresentInReferenceException
@sumanchapai
sumanchapai / astro_step.py
Created May 27, 2023 15:26
Luther Astrophysics. Step analysis on m23
# Boilerplate to allow importing `trout`
import sys
if ".." not in sys.path:
sys.path.append("..")
if "." not in sys.path:
sys.path.append(".")
import math
from m23.extract import extract_stars
from m23.norm import normalize_log_files
from m23.utils import get_radius_folder_name
from m23.internight_normalize import internight_normalize
from m23.file.aligned_combined_file import AlignedCombinedFile
from m23.file.reference_log_file import ReferenceLogFile
from m23.file.log_file_combined_file import LogFileCombinedFile
from pathlib import Path