Error displaying in prolog.

Code
Diff
  • add(A, B, R) :- 
        number(A)
        , number(B)
        , R is A + B 
        +2 %wrong part to show formatting tricks
        .
  • 1
    add(A, B, R) :- R is A + B.
    
    1+
    add(A, B, R) :- 
    
    2+
        number(A)
    
    3+
        , number(B)
    
    4+
        , R is A + B 
    
    5+
        +2 %wrong part to show formatting tricks
    
    6+
        .
    

This Kumite is created to test JQuery support on Codewars.

var jsdom = require("jsdom/lib/old-api.js");

jsdom.env(
    '<!DOCTYPE html><p>Hello world</p><a class="the-link" href="https://github.com/tmpvar/jsdom">jsdom!</a>', ["http://code.jquery.com/jquery.js"],
    function(err, window) {
        console.log(window.document.querySelector("p").textContent);
        var $ = window.$;

        $.getJSON('https://www.codewars.com/users/Javatlacati', null, function(data) {
            console.log(data);
        }).error(function(e) {
            console.log("first attempt failed\n" + JSON.stringify(e));
        });



        var name = "kazk";
        var url = "http://anyorigin.com/go?url=" + encodeURIComponent("https://www.codewars.com/users/") + name + "&callback=?";
        $.get(url, function(response) {
            console.log(response);
        }).error(function(e) {
            console.log("second attempt failed\n" + JSON.stringify(e));
        });
        console.log("contents of a.the-link:", window.$("a.the-link").text());
    }
);
Code
Diff
  • SELECT * FROM current_catalog
  • 1
    SELECT current_database();
    
    1+
    SELECT * FROM current_catalog
    

Do you know where you are?
You had a massive hangover and don't rememeber where are you.
Use your system to know info about your enviroment.

SQL

Retrieve the current database

SELECT current_database();
// add the values "codewars" to the websites array
var websites = ['codears'];

That's a simple threading test using JavaFX. It currently has troubles due to codewars JVM runner.

import java.util.concurrent.atomic.AtomicInteger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;

/** Created by Javatlacati on 08/02/2017. */
public class Aciago extends Application {
  public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage primaryStage) throws Exception {
    Thread miHilo =
        new Thread(
            new Runnable() {
              final AtomicInteger i = new AtomicInteger(0);

              @Override
              public void run() {
                System.out.println("Corriendo");
                while (true) {
                  Platform.runLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          System.out.println(i.getAndIncrement() + " ola soi un hilo :v");
                        }
                      });

                  try {
                    if (i.get() < 4) {
                      System.out.println("anuma me voi a dormir");
                      Thread.sleep(1000);
                    } else {
                      throw new InterruptedException("#PosMeMuero");
                    }
                  } catch (InterruptedException ex) {
                    System.err.println("#ToyMorido");
                    Platform.exit();
                    System.out.println("JavaFx is dead");
                    break;
                  }
                }
              }
            });

    miHilo.setName("soy el mapa soy el mapa soy el mapa soy el mapa soy el mapa!");
    miHilo.setDaemon(false);
    miHilo.start();
  }
}

Any help is welcome :)

import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by Javatlacati on 07/02/2017.
 */
public class ThreadIssueSolution extends ScheduledThreadPoolExecutor {
    public boolean isUsable=true;
    public ThreadIssueSolution() {
        super(1);
    }

    @Override
    public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
        return super.scheduleAtFixedRate(wrapRunnable(command), initialDelay, period, unit);
    }

    @Override
    public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
        return super.scheduleWithFixedDelay(wrapRunnable(command), initialDelay, delay, unit);
    }

    private Runnable wrapRunnable(Runnable command) {
        return new LogOnExceptionRunnable(command);
    }

    @Override
    protected void afterExecute(Runnable r, Throwable t) {
//        super.afterExecute(r, t);
        if(!(t == null && r == null)){
            throw new ArithmeticException("ooops");
        }
    }

    private class LogOnExceptionRunnable implements Runnable {
        private Runnable theRunnable;

        public LogOnExceptionRunnable(Runnable theRunnable) {
            super();
            this.theRunnable = theRunnable;
        }

        @Override
        public void run() {
            try {
                theRunnable.run();
            } catch (Throwable e) {
               System.err.println("error ejecutando: " + theRunnable + ". no seguirá corriendo!");
                //e.printStackTrace();
                // and re throw it so that the Executor also gets this error so that it can do what it would
                // usually do
                throw new RuntimeException(e);
            }
        }
    }
}

Shows how to use bash kta and how to create simple tests

echo Hello Bash!
JavatlacatiFailed Tests

Kotlin

Kotlin Hello World modified to show some language features

/**
 * Created by Javatlacati on 26/10/2016.
 */
object LambdaKotlin {
    @JvmStatic
    fun main(args: Array<String>) {
        val arr=arrayOf("hola","mundo","cruel")
        arr.forEach {
            println(it)
        }
    }
}
Code
Diff
  • #include <string>
    #include <stdio.h>
    
    int Main()
    {
      int arg1, arg2, add, sub, mul, quo, rem ;
    
        printf( "Enter two integer numbers : " );
        scanf( "%d%d", &arg1, &arg2 ); //no scanf provided hope to get memory garbage as number
    
        /* Perform Addition, Subtraction, Multiplication & Division */
        __asm__ ( "addl %%ebx, %%eax;" : "=a" (add) : "a" (arg1) , "b" (arg2) );
        __asm__ ( "subl %%ebx, %%eax;" : "=a" (sub) : "a" (arg1) , "b" (arg2) );
        __asm__ ( "imull %%ebx, %%eax;" : "=a" (mul) : "a" (arg1) , "b" (arg2) );
    
        __asm__ ( "movl $0x0, %%edx;"
                  "movl %2, %%eax;"
                  "movl %3, %%ebx;"
                   "idivl %%ebx;" : "=a" (quo), "=d" (rem) : "g" (arg1), "g" (arg2) );
    
        printf( "%d + %d = %d\n", arg1, arg2, add );
        printf( "%d - %d = %d\n", arg1, arg2, sub );
        printf( "%d * %d = %d\n", arg1, arg2, mul );
        printf( "%d / %d = %d\n", arg1, arg2, quo );
        printf( "%d %% %d = %d\n", arg1, arg2, rem );
    
        return 0 ;
    }
  • 1
    int main()
    
    2
    {
    
    3
      printf("%d\n", test());
    
    4
    }
    
    1+
    #include <string>
    
    2+
    #include <stdio.h>
    
    55
    6
    int test()
    
    4+
    int Main()
    
    77
    {
    
    8
      __asm__("movl $1337, %eax");
    
    6+
      int arg1, arg2, add, sub, mul, quo, rem ;
    
    7+
    8+
        printf( "Enter two integer numbers : " );
    
    9+
        scanf( "%d%d", &arg1, &arg2 ); //no scanf provided hope to get memory garbage as number
    
    10+
    11+
        /* Perform Addition, Subtraction, Multiplication & Division */
    
    12+
        __asm__ ( "addl %%ebx, %%eax;" : "=a" (add) : "a" (arg1) , "b" (arg2) );
    
    13+
        __asm__ ( "subl %%ebx, %%eax;" : "=a" (sub) : "a" (arg1) , "b" (arg2) );
    
    14+
        __asm__ ( "imull %%ebx, %%eax;" : "=a" (mul) : "a" (arg1) , "b" (arg2) );
    
    15+
    16+
        __asm__ ( "movl $0x0, %%edx;"
    
    17+
                  "movl %2, %%eax;"
    
    18+
                  "movl %3, %%ebx;"
    
    19+
                   "idivl %%ebx;" : "=a" (quo), "=d" (rem) : "g" (arg1), "g" (arg2) );
    
    20+
    21+
        printf( "%d + %d = %d\n", arg1, arg2, add );
    
    22+
        printf( "%d - %d = %d\n", arg1, arg2, sub );
    
    23+
        printf( "%d * %d = %d\n", arg1, arg2, mul );
    
    24+
        printf( "%d / %d = %d\n", arg1, arg2, quo );
    
    25+
        printf( "%d %% %d = %d\n", arg1, arg2, rem );
    
    26+
    27+
        return 0 ;
    
    99
    }
    
Fundamentals

Easy sample of how to run a hello world and use basic test.

Code
Diff
  • #include <iostream>
    #include <string>
    
    int helloCplusplus(){
      std::string str = "Hello, C++!";
      std::cout << str << '\n';
      return 0;
    }
  • 1
    System.Console.WriteLine("Hello, C#!");
    
    1+
    #include <iostream>
    
    2+
    #include <string>
    
    3+
    4+
    int helloCplusplus(){
    
    5+
      std::string str = "Hello, C++!";
    
    6+
      std::cout << str << '\n';
    
    7+
      return 0;
    
    8+
    }
    
Testing

Code from the official page

class MyTestCase extends GroovyTestCase {

    void testAssertions() {
        assertTrue(1 == 1)
        assertEquals("test", "test")

        def x = "42"
        assertNotNull "x must not be null", x
        assertNull null

        assertSame x, x
    }

}
Code
Diff
  • defmodule Solution do
      def sum(a, b) do
        a + b
      end
    end
  • 1
    sum = fn a, b -> a + b end
    
    1+
    defmodule Solution do
    
    2+
      def sum(a, b) do
    
    3+
        a + b
    
    4+
      end
    
    5+
    end
    
Code
Diff
  • sum = fn a, b -> a + b end
  • 1
    sum = fn(a, b) -> a + b end
    
    2
    sum.(2,3)
    
    1+
    sum = fn a, b -> a + b end
    
Loading more items...