Skip to content

Instantly share code, notes, and snippets.


Vasilis zerogvt

  • Greece
View GitHub Profile
zerogvt / gist:081685d53465f2266e419310fcca304a
Last active Feb 2, 2021 — forked from rb2k/gist:8372402
A jenkins script to clean up workspaces on slaves
View gist:081685d53465f2266e419310fcca304a
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
View SRE sources
* [Kubernetes production best practices](
* [Coursera SRE course](
zerogvt /
Created Mar 23, 2018 — forked from Evildethow/
Jenkins: Create SSH node, using bash and curl
#!/usr/bin/env bash
set -o nounset -o errexit -o pipefail
usage() {
cat <<EOM
$(basename $0) [OPTIONS]
$(basename $0) [ -j | --jenkins-url | -n | --node-name | -s | -d | --desc | --slave-home | -e | --executors | -sh | --ssh-host | -sp | --ssh-port
| -c | --cred-id | -l | --labels | -u | --user-id | -p | --password | -h | --help ]
View gist:9a8dcef366e53012fd91244f4e919353
git squash:
> git rebase -i HEAD~5
> git push --force origin yourbranchname
View errors.go
Exercise: Errors
Copy your Sqrt function from the earlier exercise and modify it to return an error value.
Sqrt should return a non-nil error value when given a negative number, as it doesn't support complex numbers.
Create a new type
type ErrNegativeSqrt float64
and make it an error by giving it a
View stringers_interface.go
Exercise: Stringers
Make the IPAddr type implement fmt.Stringer to print the address as a dotted quad.
For instance, IPAddr{1, 2, 3, 4} should print as "".
View fibonacci_closure.go
Exercise: Fibonacci closure
Let's have some fun with functions.
Implement a fibonacci function that returns a function (a closure) that returns successive fibonacci numbers (0, 1, 1, 2, 3, 5, ...).
View maps.go
Exercise: Maps
Implement WordCount. It should return a map of the counts of each “word” in the string s. The wc.Test function runs a test suite against the provided function and prints success or failure.
You might find strings.Fields helpful.
package main
View slices.go
Exercise: Slices
Implement Pic. It should return a slice of length dy, each element of which is a slice of dx 8-bit unsigned integers. When you run the program, it will display your picture, interpreting the integers as grayscale (well, bluescale) values.
The choice of image is up to you. Interesting functions include (x+y)/2, x*y, and x^y.
(You need to use a loop to allocate each []uint8 inside the [][]uint8.)
(Use uint8(intValue) to convert between types.)
zerogvt /
Created Jul 20, 2018 — forked from scarytom/
Script to safely de-register jenkins nodes usage: $ my-node-1 my-node-2 my-node-3
set -e
set -u
node_online() {
curl --silent "$CI_MASTER_URL/computer/$1/api/json" | grep --silent '"temporarilyOffline":false'