Skip to content

Instantly share code, notes, and snippets.

View vearutop's full-sized avatar
🐴
https://media.giphy.com/media/MEGIFlCoVhs8igonZc/giphy.gif

Viacheslav Poturaev vearutop

🐴
https://media.giphy.com/media/MEGIFlCoVhs8igonZc/giphy.gif
View GitHub Profile
// This is a quick and dirty conversion of https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/binarytrees-go-2.html
// to use slice as a container of tree.
// This version time:
// real 0m3.946s
// user 0m24.126s
// sys 0m1.671s
// Original:
// real 0m6.719s
// user 1m8.281s
// sys 0m0.862s
@vearutop
vearutop / go.mod
Created August 12, 2022 07:45
OpenTelemetry zPages instrumentation example for Go (golang)
module zpages-demo
go 1.17
require (
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0
go.opentelemetry.io/contrib/zpages v0.34.0
go.opentelemetry.io/otel v1.9.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.9.0
go.opentelemetry.io/otel/sdk v1.9.0
@vearutop
vearutop / httpclient.go
Created July 1, 2020 10:13
Go OAuth2 password-based http transport middleware
// Package oauth2 implements password-based authentication middleware.
package oauth2
import (
"context"
"fmt"
"net/http"
"time"
"golang.org/x/oauth2"
@vearutop
vearutop / 📊 Weekly development breakdown
Last active November 13, 2022 00:01
📊 Weekly development breakdown
Go 9 hrs 51 mins ███████████████▋░░░░░ 74.9%
JSON 1 hr 4 mins █▋░░░░░░░░░░░░░░░░░░░ 8.2%
PHP 47 mins █▎░░░░░░░░░░░░░░░░░░░ 6.0%
YAML 23 mins ▋░░░░░░░░░░░░░░░░░░░░ 3.0%
Markdown 21 mins ▌░░░░░░░░░░░░░░░░░░░░ 2.8%
@vearutop
vearutop / http_bench.go
Created July 11, 2019 16:45
pocket load tester
package main
import (
"github.com/VividCortex/gohistogram"
"net/http"
"os"
"time"
)
func main() {
@vearutop
vearutop / ref_test.go
Created October 24, 2018 14:16
early vs late referencing benchmark
package ref_test
import (
"testing"
)
type s struct {
ss string
}
This file has been truncated, but you can view the full file.
17:38:41 /usr/local/Cellar/go/1.11/libexec/src golint ./...
archive/tar/common.go:30:2: exported var ErrHeader should have comment or be unexported
archive/tar/common.go:99:2: const paxUid should be paxUID
archive/tar/common.go:151:2: struct field Uid should be UID
archive/tar/common.go:607:2: don't use underscores in Go names; const c_ISUID should be cISUID
archive/tar/common.go:608:2: don't use underscores in Go names; const c_ISGID should be cISGID
archive/tar/common.go:609:2: don't use underscores in Go names; const c_ISVTX should be cISVTX
archive/tar/common.go:613:2: don't use underscores in Go names; const c_ISDIR should be cISDIR
archive/tar/common.go:614:2: don't use underscores in Go names; const c_ISFIFO should be cISFIFO
archive/tar/common.go:615:2: don't use underscores in Go names; const c_ISREG should be cISREG
#!/usr/bin/env bash
default_description="something special"
while [ 1 ]
do
missing_comments=$(golint `go list ./... | grep -v /vendor/` | grep 'comment' | grep 'exported')
echo "$missing_comments"
test -z "${missing_comments// }" && exit
@vearutop
vearutop / schema.json
Last active January 1, 2024 10:53
Sample schema and error responses for JSON Schema (proposal)
{
"type": ["object", "integer"],
"properties": {
"abcde": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9_]+$": {
"oneOf": [
@vearutop
vearutop / cr2_to_jpg.sh
Last active June 5, 2018 08:48
Quick extract CR2 thumbnail to JPG keeping original EXIF with exiv2
#!/bin/bash
exiv2 ex *.CR2
exiv2 -ep3 -l ./ *.CR2
for f in *.exv; do echo $f; mv "${f%.exv}.exv" "${f%.exv}-preview3.exv"; done
exiv2 in *.jpg