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 ant = new AntBuilder() /* rules */ | |
/* copy my roadtrip pictures and videos from CD and flatten it */ | |
ant.copy(todir: "/home/michal/Pictures/Norsko2004", flatten: true /* if false (default) it copies directory structure too */) { | |
fileset(dir:"/media/Norsko 2004/Norsko 2004", casesensitive: false) { | |
include(name: "**/*.jpg") /* pictures... */ | |
include(name: "**/*.mov") /* ...and videos */ | |
} | |
} |
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
List.metaClass.collectWithIndex = { yield -> | |
def collected = [] | |
delegate.eachWithIndex { listItem, index -> | |
collected << yield(listItem, index) | |
} | |
return collected | |
} | |
assert [1, 1, 1, 1, 1].collectWithIndex { it, index -> it + index } == [1, 2, 3, 4, 5] |
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-httpclient', module='commons-httpclient', version='3.1') | |
import org.apache.commons.httpclient.* | |
import org.apache.commons.httpclient.methods.GetMethod | |
import org.apache.commons.httpclient.methods.PostMethod | |
import org.apache.commons.httpclient.cookie.CookiePolicy | |
@Grab(group='org.jsoup', module='jsoup', version='1.6.2') | |
import org.jsoup.Jsoup | |
import groovy.json.* |
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.grape.Grape; | |
// to explain why I am not using @Grape annotation | |
// see http://stackoverflow.com/questions/1641116/groovy-with-grape-and-antbuilder-classloader-problem | |
Grape.grab( | |
group: 'com.google.javascript', | |
module: 'closure-compiler', | |
version: 'r1918', | |
classLoader:this.class.classLoader.rootLoader /* needed because of ant.taskdef classloader */) |
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
@Grapes( | |
@Grab(group='org.jsoup', module='jsoup', version='1.6.2') | |
) | |
import org.jsoup.* | |
import org.jsoup.nodes.* | |
/** | |
* during build time we combine all the js files to single file (to speed up page loading) | |
* this script is part of the this script and its purpose is to collect all the external js files refered in | |
* MasterPage.html (template for the page) to feed up function which do the real combining and minifying to |
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
// ------------------- methods and extensions definitions ----------------------------- | |
List.metaClass.grepWithIndex = { yield -> | |
def greppedCollection = [] | |
delegate.eachWithIndex { value, index -> | |
if (yield(value, index)) { | |
greppedCollection << value | |
} |
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(".").eachDirRecurse { dir -> | |
/* if you wonder why not to write ~/\\/ directly see | |
http://groovy.codehaus.org/Strings+and+GString#StringsandGString-SlashyStringliterals or | |
http://jira.codehaus.org/browse/GROOVY-2451 */ | |
def bs = "\\\\" | |
def fs = "/" | |
def pattern = ~/$bs|$fs/ |
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
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); | |
//Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, "/page-name"); | |
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request); | |
httpRequest = PortalUtil.getOriginalServletRequest(httpRequest); | |
//Retrieve layout id of another portlet. Layout is synonym for Page. Will it crash if there are multiple pages??? TODO test it | |
String portletId = "portletId"; // portlet id is string and you will find this in liferay database scheme or maybe it have some logic, but i don't know what and if it's compatible between liferay versions | |
long plid = PortalUtil.getPlidFromPortletId(themeDisplay.getScopeGroupId(), portletId); | |
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
/** | |
* Using this runner every test report (gui, cli, html) will print names of tests not as test method | |
* names eg. "shouldBeLikeThatAndThat" but with spaces like "should be like that and that" for better | |
* readability. <br/><br/> | |
* | |
* <b>Usage</b>:<br/> | |
* | |
* <pre> | |
* <b>{@literal @}RunWith(ReadableTestNamesJUnitRunner.class)</b> | |
* public class DateParserTest { |
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 c = new groovy.ui.Console(getClass().getClassLoader(), new Binding()) | |
c.setVariable("ctx",this) | |
c.run() | |
def done = false | |
c.frame.windowClosing = {done = true} | |
c.frame.windowClosed = {done = true} | |
while (!done) { | |
sleep(1000) |
OlderNewer