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 org.apache.commons.io.FilenameUtils; | |
String fileNameWithOutExt = FilenameUtils.getBaseName(fileNameWithExt); | |
// or | |
String fileNameWithOutExt = FilenameUtils.removeExtension(fileNameWithExt); |
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
// Tutorial on File: http://tutorials.jenkov.com/java-io/file.html | |
def getFileWithPath = { rutaCarpeta, nom -> | |
def homePath = System.getProperty('user.home').replace('\\','/') | |
println "home Path: " + homePath | |
def directory = new File(homePath.concat("/${rutaCarpeta}/")) | |
if(!directory.exists()){ | |
boolean dirCreated = directory.mkdirs() | |
assert dirCreated | |
} |
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
// http://stackoverflow.com/questions/8098564/is-it-possible-to-specify-java-system-properties-when-running-groovy-from-comman | |
/* | |
System properties are set on the java command line using the | |
java -Dpropertyname=value | |
syntax. | |
They can also be added at runtime using | |
System.setProperty(name, value) | |
or via the various | |
System.getProperties().load() | |
methods. |
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 = 'net.sf.opencsv', module = 'opencsv', version = '2.3') | |
import au.com.bytecode.opencsv.CSVReader | |
import au.com.bytecode.opencsv.CSVParser | |
import au.com.bytecode.opencsv.CSVWriter | |
def TEST_FILE_NAME = 'test.csv' | |
def TEST_OUTPUT_FILE_NAME = 'testOut.csv' | |
List<String[]> rows = new CSVReader(new FileReader(new File(TEST_FILE_NAME)), CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_ESCAPE_CHARACTER, CSVParser.DEFAULT_QUOTE_CHARACTER, 1).readAll() | |
// to filter the resultSet: |
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
// Java System properties | |
// ======================= | |
// http://docs.oracle.com/javase/tutorial/essential/environment/properties.html | |
// http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html | |
/* | |
Key Meaning | |
================ | |
"file.separator" Character that separates components of a file path. This is "/" on UNIX and "\" on Windows. | |
"java.class.path" Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property. | |
"java.home" Installation directory for Java Runtime Environment (JRE) |
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
// OS Environment Variables | |
// ======================= | |
// http://docs.oracle.com/javase/tutorial/essential/environment/env.html | |
/* | |
Windows provides the user name in an environment variable called USERNAME, | |
while UNIX implementations might provide the user name in USER, LOGNAME, or both. | |
To maximize portability, if the env var you need is available as java system property, always use getProperty(). | |
For example, if the operating system provides a user name, it will always be available in the system property user.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
// http://stackoverflow.com/a/1169196/2906290 | |
/* | |
when calling | |
c:\scripts\MyScript.groovy from c:\users\Scott\ | |
I wanted to know c:\scripts\. | |
*/ | |
def scriptFile = getClass().protectionDomain.codeSource.location.path | |
def scriptDir = new File(scriptFile).parent |
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
-- MySQL | |
http://kedar.nitty-witty.com/blog/search-through-all-databases-tables-columns-in-mysql | |
#kedar.nitty-witty.com | |
## Table for storing resultant output | |
DROP TABLE IF EXISTS `temp_details`; | |
CREATE TABLE `temp_details` ( | |
`t_schema` varchar(45) NOT NULL, |
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
ASUS laptop (for Windows 8 at least) | |
=========== | |
1st version for entering the BIOS: | |
1. Shut down your Asus laptop. Click "Start" then click the "Shut down" button. | |
2. Power your computer back on. | |
3. Wait for the ASUS splash screen. | |
4. Press the "ALT" and "F2" keys on your keyboard as soon as you see the ASUS splash screen. Your computer will enter the BIOS. |
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
// http://omarello.com/2010/09/groovy-to-the-rescue/ | |
static void moveDocumentationToMe(pathToFolder, groupId) { | |
// move everything to my desktop, of course i could have passed as an argument, | |
// but i don't really care for now | |
FileSystemView filesys = FileSystemView.getFileSystemView() | |
def destinationDir = filesys.getHomeDirectory().getCanonicalPath() | |
//paranoia <img src="http://omarello.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"> | |
if (!destinationDir.endsWith(File.separator)) |
OlderNewer