diumenge, 11 de febrer del 2018



Little’s law

number of threads = (Requests/sec) X (ResponseTime in secs)

dissabte, 3 de febrer del 2018

ssh keys


From my laptop I will create the keys and I will expose this key to the server I want to connect using keys. Additionally we get rid of passwords , even for my user as sudo user.

jordi@LAPTOP-ELFAQNCG MINGW64 ~/.ssh
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/jordi/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/jordi/.ssh/id_rsa.
Your public key has been saved in /c/Users/jordi/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ljvEge2a/MwKp8OK73ai27v7zRFiPyPmMxJCpw0nJLU jordi@LAPTOP-ELFAQNCG
The key's randomart image is:
+---[RSA 2048]----+
| ..              |
|.. .   o         |
|o E   . o        |
| + o   o o       |
|. B o . S        |
|...o + * .       |
| . o+ X o        |
| o+o*B B .       |
|+*OX+++.+        |
+----[SHA256]-----+

jordi@LAPTOP-ELFAQNCG MINGW64 ~/.ssh
$ ssh-copy-id jordi@localhost
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/jordi/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
no such identity: /c/Users/jordi/.ssh/keys/id_rsa.pub: No such file or directory
jordi@localhost's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'jordi@localhost'"
and check to make sure that only the key(s) you wanted were added

jordi@LAPTOP-ELFAQNCG MINGW64 ~/.ssh
$ cat config
Host localhost
 Hostname localhost
 IdentityFile ~/.ssh/id_rsa
.

jordi@LAPTOP-ELFAQNCG MINGW64 ~/.ssh
$ ssh localhost
Last login: Sat Feb  3 17:27:47 2018 from gateway
[jordi@localhost ~]$

At centos to avoid password for instance to avoid pas to do sudo

/etc/ssh/sshd_config
PasswordAuthentication no

addl to the bototn
 sudo visudo
jordi ALL=(ALL) NOPASSWD: ALL

dilluns, 1 de gener del 2018

RAD in java


Some tools to rapidly create a java/groovy application  or RAD applications 

Jeddict

Grails

Spring Roo

JHipster

dissabte, 9 de desembre del 2017


Configuration of the CentOS 7 to be accesible the deamon from outside

Stop Docker

[root@localhost jordi]# systemctl stop docker

[root@localhost jordi]# cat /lib/systemd/system/docker.service

look at the

ExecStart=/usr/bin/dockerd

It is risky touch direcly the file direcly there is a edit utility in linux services

systemctl edit docker

[Service]
ExecStart=
 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

 finally start docker

[root@localhost jordi]# systemctl start docker
[root@localhost jordi]# systemctl restart docker
[root@localhost jordi]# curl http://localhost:2375 {"message":"page not found"}
[root@localhost jordi]# docker run ubuntu echo "helo world" helo world


Remember set up the firewall, A rapid to way this issue around is disable it

[root@localhost jordi]# systemctl disable firewalld

dimecres, 6 de desembre del 2017

Tomcat embed with anotated Servlet

Recently I have playing in with the Tomcat embed version. Currently Spring Boot gives a fancy, easy and rapid creation of the Main class invoking a instanting a Tomcat server. However there is a lack of official information that it makes me doubt about of readiness for production. I belive that the classic war and deployment it is going to be safer in the future and it of course much more portable . But an embeded version can have a futture for testin. I will chose war solution for cloud PaaS envirotments or container solutions such us Cloud Foundry unless Apache will decide to publich formal and clear documentation. Spring give us a OSGI version which wrap tomcat, this seeems be valid for production but Spring is Spring and I personally hate it because they reinvent the heel constantly, I lke JEE a littel bit more but my feeling is that you will never be safe either Spring nor JEE.

It is my intention to do the same test but in a JEE cointainer like Payara or Payara-micro which give us much better documentation.

Having said that. Here is the issues or poblems that I found. My goal was instanciate a Tomcat with a anotated Servlet with no web.xml and no adding explicti Servlet at all. Remember Servlet 3.0 support is a must and tomcat +7 is necessary.

I built the solution using gradle but only with java plugin, the first issue was find out the exacly dependences.

The dependeces list are in the build.gradle but is intersted notice that not all the tomcat versions worked. Also be carefull in that you maven or gradle include the anotations solution for Tomcat otherwise you can face issues.


    compile  "org.apache.tomcat:tomcat-catalina:$tomcatVersion"
    compile  "org.apache.tomcat:tomcat-util:$tomcatVersion"
    compile  "org.apache.tomcat:tomcat-jasper:$tomcatVersion"
    compile  "org.apache.tomcat:tomcat-jasper-el:$tomcatVersion" 
    compile  "org.apache.tomcat:tomcat-jsp-api:$tomcatVersion"
    compile  "org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion"
    compile  "org.apache.tomcat.embed:tomcat-embed-logging-juli:$tomcatVersion"
    compile  "org.apache.tomcat.embed:tomcat-embed-jasper:$tomcatVersion"

To be the Servlet reconzied your tomcat classpath must have the class but also the context must have the access to the servlet.class file. The easy and standart way to achieve this is include the class inside of jar file and execute it using java -jar my.jar along with all the dependences uncompress in the same jar file.

To achieve this in gradle I used the shadow gradle plugin, in Maven you can achieve the same with the maven-assembly-plugin

to run the sample the sources are in  https://github.com/jordiesc/java/tree/master/embedtomcat/JavaTomcatEmbed

$ gradle build shadowJar
$ cd build/libs
$ java -jar GroovyTomcatEmbed-all.jar

https://github.com/jordiesc/java/tree/master/embedtomcat/GroovyTomcatEmbed

Moreover you will see two versions of the project. they are almost identical apart form some details. The most important is the groovy incompatibility with Java annotations. where you must to turn curly bracktest {} into [] otherwishe the compiler will interpret a Groovy Clousre

The Java way

@WebServlet(
    name = "dataServlet",
    urlPatterns = {"/datajava"}
)

The Groovy way

@WebServlet(
    name = "dataServlet",
    urlPatterns = ["/datagroovy"]
)

just run http://localhost:8080/datajava or http://localhost:8080/datagroovy

diumenge, 12 de novembre del 2017

CSS POSITON.

STATIC. es el posicionamiento por defecto del navegador poniendo los elementos segun aparecen en el html, dom. es como si no hubiera posicionamiento. si se pone static el navegador no hace caso de los left,right,top, botton.

RELATIVE el navegador conserva el espacio que habia despues de moverlo. los porcentages solo funcionan si esta el heigh del padre. Es inportante saber que el espacio dejado despues de desplazarse continuara reservado
ABSOLUTE. los elemenos se posicionan en base a su inmediato padre , posicionado, o sea que tiene posiciones relative,absolute o fixed. El espacio no es reservado.
El ancho de un elemento absolute depende de su contenido.

FIXED. como absoluta no reserva la posicion, se ajusta al contenido las cordenatdas se calculan segun el navegador o ventana asi que  nunca se escrolla. los elementos fixed quedan fijos pero se salen del flujo de colocacion.

Posicionamiento por ejes

Siempre son posiciones desplazadas desde el margen hacia adentro. Por ejemplo top 2px moviera el elemento desde el top hacia el centro o sea hacia abajo

Solo puede haber un posicionamiento vertical y uno horizonal, css solo toma uno si hay varios.

Horizontal left, right
Vertical -> top, botton

3 dimension- z-index

MARGIN collapse.

Los top and bootion margin colapsan. con elementos posicionados absoluto no colapsan https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing

dilluns, 6 de novembre del 2017


Groovy con Gradle

Hay una manera facil de ejecutar Groovy scripts sin llegar a instalar Groovy si se tiee Gradle

$ gradle init

Genera un proyecto gradle. El fichero build.gradle

task inicio{}

println "hola mundo"
h

con el comando gradle inicio. se vera la siguiente salida

$ gradle inicio
hola mundo
:inicio UP-TO-DATE

BUILD SUCCESSFUL in 1s


task inicio{}

def lista = ["uno","dos",3]

lista.forEach {
println it
}
produce

$ gradle inicio
uno
dis
3
:inicio UP-TO-DATE

BUILD SUCCESSFUL in 1s