VM54310:600 Uncaught TypeError: _XXXXX2.default is not a constructor


VM54310:600 Uncaught TypeError: _XXXXX2.default is not a constructor


need to export default class e.g.:

export default class StateController { ...





keywords: typescript VM54310:600 Uncaught TypeError: _XXXXX2.default is not a constructor ts js webpack



Posted in Uncategorized | Leave a comment

Gradual Migration from JavaScript to TypeScript


You have an existing project in which you’d like to use TypeScript.


Simply remove the outDir from tsconfig.json, e.g.:

  "compilerOptions": {
         "allowJs": false,
    "outDir": "./tsDist/",
    "module": "es6",
    "target": "es6",
    "experimentalDecorators": true,
    "moduleResolution": "node"
  "exclude": [

Everything should work now (since ts file will be compiled to a JS file at the same location; so all the imports etc will work just fine).

Sometimes things get out of sync between ts and js files (might have something to do with IntelliJ); in that case I just manually execute tsc command.

Alternative approach didn’t work well for me; e.g. due to the 100+ errors that would need to be resolved (when I simply renamed the js -> ts files).

keywords: mixing ts js typescript javascript in the same project incremental


Posted in Uncategorized | Leave a comment

enabling decorators for mobx

mobx is really great for state management (I prefer it over redux)

it is even handier if you can use decorators; to do that its probably easier to use babel 6 (due to some of the issues described here).

using npm install –save you should end add the following packages:

 "babel": "^6.5.2",
 "babel-core": "^6.18.0",
 "babel-loader": "^6.2.7",
 "babel-plugin-transform-decorators-legacy": "^1.3.4",
 "babel-preset-es2015": "^6.18.0",
 "babel-preset-react": "^6.16.0",
 "babel-preset-stage-1": "^6.16.0",

and then just add the following to .babelrc

  "presets": [
  "plugins": ["transform-decorators-legacy"]








// —- ESNext syntax with decorators —-

ES6 decorators babel

Enabling decorators (optional) Decorators are currently a stage-2 ESNext feature. How to enable them

Posted in Uncategorized | Leave a comment

webpack issues

may need to run ‘sudo npm install’ first

install missing dependencies with `sudo npm install <DEP>`
Module parse failed: /home/neil/Dropbox/w540-bak/bitbucket/sa-client-ui/src/app.js Unexpected token (199:40)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (199:40)

This seems to fix above: `sudo npm install –save-dev babel-loader` as mentioned in https://github.com/HenrikJoreteg/hjs-webpack

`Module not found: Error: Cannot resolve module ‘react’`

seems that packages have to be installed with `sudo nmp install …`

may need to run ‘sudo npm install’ first

Posted in Uncategorized | Leave a comment

DynamoDB: An AttributeValue may not contain an empty string (Exception)


com.amazonaws.AmazonServiceException: One or more parameter values were invalid: An AttributeValue may not contain an empty string (Service: AmazonDynamoDBv2;


This cryptic message basically says that dynamodb is not able to save fields with empty strings (or null) (a rather inconvenient and artificial limitation); but doesn’t say which ones …

This post suggest a related solution that works quite nicely.

implicit class RichJsObject(original: JsObject) {
  def omitEmpty: JsObject = original.value.foldLeft(original) { 
    case (obj, (key, JsString(st))) if st.isEmpty => obj - key
    case (obj, (key, JsArray(arr))) if arr.isEmpty => obj - key
    case (obj, (_, _)) => obj

Then you can just apply it to your jsObj as: jsObj.omitEmpty

Often you may actually have a jsVallue; which could be converted to jsObj:



keywords: scala play json dynamodb empty null string insert

Posted in Uncategorized | Leave a comment

org.codehaus.mojo:nbm-maven-plugin: Module has friend dependency on but is not listed as a friend


[ERROR] Failed to execute goal org.codehaus.mojo:nbm-maven-plugin:3.14:manifest (default-manifest) on project move: Module has friend dependency on org.netbeans.bootstrap but is not listed as a friend. -> [Help 1]


Add scope: provided; e.g.:



keywords: gephi netbeans maven 0.9

Posted in Uncategorized | Leave a comment

Upgrading Gephi 0.8 to 0.9

Gephi’s API had a rather significant API changes; here are some tips for the upgrades.

This nifty repo can get you started quickly: https://github.com/gephi/gephi-plugins

This repo provides good examples of API usage: https://github.com/gephi/gephi-toolkit-demos

API Changes

AttributeColumn subGraphFitnessCol = model.getNodeTable().getColumn(FLD_SUBGRAPH_FITNESS, AttributeType.DOUBLE);


Column subGraphCol = graphModel.getNodeTable().getColumn(FLD_GRAPH_FITNESS);


AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
AttributeModel model = ac.getModel();
AttributeColumn fitnessCol = model.getNodeTable().addColumn(“utility”, AttributeType.DOUBLE); // hack: add and then removed





RankingController rankingController = Lookup.getDefault().lookup(RankingController.class);

// use sub/graph utility (depending on which graph is displayed)
Ranking ranking;
//AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
GraphModel attributeModel = graphModel;

if (jGraph.vertexSet().size() == this.superGraph.vertexSet().size()){
Column col = attributeModel.getNodeTable().getColumn(FLD_GRAPH_FITNESS);
ranking = rankingController.getModel().getRanking(Ranking.NODE_ELEMENT, col.getId() );
} else {
Column col = attributeModel.getNodeTable().getColumn(FLD_SUBGRAPH_FITNESS);
ranking = rankingController.getModel().getRanking(Ranking.NODE_ELEMENT, col.getId() );

AbstractSizeTransformer sizeTransformer = (AbstractSizeTransformer) rankingController.getModel().getTransformer(Ranking.NODE_ELEMENT, Transformer.RENDERABLE_SIZE);
rankingController.transform(ranking, sizeTransformer);


void size(boolean forceExecution) {
if (this.getIsSize() || forceExecution){
AppearanceController appearanceController = Lookup.getDefault().lookup(AppearanceController.class);
AppearanceModel appearanceModel = appearanceController.getModel();

// Get visible graph
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
org.gephi.graph.api.Graph gGraph = graphModel.getGraphVisible();
// convert to jgrapht
Graph jGraph = JGraphTUtils.wrap(gGraph);
// update sizes

// use sub/graph utility (depending on which graph is displayed)
Column col;
//AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
GraphModel attributeModel = graphModel;

if (jGraph.vertexSet().size() == this.superGraph.vertexSet().size()){
col = attributeModel.getNodeTable().getColumn(FLD_GRAPH_FITNESS);
} else {
col = attributeModel.getNodeTable().getColumn(FLD_SUBGRAPH_FITNESS);

Function sizeRanking = appearanceModel.getNodeFunction(gGraph, col, RankingNodeSizeTransformer.class);
RankingNodeSizeTransformer sizeTransformer = (RankingNodeSizeTransformer) sizeRanking.getTransformer();



Posted in Uncategorized | Leave a comment

Machine Learning Book Recommendations

I am often asked to recommend books on machine learning (ML).  Here is a WIP list of my recommendations: http://www.amazon.com/gp/registry/wishlist/1TLVK1WKJF47S/


Posted in Uncategorized | Leave a comment

Using AWS Lambda Alias with API Gateway

Using AWS lambda with specific alias through API Gateway; as described here with a command like:

aws lambda add-permission --function-name arn:aws:lambda:us-east-1:xxxxxx:function:getData --source-arn arn:aws:execute-api:us-east-1:xxxxxx:t463p6g84d/*/POST/data --principal apigateway.amazonaws.com --statement-id  --action lambda:InvokeFunction

Resulted in an error

aws: error: argument operation: Invalid choice, valid choices are:

The cause was the following could be due to the following:

The CLI command must be issued with credentials that have permission to call the “add-permission” action of the Lambda APIs.

However; I still couldn’t quite get it to work.  What did work; was adding `API Endpoint` from Lambda’s console; which assigns the necessarily permissions; seems that you can change endpoint later on and the permission will still work (I guess they are not attached to a specific endpoint).  Also don’t forget to re-deploy your API once you’ve made the changes.




Add Permission to Lambda Function

You defined your Lambda function as a stage variable; you must manually give permissions to all the functions you will use. You can do this by running the below AWS CLI command for each function, replacing the stage variable in the function-name parameter with the necessary function name.

aws lambda add-permission –function-name arn:aws:lambda:us-east-1:1111111111:function:getSectorData:${stageVariables.lambdaAlias} –source-arn arn:aws:execute-api:us-east-1:1111111111:111/*/POST/data –principal apigateway.amazonaws.com –statement-id 111-4f1f-b5e5-111 –action lambda:InvokeFunction



Posted in Uncategorized | Leave a comment

AWS Lambda invoking from code

You can invoke a lambda from your code (details); you’d probably want to use the AWSLambdaAsyncClient.

CAUTION: you have to be very careful not to make re-cursive calls (unless that is your intention); otherwise you might get into an infinite loop.  Even worse if you are making several recursive calls you might exponentially increase the number of lambda instances that are running.

Here is a small snippet attempting to ensure that you are not making direct-recursive calls (note that you might still end up with indirectly recursive calls); use at your own risk; add the following to your handler function:

if (context.getFunctionName.equals(nextFunctionName)){
  throw new RuntimeException( context.getFunctionName + "is making a recursive lambda call")




keywords: call lambda from java scala code directly




Posted in Uncategorized | Leave a comment