Harrington Web

Juniper VPN using OpenConnect

Wednesday, April 20, 2016

Finally there is a tool worth using for vpn besides the default from Juniper that works on Linux. Its rather quick to get started.

Install Arch

$ pacman -S openconnect

Install Ubuntu

$ apt-get install openconnect

Install Fedora/RedHat

$ dnf install openconnect

or this if you have older Fedora/RedHat

$ yum install openconnect

Once you have it installed you may need to reboot. This will allow proper access to /dev/net/tun

Run it

$ openconnect --juniper vpn.domain.com

I'll Fly Away - Lyrics and Chords

Wednesday, March 30, 2016
G C D E

VERSE 1:

G Some glad morning when this life is o'er, C I'll fly away

GTo a home on God's celestial shore, C I'll fly away

CHORUS:

G I'll fly away, O glory, C I'll fly away G In the morning.

G When I die, E hallelujah, by and by G I'll D I'll fly away

VERSE 2:

G When the shadows of this life have grown, C I'll fly away

G Like a bird from prison bars has flown, C I'll fly away

VERSE 3:

G Just a few more weary days, and then, C I'll fly away

GTo a land where joys shall never end, C I'll fly away

Calculate your Macronutrients

Tuesday, March 29, 2016

Macronutrient Calculator





All Weights are in grams.
Protein Carb Fat
0
0
0

Waiting for asynchronous calls in Protractor

Tuesday, March 22, 2016

Sometimes when dealing with tests the asynchronous objects are just a little ugly and hard to read. For instance if you have 3 buttons on a page and you wanted to make sure that all 3 were the same size. You would have to wrap all 3 elements together with a promise all. I am sure you can imagine the fun. With ES6 there is as new option to await asynchronous calls.

First you will need to add some libraries to your project

$ npm install babel-core babel-plugin-transform-async-to-generator

Then you will need to add some information to the protractor-conf.js

//You can add this either at the top of the file or you can put it within your onPrepare section.
require('babel-core/register');

Now create a .bashrc file

{
  "plugins": ["transform-async-to-generator"]
}

Now the fun part accessing the power of async and await. On you it statement we need to add an async.

it('should give us text', async function() {...

or like this if your are more current in syntax

it('should give us text', async() => {...

Now lets say you want to write the text to the console within your test.

it('should give us text', async() => {
  let someTxt = await $('.someElement').getText();
  console.log(someTxt);
});
It is that simple. To compare the same using a then.
it('should give us text', () => {
  $('.someElement').getText()
    .then((val) => { console.log(val) });
});
If you wanna see more Protractor help ideas you can checkout the book I am working on. Protractor: Learn Testing Angular

Query Selector: How to Or Selection

Thursday, March 17, 2016

This is probably an odd topic, however I was recently asked how could one select between 2 possible elements on a browser using Protractor. If you are unfamiliar with Protractor it is a testing tool for AngularJS applications. To start lets show a code example of what we are looking at.

<html>
  <body>
    <div id='ex1'>
      <!-- some code here -->
    </div>
    <div id='ex2'>
      <!-- some code here -->
    </div>
  </body>
</html>

Notice from the code that we have 2 divs with id's ex1 and ex2. Now depending on the code you ex1 or ex2 can be hidden. Lets say hypothetically they both do the exact same thing and you just want to click which ever one happens to be available. At the same time you also don't want to add expensive checks for isPresent or waits. To get around this you can do the following with the by.css query selector.

$('[id="ex1"], [id="ex2"]')

Did you know that this same query selector will also work within JQuery, and the DevTools Console on your browser? Give it a try on this page.

  1. Goto your DevTools Console in Browser
  2. Type: $('[id="ex1"], [id="ex2"]')
  3. Hit Enter

Add Search to Blogger

Wednesday, March 16, 2016

Simple way to add a search to your blog on Blogger.

  • Click -> Layout
  • Click -> Add a Gadget
  • Click -> HTML/Javascript
  • Paste -> Code below
<form action="/search" id="searchthis" method="get" style="display: inline;">
  <input id="search-box" name="q" size="30" style="height: 30px;" type="text" />
  <input id="search-btn" type="submit" value="Search" />
</form>

Docker Compose a Selenium Grid

There are times when you would like to Selenium Grid quickly so that it can scale to whatever testing goal is you want to achieve.
To start out you will need to get Docker you can goto Docker.com to find out more information on installing.

Create a docker-compose.yml

Make a new directory and name a file docker-compose.yml inside that directory. The contents are below.
hub:
  image: selenium/hub
  ports:
    - "4444:4444"
chrome:
  image: selenium/node-chrome
  links:
    - hub
  expose:
    - "5555"
firefox:
  image: selenium/node-firefox
  links:
    - hub
  expose:
    - "5555"
Once you have created your file goto that directory in your command line. This will create your instances and download necessary files.
$ docker-compose build
To run your instances you can run the following and it will start your servers.
$ docker-compose up
At this point you can now point your test code to http://127.0.0.1:4444 as the selenium server. You will notice at this point that you are running only 1 Chrome and 1 Firefox container on your grid. Scaling is very simple. With your servers running you just need to run an additional command to scale to your needs. For instance lets say we want to scale up to 10 Chrome instances.
$ docker-compose scale chrome 10
Voila! you now have 10 chrome containers running on your machine. Scaling works very simple, however keep in mind that memory and processors play a big role in how many you can run on a single machine. With the Chrome container memory is very important. I find that I generally want 1gb of physical memory per Chrome container that I need. Firefox seems to be less and can tolerate 512mb most the time.