Skip to content

Instantly share code, notes, and snippets.

View greghelton's full-sized avatar

Greg Helton greghelton

View GitHub Profile
@greghelton
greghelton / README.md
Last active November 12, 2026 03:34
Using Apache Ivy and Apache Ant build tools to run Clojure's REPL and Clojure code files. Clojure is LISP on the JVM.

Prerequistes
(Apache Ant and Apache Ivy can be installed with homebrew but doing so may download a JDK that you don't want.)
I downloaded Apache Ant to ~/dev/bin/ which is common to all projects
and I downloaded Ivy and placed its jar in ~/dev/bin/apache-ant-1.10.18/lib

Why use Apache Ivy? Ivy is a depedency manager for ANT. It simplifies dependency management by downloading the jar files specified in ivy.xml and the jar files those jar files require in order to run.

Examples of the commands this build file supports are:

  • Run the REPL
@greghelton
greghelton / _import-CSV-data-to-Derby-DB-with-Clojure.md
Last active November 12, 2026 01:25
Use ANT and Clojure to import CSV data to Derby DB

This gist relies on the ANT and Clojure setup shown in the previous gist.

Run the program

ant run -Dfile=./import-csv-to-derby.clj -Ddb.dir=./database/people
@greghelton
greghelton / README.md
Last active November 12, 2026 04:51
Using Clojure with Apache ANT to create a csv file and import it into a Derby database.

I wanted a simple way to run Clojure's REPL (Clojure is LISP on the JVM and REPL means Read–Eval–Print Loop) and to run Clojure code files. I started using ANT almost as long ago as when I began programming Java in 1999. I have always found ANT to be the simple way to perform most tasks in the Java environment so ANT is again my choice. In this ANT project, all dependencies are downloaded to a folder within the project and everything works very simply without having to use leinengen or clojure tools.

Here is an ANT build that downloads the clojure jar and other dependencies from the Maven repo to the project's lib folder. The ANT build.xml file includes a repl task to start the clojure REPL and a run task to run a given clojure file.

I downloaded ANT from ant.apache.org and installed it in a tools folder under my user folder. Homebrew will install ANT but it has a hard dependency on a version of Java I don't care to use.

This project's ANT commands:

  • ant resolve // downloads dependencies
@greghelton
greghelton / main.groovy
Last active September 15, 2026 07:23
Groovy that executes Stored Procedures and UDFs
import java.sql.Connection
import java.sql.DriverManager
import java.sql.CallableStatement
import java.sql.PreparedStatement
import java.sql.ResultSet
import java.sql.Types
if (args.length < 2) {
println "Usage: groovy main.groovy SCHEMA ROUTINE_NAME"
System.exit(1)
@greghelton
greghelton / CALCSVCS.rpgle
Last active September 13, 2026 07:20
Use Spock and IBM's Mapepire to unit test RPG Subproceures that are registered as UDFs. Google Gemini wrote the code.
**FREE
Ctl-Opt NoMain Option(*SrcStmt:*NoDebugIo);
// -----------------------------------------------------------------
// Subprocedure: CalculateInterest
// Computes simple interest: (Principal * Rate * Years)
// -----------------------------------------------------------------
Dcl-Proc CalculateInterest Export;
Dcl-Pi CalculateInterest Packed(15:2);
pPrincipal Packed(15:2) Const;
package org.vanillaweb;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.*;
public class FullDuplexRelay {
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
public class BrowserRelay {
@greghelton
greghelton / kotlin_and_AS400.kt
Created May 23, 2026 14:04
jt400.jar is very cool. I had chatgpt write an application that uses AS400 DTAQs. The AS400 often responds to requests from other application tiers but with DTAQs, it can send a request out to the web. Here, the request would be managed or acted on by additional Kotlin code.
import com.ibm.as400.access.AS400
import com.ibm.as400.access.DataQueue
import com.ibm.as400.access.DataQueueEntry
import com.ibm.as400.access.KeyedDataQueue
import java.nio.charset.Charset
fun main() {
// Connect to IBM i
val system = AS400(
@greghelton
greghelton / AIPlayer.swift
Last active June 27, 2026 21:43
Swift Model Training and Gameplay for Backgammon
/// Selects the best legal move for the current player using a trained NeuralNetwork.
public enum AIPlayer {
/// Returns the move that maximises P(currentPlayer wins) according to the network.
public static func bestMove(for state: GameState, network: NeuralNetwork) -> Move {
let moves = uniqueByResult(MoveGenerator.legalMoves(for: state), from: state)
let player = state.currentPlayer
return moves.max { a, b in
score(move: a, state: state, network: network, player: player)
< score(move: b, state: state, network: network, player: player)