Pages

Sunday, September 16, 2018

Fedora 28 : Using AdonisJs web framework.

AdonisJs is a Node.js web framework with a breath of fresh air and drizzle of elegant syntax on top of it.
We prefer developer joy and stability over anything else.
I tested today this web framework named AdonisJs with Fedora 28.
The main goal was to use MySQL with MariaDB from Fedora 28 distro.
Let's start with the installation of AdonisJs on Fedora 28:
[root@desk mythcat]# npm i --global @adonisjs/cli
/usr/bin/adonis -> /usr/lib/node_modules/@adonisjs/cli/index.js
...
+ @adonisjs/cli@4.0.7
added 406 packages from 182 contributors in 33.533s
Go to the default user:
[root@desk mythcat]# exit
exit
Create the application , I named myapp:
[mythcat@desk ~]$ adonis new myapp
    _       _             _         _     
   / \   __| | ___  _ __ (_)___    | |___ 
  / _ \ / _` |/ _ \| '_ \| / __|_  | / __|
 / ___ \ (_| | (_) | | | | \__ \ |_| \__ \
/_/   \_\__,_|\___/|_| |_|_|___/\___/|___/

  [1/6] 🔬  Requirements matched [node & npm]
  [2/6] 🔦  Ensuring project directory is clean [myapp]
  [3/6] 📥  Cloned [adonisjs/adonis-fullstack-app]
  [4/6] 📦  Dependencies installed
  [5/6] 📖  Environment variables copied [.env]
  [6/6] 🔑  Key generated [adonis key:generate]

🚀   Successfully created project
👉   Get started with the following commands
Let's test the default myapp with this commands:
$ cd myapp
$ adonis serve --dev

[mythcat@desk ~]$ cd myapp
[mythcat@desk myapp]$ adonis serve --dev

 SERVER STARTED 
> Watching files for changes...

2018-09-16T09:47:46.799Z - info: serving app on http://127.0.0.1:3333
This is the result of the running myapp on 127.0.0.1:3333 web address:
Let's see the folders and files from AdonisJS:
[mythcat@desk myapp]$ ls
ace  config    node_modules  package-lock.json  README.md  server.js
app  database  package.json  public             resources  start
The configuration for web files can be seen here:
[mythcat@desk myapp]$ vim  start/routes.js 
'use strict'

/*
|--------------------------------------------------------------------------
| Routes
|--------------------------------------------------------------------------
|
| Http routes are entry points to your web application. You can create
| routes for different URL's and bind Controller actions to them.
|
| A complete guide on routing is available here.
| http://adonisjs.com/docs/4.1/routing
|
*/

/** @type {import('@adonisjs/framework/src/Route/Manager'} */
const Route = use('Route')

Route.on('/').render('welcome')
~                                                                               
This is telling Adonis that when the root of the site is loaded, render a template/view called welcome.
That welcome template can be found in /resources/views/welcome.edge.
[mythcat@desk myapp]$ cd resources/
[mythcat@desk resources]$ ll
total 0
drwxrwxr-x. 2 mythcat mythcat 26 Sep 16 12:46 views
[mythcat@desk resources]$ cd views/
[mythcat@desk views]$ ll
total 4
-rw-rw-r--. 1 mythcat mythcat 339 Sep 16 12:46 welcome.edge
Let's see the source code of this default webpage:
[mythcat@desk views]$ vim welcome.edge 
...
For example, if you change into start/routes.js from welcome to index then you need to rename the welcome.edge to index.edge .
About css files you can make changes into public/style.css :
[mythcat@desk myapp]$ cd public/
[mythcat@desk public]$ vim  style.css


@import url('https://fonts.googleapis.com/css?family=Montserrat:300');

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: 'Montserrat', sans-serif;
  font-weight: 300;
  background-image: url("/splash.png");
  background-color: #220052;
}

* {
  margin: 0;
  padding: 0;
}
...
Using the mysql database is simple. Into Fedora 28 distro you can use mariadb, let's install it.
[mythcat@desk myapp]$ su
Password: 
[root@desk myapp]# dnf install mariadb mariadb-server
...
Complete!
[root@desk myapp]# systemctl start mariadb
[root@desk myapp]# systemctl status mariadb
● mariadb.service - MariaDB 10.2 database server
...
You need to make changes into .env file into your project folder.
[mythcat@desk myapp]$ vim .env
HOST=127.0.0.1
PORT=3333
NODE_ENV=development
APP_URL=http://${HOST}:${PORT}
CACHE_VIEWS=false
APP_KEY=xxxxxxxxxxxxxxxx
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=
DB_DATABASE=adonis
SESSION_DRIVER=cookie
HASH_DRIVER=bcrypt
~
Use this changes for mariadb:
DB_CONNECTION=mysql
Install into AdonisJs with this command:
[mythcat@desk myapp]$ adonis install mysql
  [1/1] 📦  Dependencies installed [mysql]
Use this mysql commands to create the database:
[mythcat@desk myapp]$ mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.2.17-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database adonis;
Query OK, 1 row affected (0.11 sec)

MariaDB [(none)]> exit;
Bye 
Let's test migration command for files to allow you to create and delete tables.
[mythcat@desk myapp]$ adonis migration:run
migrate: 1503248427885_user.js
migrate: 1503248427886_token.js
Database migrated successfully in 4.11 s
[mythcat@desk myapp]$ adonis make:migration jobs
> Choose an action undefined
✔ create  database/migrations/1537095058367_jobs_schema.js
Now that our database and tables have been created, I can create a model for handling jobs table and associated data.
The next tasks to follow depends by your website:

  • Creating a Model 
  • Creating a Controller 
  • User Authentication

Thursday, September 13, 2018

Fedora 28 : LibreOffice remote connection.

I wrote a tutorial about the remote connection in LibreOffice, see this article.
The main problem with LibreOffice development is the changes.
Now the feature Open remote is not working.
The bug is officially recognized and represented, see the page.
They inform us, see comment 31:
John R Mead 2017-12-17 22:43:03 UTC Well, it still doesn't work with LibreOffice Version: 6.0.0.0.beta1 (x64); I'm not providing screenshots this time since it's identical in everyway to my previous attempts. At the end of all the copy/pasting between LibreOffice and my browser to get all the relevant permissions, when I finally make the attempt to connect, I get the same message: The specified device is invalid. 

Current system configuration of potentially relevant software: 

Windows 10 Professional (x64) Version 1709 (build 16299.125) 
Java 9.0.1 
Microsoft - OneDrive version 17.25.1.0 (x64) 
LibreOffice Version: 6.0.0.0.beta1 (x64)

It's a common practice to see open-source software with bugs, most bugs are already available to users to avoid problems.
Most backup bugs are authentication and changes in development.

Monday, September 10, 2018

Fedora 28 : The Revel framework with golang.

The development team has a very effective text:
A high productivity, full-stack web framework for the Go language.
They used this words:
Revel provides routing, parameter parsing, validation, session/flash, templating, caching, job running, a testing framework, and even internationalization. I tested it yesterday and today I will show you how effective it is.
This framework is very easy to install and use it with Fedora 28.
I could say this is like django framework with the temptation style.
Let's start with a simple example into a folder created by me and named gocode:
[mythcat@desk ~]$ mkdir ~/gocode
[mythcat@desk ~]$ export GOPATH=~/gocode
[mythcat@desk ~]$ echo export GOPATH=$GOPATH >> ~/.bash_profile
[mythcat@desk ~]$ cd gocode/
[mythcat@desk gocode]$ go get github.com/revel/revel
[mythcat@desk gocode]$ ls
pkg  src
[mythcat@desk gocode]$ go get github.com/revel/cmd/revel
[mythcat@desk gocode]$ ls
bin  pkg  src
[mythcat@desk gocode]$ export PATH="$PATH:$GOPATH/bin"
[mythcat@desk gocode]$ revel helpDEBUG 19:24:09  revel  server.go:27: arguments by adding nil
~
~ revel! http://revel.github.io
~
usage: revel command [arguments]

The commands are:

    new         create a skeleton Revel application
    run         run a Revel application
    build       build a Revel application (e.g. for deployment)
    package     package a Revel application (e.g. for deployment)
    clean       clean a Revel application's temp files
    test        run all tests from the command-line
    version     displays the Revel Framework and Go version

Use "revel help [command]" for more information.
[mythcat@desk gocode]$ ls
bin  pkg  src
[mythcat@desk gocode]$ revel new myapp
DEBUG 19:38:50  revel  server.go:27: RegisterServerEngine: Registered engine 
~
~ revel! http://revel.github.io
~
Your application is ready:
   /home/mythcat/gocode/src/myapp

You can run it with:
   revel run myapp
[mythcat@desk gocode]$ revel run myapp
DEBUG 19:39:15  revel  server.go:27: RegisterServerEngine: Registered engine 
~
~ revel! http://revel.github.io
~
Trying to build with myapp (0x0,0x0)
DEBUG 19:39:15  revel module.go:152: Sorted keys  section=module keys=module.static 
...
Let's see the source code - in this case the default files: app.go and Index.html .
[mythcat@desk gocode]$ cd src/myapp/app/
[mythcat@desk app]$ ls
controllers  init.go  routes  tmp  views
[mythcat@desk app]$ cd controllers/
[mythcat@desk controllers]$ ls
app.go
[mythcat@desk controllers]$ cat app.go 
package controllers

import (
    "github.com/revel/revel"
)

type App struct {
    *revel.Controller
}

func (c App) Index() revel.Result {
    return c.Render()
}

[mythcat@desk App]$ cat Index.html 
The cat command will show the source code of Index.html file.
Let's add a golang variable named greeting to app.go and Index.html files:
[mythcat@desk controllers]$ cat app.go 
package controllers

import (
    "github.com/revel/revel"
)

type App struct {
    *revel.Controller
}

func (c App) Index() revel.Result {
    greeting := "Fedora and revel framework !"
    return c.Render(greeting)
} 
This variable greeting will will be add into file Index.html with tag p after It works!
This is result of two screenshots from start install and after I change with the variable greeting.

Thursday, August 9, 2018

Fedora 28 : Linux application with node.js and Electron packager.

Today I make a tutorial about how to use node.js and Electron packager to create cross-platform applications.
The tutorial show you how to create Windows, Linux and Mac OS cross-platform applications and can be found here.
This is result of running the linux application with Fedora 28:

Thursday, August 2, 2018

Fedora 28 : Godot example with linux .

Today I tested a simple example with the game engine named Godot version 3.0.6.
It was created on a Windows 8.1 operating system and exported as a linux application.
I moved the two files to the Fedora 28 operating system.
[mythcat@desk Godot_test_001]$ ll
total 41752
-rw-rw-r--. 1 mythcat mythcat    41092 Aug  2 18:34 Godot_test_001.pck
-rwxrwxr-x. 1 mythcat mythcat 42707653 Aug  2 18:34 Godot_test_001.x86_64
[mythcat@desk Godot_test_001]$ ./Godot_test_001.x86_64 
OpenGL ES 3.0 Renderer: Mesa DRI Intel(R) Ivybridge Desktop 
Mono: Initializing module...
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/usr/lib/mono/4.5/mscorlib.dll' directory.
The error occurred from the mono package and I fixed it with the installation using the dnf tool.
[root@desk mythcat]# dnf install mono-core.x86_64
Last metadata expiration check: 1:22:05 ago on Thu 02 Aug 2018 05:30:05 PM EEST.
Dependencies resolved.

...
Installed:
  mono-core.x86_64 4.8.0-14.fc28                 libgdiplus.x86_64 5.6-1.fc28                     
  mono-data.x86_64 4.8.0-14.fc28                 mono-data-sqlite.x86_64 4.8.0-14.fc28            
  mono-extras.x86_64 4.8.0-14.fc28               mono-mvc.x86_64 4.8.0-14.fc28                    
  mono-wcf.x86_64 4.8.0-14.fc28                  mono-web.x86_64 4.8.0-14.fc28                    
  mono-winforms.x86_64 4.8.0-14.fc28            

Complete!
Here's the final result:
[mythcat@desk Godot_test_001]$ ./Godot_test_001.x86_64 
OpenGL ES 3.0 Renderer: Mesa DRI Intel(R) Ivybridge Desktop 
Mono: Initializing module...
Mono: Runtime initialized
Mono: INITIALIZED

Wednesday, August 1, 2018

Fedora 28 : Unusual arguments for the dnf command.

Today I will introduce you in this tutorial some more unusual arguments for the dnf command.

  • first is check which package provides that file;
  • [root@desk mythcat]# dnf provides /etc/httpd/conf/httpd.conf
    Last metadata expiration check: 0:23:46 ago on Wed 01 Aug 2018 09:31:44 AM EEST.
    httpd-2.4.34-3.fc28.x86_64 : Apache HTTP Server
    Repo        : @System
    Matched from:
    Filename    : /etc/httpd/conf/httpd.conf
    
    httpd-2.4.34-3.fc28.x86_64 : Apache HTTP Server
    Repo        : updates
    Matched from:
    Filename    : /etc/httpd/conf/httpd.conf
    
    httpd-2.4.33-2.fc28.x86_64 : Apache HTTP Server
    Repo        : fedora
    Matched from:
    Filename    : /etc/httpd/conf/httpd.conf
  • get detailed information of a package can be viewed with the ‘info’ argument;
  • [root@desk mythcat]# dnf info httpd
    Last metadata expiration check: 0:29:01 ago on Wed 01 Aug 2018 09:31:44 AM EEST.
    Installed Packages
    Name         : httpd
    Version      : 2.4.34
    Release      : 3.fc28
    Arch         : x86_64
    Size         : 4.2 M
    Source       : httpd-2.4.34-3.fc28.src.rpm
    Repo         : @System
    From repo    : updates
    Summary      : Apache HTTP Server
    URL          : https://httpd.apache.org/
    License      : ASL 2.0
    Description  : The Apache HTTP Server is a powerful, efficient, and extensible
                 : web server.
  • allows us to see what has happened to our Linux system over time, and even undo, redo, or roll back a transaction;
  • [root@desk mythcat]# dnf history
    ID     | Command line             | Date and time    | Action(s)      | Altered
    -------------------------------------------------------------------------------
       178 | upgrade                  | 2018-08-01 09:33 | Update         |   27   
       177 | upgrade                  | 2018-07-31 12:54 | Update         |   11   
       176 | upgrade                  | 2018-07-30 20:43 | Update         |    1
  • take actions will be quicker with the ‘makecache’ argument
  • [root@desk mythcat]# time dnf makecache
    Last metadata expiration check: 0:34:10 ago on Wed 01 Aug 2018 09:31:44 AM EEST.
    Metadata cache created.
    
    real    0m4.529s
    user    0m1.420s
    sys    0m0.229s
  • list all packages that are currently installed on your Linux system;
  • [root@desk mythcat]# dnf list installed
    Installed Packages
    CharLS.x86_64                          1.0-16.fc28              @System         
    Field3D.x86_64                         1.7.2-10.fc28            @System         
    GConf2.x86_64                          3.2.6-20.fc28            @updates-testing
    GeoIP.x86_64                           1.6.12-3.fc28            @fedora         
    GeoIP-GeoLite-data.noarch              2018.06-1.fc28           @updates        
    ImageMagick.x86_64                     1:6.9.9.38-1.fc28        @updates-testing
    ImageMagick-c++.x86_64                 1:6.9.9.38-1.fc28        @updates-testing
    ImageMagick-libs.x86_64                1:6.9.9.38-1.fc28        @updates-testing
    LibRaw.x86_64                          0.18.13-1.fc28           @updates        
    ModemManager.x86_64                    1.6.12-3.fc28            @fedora 

Monday, June 25, 2018

Fedora 28 : Using the python module sh .

Today I test another python module named sh with python version 3.6.5 and Fedora 28.
This python module named sh is a full-fledged subprocess replacement for Python 2.6 - 3.5, PyPy and PyPy3 that allows you to call any program as if it were a function.
You can read bout this python module here.
I used dnf tool to search and install the pip tool :
[root@desk mythcat]# dnf search python3
Last metadata expiration check: 1:06:29 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
======================== Name Exactly Matched: python3 =========================
...
python3.x86_64 : Interpreter of the Python programming language
Next step is the install of python programming language:
[root@desk mythcat]# dnf install python3.x86_64 
Last metadata expiration check: 1:09:12 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
Package python3-3.6.5-1.fc28.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
...
I search the pip tool and then I install it:
[root@desk mythcat]# dnf search python3-pip
Last metadata expiration check: 1:15:18 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
====================== Name Exactly Matched: python3-pip ======================
python3-pip.noarch : A tool for installing and managing Python3 packages
...
[root@desk mythcat]# dnf install python3-pip.noarch 
Last metadata expiration check: 1:16:31 ago on Mon 25 Jun 2018 09:35:04 AM EEST.
Package python3-pip-9.0.3-2.fc28.noarch is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
...
The install of this python module into user mode:
[root@desk mythcat]# exit 
exit
...
[mythcat@desk ~]$ pip3.6 install --user sh
Requirement already satisfied: sh in /usr/lib/python3.6/site-packages
See next examples and tests I used :
[mythcat@desk ~]$ python3.6
Python 3.6.5 (default, Mar 29 2018, 18:20:46) 
[GCC 8.0.1 20180317 (Red Hat 8.0.1-0.19)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sh
>>> from sh import *
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1017, in _handle_fromlist
  File "/usr/lib/python3.6/site-packages/sh.py", line 3349, in __getattr__
    return self.__env[name]
  File "/usr/lib/python3.6/site-packages/sh.py", line 3187, in __getitem__
    Please import sh or import programs individually.")
RuntimeError: Cannot import * from sh. Please import sh or import programs individually.
...
>>> print(sh.ifconfig)
/usr/sbin/ifconfig
>>> print(sh.ifconfig())
...
>>> print(sh.ls())
...
>>> print(sh.ls("-l"))
...
>>> print(sh.uptime())
 11:25:03 up  1:52,  1 user,  load average: 1.10, 1.04, 1.40
...