Skip to content

Instantly share code, notes, and snippets.

View mandarjog's full-sized avatar

Mandar U Jog mandarjog

  • ex-google
  • Mountain View, CA
View GitHub Profile
@mandarjog
mandarjog / ast.py
Created December 21, 2016 04:02
ast example
def find_imports(file_list, verbose=False, init_file=None):
not_found = defaultdict(list)
modules = set()
pw_packages = defaultdict(list)
pw_modules = defaultdict(list)
init_modules = defaultdict(dict)
used_names = defaultdict(list)
for _fl in file_list:
fl = os.path.abspath(_fl)
pw_packages[os.path.dirname(fl)].append(os.path.basename(fl))
@mandarjog
mandarjog / bazel_to_go.py
Last active January 4, 2017 22:29
Make bazel workspace friendly to golang tools
#!/usr/bin/env python
#
# Makes a bazel workspace play nicely with standard go tools
# go build
# go test
# should work after this
#
# It does so by making symlinks from WORKSPACE/vendor to the bazel
# sandbox dirs
@mandarjog
mandarjog / purchases-rc.yaml
Created January 31, 2017 18:17
Replication controller with downward API
apiVersion: v1
kind: ReplicationController
metadata:
name: purchases
spec:
replicas: 1
selector:
app: purchases
template:
metadata:
@mandarjog
mandarjog / slice.go
Created March 15, 2017 18:28
slice allocation
func (f *Function) Eval(attrs attribute.Bag, fMap map[string]Func) (interface{}, error) {
fn := fMap[f.Name]
if fn == nil {
return nil, fmt.Errorf("unknown function: %s", f.Name)
}
if ufn, ok := fn.(UnmanagedFunc); ok {
return ufn.CallUnmanaged(attrs, f.Args, fMap)
}
@mandarjog
mandarjog / mixer_api.yaml
Last active March 23, 2017 23:13
Mixer Config API
swagger: '2.0'
# visit http://editor.swagger.io/ and import this document URL to view.
info:
version: "0.1.0"
title: Istio Mixer Config API
description: Mixer Configuration API allows users to configure all facets of a mixer deployment.
Mixer configuration is organized in `scope -> subject -> rule` hierarchy.
__scope__ and __subject__ are analogous to `manager > employee` relationship. A __manager__(`scope`) may configure any direct or indirect __reports__ (`subject`) including self.
mjog@devinstance:~/mixer_leak_dumps$ go tool pprof --base 1_hd_initial.txt mixs.0.2.9 hd_resting.txt
Entering interactive mode (type "help" for commands)
(pprof) top
266.20MB of 267.18MB total (99.63%)
Dropped 616 nodes (cum <= 1.34MB)
Showing top 10 nodes out of 16 (cum >= 2.01MB)
flat flat% sum% cum cum%
254.10MB 95.10% 95.10% 254.10MB 95.10% runtime.malg
11.09MB 4.15% 99.26% 11.09MB 4.15% runtime.allgadd
1.01MB 0.38% 99.63% 2.01MB 0.75% istio.io/api/mixer/v1.(*ReportRequest).Unmarshal
@mandarjog
mandarjog / reduceRepo.sh
Created October 30, 2017 20:25
Reduce Git Repo Size -- destructive
#!/bin/bash
BFG_URL=http://repo1.maven.org/maven2/com/madgag/bfg/1.12.16/bfg-1.12.16.jar
DIR=$(mktemp -d)
echo $DIR
cd $DIR
curl $BFG_URL -o bfg.jar
git clone --mirror git@github.com:istio/istio.git
@mandarjog
mandarjog / istio_Gopkg.json
Created November 8, 2017 18:52
Gopkg.json
[
{
"name": "cloud.google.com/go",
"revision": "2d3a6656c17a60b0815b7e06ab0be04eacb6e613"
},
{
"name": "github.com/Azure/go-autorest",
"revision": "1afda22949fbf449a85ac9109c3ca96d08684220"
},
{
@mandarjog
mandarjog / rename_imports.py
Last active January 17, 2018 03:24
convert python "*" imports to named imports
#!/usr/bin/env python
import ast
import sys
import os
from collections import defaultdict
import importlib
import inspect
#!/usr/bin/env python
import requests
import json
import subprocess
import collections
import argparse
import yaml
import sys