Sunday, November 12, 2017

Javascript Array intersection

Simple Javascript Array intersection

Example Fiddle

function intersection (...args) {
  if (args.length < 2) return []
  const source = args.shift()
  const src = Array.isArray(source) ? source : []
  return src.reduce((intersections, value, index, list) => {    
    const intersects = args.reduce((state, array) => {
        return Array.isArray(array) ?
          state && array.indexOf(value) !== -1 :
    }, true)
    if (intersects && intersections.indexOf(value) === -1) {
    return intersections
  }, [])

Saturday, November 11, 2017

Javascript Promise Reduction

Simple function to perform a reduce on an iterable of Promise/Non-Promise objects.

function promiseReduce (iterable, reducer, initialValue) {
  return iterable.reduce((previousPromise, currentPromise, count) => {
    return Promise.resolve(previousPromise).then(result => {
      return Promise.resolve(currentPromise).then(current => {
        return reducer(result, current, count)
  }, Promise.resolve(initialValue))
See fiddle
Or you can use Bluebird.js

Thursday, September 14, 2017

Configuring Netgear Orbi with at&t GigaPower modem

Gigabit internet

I recently upgraded to at&t gigabit internet from a 24 plan. This required me upgrade my current modem. I use quite a bit of port-forwarding for things like plex, lab servers, etc. and had a bit if difficulty getting the new modem to pass all of the traffic to my Orbi so that the Orbi can forward the traffic to the correct hosts.

Here are the steps I took in order to get everything working.


  • Netgear Orbi RBR50 + 2 RBS50 satellites
  • ARRIS BGW210-700 Modem/Router aka at&t modem

Basic Setup

WAN <= at&t model <= Orbi Star Network <= LAN


The at&t modem has a default local address space that conflicts with the Orbi's ( If you plug the Orbi into the router, the Orbi will detect this and change its own address space to If this is ok with you, please proceed. However I had a lot of static IPs on so I opted to change the at&t modem address space to

If your Orbi changed its subnet to Go into the Orbi and change it back.

Now make sure the Orbi is plugged into the at&t modem and then set up IP Passthrough in DHCPS-Fixed mode selecting your Orbi router as the device. This will assign the Orbi router the public IP address of the at&t modem

Now log into your Orbi and reboot it.

Once your Orbi is back up the IP Address listed in the INTERNET PORT should no longer be on the or subnet. If it is you will need to release and renew the INTERNET PORT IP address by clicking the CONNECTION STATUS button which will open a new window where you can RELEASE the IP and then RENEW it. The address should now be the same as the at&t router and port forwarding should work.

Good luck!

Saturday, March 28, 2015

Creating a Jersey WebService In Gatein 3.8.1/JBOSS

I have recently been playing around with GateIn at work. GateIn allows you to build a custom portal based on portlets you can develop in Java. Since it is built on JBOSS it offers things like application clustering and SSO, so its a pretty nice open source product.

However, being new to JBOSS (and java development in general) I ran into a few frustrating issues while trying to deploy a webservice application. After a few days of plugging away at it and reading some helpful blogs I was able to get it working. The issue is that GateIn/JBOSS loads its own implementation of JAX-RS and will not allow you to load any others unless you explicitly say not to in your webapp.

In this blog I will go over how to create a simple REST web service using Jersey that can be deployed and used in GateIn/JBOSS

Prerequisites (what I will be using)

  • Eclipse Luna with Dynamic Web Project Installed
  • GateIn 3.8.1 JBOSS available here
  • Java SDK (The project will need to be set to use 1.7 compatibility)
Project Setup

1. Create a new Dynamic Web Project with the Project name "hellows" and select next

2. Select next again to accept the default output folder
3. Select the checkbox next to Generate web.xml deployment descriptor and leave the rest of the defaults and then select finish to create the project

4. Since we will be using Maven to manage the dependencies, right click on the hellows project and select Configure > Convert to Maven Project
5. In the Create new POM window change the Group Id to com.vbranden (or whatever you like) and leave the rest of the defaults. Then select finish to convert the project

6. Open the hellows/pom.xml file, select the pom.xml tab on the bottom and replace it with the following then save. This will download the dependencies and place them in the project's classpath

 <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">  

7. Update the web.xml file in hellows/WebContent/WEB-INF and replace it with the following and save

 <?xml version="1.0" encoding="UTF-8"?>  
 <web-app xmlns:xsi=""  
      id="WebApp_ID" version="3.0">  
           <servlet-name>hellows servlet</servlet-name>  
           <servlet-name>hellows servlet</servlet-name>  

8. Now we need to create the actual web service. First we will create the object model for our hellows response. Create a new class under Java Resources/src named and modify the package to com.vbranden.models. Keep the rest of the defaults

Replace the code for with the following
 package com.vbranden.models;  
 import javax.xml.bind.annotation.XmlElement;  
 import javax.xml.bind.annotation.XmlRootElement;  
 @XmlRootElement(name = "HelloObject")  
 public class HelloObject {  
      private String type;  
      private String message;  
      public HelloObject() {}  
      public HelloObject(String type, String message) {  
       * @return the message  
      public String getMessage() {  
           return message;  
       * @param message the message to set  
      public void setMessage(String message) {  
           this.message = message;  
       * @return the type  
      public String getType() {  
           return type;  
       * @param type the type to set  
      public void setType(String type) {  
           this.type = type;  

9. Create a new class under Java Resources/src named and modify the package to com.vbranden.resources. Keep the rest of the defaults

Replace the code for with the following
 package com.vbranden.resources;  
 import com.vbranden.models.HelloObject;  
 public class HelloResource {  
      @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})  
      public Response getHello() {  
           // create a new HelloObject  
           HelloObject hello = new HelloObject("Flanders", "Hi-diddly-ho, neighborino");  
           return Response.ok().entity(hello).build();  

10. Next we need to create a class that extends ResourceConfig. This class will point to the package where our resources are. Create a new class under Java Resources/src named and modify the package to com.vbranden. Keep the rest of the defaults

Replace the code for with the following
 package com.vbranden;  
 import org.glassfish.jersey.server.ResourceConfig;  
 public class HelloApplication extends ResourceConfig {  
      public HelloApplication() {  

11. Finally in order to use this project as a web service in GateIn/JBOSS we need to add the jboss-deployment-structure.xml file to the folder hellows/WebContent/META-INF. Right click the folder and select New > File and create jboss-deployment-structure.xml

Replace the code for jboss-deployment-structure.xml with the following

 <?xml version="1.0" encoding="UTF-8"?>  
  <subsystem name="resteasy" />  
  <module name="javaee.api" />  
  <module name=""/>  
  <module name="org.jboss.resteasy.resteasy-jaxrs" />  
 <local-last value="true" />  

12. Now export the project as a WAR file to the directory $GATEIN_HOME/standalone/deployments/hellows.war. GateIn will automatically deploy the web service and it will be ready to test

13. Using a tool like POSTMAN you can quickly check the web service by making a get request to

Without any options the response will be XML formatted. If you would like a JSON response add an Accept header for application/json

And thats it! Hopefully this will help out those of you with problems getting a JAX-RS webservice to work in GateIn or JBOSS. 

Wednesday, June 25, 2014

VMware SSL certificates made a bit easier

If you have ever replaced certificates on a VMware product you know it can get a little confusing at times. For this reason I have written this simple powershell tool to easily create CSRs and import the replies.

The tool uses a set of canned configuration files for the various VMware products. These configuration files come directly from VMware KB articles. You can also write your own custom cfg files and place them in the templates directory for use in the tool. You must also add a line in the in the vmware-cert-tool.conf file for your custom template defaults.

You can download the tool from here. I have provided a link with OpenSSL included, but google thinks it contains a virus (which it does not)

You can get that here > VMware Certificate Tool w/ OpenSSL

If warnings make you nervous, You can get the package w/o OpenSSL included here > VMware Certificate Tool OpenSSL not Included

You will however need to download and install OpenSSL from and install it in the vmware cert tool directory under openssl or modify the powershell script to point to your installation

Now on to the screenshots...

When you run the program you will be prompted to either generate a CSR or import a reply

 You will be prompted with a list of all the current configuration templates you have in the templates directory

You will be prompted for the certificate information. In this example we are creating a request for a certificate that will be used for a load balanced SSO 5.5 instance. You can add multiple SANs and IPs

A summary will be printed, if you have made any mistakes you can start over

Several files including the CSR and private key are created. The templateUsed.txt file keeps track of the type of certificate you are requesting

At this point you are on your own to request the certificate from your CA. You can follow VMware's documentation for requesting a certificate here >

For the certificate tool you will only need the .p7b file as this contains the complete certificate chain. For ease place it in the request directory for your request

Start the certificate tool up again and select option 2 to import the reply. You will enter the common name you set for the request and specify the absolute location for the .p7b file

After the tool runs it creates all the certificate files you could ever want including the certificate itself, all of the certificates in the chain, a chain certificate without the host certificate, and even the ever elusive PEM file which contains the entire chain and private key

I hope this helps some of you out.