This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ms = java.lang.management.ManagementFactory.getRuntimeMXBean().getUptime() | |
def s = ms / 1000 | |
def min = s / 60 | |
def hours = min / 60 | |
println "Uptime: ${s} seconds/ ${min} minutes/ ${hours} hours." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sort by multiple keys | |
Collection.metaClass.sort = { Closure... closures -> | |
delegate.sort(false) { a, b -> | |
closures.findResult { c -> c(a) <=> c(b) ?: null } | |
} | |
} | |
List threads = Thread.getThreads() | |
println "${threads.size()}: Threads:" | |
threads.sort({it.threadGroup.name}, {it.name}).each { println "${it.threadGroup.name}: ${it.name.take(80)}" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isAuthenticated(User u) { | |
try { | |
return u.impersonate().isAuthenticated() | |
} | |
// Users pulled from SCM history e.a. are not GUI users | |
catch (org.acegisecurity.userdetails.UsernameNotFoundException xc) { | |
return false | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fetch all deployed artifacts of a Maven build | |
package main | |
import ( | |
"bufio" | |
"flag" | |
"fmt" | |
"io" | |
"log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show average duration of all builds for a given Jenkins job | |
// return codes: | |
// 1: bad usage | |
package main | |
import ( | |
"encoding/json" | |
"flag" | |
"fmt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate buildozer commands from POM for wsimport tasks | |
// 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"os" | |
"path" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"os" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"strconv" | |
) | |
func Bmi(m, l float64) int { | |
return int(m/(l*l) + 0.5) |
OlderNewer