View updateRemotes.sh
#!/bin/bash
if [[ $# -ne 3 ]]; then
echo "Finds and replaces patterns in remote URLs for all git repos under the PWD"
echo " Usage:"
echo " $0 remote_name old_pattern new_pattern"
echo " Example:"
echo " $0 origin myoldorg myneworg"
echo " Would find git repos under the PWD with 'myoldorg' in their URLs for"
echo " their origin remotes, and replace 'myoldorg' with 'myneworg' in each URL"
View GStringJsonSerializer.groovy
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.databind.ser.std.StdSerializer
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
@Component
View skyrockets.groovy
#!/usr/bin/env groovy
def rocketParts = [
' /\\',
'/ \\',
' ||',
' ||',
' ||',
' ||',
' ||',
View gist:6382095
/**
* Put in an init script, e.g.: $HOME/.gradle/init.d/printProperties.gradle
* Then call from a gradle project, e.g.: gradle printVersion
*/
allprojects { Project project ->
tasks.addRule( "print<PropertyName> - print the value of a property in this and any subprojects" ) { String taskName ->
if ( taskName.startsWith( "print" ) ) {
def propName = (taskName - 'print')
propName = propName[0].toLowerCase() + propName[1..-1]
task( taskName ) << { println "${propName}: ${project.properties[propName]}" }
View md5.groovy
def generateMD5( File file ) {
def digest = java.security.MessageDigest.getInstance("MD5")
file.eachByte( 4096 ) { buffer, length ->
digest.update( buffer, 0, length )
}
new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
}
View roundToMultiple.groovy
import static java.math.RoundingMode.*
import java.math.RoundingMode
/*
To round to a multiple:
1) normalize the input by dividing it by the multiple value.
2) round it to the nearest integer using the desired rounding technique
3) multiply that integer by the multiple value to produce the result
NOTES: