Saturday, October 3, 2020

A straight forward way to deploy Angular JS app to Heroku

For the whole story, visit my Medium artcile here: A straight forward way to deploy Angular JS to Heroku
Here's the cheat sheet:
ng new [my-app-name]
cd [my-app-name]
ng build
heroku create [my-app-name]
npm install express --save
vi server.js
  
const express = require('express');
const app = express();
app.use(express.static('./dist/[my-app-name]'));
app.get('/*', function(req, res) { res.sendFile('index.html', {root: 'dist/[my-app-name]'});
});
app.listen(process.env.PORT || 8080);
  
vi package.json
  
//update "start" script
"start": "node server.js"
  
heroku git:remote -a [my-app-name]
git add .
git commit -m "initial commit."
git push heroku master
open https://[my-app-name].herokuapp.com

Saturday, March 11, 2017

[LINUX] Keep shell script running in the background even after closing SSH session

If you've found yourself scratching your head how you can keep a shell script running in the background even after closing an SSH session. You're in for a treat as I've learned a new trick over the week:

nohup {shell script} &
exit


For example, if you wish to keep the Secure Connector of IBM App Connect Professional running (runclient_osgi.sh start), you'd want to do this:

nohup runclient_osgi.sh start &
exit

Thursday, February 19, 2015

[IBM WEF] Retrieving WEF Variable from within a JavaScript code

1. Add a new Variable Builder named someVariable_v
2. Add a Client JavaScript Builder (Specify explicitly)
3. To access the someVariable_v from JavaScript, just specify something like:
var variableName = '${Variable/someVariable_v}'

Wednesday, January 21, 2015

A Straight-forward Two-way Client-Server Self-Signed Certificate using Keytool

The following set of commands will generate:

  • Two (2) .jks files: clientKeystore.jks and serverKeystore.jks. 
  • Two (2) .cer files: clientcert.cer and servercert.cer

Replace the following accordingly:
{FULL_PATH} - the path where you want to place all the generated files
{NUMBER_OF_DAYS} - specify number of days the certificates will be valid (e.g. 2 years = 730, 5 years = 1825)
{CLIENT_STORE_PASS} - password for accessing the clientKeystore.jks
{CLIENT_KEY_PASS} - password for the self-signed certificate alias myclientkey
{SERVER_STORE_PASS} - password for accessing the serverKeystore.jks
{SERVER_KEY_PASS} - password for the self-signed certificage alias: myserverkey
{DN} - the distinguished name e.g. cn=Example, ou=ExmapleUnit, o=ExampleOrg, c=PH

Additional details you may wish to replace:
myclientkey - alias name for client self-signed certificate
myserverkey - alias name for server self-signed certificate
clientKeystore.jks - name of the client keystore
serverKeystore.jks - name of the server keystore
clientcert.cer - name of the exported client certificate
servercert.cer - name of the exported server certificate

For more details please see: http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/keytool.html


keytool -genkey -keystore {FULL_PATH}/clientKeystore.jks -alias myclientkey -keyalg rsa -keysize 2048 -dname "{DN}" -validity {NUMBER_OF_DAYS} -storepass {CLIENT_STORE_PASS} -keypass {CLIENT_KEY_PASS}

keytool -genkey -keystore {FULL_PATH}/serverKeystore.jks -alias myserverkey -keyalg rsa -keysize 2048 -dname "{DN}" -validity {NUMBER_OF_DAYS} -storepass {SERVER_STORE_PASS} -keypass {SERVER_KEY_PASS}

keytool -exportcert -keystore {FULL_PATH}/clientKeystore.jks -alias myclientkey -storepass {CLIENT_STORE_PASS} -file {FULL_PATH}/clientcert.cer

keytool -exportcert -keystore {FULL_PATH}/serverKeystore.jks -alias myserverkey -storepass {SERVER_STORE_PASS} -file {FULL_PATH}/servicecert.cer

keytool -importcert -keystore {FULL_PATH}/clientKeystore.jks -storetype JKS -alias myserverkey -file {FULL_PATH}/servicecert.cer -storepass {CLIENT_STORE_PASS} -keypass {CLIENT_KEY_PASS}

keytool -importcert -keystore {FULL_PATH}/serverKeystore.jks -storetype JKS -alias myclientkey -file {FULL_PATH}/clientcert.cer -storepass {SERVER_STORE_PASS} -keypass {SERVER_KEY_PASS}

Tuesday, August 26, 2014

[WebSphere Portal Server] PumaSystemException on allowOperationIfReposDown="true"

When using a federated repository, let's say you're using the following snippet of ode:

try {
 PumaLocator pumaLocator = portalPumaHome.getLocator();
 PumaProfile profile = portalPumaHome.getProfile();
 List<User> users = pumaLocator.findUsersByAttribute(attribute, loginname);

 if (users != null && users.size() > 0)
 {
  // insert happy path here

 } else {
  // insert logic for "Invalid username/password" error message
  System.out.println("Invalud username/password");
 }

} catch (PumaSystemException pse) {
 // insert logic for communication exception with user repository
 System.out.println("We are currently experiencing some technical problems. Please try again later.");
 
} catch (Exception e) {
 // insert logic for other exceptions
 System.out.println("Oops, we screwed something up.");
 
}

As shown in the code snippet, you're expecting that the PumaSystemException is returned when the user repository could not be reached. This is only true when allowOperationIfReposDown is set to false. When the allowOperationIfReposDown="true", the PumaLocator operation would not return a PumaSystemException on CommunicationException with the user repository.

Therefore, your error message for this scenario will not be returned. To work your way around this, you may add an additional logic wherein you try to lookup the bind id when the user your trying to look for could not be found:


try {
 PumaLocator pumaLocator = portalPumaHome.getLocator();
 PumaProfile profile = portalPumaHome.getProfile();
 List<User> users = pumaLocator.findUsersByAttribute(attribute, loginname);

 if (users != null && users.size() > 0)
 {
  // insert happy path here

 } else {
  // adding logic to check if user repository is available
  List<User> bindusers = pumaLocator.findUsersByAttribute(attribute, bindusername);
  if(bindusers != null && bindusers.size() > 0) {
   // Invalid username/password
   System.out.println("Invalid username/password");
  } else {
   // insert logic for communication exception with user repository
   System.out.println("We are currently experiencing some technical problems. Please try again later.");
  }
 }

} catch (Exception e) {
 // insert logic for other exceptions
 System.out.println("Oops, we screwed something up.");
 
}

And that's it, hope this helps.