Skip to content

Instantly share code, notes, and snippets.

View bhavika's full-sized avatar

Bhavika Tekwani bhavika

View GitHub Profile
@bhavika
bhavika / zsh_profile
Created January 16, 2024 18:21
ZSH Profile
git_current_branch () {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]
then
[[ $ret == 128 ]] && return
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
@bhavika
bhavika / finetune.py
Created November 25, 2017 21:45 — forked from panovr/finetune.py
Fine-tuning pre-trained models with PyTorch
import argparse
import os
import shutil
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
@bhavika
bhavika / StackedBarGraph.cs
Last active June 26, 2021 21:41
Creating a stacked bar graph in C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.UI;
@bhavika
bhavika / latency.txt
Created December 15, 2020 00:22 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
​Can you solve this puzzle? While not a requirement, we give priority consideration to candidates supplying a solution.
The 2010 Census puts populations of 26 largest US metro areas at 18897109, 12828837, 9461105, 6371773, 5965343, 5946800, 5582170, 5564635, 5268860, 4552402, 4335391, 4296250, 4224851, 4192887, 3439809, 3279833, 3095313, 2812896, 2783243, 2710489, 2543482, 2356285, 2226009, 2149127, 2142508, and 2134411.
Can you find a subset of these areas where a total of exactly 100,000,000 people live, assuming the census estimates are exactly right? Provide the answer and code or reasoning used.
@bhavika
bhavika / sudoku.py
Created November 10, 2018 07:13
Sudoku Solver
# Sudoku Solver - Peter A. Norvig
digits = '123456789'
rows = 'ABCDEFGHI'
cols = digits
def cross(A, B):
return [a+b for a in A for b in B]
squares = cross(rows, cols)
@bhavika
bhavika / PyDataDC2016_SharedResources
Last active April 19, 2018 15:31
Code and material used in PyData DC 2016 talks
1. Using Dask for Parallel Computing in Python (http://pydata.org/dc2016/schedule/presentation/59/)
Github: https://github.com/jseabold/dask-pydata-dc-2016
2. Building Your First Data Pipelines (http://pydata.org/dc2016/schedule/presentation/10/)
Github: https://github.com/hunterowens/data-pipelines
3. Doing frequentist statistics in Python (http://pydata.org/dc2016/schedule/presentation/9/)
Github: https://github.com/gapatino/Doing-frequentist-statistics-with-Scipy
4. Machine Learning with Text in scikit-learn (http://pydata.org/dc2016/schedule/presentation/12/)
@bhavika
bhavika / docker_help.txt
Last active August 2, 2017 04:59
Docker commands I use frequently
Delete all containers:
docker rm $(docker ps -a -q)
Delete all images:
docker rmi $(docker images -q)