Category: Development

Uploading a CSV to a REST web service

import org.apache.http.client.methods.*; import org.apache.http.client.*; import org.apache.http.impl.client.*; import org.apache.http.*; import org.apache.http.entity.mime.*; import org.apache.http.entity.*; import java.io.*; public class API_H01 { public static void main (String args[]) { try { HttpClient client = HttpClientBuilder.create().build(); File f = new File(“/opt/tomcat8/hierarchy.csv”); MultipartEntityBuilder builder = MultipartEntityBuilder.create();…

Jython to call REST service and write output to a file

from org.apache.http.client.methods import * from org.apache.http.impl.client import * from org.apache.http.client import * from org.apache.http import * from org.json import * from java.io import * from java.util import * from java.lang import * client = HttpClientBuilder.create().build(); url = “https://host/api/invoices”; rq =…

Example of a structure in C

This is just a placeholder for how these work. Largely, this is the predecessor of object oriented programming in that a structure has properties that can be assigned. #include #include struct student {   int studentId;   char studentName[40];  …

java dynamic SQL formatter

import java.sql.*; public class dynColumns { public static void main(String[] args) { try { Connection con = DriverManager.getConnection(“jdbc:oracle:thin:” + args[0]); Statement stm = con.createStatement(); ResultSet rst = stm.executeQuery(args[1]); ResultSetMetaData rstMeta = rst.getMetaData(); int columns = rstMeta.getColumnCount(); while (rst.next()) { for…

Does BlockingQueue.take() use CPU?

No… [root@cmhlcarchapp01 ~]# cat t.java import java.util.concurrent.*; public class t implements Runnable { static ArrayBlockingQueue Q = new ArrayBlockingQueue(5); String type; public static void main (String args[]) { t n = new t(“producer”); t n2 = new t(“consumer”); } public…

Python modules

Create an __init__.py file in each directory that will be in the tree of your import. For example, if you have the following directory structure… /opt/software/com/yourcompany/yourdivision/yourfile.py …you would issue the following commands: export PYTHONPATH=$PYTHONPATH:/opt/software touch /opt/software/com/__init__.py touch /opt/software/com/yourcompany/__init__.py touch /opt/software/com/yourcompany/yourdivision/__init__.py…