Author Archive: remkohdev

Integrating Slack Commands with API Connect and OpenWhisk

This is part 1 to build an event management application called EventQuarry, integrated into Slack, using API management, event-based APIs in OpenWhisk, Google Sheets API, IBM Watson to create a Conversation bot.

  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, find the API Connect service,
  • Create the API Connect service and open the API Connect service, this will take you by default to the ‘Drafts’ view in the ‘Designer’ perspective,
  • In the ‘Drafts’ view there are a ‘Designer’ and an ‘Explore’ perspective,
  • In addition to the ‘Drafts’ view, there is a ‘Sandbox’ view in the ‘Catalog’, which is where you see the ‘Products’. Currently, there are no Products yet, we only created a Draft,
  • Open the API Connect Drafts
  • Add a New API titled ‘<username>-slackapp’
  • Title: ‘<username>-slackapp’
  • Name: ‘<username>-slackapp’
  • Base Path: /slackapp
  • Version: 1.0.0

  • Click the ‘Create API’ button,
  • In the ‘Design’ tab, click the ‘Paths’,
  • (more…)

    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. (more…)

    Of Queen and Peasant

    For majesty a throne
    She stands in grace alone
    Her smile equally dosed
    Decisively composed

    The peasant has his land
    He stands to serve her end
    His honor is to bow
    and serve he is endowed

    The moon is to the sun
    Not his own that is done
    But in the bigger light
    He shines a little bright

    William Cronon, Nature’s Metropolis (1991)

    William Cronon, Nature’s Metropolis (1991), 385p.

    Without a doubt, one of the best books you can read to understand America in general, and Chicago and the Great West specifically.

    Easy Web Application Development for Beginners with Node-RED (2)

    Objective

    In this tutorial I will create a Node-RED server application that will process a request from a client web form. The server will save the request data in a NoSQL database.

    Requirements

    You must have:

    • Access to a Bluemix account.

    1. Create a Node-RED Starter Application

    Start to create a Node-RED Starter server application. A client application sends a form request to the Node-RED server, the server processes the form data and sends a response back to the client.

    Node-RED is a so-called visual workflow editor, which lets you create an application workflow by dragging and dropping visual nodes onto an editor.
    (more…)

    Creating a Nodejs App with Watson AlchemyAPI and CloudantDB

    WIP

    Requirements:

    Overview:

    1. Setup
    2. Setup Details
    3. Add Watson AlchemyAPI
    4. Add Cloudant DB

    Setup

    1. Login to Bluemix, in a separate tab login to Github,
    2. In Bluemix open Catalog->Boilerplates and create a ‘Node.js Cloudant DB Web Starter’ Boilerplate, named ‘<username>-nodejs-app1’, click CREATE
    3. Go to ‘Overview’, scroll down to ‘Continuous delivery’ and click ‘Enable’
    4. In the ‘Toolchain Settings’, change the name of the Toolchain to ‘<username>-nodejs-app1’, and click Create,
    5. If the Github THINK or CODE icon displays a configuration error, from the block’s dropdown icon in the topright, click the ‘Configure’ link to correct the configuration of your Github account,
    6. Go to your Github account and make sure that the repository for the new Bluemix app is created successfully,
    7. Copy the Git URL, on localhost open a commandline terminal, change to your development directory and clone the new repository,
      cd ~/dev/src/bluemix
      git clone https://github.com/remkohdev/remkohdev-nodejs-app1.git
      cd remkohdev-nodejs-app1
    8. Open the project directory in your favorite editor,
    9. Open the ‘package.json’ file and change the ‘name’ property to ‘<username>-nodejs-app1’,
    10. From the commandline, in your project directory,
      git status
      git add .
      commit -m "change package.json name property"

    (more…)

    Introduction to Cascading Style Sheets (CSS)

    Open an online editor with direct preview, e.g. http://htmledit.squarefree.com/.

    Agenda

    1. What is CSS?
    2. Where to go next?
    3. Begin with an HTML page
    4. CSS syntax and CSS selectors
    5. External, internal, inline
    6. CSS color
    7. Default HTML tags, TRBL in margins, font styles
    8. The box model
    9. Table style
    10. Navigation lists
    11. Div and centering divs
    12. Floating divs
    1. What is CSS? Says who? The W3C maintains the CSS specification and browsers individually choose to comply to the standard and support each CSS feature.
    2. w3schools.com is a good place to start learning CSS.
    3. Begin with a default HTML page,
      (more…)

    Getting Started: Creating a Java-Liberty App with Watson on Bluemix

    An extended version of this tutorial, adding a Cloudant NoSQL Database and D3js data visualization, is available here.

    Requirements:

    • Bluemix account
    • Github account

    Steps:

    1. Create the StarterApp
    2. Add the Toolchain or Continuous Integration (CI)
    3. REST API Primer
    4. Authentication in REST API
    5. Getting the Bluemix Configuration
    6. Add the AlchemyData News API Client
    7. Add a Web Form
    8. Implement the AlchemyData News API Request
    9. Create Authorization Header for Basic Auth

    1. Create the StarterApp

    (more…)

    Add Serverless Programming and Data Integration on Bluemix

    Add Serverless or Event-Based Programming using OpenWhisk:

    1. Go to the OpenWhisk service at https://console.ng.bluemix.net/openwhisk
    2. Click the ‘Develop’ button, which takes you to the Openwhisk editor,
    3. Create a new Action and implement the JavaScript function,
    4. At the bottom right, click the ‘View REST Endpoint’, and in the ‘cURL Example’, click the ‘Show Full Command’ to reveal the Base64 encoded authentication token for the OpenWhisk service,
    5. You can get the username:password credentials by installing the OpenWhisk ‘wsk’ command line and run:
      wsk property get --auth
      Or to Base64 encode it, run:
      wsk property get --auth | awk '{printf("%s", $3)}' | base64
    6. The way to call the OpenWhisk endpoint is using ‘Basic Auth’:
      https://openwhisk.ng.bluemix.net/api/v1/namespaces/<organization_id>_<space>/actions/<action>?blocking=true
    7. Then, for example:

      • Next create a new action and link the two actions together by Extending the first action and link it to the second action.
      • Next create an action to save the result to the Cloudant Database using the ‘Create Document’ action,
      • Next trigger the Slack notification

    Using Twitter data via DashDB:

    1. Create a DashDB service
    2. Create a Insights for Twitter service
    3. Open the DashDB dashboard > Load > Load Twitter Data > select the Twitter Service we created > Next
    4. In the Search for Twitter data: “#SEC posted:2016-11-01,2016-11-15”
    5. Click Get Tweet Count > Next
    6. Select ‘Load the data into new tables with this prefix:’ and enter prefix ‘SEC_Twitter’ > Next > Next > Finish

    insights_for_twitter_sec_finished

    Using public SEC data via DashDB:
    https://www.sec.gov/dera/data/financial-statement-data-sets.html
    Download the SEC file for 2016Q3: 2016q3.zip

    1. Unzip the ‘2016q3.zip’ archive,
    2. Load the 4 *.txt files: num, pre, sub, tag,
    3. Load > Load from Desktop > drop the file into the upload window,
    4. Change the separator character to ‘tab’,
    5. Don’t check the ‘Does the file have columns that contain dates or times? Yes No’, this may break the dataload sometimes, as the data is not always 100% cleaned correctly,
    6. Rename the tables so they have the prefix ‘SEC_2016Q3_’.

    Other datasets:

    • Pitney Bowes Geodata:
      1. Add the Pitney Bowes service to your Bluemix application
      2. Get AccessToken using OAuth2:
        curl -X POST -H "Authorization: Basic a2t2eetceteratVA==" -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=client_credentials' "https://api.pitneybowes.com/oauth/token"
      3. Then call the PB service:
        curl -X GET -H "Authorization: Bearer vc84ZaccesstokenoK2" "https://api.pitneybowes.com/location-intelligence/geolife/v1/demographics/byaddress?address=550%20W%2054th%20St%2C%20New%20York%2C%20NY%2010019&country=USA"
    • WeatherCompany Data:
      1. Add the WeatherCompany Data service to your Bluemix application,
      2. Get the username and password from the credentials,
      3. Daily Forecasts:
        curl -X GET "https://<username>:<password>@twcservice.mybluemix.net/api/weather/v1/geocode/33.40/-83.42/forecast/daily/10day.json?units=m&language=en-US"
      4. Current Conditions:
        curl -X GET "https://<username>:<password>@twcservice.mybluemix.net/api/weather/v1/geocode/33.40/-83.42/observations.json?language=en-US&units=m"
      5. Almanac (Historic Data):
        curl -X GET "https://<username>:<password>@twcservice.mybluemix.net/api/weather/v1/geocode/33.40/-83.42/almanac/monthly.json?start=01"
    %d bloggers like this: