Skip to content

Instantly share code, notes, and snippets.

View mihirsamdarshi's full-sized avatar

Mihir Samdarshi mihirsamdarshi

View GitHub Profile
@mihirsamdarshi
mihirsamdarshi / setup.sh
Last active September 28, 2023 20:21
Setup the basics on a Debian machine
#!/bin/bash
set -ex
sudo apt update
sudo apt install -y curl fish neovim bpytop tmux fzf
cat <<EOF > setup.fish
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
fisher install IlanCosman/tide@v5
fisher install PatrickF1/fzf.fish
@mihirsamdarshi
mihirsamdarshi / create_vm_from_img.sh
Last active May 3, 2023 06:56
Create a Proxmox VM from a .img file
#!/bin/bash
if [ $# -lt 5 ]; then
echo "Usage: ./create_vm_from_img.sh"
echo
echo "Example: create_vm_from_img.sh 8000 ubuntu-image focal-server-cloud.img 4096 6"
echo
echo "[MACHINE_ID]: The ID to assign the VM template"
echo "[TEMPLATE_NAME]: The name of the VM template"
echo "[IMAGE_LOCATION]: The location of the .img file"
@mihirsamdarshi
mihirsamdarshi / add_drop_shadow.sh
Created January 24, 2023 06:44
Convert a picture to match the macOS screenshot style
#!/usr/bin/env bash
# add_drop_shadow.sh
# Add a drop shadow to an image matching the macOS screenshot style as close as I can
#
# Usage: add_drop_shadow.sh <image> <output>
# Example: add_drop_shadow.sh image.png output.png
#
# You can use the -r option to specify whether you want to replace the original image or not
# Example: add_drop_shadow.sh -r image.png
#
@mihirsamdarshi
mihirsamdarshi / instagram_follower_tracker.py
Last active August 9, 2022 18:06
Python script to run as a cron job or manually that tracks who followed/unfollowed you
import logging
import os
import sys
import time
import pickle
from datetime import datetime
from pathlib import Path
import pandas as pd
from dotenv import dotenv_values
@mihirsamdarshi
mihirsamdarshi / main.rs
Created July 18, 2021 22:43
learning rust via rocket
#[macro_use]
extern crate rocket;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::thread;
use rocket::http::Status;
use rocket::response::status;
use rocket::response::status::Custom;
import streamlit as st
import SessionState
def display_options(session_state):
"""
Handles loading and editing of DataFrame
Parameters:
global _start
section .text
_start: mov rax, 1 ; system call for write
mov rdi, 1 ; file handle 1 is stdout
mov rsi, message ; address of string to output
mov rdx, 13 ; number of bytes of message
syscall ; invoke operating system to do the write
mov rax, 60 ; system call for exit
xor rdi, rdi ; exit code 0
syscall ; invoke operating system to exit
@mihirsamdarshi
mihirsamdarshi / interval.c
Created March 27, 2019 02:18
gets the name of the interval between two notes in an octave
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *pianoKeys[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
int firstNoteIndex;
int secondNoteIndex;
int difference;
int getIndex(char* note) {
@mihirsamdarshi
mihirsamdarshi / chord.c
Last active March 27, 2019 01:13
gives common chords upon command line input of note (only sharps)
#include <stdio.h>
#include <string.h>
char *octave[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
void major(char* note, int noteIndex, char *keys[]) {
int key1;
int key2;
if (noteIndex + 4 > 11) {
key1 = noteIndex - 8;
package lmu.cmsi281.examples;
public class BinaryTreeNodeString {
private String data;
private BinaryTreeNodeString left;
private BinaryTreeNodeString right;
public BinaryTreeNodeString(String element) {
data = element;