Skip to content

Instantly share code, notes, and snippets.

View nacx's full-sized avatar

Ignasi Barrera nacx

View GitHub Profile
@chirauki
chirauki / oauth.rb
Last active July 11, 2017 10:27
OAuth app creation and authorisation
require 'abiquo-api'
require 'json'
require 'oauth'
require 'uri'
require 'faraday'
def client(api_url, creds={})
connection_params = {
:abiquo_api_url => api_url,
:connection_options => {
@arsham
arsham / go_cpu_memory_profiling_benchmarks.sh
Last active June 26, 2024 13:32
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt
@hvoecking
hvoecking / translate.go
Last active March 28, 2024 13:52
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//