martes, 12 de diciembre de 2017

SAP can help you learn NodeJS,Angular and Microservices thanks to YAAS.io!

Another year is almost gone, and everybody is getting ready for the holidays, which usually means traveling. Having to wait in airports and stations is the perfect excuse for getting a book. In my case, I decide to get this book Manning | Node.js in Action, Second Edition.

If you are not into technical books, here is a list of great books (by Bill Gates) with deeper topics.

As with any development platform, one of the first questions one expects to answer is how to organise your code; for small developments this is trivial, but for medium to big developments, this can be a decisive factor in the quality and speed of development.

The book and the offi cial NodeJS documentation has clear ideas of how you should organise your code using modules. But if you are a newbie to NodeJS (like myself) maybe bigger and more complex examples will help you digest the concept.

It would also be helpful to see a microservice-driven implementation in real life, and better still with a fancy Angular front end.

Go to www.yaas.io! YaaS is a microservices ecosystem helping businesses to rapidly expand and build new, highly flexible solutions, and it is powered by SAP Hybris.

With this commands:

git clone https://github.com/SAP/yaas-storefront.git
cd yaas-storefront/
node install

You can get the source code of a full blown NodeJS applications based on microservices that uses Angular. 

You can have this application running in under 10 minutes, and easily enhance it.

For more details check SAP documentation: https://www.sap.com/developer/tutorials/yaas-download-run-default-storefront.html and other recommended reads:

YaaS Bites: First Steps

YaaS Bites: The essentials


Happy holidays!

miércoles, 9 de agosto de 2017

Solving a simple linear regression using TensorFlow

On 2014 I blogged about how Google is currently leading big data and machine learning world. Since then, they have been busy and one of their latest creations is TensorFlow.

Using SAP products has paid for my salary for the last 15 years, and when I learned that SAP is using Google's TensorFlow, I thought I should start learning more about it and see what the fuzz is all about.

In this blog post, I will be talking about:
  • Linear regression
  • Machine Learning
  • Programming languages
  • TensorFlow
You have been warned!

Let's start with a simple linear regression problem. We have the following table that contains the age and the weight of a certain animal.

Age
Weight
1
2,00
2
3,10
3
4,15
4
5,40
6
7,00

Using linear regression, I want to find an equation where I can input a new value of age, for example, 7 and it will predict the corresponding weight.

Using the explanation from this article, the equation for linear regression is: y = a + bx. And the equations for a and b are:



In our case, x is the age and y is the weight. Applying the above formulas, a = 1,09324324324324 and  b = 1,01148648648649.

Applying the linear regression formula on the original data, it predicts the following results:

Age (x)
Weight (y)
Predicted weight (y)
1
2,00
2,10472972972973
2
3,10
3,11621621621621
3
4,15
4,1277027027027
4
5,40
5,13918918918919
6
7,00
7,16216216216216
7

8,17364864864865

For the age of 7, the predicted weight will be 8,17.

Now let's do the same using TensorFlow.

The instructions to install and configure TensorFlow can be found here.

The code in TensorFlow looks like this:

import numpy as np
import tensorflow as tf

# Model parametersb = tf.Variable([.3], dtype=tf.float32)
a = tf.Variable([-.3], dtype=tf.float32)

# Model input and outputx = tf.placeholder(tf.float32)
linear_model = a + b * x
y = tf.placeholder(tf.float32)

# lossloss = tf.reduce_sum(tf.square(linear_model - y)) # sum of the squares# optimizeroptimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)

# training datax_train = [1,2,3,4,6]
y_train = [2,3.10,4.15,5.40,7]

# training loopinit = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init) # reset values to wrong
for i in range(1000):
  sess.run(train, {x:x_train, y:y_train})

# evaluate training accuracycurr_W, curr_b, curr_loss = sess.run([a, b, loss], {x:x_train, y:y_train})
print("a: %s b: %s loss: %s"%(curr_W, curr_b, curr_loss))

And the output is:
a: [ 1.09324002] b: [ 1.01148736] loss: 0.106047

The same values as in the manual calculation.

Now I will go through the main parts of the code.

In these lines, we pass the original data, in machine learning terminology, this is called "training the model":

x_train = [1,2,3,4,6]
y_train = [2,3.10,4.15,5.40,7]

In these lines we run the model:

sess = tf.Session()
sess.run(init) 
for i in range(1000):
  sess.run(train, {x:x_train, y:y_train})

If you need more details about getting started with TensorFlow try this link: https://www.tensorflow.org/get_started/get_started


My next blog post will be about loading data from a SAP BW source to TensorFlow. In the meantime go ahead and experiment with TensorFlow.


Cheers!


sábado, 14 de enero de 2017

4 metas de seguridad digital que puedes implementar este 2017

¡Hola!

Solo 14 días han pasado desde que comenzó el 2017 y ya dos amigos míos han sido víctimas de accesos no autorizados a sus cuentas en linea: una amiga, a su cuenta de Facebook y el otro, a su cuenta de Skype.

Aunque nunca hayas pensado en tu seguridad digital o tal vez, ya lleves un tiempo pensando en tomar ciertas acciones; este comienzo de año es las excusa perfecta para hacerlo.

El pensar en tomar acciones para protegerte puede parecer abrumador y llevarte a abandonar el intento. No hay dudas que tomar las riendas de tu seguridad te va a generar trabajo extra; por eso voy a intentar mostrarte algunas medidas que exigen poco de esfuerzo pero generan mucho valor, el equivalente a "en vez de dejar tu bicicleta simplemente apoyada contra un árbol, asegurarla".

Estos son mis consejos:

Activen la autenticación de 2 pasos, también conocidos como aprobaciones de inicio de sesión

Esta medida que usualmente requiere que ingreses tu password y además, ciertos códigos que son enviados o generados en tu teléfono, te protege en el caso de que tu password sea obtenido por terceras personas.

No todos los servicios ofrecen esta opción, pero la mayoría lo hace, aunque los nombres pueden cambiar. Por ejemplo, en Twitter se llama "Verificación de inicio de sesión", y en Facebook es "Autorización de inicio de sesión".

Estos servicios no generan molestias en el día a día porque tienes la opción de marcar tus dispositivos personales (teléfono, PC) como confiables, y pare estos no necesitarás el código adicional. Claro que se pueden volver un poco molestos cuando estas apurado en iniciar sesión en un dispositivo que nunca antes has usado, o estas en un lugar donde no hay señal para recibir los códigos.

Aquí las instrucciones para los sitios más usados, te recomiendo comenzar por los sitios que tienen tu información financiera, por ejemplo Amazon:

Amazon -> ver aquí.    Facebook -> ver aquí.  Gmail -> ver aquí. 

Usen un administrador de contraseñas

Todos tenemos un montón de cuentas en línea, y la idea de catalogarlas, cambiar las contraseñas de manera regular, usar contraseñas distintas para cada una de ellas, es enloquecedora. Precisamente por eso es que necesitas un administrador de contraseñas. Lo interesante de usar un administrador de contraseñas es que, una vez haya pasado por el proceso de alimentarlo hará tu vida más simple. No tendrás, nunca más, que pasar por el proceso de "olvidé mi contraseña" cada  vez que quieras acceder un servicio que no accedes con frecuencia o sentarte a pensar qué poner como contraseña.

Aquí hay una lista de los mejores administrador de contraseñas pagos, y también existen algunos gratuitos.

Después de instalado, añade tus cuentas más usadas, y veras que en un par de semanas, con el uso regular de las otras cuentas, estas se añadirán automáticamente cada vez que inicies sesión.

Los administradores de contraseñas no son perfectos. Estos centralizan todos tus datos, y es posible que las compañías que los proveen sean infiltradas. Ya ha ocurrido antes.

Al menos que estés dispuesto a invertir mucho de tu tiempo en una estrategia, elaborada por ti mismo, para administrar tus contraseñas, los administradores de contraseñas son una manera viable de tener tus contraseñas bajo control. ¡Haz que el 2017 sea el año en que comenzaste a usar un administrador de contraseñas!

Realicen copias de seguridad periódicamente

Puedes hacer tus copias de seguridad en dispositivos externos (discos duros externos, flashs, etc.), o en servicios en la nube, o en ambos.

Las herramientas que aconsejo más abajo cifran tus datos antes de moverlos a los dispositivos externos o a la nube. Esto es muy importante en caso de que roben tu dispositivo externo, o el servicio en la nube se vea comprometido. Dado que tu información esta cifrada, no podrán verla.

Los servicios CrashPlan and Backblaze son algunas de mis recomendaciones. CrashPlan realiza tus copias de seguridad automáticamente a dispositivos externos y a la nube.

Aprendan a usar una VPN

Cuando estas conectado al internet, la VPN crea un canal de comunicación seguro entre tu dispositivo y un servidor seguro, para evitar el espionaje de la información en los lugares que visitas en internet. El uso de una VPN son casi obligatorio si sos alguien que se conecta a redes WiFi públicas. Una advertencia: el uso de una VPN reduce la velocidad de tu internet.

Uno de mis servicios de VPN favoritos es Freedome.


Haz que la seguridad digital no sea parte de tu ya extensa lista de preocupaciones diarias y sigue estos simples cuatro consejos.