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
| //Estes exemplos podem ser encontrado na wikipedia: http://pt.wikipedia.org/wiki/Quicksort#Groovy | |
| //Execute no web groovy console: http://groovyconsole.appspot.com/script/968001 | |
| def sort(list) { | |
| if (list.isEmpty()) return list | |
| anItem = list[0] | |
| def smallerItems = list.findAll{it < anItem} | |
| def equalItems = list.findAll{it == anItem} | |
| def largerItems = list.findAll{it > anItem} | |
| sort(smallerItems) + equalItems + sort(largerItems) | |
| } |
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 grails.test.mixin.TestFor | |
| @TestFor(DadosService) | |
| class DadosServiceTests { | |
| void test_obtemDados() { | |
| def dadosBuscasService = new DadosBuscasService() | |
| def result = ['CVT', '2', '2', 'AAAA', 'Grat'] | |
| def sqlUtilService = [select: {result}] as SqlUtilService | |
| dadosBuscasService.sqlUtilService = sqlUtilService |
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
| Graeme Rocher: Grails Project Lead (CTO) | |
| ----------------------------------------------------------------------------------------------------------------------------- | |
| Links: | |
| 1º post do Graeme Rocher falando sobre grails: | |
| http://graemerocher.blogspot.com.br/search?updated-max=2006-03-15T20:48:00Z&max-results=20&start=140&by-date=false | |
| 1º Commit no Github: | |
| https://github.com/grails/grails/commit/25e0b852c9b39895fa9b831ac4a7e15a40472341 | |
| Repositório SVN (Antigo): |
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 fizzbuzz(n): | |
| if n % 3 == 0 and n % 5 == 0: | |
| return 'FizzBuzz' | |
| elif n % 3 == 0: | |
| return 'Fizz' | |
| elif n % 5 == 0: | |
| return 'Buzz' | |
| else: | |
| return str(n) |
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
| //Let see with an example: | |
| class Counter { | |
| public static long count = 0; | |
| } | |
| class UseCounter implements Runnable { | |
| public void increment() { | |
| Counter.count++; | |
| System.out.print(Counter.count + " "); |
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
| //Based on https://gist.github.com/israelst/2041698 | |
| //See it working http://groovyconsole.appspot.com/script/1265001 | |
| def dv(x, y){ | |
| result = [q : 0, r : 0] | |
| while (x >= y){ | |
| x -= y | |
| result.q += 1 | |
| } | |
| result.r = x |
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
| -Xms740m -Xmx1024m -XX:MaxPermSize=512m |
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
| o = [[id: 1, nome: 'jose'], [id: 2, nome: 'maria']] | |
| o.collect{ it << [idade: 10*it.id] } | |
| println o |
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
| class RecursiveMap{ | |
| public static TreeMap<String, String> routeCalculation (Map<String, TreeMap<String, Integer>> cityMaps, TreeMap<String, String> rota) { | |
| //Map<String, ArrayList<String>> mapping = TrainsInformation.drawAllRoutes(cityMaps); | |
| String originCity = rota.get("ORIGIN_CITY" ); | |
| String destinationCity = rota.get("DESTINATION_CITY"); | |
| String distance = rota.get("DISTANCE" ); | |
| String max = rota.get("MAX" ); | |
| String routeMapping = rota.get("ROUTE_MAPPING" ); | |
| Integer parsedDistance = Integer.parseInt(distance); |
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
| from google.appengine.api import users | |
| from google.appengine.ext import webapp | |
| from google.appengine.ext.webapp.util import run_wsgi_app | |
| from google.appengine.ext import db | |
| from google.appengine.ext.webapp import template | |
| from google.appengine.api import memcache | |
| # Set the debug level | |
| _DEBUG = True |