Skip to content

Instantly share code, notes, and snippets.

@jorgeuriarte
jorgeuriarte / restrictWipJiraValidator.groovy
Created March 17, 2014 17:11
Jira transition validator... will restrict transition if any issue is waiting in 'Testing' state for the given team.Thanks to examples like https://answers.atlassian.com/questions/134531/how-to-run-jql-query-inside-groovy-script
def user = componentManager.jiraAuthenticationContext.getLoggedInUser()
def campoCelula = componentManager.customFieldManager.customFieldObjects.find { it.fieldName.endsWith('lula IT') }
def celula = issue.getCustomFieldValue(campoCelula)
def jql = """
project = 'TICKETBIS'
and '${campoCelula.name}' = '${celula}'
and status = 'En Pruebas'
and assignee is null
"""
def searchService = componentManager.getSearchService()
@jorgeuriarte
jorgeuriarte / updateSetContent
Last active August 29, 2015 14:19
La primera versión (la existente) hace que si un valor se queda "colgado", nunca se borre. ¿Qué problema tiene la segunda?
def updateSetContent(hashkey, userKey, hashvalue, user){
def options = this.questions[hashkey].options
def valuesArray = hashvalue.split(',')
options.each{ option ->
def existia = jedis.sismember(userKey, option.value)
def existe = valuesArray.find{ it == option.value }
//si el usuario la marco como respuesta, y no existia
@jorgeuriarte
jorgeuriarte / DummyVerticle.groovy
Last active August 29, 2015 14:22
Trying to track down weird behaviour with Vertx. It essentially loads a redis queue and then translates all its elements into messages in the eventbus. The problem is once some time and load has been "suffered", the bus starts reporting "failed" sends, even though they have already been checked as "received" (check the UUIDs logs, once the failu…
package nire.verticles;
@groovy.transform.Field HANDLER_NAME = "nire.handlers.AsignarEjercicio"
def eb = vertx.eventBus()
println "Will listen at ${HANDLER_NAME}"
eb.consumer(HANDLER_NAME) { message ->
def worker = new DummyWorker()
worker.processElement(message.body().msg)
@jorgeuriarte
jorgeuriarte / Yo digo bienvenido
Last active December 10, 2015 12:38
First draft of a spanish translation for the "I say welcome" from Jim & Michele McCarthy
Yo digo bienvenido
I say welcome over and over to every and all who show me themselves in a way I can
understand because their kindness in doing so is lovely. I want more of it, and them,
in my world. They are welcome.
Digo bienvenido, una y otra vez, a todo aquel que se me muestra de modo que puedo entenderle, porque su amabilidad al hacerlo es adorable. Quiero tener más de eso y más de ellos en mi mundo. Son bienvenidos.
I say welcome because for hundreds of years we have been unwelcome in hundreds of
ways. Our feelings especially have been taboo, our deepest selves prohibited.
def openSprints = boardData.get("openSprints") as List<Map>
openSprints.findAll { it.name.contains(sprintMarkerName).xor(negate) }.each { sprint ->
sprint.get("issues")*.id.each {
issueIds.add(it.toString())
def issue = issueManager.getIssueObject(it)
def subTasks = issue?.subTaskObjects
if (subTasks) {
issueIds.addAll(subTasks.collect{it.id.toString()})
}
}
@jorgeuriarte
jorgeuriarte / zdiffstoreexample.groovy
Last active December 18, 2015 12:10
Redis zdiffstore groovy example...
@Grab(group='redis.clients', module='jedis', version='2.1.0')
import redis.clients.jedis.*
def poolconfig = new JedisPoolConfig()
def conn = (new JedisPool(poolconfig, "localhost", Protocol.DEFAULT_PORT, 0 /* Protocol.DEFAULT_TIMEOUT */, null, 0)).getResource()
def setupRestricciones(connx) {
[31276:1369774800001, /* Scores should be consistant with target zset's internal scores (categoria:78:eventos) */
38000:1412456400000,
37909:1369776600000].each { k, v -> connx.zadd('tmp:restricciones', v, k.toString()) }
@jorgeuriarte
jorgeuriarte / updatelogs.groovy
Created September 25, 2013 10:55
Script to massively update Subversion logs, so you can change commit messages (in the event of some changed convention as the prefix of issues to be linked in Jira or similar) This script will generate another, bash script, containint the commands that will be sent to the real subversion.
/**
Uso:
- Llamar:
groovy updatelogs.groovy [svn url] [PREFIJO] [revinicial] [revfinal] > updatelogs.sh
- Revisar el script updatelogs.sh generado
- Lanzar:
@jorgeuriarte
jorgeuriarte / redis-pipeline.groovy
Created November 1, 2013 11:02
Dos implementaciones diferentes del mismo método hechas por dos personas, intentando optimizar las conexiones a redis. Resulta que al final lo hicimos casi igual :)
public String generarSitemapCategorias(categoria) {
def categorias = [] as Set
def descendientes = this.redisInstance.zrange( "categoria:${categoria}:descendientes", 0, -1)
def categoriasYEventos = [:]
this.redisInstance.withPipeline { pipe ->
categoriasYEventos = descendientes.findResults {
[id: it, zcard: pipe.zcard("categoria:${it}:eventos")]
}
}
categorias = categoriasYEventos.findResults { if (it.zcard.get() > 0) it.id }
@jorgeuriarte
jorgeuriarte / redisAndFuturesLoving.groovy
Created November 8, 2013 10:56
Example of mixing asynchronous pipelined request to redis, and a concurrent algorithm with Java futures... Hints: - pipe.get() is *outside* the closure that defines de concurrent Task. - The real execution of the task (call: ...) will happen at "invokeAll(tareas)". - pipe.sync() has made redis results avalaible to tasks, even before they start b…
@Grab(group='redis.clients', module='jedis', version='2.1.0')
import redis.clients.jedis.*
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.Callable
/**
*
*/
@jorgeuriarte
jorgeuriarte / AndroidManifestDecompressor.groovy
Created September 19, 2016 10:08 — forked from seymores/AndroidManifestDecompressor.groovy
Extract AndroidManifest.xml information.
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
class AndroidXMLDecompress {
// decompressXML -- Parse the 'compressed' binary form of Android XML docs
// such as for AndroidManifest.xml in .apk files