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 emptyMap = [:] | |
| assert emptyMap.size() == 0 | |
| def notEmptyMap = ["person1":"john", "person2":"mus"] | |
| assert notEmptyMap.size() == 2 | |
| notEmptyMap.put "person3","test" //adding to existing one | |
| assert notEmptyMap.size() == 3 | |
| notEmptyMap["person4"] = "beth" | |
| assert notEmptyMap.size() == 4 |
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 myRange = 1..3 | |
| assert myRange.size() == 3 | |
| (1..3).each{it -> println it} //iterate range | |
| myRange.each{println it} | |
| assert myRange.from == 1 | |
| assert myRange.to == 3 | |
| assert myRange.contains(2) | |
| assert myRange.reverse() == [3,2,1] |
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 myCodeBlock1 = {println it; it} //closure with 1 parameter | |
| myCodeBlock1("test") | |
| assert myCodeBlock1("test") == "test" | |
| def myCodeBlock2 = {a,b -> a+b} | |
| assert myCodeBlock2(1,2) == 3 | |
| def list = ['a','b','c','d'] | |
| def newList = [] | |
| def clos = { it.toUpperCase() } //accept 1 argument |
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
| package main.groovy | |
| Calendar calendar = Calendar.instance | |
| calendar.set(2011, 2, 26) | |
| println calendar.time | |
| calendar.set(2012, 0, 1, 13,13,59) | |
| println calendar.time |
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
| package main.groovy.fp | |
| def isHeader = true | |
| def columns = [] | |
| def records1stFile = [] | |
| println "1st file ACCOUNT-after.csv" | |
| new File("ACCOUNT-after.csv").eachLine { line -> | |
| if (isHeader) { | |
| columns = line.split(",") |
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.io.FileType | |
| class FileInfo { | |
| def path | |
| def parentFolder | |
| def name | |
| def sizeBytes | |
| def sizeKb | |
| FileInfo(File file) { |
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.sql.Sql | |
| String db_server = "bun" | |
| String db_database = "bun" | |
| String db_port = "1433" | |
| String db_user = "bun" | |
| String db_password = "bun" | |
| String connectionUrl = "jdbc:sqlserver://" + db_server + ":" + db_port + | |
| ";database=" + db_database + | |
| ";user=" + db_user + |
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 shell = new GroovyShell() | |
| def file = new File("SqlGroovy.groovy") | |
| shell.evaluate(file) |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| <div class="container"> | |
| <div class="row clearfix"> | |
| <div class="col-md-12 column"> | |
| <div class="page-header"> | |
| <h1> | |
| Example page header <small>Subtext for header</small> | |
| </h1> | |
| </div> | |
| <ul class="nav nav-tabs"> | |
| <li class="active"> |