Accessing to a Server in Node JS

This time we are going to connect  to a server from the client side using NodeJS. Let’s use the http port 8088 to print the “Hello World” message:To print a content of a html file with a successful status: 200 and the port 3000 on http:GNOMEserver

Posted in τεχνολογια :: Technology | Leave a comment

Using Node.js Packages Manager (NPM)

NPM is a package manager for Node.js packages, or modules; it hosts thousands of free packages to download and use.

To begin with, npm init creates our package.json to manage packages that we are going to install such as lodash, mongo, nodemon, etc. Now, we can install the lodash module and export it whenever the index.js calls Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. Lodash’s modular methods are great for iterating arrays, objects, & strings; manipulating & testing value and creating composite functions. We were now able to concatenate first and last to formulate a full name of each user, to finally filter by age greater than 23:Another useful module that can be installed with NPM is Nodemon which monitor for any changes in your source and automatically restart your server.nodemon

Now we can run nodemon on index.js to check the information about the file:

Posted in τεχνολογια :: Technology | Tagged , , , , , , , , , , , , | Leave a comment

Coordinating a FWD event

FWD stands for Fedora Women’s Day and our main goals is to attract more women in the FLOSS world, by using Fedora and GNOME.

As one of my duties in my country is teaching using Linux and I realise that only few women are interested in IT and if I found them… fewers are interested in using IT Linux.  In these pictures of my groups at UNI,  please see how much women we have:

even if I had interact with other researchers groups at UNI, I only found two or three more

Thanks to the invitation to other universities as a speaker, I was be able to contact with other IT enthusiactic, smart and pretty women students. And, after many efforts in months, we are going to present some work we got with Fedora and GNOME, and prove to others that we can do work in IT, using these Linux tecnologies:

Thanks to the Fedora Diversity Team to trust me the organization of the event in Peru, and special thanks to Chhavi for her patient in coordinating the design 🙂

The event is programmed to happen on September 30th at 08:00 am at PUCP LabV207, including a coffee break sponsored by Fedora. I am glad that so far, we have 32 going and 113 interested people in the event 🙂

Thanks to all people of the local community who are helping me to spread the event as wellThanks Giohanny, Solanch, Lizbeth, Azul, Sheyla, Chhavi and Geny for this! 😀

Posted in FEDORA, GNOME | Tagged , , , , , , , , , | Leave a comment

Writing Node.js Modules

There are crucial reasons to use JS modules such as Maintainability, Namespacing and Reusability, among others benefits.

I consider the hello greetings as a good start to understand how modules work. Write a module called hello.js to print a message that define the beginning of the hello.js module and to export a greeting by writing the reserved words module.exports. Then write a file called index.js to invoke the module required with its path. It can be a relative path as it is shown:Improving our hello.js module, it can accept any name to make a greeting:Names are accepted even though a number would have been instead of “Tux”. A common JS module validates information by checking the type of the parameter in a function. It can be written in the same hello.js file as follow:We are defining two modules in the hello.js file, one to print the greeting and the other module to validate the type of the name entered, in case we set the name as number 200, a message of “Please enter a valid name” is shown inmediately.

And because writing in all caps is considered to be shouting, we can create another module to convert the name in the message all in lowercase if the input was written in uppercase. Another file “lower.js” is used this time to export it into the index.js file:jsmodules2

Posted in τεχνολογια :: Technology | Leave a comment

GTK, Python, WebKit and Latex Workshops on Fedora 26

This afternoon, we did two workshops at PUCP, one to present and code in GTK and the other to work with Latex, each one lasted an hour. Thanks to the organizers of INFOSOFT 2017 for the opportunity to share free Software tools to people. This event was free to everyone and we did a volunteer job as a group to promote Fedora and the GNOMe project in our local community. Special thanks to Toto, Brunito, Solanch and Fabian Orccon for their support! It was a coincidence that at the same time (4pm – 6pm), our Peru football team played against ecuador to define if Peru can go to Rusia championship or not :p

The Latex workshop ran first, it was accomplish the spaces format on paragraphs, as well as the font format such as color, sizes and forms, following by lists, adding images and use of templates. We prize the two winners (those who first finish the entire workshop) with two t-shirts of INFOSOFT, stickers and ballons 🙂

In a raw, some attendances dare to code with GTK. I explained what GTK is, what projects were development with GTK and the advantages as multiplatform tool for developers.

We only had the following widgets: window, webview, scrolled_bar, and the headerbar, with their corresponding properties. However attendances were tahnkful for the accomplish they got in only one hour. They did not use Fedora nor GNOMe before!

Some of the pictures of the workshop! Thanks to Corrado Daly, Walter Seama and Felipe Solari for their support as authorities PUCP and thanks to the AAII for the organization, everything went smoothly and well prepared! Congrats! 🙂

Posted in FEDORA, GNOME | Tagged , , , , , , , , , , , , , , | 2 Comments

Working with Buttons and Labels with GTK Python

We had another meeting with the GNOME + Fedora local group in Lima, Peru to prepare ourselves in coding to offer better IT Linux workshops and conferences.This time we: Toto, Solanch, Brunito, Martin and me, helped another “new guys” (newbies in Linux) and we installed Fedora and GNOME(dual boot).This time, we decided to work in pairs to accomplish some tasks and publish them on our blogs. My couple this time was Toto, and we worked on GTK with Python. Since we are starting in this new endeavour, we are going to prepare material for separate widgets. This time we worked with Labels and Buttons.

The consensus is that any time you click on the name of your favorite person in the team, a message about this person will be displayed. This is shown for TotoNow for Bruni Bruni, then for Solanch, and so on for Martin, and Julitas:)Any time I had an error, the voice and lessons of Felipe Borges came to my mind. Thanks to him, I was able to start with GTK 🙂

Posted in FEDORA, GNOME | Tagged , , , , , , , , , , , | 2 Comments

Introduction to Node JS

Installing NodeJS on Fedora 26

Follow this tutorial to transfer the package to our local repository:Then install nodejs with dnf as follow: Printing Hello World

Our first program is called hello.js. We are going to print the original label “Hello World” using the reserve words: console.log.

Assigning variables

We can assign variables with var or let. For security issues: let do not use the variable beyond its scope as var does. The standard since 2015 is the use of let, so throughout this tutorial we are going to use let. We can assign numbers as well as strings, then differentiate the operator of comparison such as “==” and “===”, that check the content and the type.

Constructing objects

Properties of an object can be also be code as well as its methods. In this case, we are going to define an object called student whose has a name, lastname, age and an action called say, to claim to his professor he did the homework.Creating Functions

js4There was a convention to use in ES5 the reserved word function to declare a function such suma in this case which sum two numbers a and b.In ES6, the standard for an simple arrow function defines the parameter of a function with = and the definition of the function is followed by the => structure.

Working with Loops

The use of loops is the similar as the way you use them in other programming languages as C or Python. In this case we are reusing the addOne function, previously declared to add a unit of a number. Initialize the counter i and then working with it while it is lower than 5. Whenever i is equal to 3, print the result of addOne on i.

Playing with Arrays

Starting by declaring our array, arr defines a list of elements, no matter the type of each element. One way to print each element of arr is by using an index “i” that is assigned to 0 and loop until getting the length of the array (in this case from 0 to 2), to finally print each i position of arr. Another way is by defining a variable of the array. In this case fruit is part of the arr and when it is used inside a for loop, each word that is inside arr can be printed. key is used as index of the array, and printed:

In case you need to be aware of the use of indexes of an array, you can print the items with its respectively index as it is shown in a list of fruits as follow:List of users and the forEach use 

There are two ways to declare a list of users. The first one is by declaring a list of users separated by commas and each user has its own attributes such as id and name. The other way is by assigning each user a,b, and c with its properties or attributes and then gathered together, in this case the list is called users.

To use forEach, there are another three ways to do so. Depending of the complexity of the code when you will have more lines of code, you can choose by 1) creating a function to getPeriod of the user then call it while the forEach is used. 2) Defining a function for user inside the forEach structure. 3) Use the => to apply an action on a specific object.

Filter and maps

We are defining < 3 and it will filter the values of 0,1, and 2. Since we only have id 1 and 2, the length of SomeUsers is going to be 2. Map will work on each element of the array, so the length of each element of the array is going to be shown. Julita includes a blank: 7!


Callbacks or High order Functions are defining as parameter of another function based on the functional paradigm. In this introduction we have used them to call the elements and index of an array 🙂

Mixing the code

Now suppose we have some students enrolled in their semesters and we need to count how many students are enrolled on each semester. Here we go:

Posted in Education, τεχνολογια :: Technology | Tagged , , , , | Leave a comment