GR8Conf EU Registration ends soon!

2016-05-16 Thread Søren Berg Glasius (GR8Conf EU)
Hi,

Registrations for GR8Conf EU ends one week from now, Monday May 23rd. 

You do not want to miss this year's event! Here you can learn all about Groovy, 
Grails and Gradle from the project founders and core developers!  

From the Groovy core team you can meet: Guillaume Laforge, Cedric Champeau and 
Jochen Theodorou. From the Grails core team you can meet: Jeff Brown and Graeme 
Rocher. Cedric also represents Gradle. 

The opening keynote is delivered by Ken Kousen.  

One University day with workshops, Two conference days, Three conference 
tracks, 24 speakers from all over the world. Not to mention our home brewed 
beer for Meet & Greet.

For more information, please visit gr8conf.eu now!
 

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

Re: re-using a comparison closure

2016-05-16 Thread Søren Berg Glasius (GR8Conf EU)
Hi 

You can define it in a class as a static closure


class Sorters {
     static compareVersions =  { a,b ->
         return getVersion(a).toInteger() <=> getVersion(b).toInteger()
     }
}

and use it like:

list.sort(Sorters.compareVersions)

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Guy Matz 
Reply: users@groovy.apache.org 
Date: May 16, 2016 at 17:42:21
To: users@groovy.apache.org 
Subject:  Re: re-using a comparison closure  

Thanks!  Now, I have a number of methods that need access to that closure . . . 
 Can I make the closure global?  Is there a better way?

Thanks again,
Guy

On Mon, May 16, 2016 at 11:30 AM, Søren Berg Glasius (GR8Conf EU) 
 wrote:
Hi Guy

Just assign the variable 

def comapreVersions = { a,b ->
return getVersion(a).toInteger() <=> getVersion(b).toInteger()
}

and then use it in your sort:


list.sort(compareVersions)



Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Guy Matz 
Reply: users@groovy.apache.org 
Date: May 16, 2016 at 17:28:34
To: users@groovy.apache.org 
Subject:  re-using a comparison closure

Hi!
I have to sort a list of strings based on a number within the string . . .  I 
am able to sort using something like:
list.sort( { a,b -> getVersion(a) <=> getVersion(b)})

I need to use this in a bunch of places in my code and was hoping to replace it 
with a method, like:
list.sort( compareVersions)

with compareVersions:
def compareVersions(a, b) {
  return getVersion(a).toInteger() <=> getVersion(b).toInteger()
}

putting the method (compoareVersions) into the sort as a param doesn't work.  
Anyone know what I'm missing?

Thanks!!
Guy



Re: re-using a comparison closure

2016-05-16 Thread Søren Berg Glasius (GR8Conf EU)
Hi Guy

Just assign the variable 

def comapreVersions = { a,b ->
return getVersion(a).toInteger() <=> getVersion(b).toInteger()
}

and then use it in your sort:


list.sort(compareVersions)



Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Guy Matz 
Reply: users@groovy.apache.org 
Date: May 16, 2016 at 17:28:34
To: users@groovy.apache.org 
Subject:  re-using a comparison closure  

Hi!
I have to sort a list of strings based on a number within the string . . .  I 
am able to sort using something like:
list.sort( { a,b -> getVersion(a) <=> getVersion(b)})

I need to use this in a bunch of places in my code and was hoping to replace it 
with a method, like:
list.sort( compareVersions)

with compareVersions:
def compareVersions(a, b) {
  return getVersion(a).toInteger() <=> getVersion(b).toInteger()
}

putting the method (compoareVersions) into the sort as a param doesn't work.  
Anyone know what I'm missing?

Thanks!!
Guy

Re: Groovy Running Slower With More Memory

2016-05-09 Thread Søren Berg Glasius (GR8Conf EU)
Hi Daniel,

Without knowing for sure, I would think that setting the minimum heap size to 
20G would take some time to allocate. What about just setting the maximum heap 
size, and let the JVM handle the minimum size, or start lower, like 2G.



Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Daniel Price 
Reply: users@groovy.apache.org 
Date: May 9, 2016 at 18:28:38
To: users@groovy.apache.org 
Subject:  Groovy Running Slower With More Memory  

Good Afternoon.  I've been running some Groovy 2.4.2 scripts on a Windows 7 
64-bit PC with 16GB of RAM.  My scripts are memory intensive SQL Server DB 
manipulators, and I have modified startGroovy.bat to:

%JAVA_OPTS% -Xms8192M -Xmx8192M

I recently gained access to a new server running Windows Server 2012 that has 
32GB RAM and lots of flash disk, so I thought giving Groovy more RAM might 
allow the scripts to run faster.  So I installed Groovy on the server and 
modified startGroovy.bat to:

%JAVA_OPTS% -Xms20480M -Xmx20480M

But the new server runs my scripts about twice as slow as my PC.  This is true 
even with the exact same RAM settings in startGroovy.bat.

I don't know if I should expect to see a large decrease in run time based on 
additional RAM, but an increase seems odd to me.

Could this be due to OS differences?

Thanks!

Re: aliasing methods

2016-04-13 Thread Søren Berg Glasius (GR8Conf EU)
Hi,

Can you come with some specific code examples? 

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: frenchy48 
Reply: users@groovy.apache.org 
Date: April 13, 2016 at 10:04:28
To: us...@groovy.incubator.apache.org 
Subject:  aliasing methods  

Hello all  
I have a resource file that describes alias names for method (something with  
entries like: "org.smurf.MyClass#myMethod=otherName")  

now an initialisation code will read this resource to alias "myMethod" to  
"otherName"  

there are numerous problems:  
- when doing this aliasing I do not have instances (just the class)  
- there may be methods that are overloaded  
- and methods with arguments or no argument  

code such as:  

is not completely ok (if it is null I won't make the difference between a  
no-arg method and a method with just one arg which happens to be null)  
is there a more elegant expression to do that?  
thanks  



-  
member of Grumpy Old Programmers  
--  
View this message in context: 
http://groovy.329449.n5.nabble.com/aliasing-methods-tp5732316.html  
Sent from the Groovy Users mailing list archive at Nabble.com.  


Re: Check if List is of specific size and elements of specific type

2016-03-29 Thread Søren Berg Glasius (GR8Conf EU)
@dinko yeah, that's why I choose to do my example with listVariable*.getClass() 

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Dinko Srkoč 
Reply: users@groovy.apache.org 
Date: March 29, 2016 at 14:04:50
To: users@groovy.apache.org 
Subject:  Re: Check if List is of specific size and elements of specific type  

On 29 March 2016 at 12:29, Marcos Carceles  wrote:  
> Would this work?  
>  
> listVariable*.class == [Integer, Integer]  

It would in this particular example, but this may be dangerous for  
some other cases. Try e.g. this:  

[1, [:], [class: 1]]*.class  

Cheers,  
Dinko  

>  
> On 29 March 2016 at 12:25, Maarten Boekhold  wrote:  
>>  
>> Hi,  
>>  
>> Is there a quick and easy way to do something like:  
>>  
>> assert listVariable == [int, int]  
>>  
>> eg, the list is of size 2 and each element is an int?  
>>  
>> Maarten  
>  
>  


Re: Check if List is of specific size and elements of specific type

2016-03-29 Thread Søren Berg Glasius (GR8Conf EU)
Hi Maarten,

You could be close with this.

def listVariable = [1,2]
assert listVariable*.getClass() == [int, int]

but your assert will have to be

assert listVariable*.getClass() == [Integer, Integer]

since ints are actually the object type Integer

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Maarten Boekhold 
Reply: users@groovy.apache.org 
Date: March 29, 2016 at 12:25:42
To: us...@groovy.incubator.apache.org 
Subject:  Check if List is of specific size and elements of specific type  

Hi,  

Is there a quick and easy way to do something like:  

assert listVariable == [int, int]  

eg, the list is of size 2 and each element is an int?  

Maarten  


Re: not sure about Collection.intersect

2016-02-08 Thread Søren Berg Glasius (GR8Conf EU)
And by the way,

the easy way to implement equals and haschode is this:

import groovy.transform.EqualsAndHashCode

@EqualsAndHashCode
class TestClass {
    String name
}

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Edinson E. Padrón Urdaneta 
Reply: users@groovy.apache.org 
Date: February 8, 2016 at 15:29:00
To: users@groovy.apache.org 
Subject:  Re: not sure about Collection.intersect  

I have to look at the implementation of the `intersect` method to be sure but 
does your TestClass class overwrite `hashcode` and `equal`? There should be a 
way to compare the instances of said class.

Re: not sure about Collection.intersect

2016-02-08 Thread Søren Berg Glasius (GR8Conf EU)
Hi Paul,

c1 contains one instance of TestClass, c2 contains another. Those two are not 
equals, because they probably do not implement the equals method, and thus 
comparison is done between object references in memory, and they are different, 
being two different objects.

if you equals was implemented to compare the name of TestClass I'm pretty sure 
it would work.

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Strachan, Paul 
Reply: users@groovy.apache.org 
Date: February 8, 2016 at 15:12:06
To: users@groovy.apache.org 
Subject:  not sure about Collection.intersect  

Groovy 2.4.4 / 2.4.5

 

Hi – I’d like to get a list of objects from collection A that exist in 
collection B using intersect() but I’m getting no results:

 

def c1 = []// as Set
def c2 = []// as Set
c1 << new TestClass(name: 'mike')
c2 << new TestClass(name: 'mike')
println c1.contains(c2[0])
assert c1.intersect(c2).size() == 1
  
  
Output:

 

true

Assertion failed:

 

assert c1.intersect(c2).size() == 1

   |  | |   |  |

   |  []    |   0  false

   |    [sample.TestClass@57]

   [sample.TestClass@57]

 

 

TestClass.groovy

 

package sample
import groovy.transform.EqualsAndHashCode
@EqualsAndHashCode(includes = 'name')
class TestClass {
    String name
}

 

 

Is intersect only for simple types?

 

 


**
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**

GR8Conf EU + Gradle miniSummit

2016-01-20 Thread Søren Berg Glasius (GR8Conf EU)
GR8Conf Europe is happy to announce, that this years conference will feature an 
additional track, with focus on Gradle. We call it the "Gradle miniSummit".

The conference takes place in beautiful Copenhagen, Denmark, from June 1st 
through 3rd, where the first day is a University day, with longer workshops, 
and the 2nd and 3rd are regular conference days with talks from the entire 
Groovy ecosystem. You can read more about the conference on: http://gr8conf.eu

Note to speakers:
The GR8Conf EU + Gradle miniSummit call for paper is open. Please submit your 
talks at http://cfp.gr8conf.org

Best regards,
Søren Berg Glasius
GR8Conf co-founder and organizer.

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu, Skype: sbglasius 
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem