Skip to content

Instantly share code, notes, and snippets.


Olivier Mengué dolmen

View GitHub Profile
dolmen /
Created Jan 28, 2021
Get Go module+version string from a commit from GitHub



github-go-version <owner>/<repo> <commit>
dolmen /
Last active Oct 19, 2020
Git aliases for Go developement #golang #git
# git go-version: shows the Go-modules versionning formatting of a Git commit
git config --global alias.go-version '!f(){ cd -- "${GIT_PREFIX:-.}"; TZ=UTC git log -1 '\''--date=format-local:%Y%m%d%H%M%S'\'' --abbrev=12 '\''--pretty=tformat:v0.0.0-%cd-%h'\'' "$@" ;};f'
# git go-get: shows the command to run on another Go project to upgrade this module
git config --global alias.go-get '!f(){ cd -- "${GIT_PREFIX:-.}"; TZ=UTC git log -1 '\''--date=format-local:%Y%m%d%H%M%S'\'' --abbrev=12 '\''--pretty=tformat:go get '\''"$(go list -m)"'\''@v0.0.0-%cd-%h'\'' "$@" ;};f'
# git go-shorlog: shows the 10 commits in Go-modules versionning style
git config --global alias.go-shortlog '!f(){ cd -- "${GIT_PREFIX:-.}"; TZ=UTC git log -10 '\''--date=format-local:%Y%m%d%H%M%S'\'' --abbrev=12 '\''--pretty=tformat:v0.0.0-%cd-%h %s'\'' "$@" ;};f'
dolmen / fix-url.go
Created Jun 12, 2020
Fix malformed URL query
View fix-url.go
// Fix (some kinds of) malformed URLs
package main
import (
dolmen /
Last active Jul 13, 2022


Rebuild the binaries you have built in Go module mode installed in $GOPATH/bin.

Usage: go-bin-upgrade [-n] [-v] bin1 [bin2]...


  • go-bin-upgrade -n godoc
  • (cd ~/go/bin ; go-bin-upgrade * )
dolmen /
Last active Mar 1, 2019
Nautilus script to convert a photo to reduced width of 400px
#!/usr/bin/env perl
# Install as a Nautilus script:
# perl --install
# Install dependencies:
# sudo aptitude install libimage-exiftool-perl libpath-tiny-perl imagemagick zenity
# Author: Olivier Mengué
# Created: Sun Feb 28 20:30:55 2016 +0100
dolmen / jsonroundtrip_test.go
Created Feb 19, 2019
Go: checkJSONRoundtrip
View jsonroundtrip_test.go
package main_test
import (
func checkJSONRoundtrip(t *testing.T, value interface{}, expectedJSON json.RawMessage) bool {
b, err := json.Marshal(value)
if err != nil {
dolmen / mini-pet.yaml
Last active Jan 24, 2019
Mini Swagger spec not validated by
View mini-pet.yaml
swagger: "2.0"
version: "1.0.0"
title: "Swagger Petstore"
name: "Apache 2.0"
url: ""
host: ""
basePath: "/v2"
dolmen / jsonl
Created Jul 3, 2018
Transform a JSON input containing a single array into the "JSON Lines" format
View jsonl
#!/usr/local/bin/jq -cf
# This script transforms a JSON input containing a single array into the "JSON Lines" format (
# See
# Install:
# - save this file as "jsonl"
# - install jq (
# - chmod u+rx jsonl
View structintmap.go
package structintmap
import "reflect"
func StructIntMap(value interface{}) map[string]int {
m := make(map[string]int)
structIntMap(reflect.ValueOf(value), m, "")
return m
dolmen / hello.c
Last active Feb 6, 2018
C source runnable from shell
View hello.c
///usr/bin/cc -o "${0%.c}" "$0" && exec "./${0%.c}"
// Author: Olivier Mengué
// Install: chmod u+x hello.c
#include <stdio.h>
int main()
puts("hello world");