Skip to content

Instantly share code, notes, and snippets.

@sebasalvatoreml
sebasalvatoreml / goestup.sh
Created May 24, 2019 14:35 — forked from lggomez/gosetup.sh
Easy setup to switch between go versions (1.6+) with gvm - go version manager
#!/usr/bin/env bash
echo $BASH_VERSION
# GVM readme: https://github.com/e-nikolov/gvm/blob/master/README.md
bash < <(curl -s -S -L https://raw.githubusercontent.com/e-nikolov/gvm/master/binscripts/gvm-installer)
source $HOME/.gvm/scripts/gvm
gvm install go1.6 --prefer-binary
gvm install go1.6.2 --prefer-binary
@sebasalvatoreml
sebasalvatoreml / go_cpu_memory_profiling_benchmarks.sh
Created January 31, 2019 15:39 — forked from arsham/go_cpu_memory_profiling_benchmarks.sh
Go cpu and memory profiling benchmarks. #golang #benchmark
FILENAME=$(basename $(pwd))
go test -run=. -bench=. -cpuprofile=cpu.out -benchmem -memprofile=mem.out -trace trace.out
go tool pprof -pdf $FILENAME.test cpu.out > cpu.pdf && open cpu.pdf
go tool pprof -pdf --alloc_space $FILENAME.test mem.out > alloc_space.pdf && open alloc_space.pdf
go tool pprof -pdf --alloc_objects $FILENAME.test mem.out > alloc_objects.pdf && open alloc_objects.pdf
go tool pprof -pdf --inuse_space $FILENAME.test mem.out > inuse_space.pdf && open inuse_space.pdf
go tool pprof -pdf --inuse_objects $FILENAME.test mem.out > inuse_objects.pdf && open inuse_objects.pdf
go tool trace trace.out
go-torch $FILENAME.test cpu.out -f ${FILENAME}_cpu.svg && open ${FILENAME}_cpu.svg
@sebasalvatoreml
sebasalvatoreml / two-part-mold-generator.scad
Created December 3, 2017 04:12
Two-part mold generating script for OpenSCAD
/*************************************************
Parametric two-part mold generator
Author: Jason Webb
Website: http://cs.unk.edu/~webb
Last update: 10/1/2012
A parametric two-part mold generator that constructs two-
part molds with registration marks based on STL files.
USAGE:
@sebasalvatoreml
sebasalvatoreml / after_res_hooks.js
Created August 1, 2017 19:23 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups