Skip to content

Instantly share code, notes, and snippets.

View dblevins's full-sized avatar

David Blevins dblevins

View GitHub Profile
@dblevins
dblevins / pbcut
Created March 22, 2022 21:38
Mac clipboard manipulation scripts I use the most. These all live in my ~/bin/ directory
#!/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
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.time.LocalDate;
import java.util.stream.Stream;
import static org.junit.jupiter.params.provider.Arguments.arguments;
@dblevins
dblevins / Dates.java
Last active March 14, 2022 15:40
Legacy Java 7 version. See recommended Java 8 version https://gist.github.com/dblevins/47f7508e241d775fd7007a4639d6565a
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
@dblevins
dblevins / Dates.java
Last active May 28, 2022 20:02
Works for Java 8 and above. For Java 7 and before, see this legacy version https://gist.github.com/dblevins/03df3cd5eb12f2da05997eef80ac4eca
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
Downloading from apache: https://repository.apache.org/content/repositories/releases/org/apache/tomee/tomee-webaccess/7.0.0/tomee-webaccess-7.0.0.pom
Progress (1): 4.1/10 kB
Progress (1): 7.7/10 kB
Progress (1): 10 kB
Downloaded from apache: https://repository.apache.org/content/repositories/releases/org/apache/tomee/tomee-webaccess/7.0.0/tomee-webaccess-7.0.0.pom (10 kB at 13 kB/s)
Downloading from apache: https://repository.apache.org/content/repositories/releases/org/apache/tomee/tomee/7.0.0/tomee-7.0.0.pom
Progress (1): 4.1/14 kB
Progress (1): 7.7/14 kB
Progress (1): 12/14 kB
#!/bin/bash
mkdir /tmp/test
cd /tmp/test
curl -s -O https://archive.apache.org/dist/tomee/KEYS
curl -s -O https://archive.apache.org/dist/tomee/tomee-9.0.0-M7/apache-tomee-9.0.0-M7-webprofile.tar.gz
curl -s -O https://archive.apache.org/dist/tomee/tomee-9.0.0-M7/apache-tomee-9.0.0-M7-webprofile.tar.gz.asc
echo "
list keys
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@dblevins
dblevins / verify.sh
Created April 7, 2021 22:33
Verify an Apache TomEE binary
#!/bin/bash
FILE="${1?Specify a TomEE zip, war or tar.gz to verify}"
SHA="$FILE.sha512"
[ -f "$SHA" ] || {
echo "Downloading sha512 for $FILE"
BIN="$(basename "$FILE")"
VER="$(echo "$BIN" | perl -pe 's,apache-(tomee-.*?)-[a-z]+\.(zip|tar.gz|war),$1,')"
curl -s "https://downloads.apache.org/tomee/$VER/$BIN.sha512" > "$SHA"
@dblevins
dblevins / pom.xml
Created April 7, 2021 17:22
Jakarta EE 8 TCK pom.xml usable for opening/importing the TCK as a project in Intellij. Does not build the TCK.
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>jakartaee-tck</groupId>
<artifactId>jakartaee-tck</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
com/sun/ts/tests/ejb/ee/bb/entity/bmp/allowedmethodstest
com/sun/ts/tests/ejb/ee/bb/entity/bmp/argsemantics
com/sun/ts/tests/ejb/ee/bb/entity/bmp/clientviewtest
com/sun/ts/tests/ejb/ee/bb/entity/bmp/entitybeantest
com/sun/ts/tests/ejb/ee/bb/entity/bmp/entitycontexttest
com/sun/ts/tests/ejb/ee/bb/entity/bmp/handletest
com/sun/ts/tests/ejb/ee/bb/entity/bmp/multiclienttest
com/sun/ts/tests/ejb/ee/bb/entity/bmp/nonreentranttest
com/sun/ts/tests/ejb/ee/bb/entity/bmp/reentranttest
com/sun/ts/tests/ejb/ee/bb/entity/cmp/allowedmethodstest