Skip to content

Instantly share code, notes, and snippets.

😁
Happy!

Olivier Mengué dolmen

😁
Happy!
View GitHub Profile
@dolmen
dolmen / git-go-aliases.sh
Created Jun 24, 2020
Git aliases for Go developement #golang #git
View git-go-aliases.sh
# git go-version: shows the Go-modules versionning formatting of a Git commit
git config --global alias.go-version '!f(){ 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-shorlog: shows the 10 commits in Go-modules versionning style
git config --global alias.go-shortlog '!f(){ 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
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 (
"fmt"
"log"
"net/url"
)
@dolmen
dolmen / README.md
Last active Mar 6, 2020
go-bin-upgrade
View README.md

go-bin-upgrade

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

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

Examples:

  • go-bin-upgrade -n godoc
  • (cd ~/go/bin ; go-bin-upgrade * )
@dolmen
dolmen / export-400px.pl
Last active Mar 1, 2019
Nautilus script to convert a photo to reduced width of 400px
View export-400px.pl
#!/usr/bin/env perl
# Install as a Nautilus script:
# perl export-400px.pl --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
dolmen / jsonroundtrip_test.go
Created Feb 19, 2019
Go: checkJSONRoundtrip
View jsonroundtrip_test.go
package main_test
import (
"encoding/json"
"reflect"
)
func checkJSONRoundtrip(t *testing.T, value interface{}, expectedJSON json.RawMessage) bool {
b, err := json.Marshal(value)
if err != nil {
@dolmen
dolmen / mini-pet.yaml
Last active Jan 24, 2019
Mini Swagger spec not validated by online.swagger.io/validator
View mini-pet.yaml
swagger: "2.0"
info:
version: "1.0.0"
title: "Swagger Petstore"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
@dolmen
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 (http://jsonlines.org)
# See https://stackoverflow.com/questions/42178636/how-to-use-jq-to-output-jsonl-one-independent-json-object-per-line
#
# Install:
# - save this file as "jsonl"
# - install jq (https://stedolan.github.io/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
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");
@dolmen
dolmen / darwin-signames.sh
Created Jan 17, 2018
List signal names on OS X
View darwin-signames.sh
# From /usr/include/signal.h
cc -E -dM /usr/include/signal.h | sed -nE 's/^#define (SIG[A-Z0-9]+ +[1-9][0-9]{0,1})$/\1/p' | sort -n -k 2
# Or
kill -l
You can’t perform that action at this time.