Skip to content

Instantly share code, notes, and snippets.

View sankalp-khare's full-sized avatar

Sankalp Khare sankalp-khare

View GitHub Profile
#!/usr/bin/env python
# Author : Sankalp Khare
# Date : [2014-07-22 Tue]
# the filenames and the query word are hardcoded right now, can be parameterized later as command line arguments
file1="a.txt"
file2="b.txt"
query="this"
@sankalp-khare
sankalp-khare / add-github-user-details.sh
Created June 3, 2015 21:14
sets your repo's local config so that your commits show proper name and link to your github account
#!/bin/bash
# queries you for github username and name
# sets your name, and your email as:
# name : <input-name>
# email : <input-github-username>@users.noreply.github.com
echo -n "Enter the name you want in your commits: "
read name
echo -n "Enter the github ID you want referenced: "
@sankalp-khare
sankalp-khare / check-for-sat-site.sh
Created August 27, 2015 10:14
script that alerts when sat website's maintenance message goes away
#!/bin/bash
while curl -k --silent -A 'Mozilla/6.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' 'https://sat.collegeboard.org' | grep '<h1 class="title" id="page-title">Temporarily Unavailable</h1>' >/dev/null 2>&1
do
gdate -R | tr -d '\n'
echo " | Site still in maintenance mode"
sleep 10
done
osascript -e 'tell app "System Events" to display alert "SAT Website seems to be back" message "Maintenance message has disappeared!"'
@sankalp-khare
sankalp-khare / screenshot-location.sh
Created March 27, 2021 04:04
set screenshots directory to ~/screenshots
#!/bin/bash
# exit on error from any of the subsequent commands
set -e
# ref: https://intoli.com/blog/exit-on-errors-in-bash-scripts/
# create the location
mkdir ~/screenshots
# set it
defaults write com.apple.screencapture location ~/screenshots
@sankalp-khare
sankalp-khare / switch-gnupg.sh
Created July 3, 2023 11:00
Downgrade / switch gnupg version in homebrew and pin it
#!/bin/bash -e
#-------------------------------------------------------------------------------------
# Summary: Executes commands to...
# * Check/output currently installed version of gnupg
# * Change into the brew repo/install directory
# * Find the git commit-id of the specified version of gnupg
# * git branch/switch to the commit-id
# * replace the brew installed version with the specified version (and pin it)
# * clean up the branch, switch back to master, and remove cached files
# * Check/output the newly installed version of gnupg