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
Get a File | |
curl -i -X GET -H 'Authorization: token <your token>' -d '{"path": "index.html", "message": "Initial Commit", "committer": {"name": "Jonatas Emidio", "email": "[email protected]"}, "branch": "master"}' https://api.github.com/repos/jonatasemidio/blog/contents/index.html | |
Create a File | |
curl -i -X PUT -H 'Authorization: token <your token>' -d '{"path": "index.html", "message": "Initial Commit", "committer": {"name": "Jonatas Emidio", "email": "[email protected]"}, "content": "VGVzdGluZyBHaXRIdWIgQVBJ", "branch": "master"}' https://api.github.com/repos/jonatasemidio/blog/contents/index.html | |
Update a File | |
curl -i -X PUT -H 'Authorization: token <your token>' -d '{"path": "index.html", "message": "Initial Commit", "committer": {"name": "Jonatas Emidio", "email": "[email protected]"}, "content": "VGVzdGluZyBHaXRIdWIgQVBJ", "sha":"2706f84a7078ad64fbdca10558879e6f2c323694", "branch": "master"}' https://api.github.com/repos/jonatasemidio/blog/contents/index.html | |
Delete a File |
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
f = new File('dir_file_'+ System.currentTimeMillis() +'.log') | |
new File('.').eachFileRecurse { f << it.getCanonicalPath() + '\n' } |
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
REGEX = "^[\\w\\s/<>?\".=-]*[áéíóúçàãõâêô:\\s]*\$" | |
nome = " jonatas#!@#%¨&* emidio" | |
texto = ''' | |
<?xml¨&*()¨&*( version="1.0" encoding="ISO-8859-1"?> | |
<SAIDA> | |
<HEADER> | |
<ERRO> | |
<CODIGO-ERRO>1454014207309</CODIGO-ERRO>%¨&*() | |
<ORIGEM-ERRO>The data "" is not legal for a JDOM character content 0x0 is not a legal XML character.</ORIGEM-ERRO> |
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
// Font: http://mrhaki.blogspot.fr/2015/09/groovy-goodness-removing-elements-from.html | |
// Thanks to Hubert Klein Ikkink (https://github.com/mrhaki) | |
def list = ['Groovy', 42, 'gr8!', 5.2, new Date()] | |
// Groovy adds retainAll method | |
// to remove items from collection | |
// that do not apply to the condition we | |
// define in the closure and keep those | |
// items that do apply to the condition. |
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
// Font: http://mrhaki.blogspot.fr/2015/09/groovy-goodness-removing-elements-from.html | |
// Thanks to Hubert Klein Ikkink (https://github.com/mrhaki) | |
def list = ['Groovy', '=', 'gr8!'] | |
// Groovy adds removeAll method | |
// to remove items from collection | |
// that apply to the condition we | |
// define in the closure. | |
list.removeAll { it.toLowerCase().startsWith('g') } |
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
m = [name: 'nome do cara'] | |
s = "{name:'jonatas', idade: 10}".replace("'", "") | |
s = s.replace('{', '').replace('}', '') | |
println s.split(', ').each{ | |
name = it.split(':')[0] | |
value = it.split(':')[1] |
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
O apresentador Ratinho precisa criar um quadro em seu programa chamado de "Teste de DNA". | |
Esse quadro será responsável por identificar quem é o pai da criança apresentada. | |
Basicamente será apresentado uma criança e dois possíveis pais. Onde o Ratinho será o responsável por descobrir o pai original. | |
Para isso o DNA coletado de cada possível pai será comparado com o DNA coletado do filho. | |
As 3 sequências de DNS serão informadas ao sistema que retornará com quem é o Pai. | |
Onde você será o responsável por contruir esse sistema seguindo as seguintes regras: | |
1 - O DNA com a maior pontuação (mais parecido) de compatibilidade será eleito o pai da vez; |
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.io.FileType | |
def generateTest(String dir, String projectName) { | |
createDirectories(dir+File.separator+projectName) | |
new File(dir).eachFileRecurse(FileType.FILES) { if(it.name.contains('.java')) buildTestClasses(it.toString(), projectName)} | |
} | |
def buildTestClasses(String completeFileName, String projectName){ | |
def selectedFile = new File(completeFileName) | |
def testClassFile = new File(createNameTestFile(completeFileName, projectName)) |
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
interface Buyable { | |
def buy() | |
} | |
class SomeBuyableObject implements Buyable { | |
String foo | |
def buy() { //do stuff } | |
} | |
class AnotherBuyableObject implements Buyable { |
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
Object.metaClass.findAll{println it.toString()} | |
class Dog{ String name; public String toString(){ return this.name } } | |
class Cat{ String name; public String toString(){ return this.name } } | |
class Cow{ String name; public String toString(){ return this.name } } | |
dog = new Dog(name: 'toto') | |
cat = new Dog(name: 'lili') | |
cow = new Dog(name: 'mumu') |