This file contains hidden or 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 datetime | |
| diccionario = {'MONDAY':'Lunes','TUESDAY':'Martes','WEDNESDAY':'Miercoles','THURSDAY':'Jueves', 'FRIDAY':'Viernes','SATURNDAY':'Sabado','SUNDAY':'Domingo'} | |
| fecha = datetime.date(2011, 4, 6) | |
| diaSemana = diccionario[fecha.strftime('%A').upper()] |
This file contains hidden or 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 file = new File("/tmp/image.jpg") | |
| println ">> Nombre del fichero: ${file.name}" | |
| println "HACEMOS EL RENAME" | |
| def string = "/tmp/${file.name[0..-5]}_thumb.jpg" | |
| def newFile = new File(string) | |
| file.renameTo(newFile) | |
| println ">> Nombre del fichero: ${newFile.name}" |
This file contains hidden or 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
| 'ping -c 5 google.es'.execute().waitForProcessOutput(System.out, System.err) |
This file contains hidden or 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
| @Grab(group='commons-net', module='commons-net', version='2.0') | |
| import org.apache.commons.net.ftp.FTPClient | |
| import org.apache.commons.net.ftp.FTPFile | |
| new FTPClient().with { | |
| connect '61.135.158.199' | |
| println replyString | |
| enterLocalPassiveMode() | |
| login('anonymous', '') |
This file contains hidden or 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
| buildscript { | |
| repositories { | |
| maven { url "http://repo.grails.org/grails/repo" } | |
| } | |
| dependencies { | |
| classpath "org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT" | |
| } | |
| } | |
| repositories { |
This file contains hidden or 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(destinationPath) << new File(originPath).bytes |
This file contains hidden or 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
| Object asType(Class type) { | |
| switch (type) { | |
| case String: | |
| return this.toString() | |
| break | |
| case Integer: | |
| return this.toInteger() | |
| break |
This file contains hidden or 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
| Boolean not(Boolean val) { | |
| return !val | |
| } | |
| def value = 7 | |
| def valueList = [1, 2, 3] | |
| // not value in valueList |
This file contains hidden or 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
| URL penny = new URL('http://tankian99.files.wordpress.com/2011/08/kaley_cuoco_by_m4rios.jpg') | |
| new File('/tmp/penny.jpg') << penny.openStream() | |
| URL localPenny = new URL('file:///tmp/penny.jpg') | |
| new File('/tmp/penny2.jpg') << localPenny.openStream() |
This file contains hidden or 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.json.JsonBuilder | |
| java.util.LinkedHashMap.metaClass.pprint = { -> new JsonBuilder(delegate).toPrettyString() } | |
| java.util.ArrayList.metaClass.pprint = { -> new JsonBuilder(delegate).toPrettyString() } |
OlderNewer