Author Archives: remkohdev

Ionic2: if … else … template blocks in Angular2

Angular2 supported an if-condition via the *ngIf directive.

<div *ngIf="edit == false">
VIEW
</div>
<div *ngIf="edit == true">
EDIT
</div>

Since Angular2 v4, the ngIf directive was extended with an ‘then.. else..’ syntax, in which you can reference the identifier of the HTML tags to include.

<div *ngIf="edit; then editDiv else viewDiv"></div>
<ng-template #editDiv>
EDIT
</ng-template>
<ng-template #viewDiv>
VIEW
</ng-template>

In the TypeScript component, then in the control the ‘edit’ boolean variable.

I use the ‘if.. then.. else..’ syntax for instance to display a detail page of an object in view (Read) or edit (Create/Update) form, and adding a Delete option to the view modus to complete a CRUD option. This simplifies my application development, imo, cause now the navigation in my application is mostly from List to Detail pages.

See also: NgIf Else lands in Angular 2.x+/4.0, Ashish Singh (Dec 18, 2016)

The Sommelier

The sommelier was a light-black hispanic man in his mid-twenties, perfectly mannered and composed, quick to react to my teasing wit, while at the same time leaving no trace of composition in his smile, displaying an honest exuberance. The sommelier had been held up in the wine cellar while we picked our courses from the menu and had inquired for his advice on the wine pairing. He stood lightly stooped over our table, one hand behind his back and pointed with his hand, extended in a straight angle from his shoulder, at the wine choice, an Austrian Grüner Veltliner by Hirsch from 2013, that paired well with the Spanish octopus and the Japanese hamachi.
“You got locked up in the wine cellar by your co-workers, it seemed?”
“They tend to do that, yes,” he answered with a genuine and gentle smile.
“The Château de Pressac, Grand Cru Classé, from Saint-Émilion is a French wine with a very dark hue and berry that pairs excellent with the Wagyu Beef.”
“Excellent, I trust you.”
As the sommelier walked off, one of the middle-aged Indian backwaiters walked over, holding a dark wood woven breadbasket in front of his pelvis and a silver bread tongs in his right hand hovering above the whole grain, mini bread rolls and elongated berry bread sticks, ready to grasp a single roll with his tongs and transfer it to our plates.
“No, thank you.”
We had gracefully declined already at least 3 times prior.
Immediately following the bread runner, sensing another window of opportunity to prove his value, came the water runner holding a thin, chrome water dispenser, and carrying a white napkin folded over his wrist. I could hear the ice cubes dancing in the can, clinging against the metal sides of the dispenser, creating a wild, loud motion inside. Barely without pause, his arm stretched in one flow with his walk, as his legs came to a stop the dispenser moved steadily forward, being stretched out without delay to the rim of the glass. The glass was not even half empty yet, but water poured down like an avalanche or waterfall in one wholesome fall, everything passing so quickly it could not be helped. Drops of water splashed all over the table, the glass now refilled to the rim in a wild splatter of an instant, the base of the glass soaked in condensed water rolling down the bowl along the stem of the glass and being absorbed by the saturated table cloth. Seeing the refilled bowl of water, the Hispanic runner’s smile was equally full with satisfied content of a job well done.

Nikolay Gogol, The Government Inspector (1863)

Nikolay Gogol, The Government Inspector (1863) p213-306

I am not a big fan of comedy, and certainly not of farce. Humor is too often no more than a coquette compulsion to please, it is by definition a social function, even if we might have evolved to laugh uncontrollably. Yet, watching the adaptation by Jeffrey Hatcher, I found myself to laugh without self awareness. The book however, is especially clever in the first part, but toward the end it slowly evens out into a cleverly written play without depth or wit.

The Government Inspector
Adapted by Jeffrey Hatcher
From The Government Inspector by Nikolay Gogol

The Duke Theater
a New 42nd Street project
229 West 42nd Street (between 7th & 8th)​

An Old Oak Tree Grows There

Only grow
like an old oak tree
that is firm
and will agree
reed does fold
roots do hold

Only hurry
like a steady water
as my heart
a trough of fodder
seed to nourish
love to flourish

Messenger2Watson(1): Connect Facebook to a Watson Chatbot

In Slack2Watson(1) and (2) I created a chatbot and integrated it into Slack Slash Commands. Now, let’s integrate the same chatbot into Facebook Messenger. To accomplish this I need to create a Facebook Application, add the Messenger Platform to my Facebook Application, create a Webhook, have admin access to a Facebook Page to generate a Page Access Token so I can send and receive messages send to the Facebook Page, and create the Node-RED flows to integrate the Facebook Messenger with the IBM Watson Conversation.

Steps:

  1. Create a Flow to Verify the Request for Webhook Edits in Node-RED,
  2. Create an Endpoint for the Redirect URL of the Webhook in Node-RED,
  3. Create a Facebook Application for the Messenger Platform,
  4. Enable Webhooks Integration with Node-RED,

Create a Flow to Verify the Request for Webhook Edits in Node-RED

To prepare the setup and configuration of the Facebook Application, the Messenger platform and Webhooks to enable a chatbot in Facebook Messenger, I will first create the Node-RED flows to implement the required server workflow.

The first flow is to verify the endpoint for the setup of the Facebook Application, using the ‘hub.challenge’ token.

  • Go to your Node-RED application on Bluemix at http://<username>-nodered-slackapp.mybluemix.net/,
  • Click the ‘Go to your Node-RED flow editor’ button,
  • If you’re not logged in yet, log in now,
  • Add a new flow tab and rename the flow ‘Facebook Messenger’,
  • To verify your endpoint during setup of your Webhook, or when you update an existing topic subscription of your Webhook, Facebook sends a GET request. The request will include:
    hub.mode=subscribe
    hub.challenge — a random string
    hub.verify_toke
  • Continue reading

Slack2Watson(2): Connect Slack to a Watson Chatbot with Node-RED

Using:

  • Slash Commands in Slack,
  • Watson Conversation service to create a ChatBot,
  • Node-RED to configure the Application Flow,

Using a chatbot, I want to automate the following scenario:

  1. user: Hello
  2. chatbot: Hello. Where are you?
  3. user: hi, i am at the Rubin Museum.
  4. chatbot: I love the Rubin Museum. Shall I give you some recomendations of my personal favorites?
  5. user: oh yes, I would love some recommendations.
  6. chatbot: do you like sculpture, paintings or ornaments?
  7. user: i prefer paintings!
  8. chatbot: ok, here are my favorite paintings at the Rubin Museum: a, b, c

Steps:

  1. Create the Watson Conversation for the Rubin Museum Scenario,
  2. Test the Conversation for the Rubin Museum Scenario,
  3. Setup Slash Commands in Slack,
  4. Create the Node-RED Flow to Watson Conversation,
  5. Add Token Validation of the Slack Request to Node-RED Flow,

Create the Watson Conversation for the Rubin Museum Scenario

  • Go to IBM Bluemix and login to your account,
  • To create the Watson Conversation, click the ‘Create Service’ button, which will take you to the Catalog, or
  • Go to the Catalog, Under ‘Services’ filter by ‘Watson’, or in the catalog browse to the Watson section,
  • Click the ‘Conversation’ service,
  • Agree or change the ‘Service name’ and the ‘Credentials name’, and click the ‘Create’ button,
  • Under the ‘Credentials’ tab, you will find the username, password, and workspace ID that you need later to configure access to the conversation service,
  • Click the green ‘Launch tool’ button,
  • First create a workspace, click ‘Create’, name the workspace ‘Watson2Slack-Workspace’, and click ‘Create’,
  • You are now in your Conversation workspace, and you should see 3 tabs: Intents, Entities, and Dialog,

    Continue reading

Erik Larson, The Devil in the White City (2004)

Erik Larson, The Devil in the White City (2004) 390p.

I have read ‘The Devil in the White City’ as a trilogy, together with ‘Nature’s Metropolis‘ and ‘The Jungle’, and the overlap and synergies between the three works is so insightful to understand the roots of modern America, which sprouted in the Gilded Age of Chicago. Americans in general have perhaps a short memory and a shallow desire to understand their history or present, as they are so energetically working to build their future, but as they strive thus forward, they fail to see the straight trail they leave behind. The history of Chicago is interestingly also transcending the contemporary spleen of American culture. ‘Nature’s Metropolis’ more than any other work perhaps, gives a more comprehensive insight into the shared destiny of the northern East Coast and the Great West and South. The history of Chicago is the stitching between the common descent, by opening the gap between the White City and the Black City, between the amazing wonders and creative forces of the American Dream on one hand and the devastating destruction and humiliation of the American Psyche on the other, by describing a meticulous history of the ‘World’s Columbian Exposition‘ of 1893 and a portrait of America’s first serial killer H.H. Holmes.

Looking forward to the feature movie with Leonardo diCaprio by Martin Scorsese.

Slack2Watson (1): Connect API Connect to Serverless OpenWhisk

‘Slack2Watson (1): Connect API Connect to Serverless OpenWhisk’ is part 1 of an application called Slack2Watson, which integrates a ChatBot into Slack and allows you to retrieve information about events via Slash Commands in Slack. In part 1, I will set up the ‘API Connect’ service and link the APIs in ‘API Connect’ to the OpenWhisk functions.

Integration is managed using API management in ‘API Connect,’ serverless or event-based APIs in OpenWhisk, and IBM Watson to create the Conversation bot. Some data is retrieved via Google Sheets API.

  1. Create API Connect API v1.0.0
  2. Publish the API
  3. Create an OpenWhisk action
  4. Connect API Connect to OpenWhisk

Requirements

This tutorial uses the OpenWhisk service and the API Connect service on http://bluemix.net, the IBM Cloud. Create an account on IBM Bluemix to run this tutorial.

1. Create API Connect API v1.0.0

  • Go to the Bluemix Catalog,
  • In the left menu select the ‘APIs’ category, and click the ‘API Connect’ service,
  • Click the ‘CREATE’ button to create the ‘API Connect’ service,
  • Click the ‘Sandbox’ icon to go to the Sandbox view with a list of products, which currently says ‘There are no products available in the selected catalog.’,
  • Go to the ‘Navigate to’ icon next to the ‘Home’ icon, and click ‘Drafts’, which will take you by default to the ‘Drafts’ view in the ‘Designer’ perspective,
  • In the ‘Drafts’ view, you see a ‘Products’ tab and an ‘APIs’ tab, click the ‘APIs’ tab,
  • Click the ‘ADD’ button and add a ‘New API’ titled ‘<username>-slack2watson’
  • Title: ‘<username>-slack2watson’
  • Name: ‘<username>-slack2watson’
  • Base Path: /slack2watson
  • Version: 1.0.0

Continue reading

Yu Hua, To Live (1993)

Yu Hua, To Live (1993), 250p.

Yu Hua “once heard an American folk song entitled ‘Old Black Joe,’ a song about an elderly black slave who experienced a life’s worth of hardships, including the passing of his entire family, yet he still looked upon the world with eyes of kindness, offering not the slightest complaint.” Hearing the folk song ‘Old Black Joe’ became the inspiration for ‘To Live’, in which an elderly Chinese man, Fugui, has passed a life of hardship including losing his entire family. Central to the story is also a wisdom by the grandfather of Fugui: the chicken becomes a goose, the goose becomes a lamb, the lamb grows up to become a sheep, the sheep becomes an ox. After the ox, there is communism.

It is really hard to read the book and determine if it is about the indestructible hope of man or if it is about the inevitable suffering of man. One certainty exists, life is beckoning death. “As the black night descended from the heavens, I knew that in the blink of an eye I would witness the death of the sunset. I saw the exposed and firm chest of the vast earth; its pose was one of calling, of beckoning. And just as a mother beckons her children, so the earth beckoned the coming of night.” One of the saddest books ever written, and yet anyone will find a moment of happiness. “In the end, it turned out all for the best.”

To Live (1994) by Zhang Yimou.

A Critique on Judeo-Christian Populism and Islam

Too often, I hear the claim by populists that Islam is a Trojan Horse in Western society, that the Islam is an enemy to Western values. The theory of a fundamental clash of cultures between Judeo-Christianity and Islam is the very pillar of Islamophobic popularism today. This co-called Strauss–Howe generational theory comes from amateur historians and populist authors William Strauss and Neil Howe from the US, who both see a war between Islam and the West as the ‘fourth turning.’ I studied history and am an amateur historian myself, but I believe in facts rather than ‘alternative facts’, in truths rather than convictions.

The true foundation of Modernist Western ethics and current social values however is not religion but happiness. As a humanist, I believe that the pursuit of happiness is what drives man. Man advances through learning. Happiness, Epicurus says, is the absence of physical and mental suffering. Happiness is ensured in Freedom and Democracy, which are the legal form of this pursuit. This pursuit of happiness requires, according to Lucretius, the seeking of truth. It is science, not religion, that is the foundation of the pursuit of happiness, and therefor the true foundation of Western modernist culture.

With the rise of populism claiming to be the true defenders of our Western values, it seems that we Western humanists of the 21st century do not know whom to fight. The left is easily cornered by the right to be defenders of Islam, and out of instinct too easily accepts this role. But humanists should understand that the anti-Islamic populists are not worse but equal enemies as is Islam. The left has become complacent and overconfident in its fight against religion.

When I grew up however, it was not Judaism or Christianity that shaped my thinking and my values, but a series of Western thinkers whose works radically opposed Judeo-Christian culture. Western modernist culture instead of being Judeo-Christian or welcome to Islam, is instead radically anti-religious. Continue reading