Skip to content

Instantly share code, notes, and snippets.

@jorgeuriarte
jorgeuriarte / checkssl.sh
Created October 25, 2016 14:58
Check SSL Ciphers available in a given URL
#!/usr/bin/env bash
#OpenSSL requires the port number.
#ws.seur.com
#SERVER=80.65.15.72:443
SERVER=54.187.119.242:443
DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
@jorgeuriarte
jorgeuriarte / closureTimer.groovy
Created October 12, 2016 12:18
Ejemplo de contexto de closures arrastrado en Groovy
@Grab("io.vertx:vertx-core:3.3.3")
import io.vertx.core.Vertx
def schedulerId
def vertx = Vertx.vertx()
(1..10).each { it ->
vertx.setTimer(2000, {
println """
Hola, este es ${schedulerId}
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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()) }