This file contains 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='com.ocpsoft', module='ocpsoft-pretty-time', version='1.0.7') | |
import groovy.time.TimeCategory | |
import com.ocpsoft.pretty.time.PrettyTime | |
Date.metaClass.pretty = {it -> | |
def p = new PrettyTime(it, new Locale("hr")) | |
p.format(delegate) | |
} | |
use(TimeCategory){ |
This file contains 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.swing.SwingBuilder | |
import java.awt.BorderLayout as BL | |
import java.awt.datatransfer.Clipboard | |
import java.awt.datatransfer.StringSelection | |
import java.awt.Toolkit | |
import javax.swing.* | |
class UUIDgenerator { | |
def readIcon() { | |
byte[] iconBytes = new byte[990] |
This file contains 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.JsonOutput | |
class User { | |
def ime | |
def prezime | |
} | |
def u = new User(ime:'Ime', prezime:'Prezime') | |
use (JsonOutput) { |
This file contains 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
serverJvm = AdminControl.queryNames('WebSphere:type=JVM,*') | |
print 'Generating dump for server: ' + serverJvm | |
dumpFile = AdminControl.invoke(serverJvm, 'generateHeapDump') | |
print 'Heap dump file: ' + dumpFile |
This file contains 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
int sum | |
(1..999).each { int i -> sum += i%3==0 ? i : i%5==0 ? i:0 } | |
print sum |
This file contains 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
int fib(int to, int fibMinOne=0, int fibMinTwo=0) { | |
to > 2 ? ((fibMinTwo==0 ? fib(to - 2):fibMinTwo) + (fibMinOne==0 ? fib (to - 1):fibMinOne)) : to == 2 ? 2: (to== 1 ? 1: 0); | |
} | |
int sum | |
int fibMinOne | |
int fibMinTwo | |
for (int i=0;; i++) { def f = fib(i,fibMinOne,fibMinTwo); fibMinTwo=fibMinOne;fibMinOne=f;if (f>4e6) break; sum+=f%2==0?f:0} | |
print sum |
This file contains 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
@GrabConfig(systemClassLoader=true) | |
@Grapes( | |
@Grab(group='javax.mail', module='mail', version='1.4.4') | |
) | |
def ant = new AntBuilder() | |
ant.mail(mailhost:'localhost', mailport:25, subject:'Test message') { | |
from(address:'mySystem@localhost') | |
cc(address:'mySystem@localhost') | |
to(address:'tester@localhost') |
This file contains 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 javax.mail.*; | |
import javax.mail.internet.*; | |
@GrabConfig(systemClassLoader=true) | |
@Grapes( | |
@Grab(group='javax.mail', module='mail', version='1.4.4') | |
) | |
// setup connection | |
Properties props = new Properties(); | |
def host = "localhost"; |
This file contains 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 net.croz.jms.test; | |
import java.util.Date; | |
import java.util.Hashtable; | |
import javax.jms.JMSException; | |
import javax.jms.MessageProducer; |
This file contains 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://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath | |
def dirName = 'd:\\tmp\\' | |
def MAX_PATH = 260 | |
def FILE_NAME = 12 | |
def NULL_SIZE = 1 | |
def i = dirName.length() | |
while (i < MAX_PATH - FILE_NAME - NULL_SIZE) { | |
def iLen = (i as String).length() | |
def currLenValue = i + iLen |
OlderNewer