Skip to content

Instantly share code, notes, and snippets.

Avatar

Sai Teja Suram dotslash

View GitHub Profile
View gcp_publicload.py
#!/usr/bin/env python
"""
Uploads files to gcs buckets
Expectations:
1. Setup gcp credentials (via GOOGLE_APPLICATION_CREDENTIALS env var)
2. Setup SCRATCH_UPLOAD_BUCKET to the gcp bucket to place the files.
Examples:
# help
View rocks_example.cc
// osx instructions on Mojave (as of 2020-12-27)
// brew install llvm
// brew insall rocksdb
// llvm-g++ -std=c++14 -L /usr/local/Cellar/rocksdb/6.14.6_1/lib -lrocksdb rocks_example.cc
#include "rocksdb/db.h"
#include <iostream>
#include <cassert>
#include <sstream>
void assert_status(rocksdb::Status status, std::string msg ) {
View keybase.md

Keybase proof

I hereby claim:

  • I am dotslash on github.
  • I am yesteapea (https://keybase.io/yesteapea) on keybase.
  • I have a public key ASCJF5otpI9QimPmbLAZQTpROSn38K90-rH8CQM2gcDfEwo

To claim this, I am signing this object:

View json_pretty_print.py
import sys
import json
import argparse
from colored import fg, bg, attr
ARGS = None # initialized in main.
MAX_WIDTH = 100 # overriden in main.
LENGTH_CACHE = {}
LENGTH_CACHE_HITS = 0
LENGTH_CACHE_MISSES = 0
View covid_ind.sh
# Setup
# pip install colored tabulate
# brew install jq (mac)
# sudo apt-get install jq (ubuntu)
alias json_tabulate='python -c "from colored import fg, bg, attr; import json; import fileinput; import tabulate; lines=[line for line in fileinput.input() if line.strip()]; dicts=json.loads(\" \".join(lines)); keys = (dicts and dicts[0].keys()) or []; keys = {k:fg(\"yellow\") + attr(\"bold\")+ k + attr(\"reset\") for k in keys}; print(tabulate.tabulate(dicts, headers=keys))"'
alias update_covid_ind='curl https://api.covid19india.org/data.json > ~/tmp/covid_ind.json'
alias covid_ind_tests='jq ".tested | map({totalpositivecases, totalindividualstested, samplereportedtoday, as_of: .updatetimestamp})" ~/tmp/covid_ind.json | json_tabulate'
alias covid_ind_states='jq ".statewise | map({state, confirmed, new: .deltaconfirmed, last_updated: .lastupdatedtime})" ~/tmp/covid_ind.json | json_tabulate'
alias covid_ind_daily='jq ".cases_time_series | map({date, dailyconfirmed, totalconfirmed}) | .[-20:]" ~/tmp/covid_ind.js
View exp_wait_for_perm.py
# Usage:
# > python exp_wait_for_perm.py 12
# > python exp_wait_for_perm.py 3
# Needs - numpy
from numpy.random import seed
from numpy.random import randint
from collections import defaultdict as ddict
import sys
import time
View SnapshottableArray.scala
import scala.collection.mutable.ListBuffer
trait SnapshottableArray {
// Regular array operations
def set(index: Int, value: Int): Unit
def get(index: Int): Int
// Creates a snapshot and returns a handle to the snapshot
def snapshot(): Int
View python_util.py
default_date_format = "";
def now():
pass
def ts_to_dt():
pass
def dt_to_string(dt, format=default_date_format):
pass
View main.py
from sklearn.preprocessing import LabelEncoder
from sklearn.cross_validation import train_test_split
import json
import re
import time
import sys
import scipy.sparse as sparse
from sklearn.ensemble import GradientBoostingClassifier, RandomForestClassifier
from sklearn.naive_bayes import MultinomialNB
from sklearn.linear_model import SGDClassifier
View .vimrc
" ===============VUNDLE============
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required