Creating Notes with Node.js

The first step to develop a basic app to handle notes is to create a directory to gather all the files required.

We are going to create a package.json with the command npm initAdditional, some packages as nodemon, lodash and yargs that are going to be used: npm install nodemon -g, npm install lodash –save,npm install yargs –save

Then, create three module files to add, list, read and remove files. To add:Now we can import the modules to index:

 

 

 

 

 

 

 

 

 

 

Now we can test the program by adding a title and body to a note:As well as the addingNote, the file ListingNote and ReadingNote are created:

 

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

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