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
// An example of how to configure the CliBuilder to read command line arguments in Groovy. | |
def cli = new CliBuilder( usage: 'groovy launcher' ) | |
// Option help | |
cli.h(longOpt: 'help', 'usage information') | |
// Option script | |
cli.s(argName:'script', longOpt:'script', required: true, | |
args: 1, 'Script filename') |
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
#!/bin/bash | |
while getopts "u:p:" opt; do | |
case $opt in | |
u) | |
echo "-u was triggered, Parameter: $OPTARG" | |
dbuser="$OPTARG" | |
;; | |
p) |
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
"title".center( 40, "-") |
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
new File("simple.tab").withReader{r-> | |
line = r.readLine(); | |
println "first line: $line" | |
r.splitEachLine("\t"){fields-> | |
println "fields on line: $fields" | |
} | |
} |
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
// ReflectionToStringBuilder wraps a class and outputs a string describing | |
// its attributes, more or less similar to var_dump in PHP | |
import org.apache.commons.lang.builder.ReflectionToStringBuilder | |
variable= new ComplexObject() | |
println new ReflectionToStringBuilder( variable).toString() |
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
// Groovy: Reading XML with Java DocumentBuilder parsing with Java XPath | |
import javax.xml.parsers.DocumentBuilder; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
import javax.xml.xpath.* | |
import org.w3c.dom.Document; | |
File f= new File( 'data.xml') | |
// Reading a Document Builder with Java style |
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
import groovy.xml.DOMBuilder | |
import javax.xml.parsers.* | |
// URL to read | |
def url= "http://stackoverflow.com/feeds/tag?tagnames=groovy&sort=newest" | |
// Parse the text | |
def doc | |
// Reading with XmlSlurper | |
doc = new XmlSlurper().parse( url) |
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
// Groovy | |
import static javax.xml.xpath.XPathConstants.* | |
import javax.xml.xpath.* | |
import groovy.xml.DOMBuilder | |
import groovy.xml.dom.DOMCategory | |
import org.w3c.dom.Document; | |
url= "http://stackoverflow.com/feeds/tag?tagnames=groovy&sort=newest" | |
xml= url.toURL().text |
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
mysql -e "show table status" | awk -F'\t' '\ | |
{\ | |
printf ("%-25s %15d\n", $1,$7); \ | |
s+=$7 \ | |
} \ | |
END{ print "resultado: ", s} \ | |
' |
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
notas de integracion | |
opciones: | |
public_key | |
private_key | |
bluevia_auth_cookie_name: la cookie que vamos a utilizar para la autenticacion. | |
bluevia_cookies: nombres de las cookies. | |
bluevia_login_url: url de la pagina de login de bluevia | |
bluevia_register_url: url de la pagina de registro de bluevia | |
bluevia_edit_profile_url: url de la pagina de perfil de un usuario de bluevia |
OlderNewer