Skip to content

Instantly share code, notes, and snippets.

Avatar

David Blevins dblevins

View GitHub Profile
@dblevins
dblevins / Dates.java
Last active May 28, 2022
Works for Java 8 and above. For Java 7 and before, see this legacy version https://gist.github.com/dblevins/03df3cd5eb12f2da05997eef80ac4eca
View Dates.java
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
/**
* This pattern has the following benefits:
*
* - Date formats are referenced as a strong type
* - Code completion on patterns
View jakartaee-api-9.1-M2-SNAPSHOT-tomcat.jar.txt
META-INF/
META-INF/DEPENDENCIES
META-INF/LICENSE
META-INF/LICENSE.md
META-INF/LICENSE.txt
META-INF/MANIFEST.MF
META-INF/NOTICE
META-INF/NOTICE.md
META-INF/mailcap.default
META-INF/maven/
View javaee-api-8.0-6-tomcat.jar.txt
META-INF/MANIFEST.MF
META-INF/
META-INF/DEPENDENCIES
javaee-api-feature.xml
org/
org/apache/
org/apache/openejb/
org/apache/openejb/javaee/
org/apache/openejb/javaee/api/
org/apache/openejb/javaee/api/activator/
View MapperAPI-Exceptions.adoc
View JsonbAPI-Exceptions.adoc
# Jsonb API scenario current proposed

1

JsonbCreator

constructor

JsonbException

JsonbException

2

JsonbCreator

factory

JsonbException

JsonbException

3

Deserialization

arrayOfShortFromString

JsonbException

JsonbException

View chars-vs-bytes.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
public class Foo {
public static void main(String[] args) throws IOException {
final char c = 'ñ';
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
View startup-times-7-and-8.txt
2422 apache-tomee-7.0.0-M1-plus 139 3555 6034 ssssssssssssssssssssssss
2424 apache-tomee-7.0.0-plus 138 3339 5874 ssssssssssssssssssssssss
2429 apache-tomee-7.0.3-plus 139 3434 5929 ssssssssssssssssssssssss
2431 apache-tomee-7.0.1-plus 139 3250 5717 ssssssssssssssssssssssss
2450 apache-tomee-7.0.2-plus 139 3370 5919 sssssssssssssssssssssssss
2451 apache-tomee-7.0.0-M3-plus 139 3419 5944 ssssssssssssssssssssssss
2466 apache-tomee-7.0.4-plus 139 3510 6111 sssssssssssssssssssssssss
2475 apache-tomee-7.0.0-M2-plus 139 3314 5827 ssssssssssssssssssssssss
2526 apache-tomee-7.0.5-plus 139 3691 6263 sssssssssssssssssssssssss
2526 apache-tomee-7.1.0-plus 139 3684 6332 ssssssssssssssssssssssssss
@dblevins
dblevins / pbcut
Created Mar 22, 2022
Mac clipboard manipulation scripts I use the most. These all live in my ~/bin/ directory
View pbcut
#!/bin/bash
# Useful for when you want to trim off leading spaces from clipboard text
# Say you grab a chunk of code from a markdown document and want to remove
# the four spaces at the front:
#
# pbcut -c 5-
pbpaste | cut "$@" | pbcopy
pbpaste
View trycrest.sh
#!/bin/bash
mvn archetype:generate -DarchetypeGroupId=org.tomitribe \
-DarchetypeArtifactId=tomitribe-crest-archetype \
-DarchetypeVersion=0.19 \
-Dversion=1.0-SNAPSHOT \
-DgroupId=org.example -DartifactId=mycommand &&
cd mycommand/ &&
mvn clean install &&
./target/mycommand ls .
View Dates.java
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
/**
* This pattern has the following benefits:
*
* - Date formats are referenced as a strong type