Skip to content

Instantly share code, notes, and snippets.

View rodrigoSaladoAnaya's full-sized avatar

Rodrigo Salado Anaya rodrigoSaladoAnaya

View GitHub Profile
/**
* Buzz, Woody, Rex, and Hamm have to escape from Zurg.a They merely have
* to cross one last bridge before they are free. However,
* the bridge is fragile and can hold at most two of them at the same time.
* Moreover, to cross the bridge a flashlight is needed to avoid traps and broken parts.
* The problem is that our friends have only one flashlight with one battery that lasts for
* only 60 minutes (this is not a typo: sixty). The toys need different times to cross the
* bridge (in either direction):
*
* TOY TIME
/**
* Ver: http://www.codewars.com/kata/common-denominators
*/
def list_rationals = [
[1, 2], [1, 3], [1, 4], //...
]
def mc = list_rationals.inject(1) { c, i ->
c * i[1]
@rodrigoSaladoAnaya
rodrigoSaladoAnaya / gist:72c470aa5e298bf7fdb0
Last active August 29, 2015 14:21
Borra una ventana muy molesta que no deja ver el video https://www.youtube.com/watch?v=14V2T1EONR8
//Yo use la consola de firebug en firefox, se tiene que ejecutar dos veces por que
// sale este error 'Error: An invalid or illegal string was specified'
(function() {
var script = document.createElement("SCRIPT");
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName("head")[0].appendChild(script);
var checkReady = function(callback) {
if (window.jQuery) {
callback(jQuery);
@rodrigoSaladoAnaya
rodrigoSaladoAnaya / TestEcoCSharp.cs
Created February 18, 2015 00:24
Ejemplo de como se manda una trama tipo 'eco' a test (C#)
using System.IO;
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
class Program
{
static void Main()
{
/**
* vertx version:
* 2.1.2 (built 2014-07-24 07:45:28)
* test:
* vertx run shared_set_error.groovy
**/
import org.vertx.java.core.shareddata.impl.SharedSet
SharedSet<String> sharedSet = vertx.sharedData.getSet(
package you.mane
import javax.naming.directory.InitialDirContext
class Clazz {
static mailExchange(String email) {
def emailParts = email.split('@')
if (emailParts.size() == 2) {
try {
def domainName = emailParts[1]
def iniDir = new InitialDirContext();
@rodrigoSaladoAnaya
rodrigoSaladoAnaya / TestLikeSpec.groovy
Created July 18, 2014 01:17
Un ejemplo de como usar GertxSpecification
package com.tu.starup
class TestLikeSpec extends GertxSpecification {
def setupSpec() { //Se despliegan primero los verticles
deployVerticle('aplica_like.groovy')
}
def cleanup() {
}
@rodrigoSaladoAnaya
rodrigoSaladoAnaya / GertxSpecification.groovy
Last active August 29, 2015 14:04
Como hacer una prueba de integración a un verticle Vert.x
package corg.grails.gertx
import org.junit.Ignore
import spock.lang.Shared
import spock.lang.Specification
import org.vertx.java.core.AsyncResult
import org.vertx.java.core.Handler
import org.vertx.java.core.eventbus.EventBus
import org.vertx.java.core.eventbus.Message
import org.vertx.java.core.json.JsonObject
import org.vertx.groovy.core.http.RouteMatcher
import groovy.sql.Sql
// Use this driver and put the jar in the classpath:
// http://mvnrepository.com/artifact/postgresql/postgresql/8.4-702.jdbc4
def server = vertx.createHttpServer()
def routeMatcher = new RouteMatcher()
routeMatcher.getWithRegEx(".*") {req ->
def db = [
@rodrigoSaladoAnaya
rodrigoSaladoAnaya / BootStrap.groovy
Last active December 19, 2015 14:58
How to integrating Vert-x in Grails using a PlatformManager. (Test)
//grails-app/conf/BootStrap.groovy
import org.vertx.java.platform.PlatformLocator
class BootStrap {
def vertxPlatformManager
def init = { servletContext ->
vertxPlatformManager = PlatformLocator.factory.createPlatformManager()
URL[] classpath = [new File('./src/verticles').toURI().toURL()]
vertxPlatformManager.deployVerticle(