Skip to content

Instantly share code, notes, and snippets.

View jhinrichsen's full-sized avatar

Jochen Hinrichsen jhinrichsen

View GitHub Profile
fn name(line: &str) -> &str {
let mut f = line.split("|");
f.next();
f.next();
f.next();
f.next();
f.next();
f.next();
f.next();
let s = f.next().unwrap();
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 12:28
Linux: plot threads and processes usage over time (see related Gist 'threads')
package main
import (
"bufio"
"flag"
"image/color"
"io"
"log"
"os"
"strconv"
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 12:26
Linux: report number of processes and threads
// This package is Linux only
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"strconv"
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 12:24
Bazel: transform Maven wsimport tasks from POM into buildozer commands
// Needs to be executed in the root of the Maven project because files are
// looked up relative to module directory
package main
import (
"encoding/xml"
"flag"
"fmt"
"log"
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 12:12
Jenkins: commandline utility that downloads artifacts a Maven build has deployed to a Maven repository. Useful because Nexus does not offer a build brace.
package main
import (
"bufio"
"flag"
"fmt"
"io"
"log"
"net/http"
"net/url"
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 11:59
Minimal email commandline client
package main
import (
"bytes"
"fmt"
"log"
"net/smtp"
"os"
"os/user"
)
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 11:54
Jenkins: Show average duration of all builds for a given freestyle job
// Show average duration of all builds for a given Jenkins freestyle job
// return codes:
// 1: bad usage
package main
import (
"encoding/json"
"flag"
"fmt"
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 11:49
GCD (greatest common denominator) commandline utility, implementation based on Euclid
package main
import (
"os"
"strconv"
)
func euclid(i, j int) int {
for i != j {
if i > j {
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 11:48
BMI commandline calculator
package main
import (
"fmt"
"os"
"strconv"
)
func Bmi(m, l float64) int {
return int(m/(l*l) + 0.5)
@jhinrichsen
jhinrichsen / main.go
Created April 12, 2018 11:45
Schedule Sonatype Nexus tasks that rebuild npm metadata via REST
// Schedule Nexus tasks that rebuild npm metadata via REST
// Logging on stderr, run response as JSON on stdout
package main
import (
"encoding/json"
"flag"
"fmt"
"io"