One of the most common things we want to do when web programming is supply a list of values in drop-down or form fields etc.. So we don’t have to maintain the values ( sometimes very large lists ) in the code itself it is often times best practice to keep the in your db…
Tag: programming
Writing a Simple Javascript Form to Capture Data
In this article Andrew Alpaugh gives some examples on how to capture form data in a website you are developing and prepare the data to insert into the database.
Extracting http status and reason phrase in Mule 4 Dataweave 2.0 language
It took me forever to figure out this seemingly simple task so now I want to share in case another mule developer out there is having the same problem and can stumble across this example! Here’s an example DataWeave 2.0 function that captures the HTTP status code and reason phrase from an HTTP response: extractHttpStatus(response:…
OOP vs Functional Programming
What are the differences between oo programming and functional programming? Scott Andrew Alpaugh writes to explain.
Simple shell script to find and replace strings in files
#!/bin/bash # Define the search and replace strings search=”old_text” replace=”new_text” # Define the directory to search (include trailing slash) dir=”/path/to/search/in/” # Find all files in the directory and its subdirectories files=$(find $dir -type f) # Iterate through each file for file in $files; do # Check if the file contains the search string…
Writing a simple mapper in Java
This can be done using the Jackson library and can be very useful in small to medium data transformation applications! In this example, the source data is in JSON format and has fields “name”, “age”, and “address”. The target data format is defined as a Java class with fields “firstName”, “age”, and “city”. The ObjectMapper’s…
How to encode/decode base64 using Java
In Java, you can use the Base64 class in the java.util package to encode and decode data in Base64. To encode data in Base64, you can use the getEncoder() method to obtain an encoder, and then use the encodeToString() method to perform the encoding: Copy codeimport java.util.Base64; public class Main { public static void main(String[]…
Creating a JWT token in Java
I ran across this problem on a project and I thought I’d share some sample code to get you going. As far as passing the generated jwt you can do it as a header Authorization parameter. A good tool for trying this out is postman which you can download with the link below. In a…