Skip to content

Instantly share code, notes, and snippets.

View greghelton's full-sized avatar

Greg Helton greghelton

View GitHub Profile
@greghelton
greghelton / FIRSTPGM.RPGLE
Created February 7, 2014 03:57
Unit Test for ILE RPG
h option(*srcstmt:*nodebugio)
* compile with 15 to CRTMOD then run
* CRTPGM FIRSTPGM BNDSRVPFM(TESTFIRST)
d bankAccount1 ds QUALIFIED
d accountNbr 7P 0
d balance 11P 2
d bankAccount2 ds QUALIFIED
d accountNbr 7P 0
d balance 11P 2
@greghelton
greghelton / CORS_Node.html
Last active August 29, 2015 14:00
The book Pro AngularJS has a ToDo List application that I modified so that it gets its JSON model data from a Java servlet running on Tomcat hence, the servlet must set the CORS header to allow cross-origin resource sharing. CORS_node.html is served by the node.js server. The HTML requests the JSON data with the URL on line 17 of the html file. …
<!DOCTYPE html>
<html ng-app="todoApp">
<head>
<title>TO DO List</title>
<link href="bootstrap.css" rel="stylesheet" />
<link href="bootstrap-theme.css" rel="stylesheet" />
<script src="angular.js"></script>
<script>
var model = {
@greghelton
greghelton / books.sql in Postgres
Last active August 29, 2015 14:01
Postgres install plus a database of books and authors created in Postgres.
DROP TABLE IF EXISTS authors, books;
DROP SEQUENCE IF EXISTS author_id_seq, book_id_seq;
CREATE SEQUENCE author_id_seq START 1;
CREATE SEQUENCE book_id_seq START 1;
create table authors (
id INTEGER PRIMARY KEY DEFAULT NEXTVAL('author_id_seq'),
name VARCHAR(50) NOT NULL,
UNIQUE(name)
@greghelton
greghelton / MySqlBatchInsert.java
Last active August 29, 2015 14:02
Data extract from (1.) Oracle database and (2.) AS400 database and insert the data into MySQL database.
import java.sql.*;
import java.util.Properties;
public class MySqlBatchInsert {
int counter = 0;
Connection conn;
PreparedStatement ps;
public MySqlBatchInsert() throws SQLException, ClassNotFoundException {
String url = "jdbc:mysql:///rmswms";
@greghelton
greghelton / ADDDUR.rpgle
Last active August 29, 2015 14:05
Functions to expose RPG's date functionality to CLLE programs.
h nomain option(*nodebugio:*srcstmt) debug(*yes)
*
d getnow pr 26A
*
d adddur pr 26A
d initalValue 26A VALUE
d scale 3P 0 VALUE
d units 7A VALUE
d success 4A
*
@greghelton
greghelton / TST_ADDDUR.rpgle
Last active August 29, 2015 14:05
Testing the RPGLE Date Function Subprocedure. This technique was devised by my coworker, Deborah. The TST_ADDDUR RPGLE program below calls the ADDDUR subprocedure that is shown in the previous gist.. The TST_ADDDUR program requires the ADDDUR module to be linked into a SRVPGM and added to the ADDDUR binding directory. See the H spec in the code …
H option(*srcstmt : *nodebugio) debug(*yes) bnddir('ADDDUR')
H dftactgrp(*no) actgrp(*caller)
H EXTBININT(*YES)
H ALWNULL(*USRCTL)
H copyright('(C) COPYRIGHT StoneEagle Insurance Systems, Inc. 2010')
*=========================================================================
*
* Pgm : TST_ADDDUR - Test Add Duration
* Pgmer:
* Date : August 2014
@greghelton
greghelton / AS400webpage.rb
Last active August 29, 2015 14:05
This is a Sinatra app displays the result set from an AS400 RPG program in a web page. The RPG program takes two character strings as input parameters and capitalizes them and returns them in a two field resultset. (Note: this code leaves the resultset, statement and connection in limbo). Execute this code by first starting the JRuby app then en…
require 'sinatra'
gem 'sinatra'
require 'sinatra/reloader' if development?
require 'jt400.jar'
require 'yaml'
set :public_folder, 'public'
db = YAML.load_file '/config/database.yml'
Java::JavaClass.for_name db['driver']
connection = java.sql.DriverManager.get_connection(db['dburl'], db['username'], db['password'])
@greghelton
greghelton / dbdatatypes.rb
Last active August 29, 2015 14:06
JRuby to determine DataType codes from the ResultSet metadata. INT is datatype 4 and BIGINT is datatype -5. Also see CHAR, VARCHAR, DATE, TIME, TIMESTAMP, DOUBLE and DECIMAL.
require 'sinatra'
require 'sinatra/reloader' if development?
require 'lib/jt400.jar'
require 'bigdecimal'
require 'yaml'
require 'json'
set :public_folder, 'public'
db = YAML.load_file '/config/db.yml'
Java::JavaClass.for_name db['driver']
@greghelton
greghelton / datatables.sql
Created September 8, 2014 15:54
database for the datatables.net example
create table Employee (
id int generated always as identity Primary Key
, name varchar(50)
, title varchar(50)
, office varchar(50)
, extension char(4)
, startdate DATE
, salary int);
insert into Employee (name, title, office, extension, startdate, salary) values
@greghelton
greghelton / jumpstart_sinatra_ch2.md
Last active August 29, 2015 14:06
Chapter 2 of Bootstrap Sinatra
  • learning erb