Skip to content

Instantly share code, notes, and snippets.

View prateek's full-sized avatar

Prateek Rungta prateek

View GitHub Profile
@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:
@prateek
prateek / golang_import_order_cleaner.py
Last active February 28, 2020 20:16
import ordering cleanup
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# golang_import_order_cleaner.py: cleans up import orders in golang files per the m3db convention
#
# Warning: This is very much alpha, take a backup of your files (e.g. commit to git) before running this.
#
# example usage:
# (1) Update all *.go files in the local directory (except vendor/), in-place
# $ golang_import_order_cleaner.py -o inplace
@prateek
prateek / get_file_list.go
Created June 24, 2017 17:43
getFileList #golang
// function to get list of files in a directory, recursively
getFileList := func(path string) map[string]struct{} {
fileList := make(map[string]struct{})
err = filepath.Walk(path, func(path string, f os.FileInfo, err error) error {
fileList[path] = struct{}{}
return nil
})
require.NoError(t, err)
return fileList
@prateek
prateek / ssh_client.go
Created January 30, 2017 23:52 — forked from iamralch/ssh_client.go
SSH client in GO
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"strings"
@prateek
prateek / README.md
Created November 9, 2015 22:16 — forked from laserson/README.md
Generate FlameGraph for Python code using plop

Create a FlameGraph to visualize where your code is spending its time.

Requires plop and FlameGraph.

// once upon a time, what did I see, but two RDDs
val tableA = sc.parallelize(List((1,2), (3,4), (5,6)))
val tableB = sc.parallelize(List((1,'A'), (3,'B'), (5,'C')))
// one of them small enough to fit into map
val mapTableB = tableB.collectAsMap
// which everyone could read
val broadcastB = sc.broadcast(mapTableB)
// and join for all eternity
val mapJoin = tableA.map({case (id, value) => (id, value, broadcastB.value.get(id))})
// q.e.d.
/**
* Created by prungta on 7/22/15.
*/
import org.apache.oozie.client.AuthOozieClient;
import org.apache.oozie.client.OozieClient;
import org.apache.oozie.client.OozieClientException;
import org.apache.oozie.client.WorkflowJob;
import javax.security.auth.Subject;
import javax.security.auth.login.AppConfigurationEntry;