Skip to content

Instantly share code, notes, and snippets.

View prateek's full-sized avatar

Prateek Rungta prateek

View GitHub Profile
@prateek
prateek / getOpenTabs.sh
Created December 28, 2022 04:33 — forked from NoahCardoza/getOpenTabs.sh
[OSX] Lists the URLs of all the open tabs in a specified browser.
#!/bin/bash
# args: browser
# example: ./getOpenTabs.sh "Brave Browser"
# credits:
# https://gist.github.com/samyk/65c12468686707b388ec43710430a421
# TODO:
# validate args
# don't open app if not already open
@prateek
prateek / keysdistribution_test.go
Created December 17, 2022 01:37
TestKeysDistribution demonstrates why you have to be careful when picking hash functions while double hashing.
package main
import (
"fmt"
"hash/crc32"
"math"
"testing"
)
/*
@prateek
prateek / collective-claims-data-extraction.md
Last active June 21, 2019 19:13
Extract Claims Data from Collective Health.

Free your Collective Claim Data(!)

Found it much easier to hijack their APIs using Chrome (as opposed to browser scraping).

Broke the process into two parts:

  1. Getting a list of all relevant claims
  2. Retrieving PDFs for said claims

(1) Getting a list of all relevant claims

@prateek
prateek / diff-glide-dep.sh
Last active September 29, 2018 04:06
Generate diff-able summaries for glide.{yaml|lock} and Gopkg.{toml|lock} file
#!/bin/bash
# requires https://github.com/dbohdan/remarshal
# generate diff summary for .lock file
cat <(cat glide.lock| yaml2json -i - -o - | jq -r '.imports[] | .name + " " + .version') \
<(cat glide.lock| yaml2json -i - -o - | jq -r '.testImports[] | .name + " " + .version') \
| sort | uniq > glide.lock.summary
@prateek
prateek / pilosa_vs_upstream_roaring.md
Last active May 13, 2018 14:52
upstream roaring v pilosa simple perf benchmarks

For sure. So using some tests I had while testing mem <-> fst segment serialization, as a poor man's benchmark:

# pilosa 
❯ time go test ./index/segment/tests -count=10
ok  	github.com/m3db/m3ninx/index/segment/tests 2.192s
/Users/prungta/code/go1.10.2/bin/go test ./index/segment/tests -count=10  3.81s user 0.47s system 131% cpu 3.266 total

# roaring binary 
❯ time go test ./index/segment/tests -count=10
@prateek
prateek / vellum_example_usage.go
Last active May 14, 2018 18:31
vellum example usage
package main
import (
"bytes"
"github.com/couchbaselabs/vellum"
vregex "github.com/couchbaselabs/vellum/regexp"
)
func main() {
@prateek
prateek / reporter.go
Created May 6, 2018 03:32
gomock.Reporter
// Package test contains utility methods for testing.
package test
import (
"fmt"
"testing"
"github.com/golang/mock/gomock"
)
@prateek
prateek / generate.sh
Created March 9, 2018 08:11
Generate m3db org's package dag structure
#!/bin/bash
if ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v dot)" ]; then
echo 'Error: graphviz (dot) is not installed.' >&2
exit 1
fi
@prateek
prateek / import.go
Created January 24, 2018 22:56
Golang import linter skeleton
package importlint
import (
"go/ast"
"go/token"
)
// NB(prateek): http://goast.yuroyoro.net/ is enormously helpful.
// importDecl is the collection of importGroups contained in a single import block.
@prateek
prateek / goroutine_histogram.py
Created July 7, 2017 18:15
Parse goroutine dumps
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import argparse
import operator
from collections import defaultdict
import re
def parseFile(f):
with open(f, 'r') as opened: