Skip to content

Instantly share code, notes, and snippets.

View bekwam's full-sized avatar

Bekwam, Inc bekwam

View GitHub Profile
@bekwam
bekwam / maven-jdk18-build-section
Created June 17, 2015 11:23
A snippet of a pom.xml for specifying the Java version; Intellij defaults to 1.5 if this isn't present
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
@bekwam
bekwam / gist:e50d563f400364f1910b
Created September 3, 2015 02:31
Example of JavaFX GridPane
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(0, 10, 0, 10));
// Category in column 2, row 1
Text category = new Text("Sales:");
category.setFont(Font.font("Arial", FontWeight.BOLD, 20));
grid.add(category, 1, 0);
states.add(new Pair<String, String>("AL", "Alabama"));
states.add(new Pair<String, String>("AK", "Alaska"));
states.add(new Pair<String, String>("AZ", "Arizona"));
states.add(new Pair<String, String>("AR", "Arkansas"));
states.add(new Pair<String, String>("CA", "California"));
states.add(new Pair<String, String>("CO", "Colorado"));
states.add(new Pair<String, String>("CT", "Connecticut"));
states.add(new Pair<String, String>("DE", "Delaware"));
states.add(new Pair<String, String>("DC", "Dist. of Columbia"));
states.add(new Pair<String, String>("FL", "Florida"));
provinces.add(new Pair<String, String>("AB", "Alberta"));
provinces.add(new Pair<String, String>("BC", "British Columbia"));
provinces.add(new Pair<String, String>("MB", "Manitoba"));
provinces.add(new Pair<String, String>("NB", "New Brunswick"));
provinces.add(new Pair<String, String>("NL", "Newfoundland and Labrador"));
provinces.add(new Pair<String, String>("NS", "Nova Scotia"));
provinces.add(new Pair<String, String>("NT", "Northwest Territories"));
provinces.add(new Pair<String, String>("NU", "Nunavut"));
provinces.add(new Pair<String, String>("ON", "Ontario"));
provinces.add(new Pair<String, String>("PE", "Prince Edward Island"));
@bekwam
bekwam / gist:4386133492546a1f945c
Created October 16, 2015 11:53
JavaFX StringConverter for an Enum
cbType.setConverter( new StringConverter<SigningArgumentsType>() { // enum SigningArgumentsType; defined all caps
@Override
public String toString(SigningArgumentsType type) {
return StringUtils.capitalize(StringUtils.lowerCase(String.valueOf(type)));
}
@Override
public SigningArgumentsType fromString(String type) {
return Enum.valueOf(SigningArgumentsType.class, StringUtils.upperCase(type));
@bekwam
bekwam / gist:6c0ea2b834a89e06c2b1ca26b459ae5c
Created November 5, 2016 21:45
Convert ArrayList of String to List of JavaFX Labels
List<String> list = new ArrayList<>();
list.add( "a" );
list.add( "b" );
list.add( "c" );
List<Label> labels = list
.stream()
.map( Label::new )
.collect(Collectors.toList());
@bekwam
bekwam / FullScreenApp.java
Created February 7, 2017 22:07
A JavaFX App That Takes Up the Whole Screen (Primary)
public class FullScreenApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
VBox vbox = new VBox(new Label("Hello, World!"));
vbox.setAlignment(Pos.TOP_CENTER); // 0, auto
Scene scene = new Scene( vbox );
@bekwam
bekwam / ClassWithSurrogateKey.kt
Created August 16, 2018 11:16
Kotlin Class With Surrogate Key Field
data class ClassWithSurrogateKey(val field1 : String, val field2 : Int) {
val id = nextId() // always increasing
companion object {
private var idgen = 1 // faux static class member
fun nextId() = idgen++
}
}
@bekwam
bekwam / FetchResultsSerializer.java
Created December 30, 2018 16:32
Stream-Only Custom Gson
import com.google.gson.*;
import org.apache.commons.lang3.tuple.Pair;
import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collector;
//
// Converts a List of Pair<String, Long> into a JSON array of objects where the key of the Pair is
// field name "url" and the value is "fileSize"
@bekwam
bekwam / web.xml
Created January 2, 2019 15:43
WildFly 15 Empty web.xml File
<?xml version="1.0"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>