Skip to content

Instantly share code, notes, and snippets.

View aaditkamat's full-sized avatar

Aadit Kamat aaditkamat

View GitHub Profile
@aaditkamat
aaditkamat / generate_sql_statements.py
Last active February 5, 2025 19:59
Create SQL DDL and DML statements based on CSV data
import pandas as pd
def create_sql_create_statements(df: pd.DataFrame, table_name: str) -> str:
dtype_mapping = {
pd.Series({'a': '3'}).dtype: 'TEXT',
pd.Series({'a': 3}).dtype: 'INT',
pd.Series({'a': 3.0}).dtype: 'FLOAT',
pd.Series({'a': pd.to_datetime('2021-12-3')}).dtype: 'TIMESTAMP'
}
create_statement_string = f'CREATE TABLE {table_name} (\n'
@aaditkamat
aaditkamat / brew-cask-check.sh
Created December 2, 2024 17:26
Check if newly created Homebrew cask meets the requirements
execute_checks() {
local cask=$1
brew audit --cask --online "$cask"
brew style --fix "$cask"
brew audit --cask --new "$cask"
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --cask "$cask"
brew uninstall --cask "$cask"
}
read -p "Enter the cask name: " cask
@aaditkamat
aaditkamat / github_clean_fork.py
Created November 20, 2024 15:44
Python script to clean GitHub fork
import os
import datetime
import pytz
from github import Github
from github.GithubException import GithubException
def cleanup_inactive_forks(github_token, username, repos_to_delete, inactive_days=30):
"""
Remove GitHub forks that haven't been updated in the past month.
@aaditkamat
aaditkamat / summarize.py
Created June 26, 2024 14:49
Summarize any text in 13 sentences using Sumy
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer
with open('transcript.txt') as in_file:
text = in_file.read()
parser = PlaintextParser.from_string(text, Tokenizer("english"))
summarizer = LsaSummarizer()
num_sentences = 13
@aaditkamat
aaditkamat / delete_unsuccessful_workflow.sh
Last active July 16, 2023 23:02
Delete unsuccessful repository workflows
# Install brew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install the JSON processing command line utility
brew install jq
# List workflow runs for a repository
runs=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
@aaditkamat
aaditkamat / Login.js
Created September 18, 2022 08:02
Example of unit tests for a Login form built with Chakra UI
const displayErrors = (isEmailError, isPasswordError) => {
if (isEmailError) {
return (
<FormErrorMessage data-testid={testids.login.error.email}>
Email is required.
</FormErrorMessage>
);
}
if (isPasswordError) {
return (
@aaditkamat
aaditkamat / example.test.js
Last active September 18, 2022 08:00
Unit testing with Jest and React Testing Library
beforeAll(() => {
console.log("This statement will get executed before all the test cases");
});
afterAll(() => {
console.log("This statement will get executed after all the test cases");
});
describe("test suite", () => {
beforeEach(() => {
@aaditkamat
aaditkamat / twitter-unfollow-all.js
Created April 22, 2022 00:33 — forked from oatycreates/twitter-unfollow-all.js
Unfollow All for Twitter
/*
* Unfollow All for Twitter
*
* Go to https://twitter.com/<YourUserName>/following and run the
* below code in the console to gradually unfollow all accounts
* you are following, this should play nice with any rate limiting.
* Built on current Firefox (2021-08-26) though may work for others.
*
* Author: https://twitter.com/OatyCreates
* Copyright 2021-Present @oatycreates
@aaditkamat
aaditkamat / instagram-unfollow-users.md
Created April 22, 2022 00:31 — forked from berstend/instagram-unfollow-users.md
Mass unfollow users on Instagram (no app needed)
  • Go to your profile on instagram.com (sign in if not already)
  • Click on XXX following for the popup with the users you're following to appear
  • Open Chrome Devtools and Paste the following into the Console and hit return:
(async function(){
  const UNFOLLOW_LIMIT = 800
  const delay = (ms) => new Promise(_ => setTimeout(_, ms))
  const findButton = (txt) => [...document.querySelectorAll("button").entries()].map(([pos, btn]) => btn).filter(btn => btn.innerHTML === txt)[0]
@aaditkamat
aaditkamat / unfollow_youtube.js
Last active October 2, 2023 23:52
Script to mass unsubscribe from all YouTube channels
var i = 0;
var myVar = setInterval(myTimer, 3000);
function myTimer () {
var els = document.getElementById("grid-container").getElementsByClassName("ytd-expanded-shelf-contents-renderer");
if (i < els.length) {