Skip to content

Instantly share code, notes, and snippets.

View mvitaly's full-sized avatar

Vitaly Polonetsky mvitaly

View GitHub Profile
#!/bin/bash
set -euo pipefail
# Define color codes
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
RESET="\033[0m"
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: gopl.io/ch1/ex-ext
BenchmarkEmptySelect-4 300000000 4.69 ns/op
BenchmarkEmptyLen-4 2000000000 0.58 ns/op
BenchmarkEmptyLenThenSelect-4 2000000000 0.59 ns/op
BenchmarkFullSelect-4 30000000 39.0 ns/op
BenchmarkFullLen-4 200000000 11.2 ns/op
BenchmarkFullLenThenSelect-4 200000000 10.2 ns/op
@mvitaly
mvitaly / spark_print_launch_command.sh
Created September 25, 2017 23:18
Print classpath of spark-submit
SPARK_PRINT_LAUNCH_COMMAND=true spark-submit 2>&1 | head -1
@mvitaly
mvitaly / tabs_to_rows.sh
Last active June 6, 2017 07:15
awk pivot tab separated columns into indexed rows (starts with 0)
awk 'BEGIN{FS="\t"; offset=-1}{print "********************\nRecord number", NR, "\n********************"; for(i=1;i<=NF;i++){print i+offset, $i}; print "\n"}'
@mvitaly
mvitaly / Fixed-length-fields.txt.groovy
Last active January 24, 2022 13:22
DataGrip extractor for txt file with fixed length columns
SEPARATOR = "|"
SPACE = " "
CORNER = "+"
LINE = "-"
NEWLINE = System.getProperty("line.separator")
def outRecord(columnLengths, row, separator=SEPARATOR, padding=SPACE) {
OUT.append(separator)
[columnLengths, row].transpose().each { size, value ->
OUT.append(padding + value.padRight(size, padding) + padding + separator)
@mvitaly
mvitaly / Dockerfile
Created November 10, 2015 18:27
testim-cli Dockerfile
FROM node
RUN npm i -g @testim/testim-cli
ENTRYPOINT ["testim"]
@mvitaly
mvitaly / gist:5313099
Last active December 15, 2015 19:39
Get location of a .class file in java
clazz.getProtectionDomain().getCodeSource().getLocation();