-amd keeps the build focused only on the necessary packages (not the full fhir-parent)
Idempotent Execution of the Role Creation
su - db2inst1 -c "db2 \"connect to fhirdb\" && db2 \" BEGIN IF (SELECT ROLENAME FROM SYSCAT.ROLES WHERE ROLENAME = 'FHIRSERVER') IS NULL THEN EXECUTE IMMEDIATE 'CREATE ROLE FHIRSERVER'; END IF; END;\""
su - db2inst1 -c "db2 \"connect to fhirdb\" && db2 \" BEGIN IF (SELECT ROLENAME FROM SYSCAT.ROLES WHERE ROLENAME = 'FHIRBATCH') IS NULL THEN EXECUTE IMMEDIATE 'CREATE ROLE FHIRBATCH'; END IF; END;\""
Shell Pipestatus
Checking the Status of any command in a pipe, it was helpful in some automation where I had to wait on a jar to finish and check the output. Source
docker run -p 8080:8080 --rm apache/nifi:latest bash
Find the docker container id
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
09d2a7395fa2 apache/nifi:latest "../scripts/start.sh…" 7 seconds ago Up 6 seconds 8000/tcp, 8443/tcp, 10000/tcp, 0.0.0.0:8080->8080/tcp gracious_rosalind
Copy the fhirKeystore.p12 (in this case we just updated this one only).
Extracting a resource from a FHIR Bundle with over 10000 entries, and you know there is a problem at a specific resource, then you can use jq and array processing to extract the resource:
Thomas Alva Edison was a famous American inventor and businessman, “described as America’s greatest inventor”, and was one of the most prolific inventors in US history. Thomas Edison was granted/filed 1084 patents from 1847-1931.[1] He’s just one cool inventor – lamps, light bulbs, phonograph and so many more life changing inventions.
Google Patents has a wonderful depth of patent history, and the history is searchable with custom search strings:
inventor:(Thomas Edison) before:priority:19310101
inventor:(Paul R Bastide) after:priority:2009-01-01
Google provides a seriously cool feature – a downloadable csv. Pandas anyone? The content is provided in an agreement between the USPTO and Google. Google also provides it as part of the Google APIs/Platform. The data is fundamentally public, and Google has made it very accessible with some GitHub examples. [2] The older patent data more difficult to search as the content has been scraped from Optical Character Recognition.
I have found a cross-section of three things I am very interested in: History, Inventing and Data Science. Time to see what cool things about the Edison data.
Step
To start the playing with the data, one must install Jupyter.
Launch the Edison notebook and follow along with the cells.
The notebook renders some interesting insights using numpy, pandas, matplotlib and scipy. The notebook includes a cell to install python libraries, and once one executes the per-requisites cell; all is loaded.
The Jupyter notebook loads the data using an input cell, once run, the analytics enable me to see the number of co-inventors (but need to cleanse the data first).
One notices that Thomas Alva is not an inventor in those results, as such one needs to modify to the notebook to use the API with more recent Inventors. With the comprehensive APIs from USPTO, one extracts patent data by one of a number of JSON REST APIs. Kudos to the USPTO to really open up the data and the API.
Conclusion
All-in the APIs/Python/Jupyter Notebook/Analysis are for fun, and provide insight into Thomas Edison’s patent data – one focused individual.
References
[1] Prolific Inventors https://en.wikipedia.org/wiki/List_of_prolific_inventors number wise it appears to conflict with https://en.wikipedia.org/wiki/List_of_Edison_patents which reports 1093 (it’s inclusive of design patents) [2] Google / USPTO Patent Data https://www.google.com/googlebooks/uspto-patents.html [3] USPTO Open Data https://developer.uspto.gov/about-open-data and https://developer.uspto.gov/api-catalog
[4] PatentsView http://www.patentsview.org/api/faqs.html
To simply testing with Zookeeper on a remote Kafka cluster, one must connect to the client application ports on the backend. When the remote Kafka cluster has multiple nodes and behind a firewall and a SSH jump server, the complexity is fairly high. Note, the SSH jump server is the permitted man in the middle. The client must allow application access to Zookeeper on Kafka – listening locally. Current techniques allow for a single port hosted on the developers machine for instance, 2181 listening on the local machine, and a single remote server. This approach is not reliable – servers are taken out of service, added back, fail, or reroute to the master (another separate server).
3 – Save the hosts file 4 – Setup Available interfaces (1 for each unique service) 1 is already up and in use (you only need to add the extras)
sudo ifconfig lo0 alias 127.0.0.2 up
sudo ifconfig lo0 alias 127.0.0.3 up
sudo ifconfig lo0 alias 127.0.0.4 up
sudo ifconfig lo0 alias 127.0.0.5 up
5 – Setup the port forwarding, forward to jump server ssh -L 30991:localhost:30991 jump-server 6 – Forward to Kafka server ssh -L 30991:localhost:2181 kafka-1 7 – Loop while on kafka server while true; do echo “waiting”; sleep 180; done 8 – Repeat for each kafka server increasing the port by 1 (refer to ports section for mapping) 9 – Setup the Terminal – node krb5-tcp.js 10 – Setup the Terminal – node proxy_socket.js
echo stats | nc kafka-1 2181 Zookeeper version: 3.4.6-IBM_4–1, built on 06/17/2016 01:58 GMT Clients: /192.168.12.47:50404[1](queued=0,recved=1340009,sent=1360508) /192.168.12.46:48694[1](queued=0,recved=1348346,sent=1368936) /192.168.12.48:39842[1](queued=0,recved=1341655,sent=1362178) /0:0:0:0:0:0:0:1:39644[0](queued=0,recved=1,sent=0)
public class MyCallBackHandler implements CallbackHandler { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) { System.out.println(callbacks[i]); } } }
For a project I am working on I needed to rewrite a DGram port. I moved the ports around and found a few quick tests.
Testing with NC
my-machine:~$ echo -n “data-message” | nc -v -4u -w1 localhost 88
found 0 associations
found 1 connections:
1: flags=82<CONNECTED,PREFERRED>
outif (null)
src 127.0.0.1 port 53862
dst 127.0.0.1 port 88
rank info not available
Connection to localhost port 88 [udp/radan-http] succeeded!
Rewriting incoming datagrams to another port
You can run the sample, and get the results as follows
In my last few projects, I have used Test-NG. Uniquely in my current project, I had to generate tests programmatically. Instead of writing one test for each element in the project, I am able to generate a bunch at-will using the following pattern:
Factory
package test;
import org.testng.annotations.Factory;
public class DynamicTestFactory {
@Factory
public Object[] createInstances() {
Object[] result = new Object[10];
for (int i = 0; i < 10; i++) {
result[i] = new ExampleProcessorTest(Integer.toString(i * 10)+ "A",Integer.toString(i*10) + "B");
}
return result;
}
}
Test
package test;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
public class ExampleProcessorTest {
private String a;
private String b;
public ExampleProcessorTest(String a, String b) {
this.a = a;
this.b = b;
}
@Test
public void testServer() {
System.out.println("TEST");
assertTrue(true);;
}
}
Running Code
[RemoteTestNG] detected TestNG version 6.9.10
[TestNG] Running:
/private/var/folders/07/sw3n5r3170q202d5j4tx8fhw0000gn/T/testng-eclipse--1754065412/testng-customsuite.xml
TEST
TEST
TEST
TEST
TEST
TEST
TEST
TEST
TEST
TEST
PASSED: testServer
PASSED: testServer
PASSED: testServer
PASSED: testServer
PASSED: testServer
PASSED: testServer
PASSED: testServer
PASSED: testServer
PASSED: testServer
PASSED: testServer
===============================================
Default test
Tests run: 10, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 10, Failures: 0, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@76a4d6c: 9 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 5 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@32cf48b7: 4 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@130f889: 23 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@6e2c9341: 8 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@58a90037: 10 ms
I can also trigger using testng.xml <class name="DynamicTestFactory" />
# Create the Zip File
$compress = @{
LiteralPath= $pre_it_logs
CompressionLevel = 'Fastest'
DestinationPath = $zip_file
}
Compress-Archive @compress -Force
Ignoring Self-Signed Certs with Powershell
Also a step to test our server, but hit an issue with the certificate
# Ignore Self Signed Certificates and use TLS
# Reference https://stackoverflow.com/a/46254549/1873438
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
Add-Type -TypeDefinition @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy