Skip to content

Instantly share code, notes, and snippets.

View vsinha's full-sized avatar

Viraj Sinha vsinha

View GitHub Profile
@vsinha
vsinha / .zshrc
Created September 19, 2023 14:25
f - quickly change directories
function f() {
local dirname
dirname=$(cat ~/fcd/fcd-dirs.txt | fzf) || return
cd "$dirname"
}
function _f_no_cache() {
local paths=(
~/my-corporate-dev-dir/
~/dev
@vsinha
vsinha / relative_resize.py
Created October 25, 2022 22:40
kitty relative_resize.py
#!/usr/bin/env python3
from kittens.tui.handler import result_handler
def main(args):
pass
@result_handler(no_ui=True)
@vsinha
vsinha / speak-random-notes.py
Created April 14, 2022 18:24
Git gud at guitar. Speaks a random note so you can practice finding the note by name. Ideally put this script in its own folder and run it from there, as it uses the filesystem to store the created note MP3 files.
import random
import time
from gtts import gTTS
import os
sleep_sec = 0.25
natural_notes = ["A", "B", "C", "D", "E", "F", "G"]
prev = None
@vsinha
vsinha / print-random-guitar-notes.py
Created April 14, 2022 16:47
for memorizing notes on the guitar fretboard
import random
import time
sleep_sec = 1
natural_notes = ["A", "B", "C", "D", "E", "F", "G"]
prev = None
def print_randomly():
global prev
@vsinha
vsinha / main.cpp
Created September 23, 2016 16:58
esp8266 arduino wifi
#include <ESP8266WiFi.h>
const char* ssid = "************";
const char* password = "****************";
WiFiServer server(80);
void setup()
{
Serial.begin(115200);
def searchForStraight(self, cards, length):
expected = cards[0].rank # initialize to first card
counter = 0 # keep track of length of# the current straight
for card in cards:
#print('rank: ', card.rank, ', expect: ', expected)
if card.rank == expected: # we are inside a "straight",
# potentially of length 1
counter += 1
elif card.rank == expected-1: # if this is another of the card we just saw
### Keybase proof
I hereby claim:
* I am vsinha on github.
* I am vsinha (https://keybase.io/vsinha) on keybase.
* I have a public key whose fingerprint is 1F74 0BBE 8863 B0AA 1742 BBA5 3D92 77B3 53E7 8BE6
To claim this, I am signing this object:
@vsinha
vsinha / plot.html
Created August 8, 2014 23:34
dygraphs plot tool for stock data (stored as csvs in data/ folder relative to wherever this file is). Run "python -m SimpleHTTPServer" in the folder this file is in
<html>
<head>
<script type="text/javascript" src="dygraph-combined.js"></script>
<style>
body{
font-family:"Helvetica";
}
.graph {
height: 250px;
import operator
# create a dict
d = dict()
d[0] = 10
d[1] = 20
d[2] = 20
# find the max value
maxValue = max(d)