Skip to content

Instantly share code, notes, and snippets.

View greghelton's full-sized avatar

Greg Helton greghelton

View GitHub Profile
package com.testing;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropertiesExample {
public PropertiesExample() throws IOException {
Properties properties = new Properties();
InputStream propertiesStream = PropertiesExample.class.getClassLoader().getResourceAsStream("testthis.properties");
properties.load(propertiesStream);
@greghelton
greghelton / RxObservableApp.java
Last active April 22, 2016 22:06
Using RxJava for the first time.
package com.testing;
import java.util.Arrays;
import java.util.List;
import rx.Observable;
import rx.functions.Action1;
public class RxObservableApp {
List<String> helloList;
Observable<String> observatory;
@greghelton
greghelton / BL0100M01.rpgle
Last active December 21, 2019 19:15
RPG program PINGJAVA communicates with a Java program via data queues (DTAQ)
ctl-opt nomain;
ctl-opt Option(*Srcstmt:*Nodebugio:*NoUnRef)
Debug( *Yes ) Bnddir('QUSAPIBD');
**********************************************************************
**********************************************************************
* Program Id: BL0100M01
* This program gets the latitude and longitude from the data
* queues from java program JsonDataQueues and sends commands
* to ping and shutdown the java app.
**********************************************************************
@greghelton
greghelton / DATAQTESTS.rpgle
Last active March 27, 2019 21:50
Using an AS400 data queue to function as one or more arrays.
ctl-opt Main(Main) option(*srcstmt:*nodebugio:*nounref);
// **************************************************************
// CRTDTAQ DTAQ(qtemp/DTAQ512) MAXLEN(526) SEQ(*KEYED) KEYLEN(14)
// crtpgm dataqtests module(dataqtests dataqueues)
// **************************************************************
dcl-proc Main;
dcl-pi *N;
end-pi;
dcl-pr arrayPut INT(10) extproc(*DCLCASE);
@greghelton
greghelton / DataQueues.java
Last active February 23, 2024 21:31
The RPG application places an address and a key it has generated on the request queue. Java reads the request queue and sends the address to Google. Google responds with the latitude and longitude which the Java app places on the keyed data queue with a key value of the key the RPG generated. The response on the keyed queue is read by the RPG.
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.DataQueue;
import com.ibm.as400.access.ErrorCompletingRequestException;
import com.ibm.as400.access.IllegalObjectTypeException;
@greghelton
greghelton / FipCodes.java
Last active February 19, 2016 21:28
After downloading the county fip codes from the US Census web site as a CSV file you can utilize them in your program as follows.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class FipCodes {
String state;
String stateCode;
@greghelton
greghelton / JsonGeoService.java
Last active December 20, 2019 19:58
Signing the URL and parsing the JSON are the challenges to the programmer using google for the first time.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@greghelton
greghelton / Geocoding.java
Last active December 20, 2019 21:59
Set credentials for using Google geocoding API then get the lat and lang and use DecimalFormat when updating character fields in the database.
boolean failed = false;
static final String key = "get this from google";
static final String id = "get this from google";
static final GeoApiContext context
= new GeoApiContext().setEnterpriseCredentials(id, key);
try {
GeocodingResult[] result
= GeocodingApi.geocode(context, address).await();
double lat = result[0].geometry.location.lat;
double lng = result[0].geometry.location.lng;
@greghelton
greghelton / as400-express.js
Created December 23, 2015 03:39
Connected to AS400 from Ubuntu running on VirtualBox. node-jt400 fails installing on Windows hence the use of Ubuntu on VirtualBox.
// run on Ubuntu since node-jt400 fails to install on Windows.
var express = require('express');
var app = express();
var pool = require('node-jt400').pool(
{host: 'DPITEST', user: 'GAH285', password: 'guess-again'});
app.get('/', function(req, res) {
pool.query('SELECT * FROM GAH285/FUNNYFILE')
.then(function(results) {
console.log(results[0]);
@greghelton
greghelton / LOGSTASHER.RPGLE
Last active August 28, 2023 14:03
Reads AS400 Journals and creates tables for reading by Java client of Logstash app.
* Logstasher - program to run as RCVJRNE exit point.
* It will create tables of journal records in which the blob
* field JOESD is parsed into the fields of the record that
* is the subject of the journal record.
* - - - - - - - - - - - - - - - - - - - - - - - -
* dependencies
* 1. LOGSTASH Data Area provides properties
* 2. FLATFILE Physical File required for compile
* 3. QCMDEXC
* 4. SQL