Skip to content

Instantly share code, notes, and snippets.

View dotslash's full-sized avatar
🍊
🍒

Sai Teja Suram dotslash

🍊
🍒
View GitHub Profile
#!/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
// 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 ) {

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:

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
# 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
# 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
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
@dotslash
dotslash / find_parent.lua
Last active April 19, 2017 20:17
Redis lua graph traversal
--"9e4c3550b2961d085916ecdead255cde6b450f6b"
local ret = KEYS[1]
local limit = 100
while limit ~= 0 do
local pres = redis.pcall("GET", ret)
if pres == nil or type(pres) == "boolean" then return ret end
ret = pres
limit = limit - 1
end
return ret
default_date_format = "";
def now():
pass
def ts_to_dt():
pass
def dt_to_string(dt, format=default_date_format):
pass
@dotslash
dotslash / .vimrc
Last active September 13, 2016 17:26
" ===============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