Monday, April 3, 2017

archlinux - error during update (pacman) #2

Error during update:

$ pacman -Syu

...
:: Proceed with installation? [Y/n] 
(163/163) checking keys in keyring                 [#################] 100%
(163/163) checking package integrity               [#################] 100%
(163/163) loading package files                    [#################] 100%
(163/163) checking for file conflicts              [#################] 100%
error: failed to commit transaction (conflicting files)
ca-certificates-utils: /etc/ssl/certs/ca-certificates.crt exists in filesystem
Errors occurred, no packages were upgraded.


Solution:

remove /etc/ssl/certs/ca-certificates.crt e.g.:

$ mv /etc/ssl/certs/ca-certificates.crt/etc/ssl/certs/ca-certificates.bak


Good advice:

update keyrings before the full update:

$ pacman -S archlinux-keyring



References:
https://bugs.archlinux.org/task/53217

Wednesday, March 15, 2017

SAP HANA Express - XSA - XS Advanced Application Resource Files

- mta.yaml -> MTA development descriptor

Development descriptor for a multi-target application (MTA). The information in the mta.yaml file provides instructions for the MTA development and build process.


- xs-app.json -> The XS Advanced Application Router Descriptor

The application descriptor is a file that contains the configuration information used by the application router. The file is named xs-app.json and its content is formatted according to JavaScript object Notation (JSON) rules. The following example of an xs-app.json file shows the configuration for a XS application consisting of static resources and JavaScript files.




References:
https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.00/en-US/8635e0b43f6744d6b40ba247b11b352e.html
https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.00/en-US/4486ada1af824aadaf56baebc93d0256.html
https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/1.0.12/en-US/96c7545f62504d55b669010d8fb9c41e.html
https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/1.0.12/en-US/5f77e58ec01b46f6b64ee1e2afe3ead7.html

Tuesday, March 14, 2017

SAP HANA Express - XSA - NPM errors

In a fresh HANA express install, some variables must be set in order to the system download and install the NPM packages correctly.

error message:

npm ERR! 404 no such package available : jade

Some configuration must be set in di-local-npm-registry application.

Solution:

$ xs set-env di-local-npm-registry UPSTREAM_LINK http://registry.npmjs.org/
$ xs restage di-local-npm-registry
$ xs restart di-local-npm-registry


References:
https://answers.sap.com/questions/42964/hana-express-vm-tutorials-packagejson-dependencies.html
https://blogs.sap.com/2017/02/02/xs-advanced-nodejs-upstream-registry/
- https://bitbucket.org/alunde/mta_upstream_registry
https://archive.sap.com/discussions/thread/3921267

Wednesday, March 8, 2017

#1.6 Angular 2 Basics

1. Start installing the angular cli:

$ sudo npm install -g angular-cli


2. in the app directory, run the below command in order to create the angular "app" folder, which is the source for the frontend angular app:

$ ng new angular-src
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.

To disable this warning use "ng set --global warnings.packageDeprecation=false".

installing ng2
  create .editorconfig
  create README.md
  create src/app/app.component.css
  create src/app/app.component.html
  create src/app/app.component.spec.ts
  create src/app/app.component.ts
  create src/app/app.module.ts
  create src/assets/.gitkeep
  create src/environments/environment.prod.ts
  create src/environments/environment.ts
  create src/favicon.ico
  create src/index.html
  create src/main.ts
  create src/polyfills.ts
  create src/styles.css
  create src/test.ts
  create src/tsconfig.json
  create angular-cli.json
  create e2e/app.e2e-spec.ts
  create e2e/app.po.ts
  create e2e/tsconfig.json
  create .gitignore
  create karma.conf.js
  create package.json
  create protractor.conf.js
  create tslint.json
Successfully initialized git.
Installing packages for tooling via npm.

Installed packages for tooling via npm.
Project 'angular-src' successfully created.


3. in the newly created folder "angular-src" edit the file "angular-cli.json" as below:

  "apps": [
    {
      "root": "src",
      "outDir": "dist",

change "outDir" from "dist" to "../public" which is an existing directory in the root app directory;


4. Some comments on files that are generated by Angular:

a) angular-src/src/app/app.module.ts -> declaration of all modules / components / services:
components -> declaration section;
modules -> imports section;
services -> providers section;

b) angular-src/src/app/app.component.ts -> has a decorator for the component, allowing to add metadata e.g. selector (html tag), template (html), style (css) and main class for the component;


5. Components and services can be generated by angular-cli e.g.: create a separated directory for components (angular-src/src/app/components) and, once into the components directory, run the following command:

$ ng g component <component_name>

where g stands for "generate";

e.g.: create component home:
$ ng g component home
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.

To disable this warning use "ng set --global warnings.packageDeprecation=false".

installing component
  create src/app/components/home/home.component.css
  create src/app/components/home/home.component.html
  create src/app/components/home/home.component.spec.ts
  create src/app/components/home/home.component.ts
  update src/app/app.module.ts

At the same time, the app modules file is updated with the newly created component;


6. Router definition:

a) in angular-src/src/app/app.module.ts -> import RouterModule and Routes from '@angular/router';
import {RouterModule, Routes} from '@angular/router';

b) include the router modules in the imports section;
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot(appRoutes)
]

c) define appRoutes object array with all the routes, e.g.:
const appRoutes: Routes = [
  { path: "", component: HomeComponent },
  { path: "register", component: RegisterComponent },
  { path: "login", component: LoginComponent },
  { path: "dashboard", component: DashboardComponent },
  { path: "profile", component: ProfileComponent }
]

d) change app.component.html in order to add the router tag:
<h1>
  {{title}}
</h1>
<app-navbar></app-navbar>
<div class="container">
    <router-outlet></router-outlet>
</div>


7. Create the navbar component and the corresponding links to home, register and login:
<nav class="navbar navbar-default">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">MEAN App</a>
    </div>
    <div id="navbar" class="collapse navbar-collapse">
      <ul class="nav navbar-nav navbar-left">
        <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}"><a [routerLink]="['/']">Home</a></li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}"><a [routerLink]="['/login']">Login</a></li>
        <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}"><a [routerLink]="['/register']">Register</a></li>
      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>



References:
https://youtu.be/zrViDpWiNVE?list=PLillGF-RfqbZMNtaOXJQiDebNXjVapWPZ
http://getbootstrap.com/examples/starter-template/
- https://bootswatch.com/

Tuesday, February 28, 2017

#1.5 Node.js Basics - authentication + JWT

This part is focused on authentication and json web token (jwt):

#1.4 Node.js Basics - user model

Create a model for user, together with some functions to interact with the database:

1. Create /model/user.js as below:

const mongoose = require('mongoose');
const bcrypt   = require('bcryptjs');
const config   = require('../config/database');

// User Schema
const userSchema = mongoose.Schema({
    name:     { type: String },
    email:    { type: String, required: true },
    username: { type: String, required: true },
    password: { type: String, required: true }
});

const user = module.exports = mongoose.model('User', userSchema);

module.exports.getUserById = function (id, callback) {
    user.findById(id, callback)
}

module.exports.getUserByUsername = function (username, callback) {
    const query = { username: username };
    user.findOne(query, callback);
}

module.exports.addUser= function (newUser, callback) {
    bcrypt.genSalt(10, (err, salt) => {
        bcrypt.hash(newUser.password, salt, (err, hash) => {
            if(err) throw err;
            newUser.password = hash;
            newUser.save(callback);
        })
    })
}

Described above is the DB schema (userSchema), two functions to query user data from DB and one to add user data to DB.

#1.3 Node.js Basics - using npm and angular cli

Prerequisites: node.js, npm

1. Create a directory for the project e.g.:
$ mkdir /Projects/meanapp
$ cd  /Projects/meanapp

Monday, February 27, 2017

#1.2 Angular2 Basics - start cloning angular quickstart

Prerequisites: node.js, npm

In the arch linux shell:

1. create a directory for the project e.g. /Projects

#1.1 MongoDB basics

1. Installing on archLinux: Install mongodb from official repositories:

# pacman -S mongodb

Monday, January 30, 2017

Windows 10 slow initialization | high disk / cpu / memory utilization

I've been using Windows 10 since mid-2016 and it was working fine, until some day after a system update around dec-16 the initialization would take forever. I mean around 5 to 10 minutes to start up Windows. The system initializes with black screen and the mouse cursor active, but need to wait all the mentioned time to load the desktop and enable the system for use. I am running a core-i7 4770 with 16gb RAM and SSD, so the initialization should take a few seconds.

Apparently the issue is caused by the "Microsoft Compatibility Telemetry" app / service which takes all computer resources to do some dirt work and send data to Microsoft.

Sunday, January 29, 2017

node.js and express for dummies (1)

I've been looking for tutorials on the internet about node.js for beginners. The very basic steps in order to start doing something like "Hello World" are described below. Note that I am a completely dummy in this subject, so maybe there is something missing. A reminder to myself: please do update this post in the future.

Working on Arch Linux

Sunday, January 8, 2017

archlinux - error during update (pacman)

ERROR #1:

# sudo pacman -Syu
(...)
error: jasper: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/jasper-2.0.10-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: krb5: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/krb5-1.13.7-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: libpsl: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/libpsl-0.16.1-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: gegl: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/gegl-0.3.8-3-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: libwmf: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/libwmf-0.2.8.4-14-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: gimp: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/gimp-2.8.18-4-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: vala: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/vala-0.34.4-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: libraw: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/libraw-0.17.2-3-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: smplayer: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/smplayer-16.11.0-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: wget: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/wget-1.18-3-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] 
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.

Solution: 

# sudo pacman -S archlinux-keyring
resolving dependencies...
looking for conflicting packages...

Packages (1) archlinux-keyring-20170104-1

Total Installed Size:  0.81 MiB
Net Upgrade Size:      0.03 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                     [######################] 100%
(1/1) checking package integrity                   [######################] 100%
(1/1) loading package files                        [######################] 100%
(1/1) checking for file conflicts                  [######################] 100%
(1/1) checking available disk space                [######################] 100%
:: Processing package changes...
(1/1) upgrading archlinux-keyring                  [######################] 100%
==> Appending keys from archlinux.gpg...
==> Locally signing trusted keys in keyring...
  -> Locally signing key 0E8B644079F599DFC1DDC3973348882F6AC6A4C2...
  -> Locally signing key 684148BB25B49E986A4944C55184252D824B18E8...
  -> Locally signing key 91FFE0700E80619CEB73235CA88E23E377514E00...
  -> Locally signing key 44D4A033AC140143927397D47EFD567D4C7EA887...
  -> Locally signing key 27FFC4769E19F096D41D9265A04F9397CDFD6BB0...
  -> Locally signing key AB19265E5D7D20687D303246BA1DFB64FFF979E7...
==> Importing owner trust values...
==> Disabling revoked keys in keyring...
  -> Disabling key F5A361A3A13554B85E57DDDAAF7EF7873CFD4BB6...
  -> Disabling key 7FA647CD89891DEDC060287BB9113D1ED21E1A55...
  -> Disabling key D4DE5ABDE2A7287644EAC7E36D1A9E70E19DAA50...
  -> Disabling key BC1FBE4D2826A0B51E47ED62E2539214C6C11350...
  -> Disabling key 9515D8A8EAB88E49BB65EDBCE6B456CAF15447D5...
  -> Disabling key 4A8B17E20B88ACA61860009B5CED81B7C2E5C0D2...
  -> Disabling key 63F395DE2D6398BBE458F281F2DBB4931985A992...
  -> Disabling key 0B20CA1931F5DA3A70D0F8D2EA6836E1AB441196...
  -> Disabling key 8F76BEEA0289F9E1D3E229C05F946DED983D4366...
  -> Disabling key 66BD74A036D522F51DD70A3C7F2A16726521E06D...
  -> Disabling key 81D7F8241DB38BC759C80FCE3A726C6170E80477...
  -> Disabling key E7210A59715F6940CF9A4E36A001876699AD6E84...
==> Updating trust database...
gpg: next trustdb check due at 2017-09-07



ERROR #2:

# sudo pacman -Syu
(...)
error: failed to commit transaction (conflicting files)
ttf-dejavu: /etc/fonts/conf.d/20-unhint-small-dejavu-sans-mono.conf exists in filesystem
ttf-dejavu: /etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf exists in filesystem
ttf-dejavu: /etc/fonts/conf.d/20-unhint-small-dejavu-serif.conf exists in filesystem
ttf-dejavu: /etc/fonts/conf.d/57-dejavu-sans-mono.conf exists in filesystem
ttf-dejavu: /etc/fonts/conf.d/57-dejavu-sans.conf exists in filesystem
ttf-dejavu: /etc/fonts/conf.d/57-dejavu-serif.conf exists in filesystem
Errors occurred, no packages were upgraded.

Solution: 

# sudo pacman -S --force ttf-dejavu
resolving dependencies...
looking for conflicting packages...

Packages (1) ttf-dejavu-2.37-1

Total Installed Size:  9.75 MiB
Net Upgrade Size:      0.57 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                     [######################] 100%
(1/1) checking package integrity                   [######################] 100%
(1/1) loading package files                        [######################] 100%
(1/1) checking for file conflicts                  [######################] 100%
(1/1) checking available disk space                [######################] 100%
:: Processing package changes...
(1/1) upgrading ttf-dejavu                         [######################] 100%


References:

Thursday, January 5, 2017

SAP HANA Express - XS Advanced Model - User Provided Service to connect to non-HDI DB schemas

Annotation 2017-01-05: Nothing important happened today. Just the average dinner with fried pork loin steak, potatoes and baked mushrooms seasoned with black pepper, garlic, salt and butter. As always, I ate a lot!

HANA - in order to access a table within another container, or connect to existing database schemas which aren’t managed by HDI (this would be the case for replicated schemas or ERP ABAP schemas for instance) - need to create the User Provided Service (xs cups) manually from the command line;

Sample pass parameters as JSON to create a service non-interactively:

# xs cups CROSS_SCHEMA_SFLIGHT -p "{\"host\":\"<host>\",\"port\":\"30013\",\"user\":\"<user>\",\"password\":\"<pwd>\",\"driver\":\"com.sap.db.jdbc.Driver\",\"tags\":[\"hana\"] , \"schema\" : \"SFLIGHT\" }"

Then modify the requires section of the core-db module in the mta.yaml:

   - name: CrossSchemaService
     group: SERVICE_REPLACEMENTS
     properties:
       key: hdi-sflight-service
       service: ~{sflight-service-name} 


Then modify the resources section of the mta.yaml:

  - name: CrossSchemaService
    type: org.cloudfoundry.existing-service
    parameters:
      service-name: CROSS_SCHEMA_SFLIGHT "same service name created in the command line
    properties:
      sflight-service-name: ${service-name}


Note that indentation is important when editing the mta.yaml !!!

Then create a new folder called cfg under the core-db folder. Create a new file in the cfg
folder called SFLIGHT.hdbgrants with the following code:

{
  "hdi-sflight-service": {
    "object_owner" : {
      "schema_privileges":[ 
        { 
          "reference":"SFLIGHT",
          "privileges_with_grant_option":["SELECT", "SELECT METADATA"]
        }
      ]
    },
    "application_user" : {
      "schema_privileges":[ 
        { 
          "reference":"SFLIGHT",
          "privileges_with_grant_option":["SELECT", "SELECT METADATA"]
        }
      ]
    }
  }
}


Then create a new file called sflight.hdbsynonym in the data folder within the src folder. Enter the corresponding Synonym, Table and Schema name. As a result the tables will be available to be consumed within CDS  artifacts.

The above information was extracted from the HANA5 exercises, and it is also available in the Developer Guide for SAP HANA XSA Model (SP12).


Wednesday, January 4, 2017

Happy new year

Just started studying again, about to start a "XS Advanced Application Project". As described in the developer guide, "The end-to-end process of developing an application that you want to deploy on SAP HANA is straight forward". Let's see how straight forward is the process, it must probably be not so straight forward for dummies (beginners) like myself.


I tried beer battered cod fish for dinner and the result was satisfactory. Followed the foodnetwork recipe today. Next time I'll try the allrecipes recipe.